sat-dama-http-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: Budiarto Herman <budiarto.herman@magister.fi>
19  *
20  */
21 
22 #include "ns3/config-store-module.h"
23 #include "ns3/core-module.h"
24 #include "ns3/internet-module.h"
25 #include "ns3/network-module.h"
26 #include "ns3/satellite-module.h"
27 #include "ns3/traffic-module.h"
28 
29 using namespace ns3;
30 
42 NS_LOG_COMPONENT_DEFINE("sat-dama-http-sim-tn9");
43 
44 int
45 main(int argc, char* argv[])
46 {
47  // Spot-beam over Finland
48  uint32_t beamId = 18;
49  uint32_t endUsersPerUt(1);
50  uint32_t utsPerBeam(1);
51  uint32_t crTxConf(0);
52 
53  double simLength(300.0); // in seconds
54 
56  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
57 
59  Ptr<SimulationHelper> simulationHelper =
60  CreateObject<SimulationHelper>("example-dama-http-sim-tn9");
61 
62  // To read attributes from file
63  std::string inputFileNameWithPath =
64  Singleton<SatEnvVariables>::Get()->LocateDirectory("contrib/satellite/examples") +
65  "/tn9-dama-input-attributes.xml";
66 
103  // read command line parameters given by user
104  CommandLine cmd;
105  cmd.AddValue("simLength", "Simulation duration in seconds", simLength);
106  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
107  cmd.AddValue("crTxConf", "CR transmission configuration", crTxConf);
108  simulationHelper->AddDefaultUiArguments(cmd, inputFileNameWithPath);
109  cmd.Parse(argc, argv);
110 
111  Config::SetDefault("ns3::ConfigStore::Filename", StringValue(inputFileNameWithPath));
112  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
113  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
114  ConfigStore inputConfig;
115  inputConfig.ConfigureDefaults();
116 
117  simulationHelper->SetSimulationTime(simLength);
118  simulationHelper->SetUserCountPerUt(endUsersPerUt);
119  simulationHelper->SetUtCountPerBeam(utsPerBeam);
120 
121  // Set beam ID
122  std::stringstream beamsEnabled;
123  beamsEnabled << beamId;
124  simulationHelper->SetBeams(beamsEnabled.str());
125 
126  // NCC configuration
127  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
128  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
129 
130  // RBDC
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 
139  switch (crTxConf)
140  {
141  // Periodical control slots
142  case 0: {
143  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
144  EnumValue(SatEnums::RA_MODEL_OFF));
145  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
146  break;
147  }
148  // Slotted ALOHA
149  case 1: {
150  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
152  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
153  break;
154  }
155  // CRDSA (loose RC 0)
156  case 2: {
157  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
158  EnumValue(SatEnums::RA_MODEL_CRDSA));
159  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
160  Config::SetDefault("ns3::SatUtHelper::UseCrdsaOnlyForControlPackets", BooleanValue(false));
161  break;
162  }
163  default: {
164  NS_FATAL_ERROR("Unsupported crTxConf: " << crTxConf);
165  break;
166  }
167  }
168 
169  // Creating the reference system. Note, currently the satellite module supports
170  // only one reference system, which is named as "Scenario72". The string is utilized
171  // in mapping the scenario to the needed reference system configuration files. Arbitrary
172  // scenario name results in fatal error.
173  simulationHelper->CreateSatScenario();
174 
178  simulationHelper->InstallTrafficModel(SimulationHelper::HTTP,
181  MilliSeconds(3));
182 
186  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
187 
188  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_PLOT);
189  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
190  s->AddPerBeamRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
191  s->AddPerBeamRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
192  s->AddPerBeamRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
193 
194  s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
195  s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
196  s->AddPerBeamRtnDevDelay(SatStatsHelper::OUTPUT_CDF_FILE);
197  s->AddPerBeamRtnDevDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
198  s->AddPerBeamRtnPhyDelay(SatStatsHelper::OUTPUT_CDF_FILE);
199  s->AddPerBeamRtnPhyDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
200 
201  s->AddPerBeamFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_PLOT);
202  s->AddPerBeamFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
203  s->AddPerBeamFwdUserDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
204  s->AddPerBeamFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
205  s->AddPerBeamFwdUserPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
206 
207  s->AddPerBeamFwdAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
208  s->AddPerBeamFwdAppDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
209  s->AddPerBeamFwdDevDelay(SatStatsHelper::OUTPUT_CDF_FILE);
210  s->AddPerBeamFwdDevDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
211  s->AddPerBeamFwdPhyDelay(SatStatsHelper::OUTPUT_CDF_FILE);
212  s->AddPerBeamFwdPhyDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
213 
214  s->AddPerBeamRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
215  s->AddPerBeamFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
216  s->AddPerBeamWaveformUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
217  s->AddPerBeamCapacityRequest(SatStatsHelper::OUTPUT_SCATTER_FILE);
218  s->AddPerBeamResourcesGranted(SatStatsHelper::OUTPUT_SCATTER_PLOT);
219 
220  s->AddPerBeamFeederCrdsaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
221  s->AddPerBeamFeederCrdsaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
222  s->AddPerBeamFeederSlottedAlohaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
223  s->AddPerBeamFeederSlottedAlohaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
224 
225  NS_LOG_INFO("--- sat-dama-http-sim-tn9 ---");
226  NS_LOG_INFO(" Simulation length: " << simLength);
227  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
228  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
229  NS_LOG_INFO(" ");
230 
234  // std::stringstream filename;
235  // filename << "tn9-dama-onoff-output-attributes-ut" << utsPerBeam
236  // << "-conf" << crTxConf << ".xml";
237  //
238  // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
239  // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
240  // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
241  // ConfigStore outputConfig;
242  // outputConfig.ConfigureDefaults ();
243 
247  simulationHelper->RunSimulation();
248 
249  return 0;
250 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.