sat-per-packet-if-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/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 
29 #include <sys/stat.h>
30 #include <unistd.h>
31 
32 using namespace ns3;
33 
44 NS_LOG_COMPONENT_DEFINE("sat-per-packet-if-sim-tn9");
45 
46 int
47 main(int argc, char* argv[])
48 {
49  uint32_t endUsersPerUt(1);
50  uint32_t utsPerBeam(220); // expected to be equivalent with 70% system load
51  DataRate dataRate(32000); // in bps
52  uint32_t beamConf(0);
53  uint32_t fadingConf(0);
54 
55  uint32_t packetSize(1280); // in bytes
56  double simLength(50.0); // in seconds
57  Time appStartTime = Seconds(0.1);
58 
60  auto simulationHelper = CreateObject<SimulationHelper>("example-per-packet-if-sim-tn9");
61  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
62 
63  // To read attributes from file
64  std::string pathToFile = Singleton<SatEnvVariables>::Get()->LocateFile(
65  "contrib/satellite/examples/tn9-dama-input-attributes.xml");
66 
102  // read command line parameters given by user
103  CommandLine cmd;
104  cmd.AddValue("simLength", "Simulation duration in seconds", simLength);
105  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
106  cmd.AddValue("beamConf", "Beam configuration", beamConf);
107  cmd.AddValue("fadingConf", "Fading configuration (0: Markov, 1: Rain)", fadingConf);
108  simulationHelper->AddDefaultUiArguments(cmd, pathToFile);
109  cmd.Parse(argc, argv);
110 
111  Config::SetDefault("ns3::ConfigStore::Filename", StringValue(pathToFile));
112  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
113  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
114 
115  ConfigStore inputConfig;
116  inputConfig.ConfigureDefaults();
117 
118  // NCC configuration
119  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
120  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
121 
122  // RBDC
123  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
124  BooleanValue(false));
125  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed", BooleanValue(true));
126  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_MinimumServiceRate",
127  UintegerValue(16));
128  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
129  BooleanValue(false));
130  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_OFF));
131  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
132 
133  // Per-packet interference
134  Config::SetDefault("ns3::SatUtHelper::DaFwdLinkInterferenceModel",
136  Config::SetDefault("ns3::SatGeoHelper::DaFwdLinkInterferenceModel",
138  Config::SetDefault("ns3::SatGeoHelper::DaRtnLinkInterferenceModel",
140  Config::SetDefault("ns3::SatGwHelper::DaRtnLinkInterferenceModel",
142 
143  switch (fadingConf)
144  {
145  case 0: {
146  // Markov fading
147  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_MARKOV));
148  break;
149  }
150  case 1: {
151  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_OFF));
152 
153  // Rain fading
154  // Note, that the positions of the fading files do not necessarily match with the
155  // beam location, since this example is not using list position allocator!
156  Config::SetDefault("ns3::SatChannel::EnableExternalFadingInputTrace", BooleanValue(true));
157  Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtFwdDownIndexFileName",
158  StringValue("BeamId-1_256_UT_fading_fwddwn_trace_index.txt"));
159  Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtRtnUpIndexFileName",
160  StringValue("BeamId-1_256_UT_fading_rtnup_trace_index.txt"));
161 
162  break;
163  }
164  default: {
165  NS_FATAL_ERROR("Unsupported fadingConf: " << fadingConf);
166  break;
167  }
168  }
169 
170  simulationHelper->SetSimulationTime(simLength);
171  simulationHelper->SetUtCountPerBeam(utsPerBeam);
172  simulationHelper->SetUserCountPerUt(endUsersPerUt);
173  switch (beamConf)
174  {
175  // Single beam
176  case 0: {
177  // Spot-beam over Finland
178  simulationHelper->SetBeamSet({18});
179  break;
180  }
181  // All co-channel beams (e.g., color 1 with 72/4 = 18 beams)
182  case 1: {
183  // choose beams from user link frequency ID = 1 (TN3 appendix A)
184  simulationHelper->SetBeamSet(
185  {1, 3, 5, 7, 9, 22, 24, 26, 28, 30, 44, 46, 48, 50, 59, 61, 70, 72});
186  break;
187  }
188  default: {
189  NS_FATAL_ERROR("Unsupported beam configuration: " << beamConf);
190  }
191  }
192 
193  // Creating the reference system. Note, currently the satellite module supports
194  // only one reference system, which is named as "Scenario72". The string is utilized
195  // in mapping the scenario to the needed reference system configuration files. Arbitrary
196  // scenario name results in fatal error.
197  Ptr<SatHelper> helper = simulationHelper->CreateSatScenario();
198 
202  simulationHelper->InstallTrafficModel(SimulationHelper::ONOFF,
205  appStartTime,
206  Seconds(simLength + 1),
207  MilliSeconds(50));
208 
212  Ptr<SatStatsHelperContainer> s = CreateObject<SatStatsHelperContainer>(helper);
213 
214  s->AddGlobalFwdCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
215  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
216 
217  s->AddGlobalRtnFeederLinkSinr(SatStatsHelper::OUTPUT_CDF_FILE);
218  s->AddGlobalRtnUserLinkSinr(SatStatsHelper::OUTPUT_CDF_FILE);
219 
220  s->AddGlobalRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_CDF_FILE);
221  s->AddGlobalRtnUserLinkRxPower(SatStatsHelper::OUTPUT_CDF_FILE);
222 
223  NS_LOG_INFO("--- sat-per-packet-if-sim-tn9 ---");
224  NS_LOG_INFO(" Packet size: " << packetSize);
225  NS_LOG_INFO(" Simulation length: " << simLength);
226  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
227  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
228  NS_LOG_INFO(" ");
229 
233  // std::stringstream filename;
234  // filename << "tn9-per-packet-if-output-attributes-ut" << utsPerBeam
235  // << "-conf" << beamConf << ".xml";
236  //
237  // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
238  // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
239  // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
240  // ConfigStore outputConfig;
241  // outputConfig.ConfigureDefaults ();
242 
246  simulationHelper->RunSimulation();
247 
248  return 0;
249 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.