sat-lora-constellation-example.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: Bastien Tauran <bastien.tauran@viveris.fr>
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 
39 NS_LOG_COMPONENT_DEFINE("sat-lora-constellation-example");
40 
41 int
42 main(int argc, char* argv[])
43 {
44  // Variables
45  std::string beams = "30 43";
46  uint32_t nbGwUser = 1;
47  uint32_t nbUtsPerBeam = 5;
48  uint32_t nbEndUsersPerUt = 1;
49 
50  Time appStartTime = Seconds(0.001);
51  Time simLength = Seconds(15.0);
52 
53  uint32_t packetSize = 24;
54  Time loraInterval = Seconds(10);
55  std::string interval = "10s";
56 
57  double frameAllocatedBandwidthHz = 15000;
58  double frameCarrierAllocatedBandwidthHz = 15000;
59  double frameCarrierRollOff = 0.22;
60  double frameCarrierSpacing = 0;
61  uint32_t frameSpreadingFactor = 256;
62 
63  bool interferenceModePerPacket = true;
64  bool displayTraces = true;
65 
66  Time firstWindowDelay = MilliSeconds(1500);
67  Time secondWindowDelay = Seconds(2);
68  Time firstWindowDuration = MilliSeconds(400);
69  Time secondWindowDuration = MilliSeconds(500);
70  Time firstWindowAnswerDelay = Seconds(1);
71  Time secondWindowAnswerDelay = Seconds(2);
72 
73  Ptr<SimulationHelper> simulationHelper =
74  CreateObject<SimulationHelper>("example-lora-constellation");
75 
76  // read command line parameters given by user
77  CommandLine cmd;
78  cmd.AddValue("modelPP", "interferenceModePerPacket", interferenceModePerPacket);
79  cmd.AddValue("traces", "displayTraces", displayTraces);
80  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", nbUtsPerBeam);
81  cmd.AddValue("simLength", "Simulation duration in seconds", simLength);
82  cmd.AddValue("packetSize", "Constant packet size in bytes", packetSize);
83  cmd.AddValue("loraInterval",
84  "Interval between two transmissions for each UT in seconds",
85  loraInterval);
86  cmd.AddValue("frameAllocatedBandwidthHz",
87  "Allocated bandwidth in Hz",
88  frameAllocatedBandwidthHz);
89  cmd.AddValue("frameCarrierAllocatedBandwidthHz",
90  "Allocated carrier bandwidth in Hz",
91  frameCarrierAllocatedBandwidthHz);
92  cmd.AddValue("frameCarrierRollOff", "Roll-off factor", frameCarrierRollOff);
93  cmd.AddValue("frameCarrierSpacing", "Carrier spacing factor", frameCarrierSpacing);
94  cmd.AddValue("frameSpreadingFactor", "Carrier spreading factor", frameSpreadingFactor);
95 
96  cmd.AddValue("firstWindowDelay",
97  "Delay between end of transmission and opening of first window on End Device",
98  firstWindowDelay);
99  cmd.AddValue("secondWindowDelay",
100  "Delay between end of transmission and opening of second window on End Device",
101  secondWindowDelay);
102  cmd.AddValue("firstWindowDuration", "First window duration on End Device", firstWindowDuration);
103  cmd.AddValue("secondWindowDuration",
104  "Second window duration on End Device",
105  secondWindowDuration);
106  cmd.AddValue("firstWindowAnswerDelay",
107  "Delay between end of reception and start of ack on first window on Gateway",
108  firstWindowAnswerDelay);
109  cmd.AddValue("secondWindowAnswerDelay",
110  "Delay between end of reception and start of ack on second window on Gateway",
111  secondWindowAnswerDelay);
112  simulationHelper->AddDefaultUiArguments(cmd);
113  cmd.Parse(argc, argv);
114 
116  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
117  EnumValue(SatEnums::REGENERATION_NETWORK));
118  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
119  EnumValue(SatEnums::REGENERATION_NETWORK));
120 
121  // Enable Lora
122  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
123  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
125 
126  // Config::SetDefault ("ns3::SatLoraConf::Standard", EnumValue (SatLoraConf::EU863_870));
127  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
128 
129  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
130  TimeValue(firstWindowDelay));
131  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay",
132  TimeValue(secondWindowDelay));
133  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
134  TimeValue(firstWindowDuration));
135  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
136  TimeValue(secondWindowDuration));
137  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay",
138  TimeValue(firstWindowAnswerDelay));
139  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay",
140  TimeValue(secondWindowAnswerDelay));
141 
142  // Defaults
143  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
144  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
145 
146  // Superframe configuration
147  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
149  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
151  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz",
152  DoubleValue(frameAllocatedBandwidthHz));
153  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
154  DoubleValue(frameCarrierAllocatedBandwidthHz));
155  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierRollOff",
156  DoubleValue(frameCarrierRollOff));
157  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierSpacing",
158  DoubleValue(frameCarrierSpacing));
159  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_SpreadingFactor",
160  UintegerValue(frameSpreadingFactor));
161 
162  // CRDSA only
163  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaServiceCount", UintegerValue(4));
164  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
165  BooleanValue(false));
166  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
167  BooleanValue(false));
168  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
169  BooleanValue(false));
170  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
171  BooleanValue(false));
172  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
173  BooleanValue(false));
174  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
175  BooleanValue(false));
176  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
177  BooleanValue(false));
178  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
179  BooleanValue(false));
180  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
181  BooleanValue(false));
182  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
183  BooleanValue(false));
184  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
185  BooleanValue(false));
186  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
187  BooleanValue(false));
188 
189  // Configure RA
190  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
191  EnumValue(SatPhyRxCarrierConf::EM_AVI));
192  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
193  EnumValue(SatPhyRxCarrierConf::EM_AVI));
194  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
195  if (interferenceModePerPacket)
196  {
197  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
199  }
200  else
201  {
202  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
204  }
205  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
207  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
209  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
210 
211  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
212  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
213  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDelay", StringValue("0s"));
214  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::FirstWindow", StringValue("0s"));
215  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
216  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::SpreadingFactor", UintegerValue(1));
217  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::DetectionThreshold", DoubleValue(0));
218  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
219 
220  // Set random access parameters
221  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
222  UintegerValue(3));
223  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
224  UintegerValue(6));
225  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
226  UintegerValue(2));
227  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
228  UintegerValue(50));
229  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
230  UintegerValue(1));
231  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
232  UintegerValue(1));
233  Config::SetDefault(
234  "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
235  DoubleValue(0.99));
236  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
237  UintegerValue(3));
238  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_SlottedAlohaAllowed",
239  BooleanValue(false));
240  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_CrdsaAllowed",
241  BooleanValue(false));
242  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_EssaAllowed", BooleanValue(true));
243 
244  // Traffics
245  simulationHelper->SetSimulationTime(simLength);
246 
247  simulationHelper->SetGwUserCount(nbGwUser);
248  simulationHelper->SetUtCountPerBeam(nbUtsPerBeam);
249  simulationHelper->SetUserCountPerUt(nbEndUsersPerUt);
250  simulationHelper->SetBeams(beams);
251 
252  simulationHelper->LoadScenario("constellation-eutelsat-geo-2-sats-isls-lora");
253 
254  simulationHelper->CreateSatScenario();
255 
256  /*simulationHelper->GetTrafficHelper()->AddLoraCbrTraffic(
257  loraInterval,
258  packetSize,
259  Singleton<SatTopology>::Get()->GetGwUserNodes(),
260  Singleton<SatTopology>::Get()->GetUtUserNodes(),
261  appStartTime,
262  simLength,
263  Seconds(1));*/
264 
265  simulationHelper->GetTrafficHelper()->AddLoraPeriodicTraffic(
266  loraInterval,
267  packetSize,
268  Singleton<SatTopology>::Get()->GetUtNodes(),
269  appStartTime,
270  simLength,
271  Seconds(1));
272 
273  // Outputs
274  simulationHelper->EnableProgressLogs();
275 
276  std::string outputPath = Singleton<SatEnvVariables>::Get()->LocateDirectory(
277  "contrib/satellite/data/sims/example-lora-constellation");
278  Config::SetDefault("ns3::ConfigStore::Filename",
279  StringValue(outputPath + "/output-attributes.xml"));
280  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
281  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
282  ConfigStore outputConfig;
283  outputConfig.ConfigureDefaults();
284 
285  if (displayTraces)
286  {
287  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
288 
289  s->AddGlobalFeederEssaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
290  s->AddGlobalFeederEssaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
291  s->AddPerUtFeederEssaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
292  s->AddPerUtFeederEssaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
293 
294  s->AddGlobalFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
295  s->AddGlobalFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
296  s->AddPerUtFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
297  s->AddPerUtFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
298 
299  s->AddGlobalRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
300  s->AddGlobalRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCATTER_FILE);
301  s->AddPerBeamRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
302  s->AddPerBeamRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCATTER_FILE);
303 
304  s->AddPerSatFwdFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
305  s->AddPerSatFwdFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
306  s->AddPerSatRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
307  s->AddPerSatRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
308 
309  s->AddPerSatFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
310  s->AddPerSatFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
311  s->AddPerSatRtnUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
312  s->AddPerSatRtnUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
313 
314  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
315  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
316  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
317  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
318 
319  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
320  s->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
321  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
322  s->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
323 
324  s->AddPerUtRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
325  s->AddPerUtRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
326  s->AddPerUtRtnAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
327  s->AddPerUtRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
328 
329  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
330  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
331  s->AddPerUtRtnCompositeSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
332  s->AddPerUtRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
333 
334  s->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
335  s->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
336  s->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
337  s->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
338 
339  s->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCALAR_FILE);
340  s->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
341  s->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCALAR_FILE);
342  s->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
343 
344  s->AddPerUtFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
345  s->AddPerUtFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
346  s->AddPerUtFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
347  s->AddPerUtFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
348 
349  s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
350  s->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
351  s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
352  s->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
353  s->AddPerUtFwdAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
354  s->AddPerUtFwdMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
355  s->AddPerUtFwdAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
356  s->AddPerUtFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
357  }
358 
359  simulationHelper->RunSimulation();
360 
361  return 0;
362 
363 } // end of `int main (int argc, char *argv[])`
@ SATELLITE
For Satellite.
@ SUPER_FRAME_CONFIG_4
SUPER_FRAME_CONFIG_4.
@ CONFIG_TYPE_4
Configuration type 4 (ESSA)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.