sat-dama-sim-tn9.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: Jani Puttonen <jani.puttonen@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 
42 NS_LOG_COMPONENT_DEFINE("sat-dama-sim-tn9");
43 
44 int
45 main(int argc, char* argv[])
46 {
47  // LogComponentEnable ("sat-dama-sim-tn9", LOG_LEVEL_INFO);
48 
49  // Spot-beam over Finland
50  uint32_t beamId = 18;
51  uint32_t endUsersPerUt(1);
52  uint32_t utsPerBeam(220); // 80% system load according to NCC-2
53  uint32_t nccConf(0);
54  uint32_t fadingConf(0);
55 
56  // 16 kbps per end user
57  uint32_t packetSize(1280); // in bytes
58  double intervalSeconds = 0.64;
59 
60  double simLength(300.0); // in seconds
61  Time appStartTime = Seconds(0.1);
62 
64  auto simulationHelper = CreateObject<SimulationHelper>("example-dama-sim-tn9");
65  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
66 
67  std::string inputFileNameWithPath =
68  Singleton<SatEnvVariables>::Get()->LocateDirectory("contrib/satellite/examples") +
69  "/tn9-dama-input-attributes.xml";
70 
71  // read command line parameters given by user
72  CommandLine cmd;
73  cmd.AddValue("simLength", "Simulation duration in seconds", simLength);
74  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
75  cmd.AddValue("nccConf", "NCC configuration", nccConf);
76  cmd.AddValue("fadingConf", "Fading configuration (0: Markov, 1: Rain)", fadingConf);
77  simulationHelper->AddDefaultUiArguments(cmd, inputFileNameWithPath);
78  cmd.Parse(argc, argv);
79 
80  // To read attributes from file
81  Config::SetDefault("ns3::ConfigStore::Filename", StringValue(inputFileNameWithPath));
82  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
83  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
84  ConfigStore inputConfig;
85  inputConfig.ConfigureDefaults();
86 
125  simulationHelper->SetUtCountPerBeam(utsPerBeam);
126  simulationHelper->SetUserCountPerUt(endUsersPerUt);
127  simulationHelper->SetSimulationTime(simLength);
128  simulationHelper->SetBeamSet({beamId});
129 
130  // RBDC + periodical control slots
131  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
132  BooleanValue(false));
133  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed", BooleanValue(true));
134  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_MinimumServiceRate",
135  UintegerValue(16));
136  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
137  BooleanValue(false));
138  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
139 
140  switch (nccConf)
141  {
142  case 0: {
143  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_0"));
144  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(false));
145  break;
146  }
147  case 1: {
148  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_1"));
149  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
150  break;
151  }
152  case 2: {
153  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
154  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
155  break;
156  }
157  default: {
158  NS_FATAL_ERROR("Unsupported nccConf: " << nccConf);
159  break;
160  }
161  }
162 
163  switch (fadingConf)
164  {
165  case 0: {
166  // Markov fading
167  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_MARKOV));
168  break;
169  }
170  case 1: {
171  // Rain fading
172  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_OFF));
173 
174  // Note, that the positions of the fading files do not necessarily match with the
175  // beam location, since this example is not using list position allocator!
176  Config::SetDefault("ns3::SatChannel::EnableExternalFadingInputTrace", BooleanValue(true));
177  Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtFwdDownIndexFileName",
178  StringValue("BeamId-1_256_UT_fading_fwddwn_trace_index.txt"));
179  Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtRtnUpIndexFileName",
180  StringValue("BeamId-1_256_UT_fading_rtnup_trace_index.txt"));
181 
182  break;
183  }
184  default: {
185  NS_FATAL_ERROR("Unsupported fadingConf: " << fadingConf);
186  break;
187  }
188  }
189 
190  // Creating the reference system. Note, currently the satellite module supports
191  // only one reference system, which is named as "Scenario72". The string is utilized
192  // in mapping the scenario to the needed reference system configuration files. Arbitrary
193  // scenario name results in fatal error.
194  simulationHelper->CreateSatScenario();
195 
196  // setup CBR traffic
197  Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(Seconds(intervalSeconds)));
198  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
199 
200  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
203  appStartTime,
204  Seconds(simLength),
205  MilliSeconds(50));
206 
210  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
211 
212  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_PLOT);
213  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
214  s->AddPerBeamRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
215  s->AddPerBeamRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
216  s->AddPerBeamRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
217 
218  s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
219  s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_PLOT);
220 
221  s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
222  s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
223 
224  s->AddPerBeamRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_PLOT);
225  s->AddPerBeamRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_PLOT);
226 
227  s->AddPerBeamRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
228  s->AddPerBeamFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
229  s->AddPerBeamWaveformUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
230  s->AddPerBeamCapacityRequest(SatStatsHelper::OUTPUT_SCATTER_FILE);
231  s->AddPerBeamResourcesGranted(SatStatsHelper::OUTPUT_SCATTER_PLOT);
232 
233  NS_LOG_INFO("--- sat-dama-sim-tn9 ---");
234  NS_LOG_INFO(" Packet size: " << packetSize);
235  NS_LOG_INFO(" Simulation length: " << simLength);
236  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
237  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
238  NS_LOG_INFO(" ");
239 
243  // std::stringstream filename;
244  // filename << "tn9-dama-output-attributes-ut" << utsPerBeam
245  // << "-ncc" << nccConf
246  // << "-fading" << fadingConf << ".xml";
247  //
248  // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
249  // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
250  // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
251  // ConfigStore outputConfig;
252  // outputConfig.ConfigureDefaults ();
253 
257  simulationHelper->RunSimulation();
258 
259  return 0;
260 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.