sat-ra-sim-tn9-comparison.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Magister Solutions
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Frans Laakso <frans.laakso@magister.fi>
19  *
20  */
21 
22 #include "ns3/applications-module.h"
23 #include "ns3/config-store-module.h"
24 #include "ns3/core-module.h"
25 #include "ns3/internet-module.h"
26 #include "ns3/network-module.h"
27 #include "ns3/satellite-module.h"
28 #include "ns3/traffic-module.h"
29 
30 using namespace ns3;
31 
58 NS_LOG_COMPONENT_DEFINE("sat-ra-sim-tn9-comparison");
59 
60 int
61 main(int argc, char* argv[])
62 {
63  uint32_t beamId(18);
64  uint32_t endUsersPerUt(1);
65  uint32_t utsPerBeam(1);
66  uint32_t packetSize(1);
67  uint32_t numOfInstances(3);
68  double intervalInSeconds(0.1);
69  bool isNoisy(false);
70 
71  double simLength(60.0); // in seconds
72  Time appStartTime = Seconds(0.1);
73 
75  auto simulationHelper = CreateObject<SimulationHelper>("example-ra-sim-tn9-comparison");
76  // To read attributes from file
77  std::string inputFileNameWithPath =
78  Singleton<SatEnvVariables>::Get()->LocateDirectory("contrib/satellite/examples") +
79  "/tn9-ra-input-attributes.xml";
80 
81  // read command line parameters given by user
82  CommandLine cmd;
83  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
84  cmd.AddValue("numOfInstances", "Number of CRDSA packet instances", numOfInstances);
85  cmd.AddValue("isNoisy", "If true, may print some logging messages", isNoisy);
86  simulationHelper->AddDefaultUiArguments(cmd, inputFileNameWithPath);
87  cmd.Parse(argc, argv);
88 
89  if (isNoisy)
90  {
91  LogComponentEnable("sat-ra-sim-tn9", LOG_INFO);
92  }
93 
94  Config::SetDefault("ns3::ConfigStore::Filename", StringValue(inputFileNameWithPath));
95  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
96  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
97  ConfigStore inputConfig;
98  inputConfig.ConfigureDefaults();
99 
100  // Enable Random Access with all available modules
101  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
103 
104  // Set Random Access interference model
105  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
107 
108  // Set Random Access collision model
109  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
111 
112  // Disable fading
113  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_OFF));
114 
115  // Disable C/NO reporting
116  Config::SetDefault("ns3::SatRequestManager::CnoReportInterval", TimeValue(Seconds(60.0)));
117 
118  // Disable periodic control slots
119  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
120 
121  // Set dynamic load control parameters
122  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
123  BooleanValue(false));
124  Config::SetDefault(
125  "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
126  UintegerValue(10));
127 
128  // Set random access parameters
129  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
130  UintegerValue(1));
131  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
132  UintegerValue(6));
133  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
134  UintegerValue(0));
135  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
136  UintegerValue(50));
137  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
138  UintegerValue(1));
139  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
140  UintegerValue(1));
141  Config::SetDefault(
142  "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
143  DoubleValue(0.99));
144  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
145  UintegerValue(numOfInstances));
146 
147  // Disable CRA and DAMA
148  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
149  BooleanValue(false));
150  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
151  BooleanValue(false));
152  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
153  BooleanValue(false));
154  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
155  BooleanValue(false));
156  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
157  BooleanValue(false));
158  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
159  BooleanValue(false));
160  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
161  BooleanValue(false));
162  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
163  BooleanValue(false));
164  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
165  BooleanValue(false));
166  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
167  BooleanValue(false));
168  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
169  BooleanValue(false));
170  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
171  BooleanValue(false));
172 
173  // Creating the reference system.
174  simulationHelper->SetSimulationTime(simLength);
175  simulationHelper->SetUserCountPerUt(endUsersPerUt);
176  simulationHelper->SetUtCountPerBeam(utsPerBeam);
177  simulationHelper->SetBeamSet({beamId});
178 
179  simulationHelper->LoadScenario("geo-33E");
180 
181  simulationHelper->CreateSatScenario();
182 
186  simulationHelper->GetTrafficHelper()->AddCbrTraffic(
189  Seconds(intervalInSeconds),
190  packetSize,
191  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
192  Singleton<SatTopology>::Get()->GetUtUserNodes(),
193  appStartTime,
194  Seconds(simLength + 1),
195  Seconds(0.01));
196 
197  if (isNoisy)
198  {
199  const double kbps = packetSize / intervalInSeconds / 125.0;
200  std::cout << "Each of " << utsPerBeam * endUsersPerUt << " UT Users"
201  << " offer bandwidth of " << kbps << " kbps" << std::endl;
202  }
203 
207  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
208 
209  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
210  s->AddPerBeamRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
211  s->AddPerBeamRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
212  s->AddPerBeamRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
213 
214  s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
215  s->AddPerBeamRtnDevDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
216  s->AddPerBeamRtnPhyDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
217  s->AddPerBeamRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
218 
219  s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
220  s->AddPerBeamRtnDevDelay(SatStatsHelper::OUTPUT_CDF_FILE);
221  s->AddPerBeamRtnPhyDelay(SatStatsHelper::OUTPUT_CDF_FILE);
222  s->AddPerBeamRtnMacDelay(SatStatsHelper::OUTPUT_CDF_FILE);
223 
224  // s->AddPerUtUserRtnAppThroughput (SatStatsHelper::OUTPUT_SCALAR_FILE);
225  // s->AddPerUtUserRtnAppThroughput (SatStatsHelper::OUTPUT_SCATTER_FILE);
226  // s->AddPerUtUserRtnAppThroughput (SatStatsHelper::OUTPUT_SCATTER_PLOT);
227  // s->AddPerUtUserRtnDevThroughput (SatStatsHelper::OUTPUT_SCATTER_FILE);
228  // s->AddPerUtUserRtnDevThroughput (SatStatsHelper::OUTPUT_SCATTER_PLOT);
229 
230  // s->AddPerUtUserRtnAppDelay (SatStatsHelper::OUTPUT_CDF_FILE);
231  // s->AddPerUtUserRtnAppDelay (SatStatsHelper::OUTPUT_CDF_PLOT);
232  // s->AddPerUtRtnDevDelay (SatStatsHelper::OUTPUT_CDF_FILE);
233  // s->AddPerUtRtnDevDelay (SatStatsHelper::OUTPUT_CDF_PLOT);
234 
235  s->AddPerBeamRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
236  s->AddPerBeamRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_PLOT);
237 
238  s->AddPerBeamResourcesGranted(SatStatsHelper::OUTPUT_CDF_FILE);
239  s->AddPerBeamResourcesGranted(SatStatsHelper::OUTPUT_CDF_PLOT);
240 
241  s->AddPerBeamFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
242  s->AddPerBeamWaveformUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
243 
244  s->AddPerBeamRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
245 
246  s->AddPerBeamFeederCrdsaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
247  s->AddPerBeamFeederCrdsaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
248  s->AddPerBeamFeederSlottedAlohaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
249  s->AddPerBeamFeederSlottedAlohaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
250 
251  // s->AddPerUtFeederCrdsaPacketCollision (SatStatsHelper::OUTPUT_SCALAR_FILE);
252  // s->AddPerUtFeederCrdsaPacketError (SatStatsHelper::OUTPUT_SCALAR_FILE);
253  // s->AddPerUtFeederSlottedAlohaPacketCollision (SatStatsHelper::OUTPUT_SCALAR_FILE);
254  // s->AddPerUtFeederSlottedAlohaPacketError (SatStatsHelper::OUTPUT_SCALAR_FILE);
255 
256  NS_LOG_INFO("--- sat-ra-sim-tn9-comparison ---");
257  NS_LOG_INFO(" Packet size: " << packetSize);
258  NS_LOG_INFO(" Simulation length: " << simLength);
259  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
260  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
261  NS_LOG_INFO(" ");
262 
266  // std::stringstream filename;
267  // filename << "tn9-ra-comparison-output-attributes-uts-" << utsPerBeam << "-instances-" <<
268  // numOfInstances << ".xml";
269  //
270  // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
271  // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
272  // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
273  // ConfigStore outputConfig;
274  // outputConfig.ConfigureDefaults ();
275 
279  simulationHelper->RunSimulation();
280 
281  return 0;
282 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.