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