sat-essa-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-essa-example");
40 
41 int
42 main(int argc, char* argv[])
43 {
44  // Variables
45  std::string beams = "8";
46  uint32_t nbGw = 1;
47  uint32_t nbUtsPerBeam = 100;
48  uint32_t nbEndUsersPerUt = 1;
49 
50  Time appStartTime = Seconds(0.001);
51  Time simLength = Seconds(60.0);
52 
53  uint32_t packetSize = 64;
54  std::string dataRate = "5kbps";
55  std::string onTime = "0.2";
56  std::string offTime = "0.8";
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  Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("example-essa");
68 
69  // read command line parameters given by user
70  CommandLine cmd;
71  cmd.AddValue("modelPP", "interferenceModePerPacket", interferenceModePerPacket);
72  cmd.AddValue("traces", "displayTraces", displayTraces);
73  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", nbUtsPerBeam);
74  cmd.AddValue("simLength", "Simulation duration in seconds", simLength);
75  cmd.AddValue("packetSize", "Constant packet size in bytes", packetSize);
76  cmd.AddValue("dataRate", "Data rate (e.g. 500kb/s)", dataRate);
77  cmd.AddValue("onTime", "Time for packet sending is on in seconds", onTime);
78  cmd.AddValue("offTime", "Time for packet sending is off in seconds", offTime);
79  cmd.AddValue("frameAllocatedBandwidthHz",
80  "Allocated bandwidth in Hz",
81  frameAllocatedBandwidthHz);
82  cmd.AddValue("frameCarrierAllocatedBandwidthHz",
83  "Allocated carrier bandwidth in Hz",
84  frameCarrierAllocatedBandwidthHz);
85  cmd.AddValue("frameCarrierRollOff", "Roll-off factor", frameCarrierRollOff);
86  cmd.AddValue("frameCarrierSpacing", "Carrier spacing factor", frameCarrierSpacing);
87  cmd.AddValue("frameSpreadingFactor", "Carrier spreading factor", frameSpreadingFactor);
88  simulationHelper->AddDefaultUiArguments(cmd);
89  cmd.Parse(argc, argv);
90 
91  // Defaults
92  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
93  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
94 
95  // Superframe configuration
96  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
98  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
100  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz",
101  DoubleValue(frameAllocatedBandwidthHz));
102  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
103  DoubleValue(frameCarrierAllocatedBandwidthHz));
104  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierRollOff",
105  DoubleValue(frameCarrierRollOff));
106  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierSpacing",
107  DoubleValue(frameCarrierSpacing));
108  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_SpreadingFactor",
109  UintegerValue(frameSpreadingFactor));
110 
111  // CRDSA only
112  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaServiceCount", UintegerValue(4));
113  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
114  BooleanValue(false));
115  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
116  BooleanValue(false));
117  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
118  BooleanValue(false));
119  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
120  BooleanValue(false));
121  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
122  BooleanValue(false));
123  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
124  BooleanValue(false));
125  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
126  BooleanValue(false));
127  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
128  BooleanValue(false));
129  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
130  BooleanValue(false));
131  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
132  BooleanValue(false));
133  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
134  BooleanValue(false));
135  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
136  BooleanValue(false));
137 
138  // Configure RA
139  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
140  if (interferenceModePerPacket)
141  {
142  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
144  }
145  else
146  {
147  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
149  }
150  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
152  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
154  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_FSIM));
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 
189  // Traffics
190  simulationHelper->SetSimulationTime(simLength);
191 
192  simulationHelper->SetGwUserCount(nbGw);
193  simulationHelper->SetUtCountPerBeam(nbUtsPerBeam);
194  simulationHelper->SetUserCountPerUt(nbEndUsersPerUt);
195  simulationHelper->SetBeams(beams);
196 
197  simulationHelper->LoadScenario("geo-33E-fsim");
198 
199  simulationHelper->CreateSatScenario();
200 
201  simulationHelper->GetTrafficHelper()->AddOnOffTraffic(
204  dataRate,
205  packetSize,
206  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
207  Singleton<SatTopology>::Get()->GetUtUserNodes(),
208  "ns3::ConstantRandomVariable[Constant=" + onTime + "]",
209  "ns3::ConstantRandomVariable[Constant=" + offTime + "]",
210  appStartTime,
211  simLength,
212  Seconds(0));
213 
214  // Outputs
215  simulationHelper->EnableProgressLogs();
216 
217  std::string outputPath = Singleton<SatEnvVariables>::Get()->LocateDirectory(
218  "contrib/satellite/data/sims/example-essa");
219  Config::SetDefault("ns3::ConfigStore::Filename",
220  StringValue(outputPath + "/output-attributes.xml"));
221  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
222  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
223  ConfigStore outputConfig;
224  outputConfig.ConfigureDefaults();
225 
226  if (displayTraces)
227  {
228  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
229 
230  s->AddGlobalFeederEssaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
231  s->AddGlobalFeederEssaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
232  s->AddPerUtFeederEssaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
233  s->AddPerUtFeederEssaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
234 
235  s->AddGlobalFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
236  s->AddGlobalFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
237  s->AddPerUtFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
238  s->AddPerUtFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
239 
240  s->AddGlobalRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
241  s->AddGlobalRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCATTER_FILE);
242  s->AddPerBeamRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
243  s->AddPerBeamRtnFeederWindowLoad(SatStatsHelper::OUTPUT_SCATTER_FILE);
244 
245  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
246  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
247  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
248  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
249 
250  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
251  s->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
252  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
253  s->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
254 
255  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
256  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
257  s->AddPerUtRtnCompositeSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
258  s->AddPerUtRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
259 
260  s->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
261  s->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
262  s->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_SCALAR_FILE);
263  s->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
264 
265  s->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCALAR_FILE);
266  s->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
267  s->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCALAR_FILE);
268  s->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
269  }
270 
271  simulationHelper->RunSimulation();
272 
273  return 0;
274 
275 } // end of `int main (int argc, char *argv[])`
@ 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.