sat-lora-handover-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 
40 NS_LOG_COMPONENT_DEFINE("sat-lora-handover-example");
41 
42 int
43 main(int argc, char* argv[])
44 {
45  Time appStartTime = Seconds(0.001);
46  Time simLength = Seconds(100);
47 
48  uint32_t packetSize = 24;
49  Time loraInterval = Seconds(10);
50  std::string interval = "10s";
51 
52  double frameAllocatedBandwidthHz = 15000;
53  double frameCarrierAllocatedBandwidthHz = 15000;
54  double frameCarrierRollOff = 0.22;
55  double frameCarrierSpacing = 0;
56  uint32_t frameSpreadingFactor = 256;
57 
58  Time firstWindowDelay = MilliSeconds(1000);
59  Time secondWindowDelay = Seconds(2);
60  Time firstWindowDuration = MilliSeconds(900);
61  Time secondWindowDuration = MilliSeconds(400);
62  Time firstWindowAnswerDelay = Seconds(1);
63  Time secondWindowAnswerDelay = Seconds(2);
64 
65  Ptr<SimulationHelper> simulationHelper =
66  CreateObject<SimulationHelper>("example-lora-handover");
67 
69  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
71  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
73 
74  // Enable Lora
75  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
76  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
78 
79  // Config::SetDefault ("ns3::SatLoraConf::Standard", EnumValue (SatLoraConf::EU863_870));
80  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
81 
82  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
83  TimeValue(firstWindowDelay));
84  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay",
85  TimeValue(secondWindowDelay));
86  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
87  TimeValue(firstWindowDuration));
88  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
89  TimeValue(secondWindowDuration));
90  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay",
91  TimeValue(firstWindowAnswerDelay));
92  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay",
93  TimeValue(secondWindowAnswerDelay));
94 
95  // Defaults
96  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
97  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
98 
99  // Superframe configuration
100  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
102  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
104  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz",
105  DoubleValue(frameAllocatedBandwidthHz));
106  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
107  DoubleValue(frameCarrierAllocatedBandwidthHz));
108  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierRollOff",
109  DoubleValue(frameCarrierRollOff));
110  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierSpacing",
111  DoubleValue(frameCarrierSpacing));
112  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_SpreadingFactor",
113  UintegerValue(frameSpreadingFactor));
114 
115  // CRDSA only
116  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaServiceCount", UintegerValue(4));
117  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
118  BooleanValue(false));
119  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
120  BooleanValue(false));
121  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
122  BooleanValue(false));
123  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
124  BooleanValue(false));
125  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
126  BooleanValue(false));
127  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
128  BooleanValue(false));
129  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
130  BooleanValue(false));
131  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
132  BooleanValue(false));
133  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
134  BooleanValue(false));
135  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
136  BooleanValue(false));
137  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
138  BooleanValue(false));
139  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
140  BooleanValue(false));
141 
142  // Configure RA
143  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
144  EnumValue(SatPhyRxCarrierConf::EM_AVI));
145  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
146  EnumValue(SatPhyRxCarrierConf::EM_AVI));
147  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
148  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
150  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
152  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
154  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
155 
156  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
157  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
158  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDelay", StringValue("0s"));
159  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::FirstWindow", StringValue("0s"));
160  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
161  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::SpreadingFactor", UintegerValue(1));
162  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::DetectionThreshold", DoubleValue(0));
163  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
164 
165  // Set random access parameters
166  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
167  UintegerValue(3));
168  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
169  UintegerValue(6));
170  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
171  UintegerValue(2));
172  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
173  UintegerValue(50));
174  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
175  UintegerValue(1));
176  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
177  UintegerValue(1));
178  Config::SetDefault(
179  "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
180  DoubleValue(0.99));
181  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
182  UintegerValue(3));
183  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_SlottedAlohaAllowed",
184  BooleanValue(false));
185  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_CrdsaAllowed",
186  BooleanValue(false));
187  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_EssaAllowed", BooleanValue(true));
188 
190  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
191  EnumValue(SatEnums::REGENERATION_NETWORK));
192  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
193  EnumValue(SatEnums::REGENERATION_NETWORK));
194 
195  Config::SetDefault("ns3::SatHelper::HandoversEnabled", BooleanValue(true));
196  Config::SetDefault("ns3::SatHandoverModule::NumberClosestSats", UintegerValue(2));
197 
198  Config::SetDefault("ns3::SatGwMac::DisableSchedulingIfNoDeviceConnected", BooleanValue(true));
199  Config::SetDefault("ns3::SatOrbiterMac::DisableSchedulingIfNoDeviceConnected",
200  BooleanValue(true));
201 
203  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
204 
206  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
207 
208  Ptr<SimulationHelperConf> simulationConf = CreateObject<SimulationHelperConf>();
209  simulationHelper->SetSimulationTime(simLength);
210  simulationHelper->SetGwUserCount(1);
211  simulationHelper->SetUserCountPerUt(1);
212  std::set<uint32_t> beamSetAll = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
213  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
214  31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
215  46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
216  61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72};
217  simulationHelper->SetBeamSet(beamSetAll);
218  simulationHelper->SetUserCountPerMobileUt(simulationConf->m_utMobileUserCount);
219 
220  simulationHelper->LoadScenario("constellation-leo-2-satellites-lora");
221 
222  simulationHelper->CreateSatScenario(SatHelper::NONE);
223 
224  simulationHelper->GetTrafficHelper()->AddLoraCbrTraffic(
225  loraInterval,
226  packetSize,
227  Singleton<SatTopology>::Get()->GetGwUserNode(0),
228  Singleton<SatTopology>::Get()->GetUtUserNodes(),
229  appStartTime,
230  simLength,
231  Seconds(3));
232 
233  /*simulationHelper->GetTrafficHelper()->AddLoraPeriodicTraffic(
234  loraInterval,
235  packetSize,
236  Singleton<SatTopology>::Get()->GetUtNodes(),
237  appStartTime,
238  simLength,
239  Seconds(3));*/
240 
241  // Outputs
242  std::string outputPath = Singleton<SatEnvVariables>::Get()->LocateDirectory(
243  "contrib/satellite/data/sims/example-lora-handover");
244  Config::SetDefault("ns3::ConfigStore::Filename",
245  StringValue(outputPath + "/output-attributes.xml"));
246  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
247  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
248  ConfigStore outputConfig;
249  outputConfig.ConfigureDefaults();
250 
251  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
252 
253  s->AddGlobalFeederEssaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
254  s->AddGlobalFeederEssaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
255  s->AddPerUtFeederEssaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
256  s->AddPerUtFeederEssaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
257 
258  s->AddGlobalFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
259  s->AddGlobalFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
260  s->AddPerUtFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
261  s->AddPerUtFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
262 
263  s->AddGlobalRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
264  s->AddGlobalRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCATTER_FILE);
265  s->AddPerBeamRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
266  s->AddPerBeamRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCATTER_FILE);
267 
268  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
269  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
270  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
271  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
272 
273  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
274  s->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
275  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
276  s->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
277 
278  s->AddPerUtRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
279  s->AddPerUtRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
280  s->AddPerUtRtnAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
281  s->AddPerUtRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
282 
283  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
284  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
285  s->AddPerUtRtnCompositeSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
286  s->AddPerUtRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
287 
288  s->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
289  s->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
290  s->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
291  s->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
292 
293  s->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCALAR_FILE);
294  s->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
295  s->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCALAR_FILE);
296  s->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
297 
298  s->AddPerUtFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
299  s->AddPerUtFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
300  s->AddPerUtFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
301  s->AddPerUtFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
302 
303  s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
304  s->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
305  s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
306  s->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
307 
308  s->AddPerUtFwdAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
309  s->AddPerUtFwdMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
310  s->AddPerUtFwdAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
311  s->AddPerUtFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
312 
313  simulationHelper->EnableProgressLogs();
314  simulationHelper->RunSimulation();
315 
316  return 0;
317 }
@ NONE
NONE Not used.
@ 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.