sat-profiling-sim-tn8.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: Frans Laakso <frans.laakso@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 
44 NS_LOG_COMPONENT_DEFINE("sat-profiling-sim-tn8");
45 
46 void
48 {
49  std::cout << "Time: " << Simulator::Now().GetSeconds() << "s" << std::endl;
50 }
51 
52 int
53 main(int argc, char* argv[])
54 {
55  uint32_t endUsersPerUt(1);
56  uint32_t utsPerBeam(1);
57  uint32_t profilingConf(0);
58 
59  // 256 kbps per end user
60  uint32_t packetSize(1280); // in bytes
61  double intervalSeconds = 0.04;
62 
63  double simLength; // defined later in scenario creation
64  Time appStartTime = Seconds(0.1);
65 
67  auto simulationHelper = CreateObject<SimulationHelper>("example-profiling-sim-tn8");
68 
69  // To read attributes from file
70  // std::string inputFileNameWithPath = Singleton<SatEnvVariables>::Get ()->LocateDirectory
71  // ("contrib/satellite/examples") + "/tn8-profiling-input-attributes.xml"; Config::SetDefault
72  // ("ns3::ConfigStore::Filename", StringValue (inputFileNameWithPath)); Config::SetDefault
73  // ("ns3::ConfigStore::Mode", StringValue ("Load")); Config::SetDefault
74  // ("ns3::ConfigStore::FileFormat", StringValue ("Xml")); ConfigStore inputConfig;
75  // inputConfig.ConfigureDefaults ();
76 
77  // read command line parameters given by user
78  CommandLine cmd;
79  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
80  cmd.AddValue("profilingConf", "Profiling configuration", profilingConf);
81  simulationHelper->AddDefaultUiArguments(cmd);
82  cmd.Parse(argc, argv);
83 
84  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
85  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
86 
87  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
88  BooleanValue(false));
89  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed", BooleanValue(true));
90  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_MinimumServiceRate",
91  UintegerValue(64));
92  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
93  BooleanValue(false));
94 
95  // Creating the reference system. Note, currently the satellite module supports
96  // only one reference system, which is named as "Scenario72". The string is utilized
97  // in mapping the scenario to the needed reference system configuration files. Arbitrary
98  // scenario name results in fatal error.
99  Ptr<SatHelper> helper;
100  switch (profilingConf)
101  {
102  // Single beam
103  case 0: {
104  // Spot-beam over Finland
105  uint32_t beamId = 18;
106  simLength = 60.0; // in seconds
107 
108  // create user defined scenario
109  simulationHelper->SetUtCountPerBeam(utsPerBeam);
110  simulationHelper->SetUserCountPerUt(endUsersPerUt);
111  simulationHelper->SetBeamSet({beamId});
112  simulationHelper->SetSimulationTime(simLength);
113  helper = simulationHelper->CreateSatScenario();
114  break;
115  }
116  // Full
117  case 1: {
118  simLength = 30.0; // in seconds
119 
120  simulationHelper->SetSimulationTime(simLength);
121  helper = simulationHelper->CreateSatScenario(SatHelper::FULL);
122  break;
123  }
124  default: {
125  NS_FATAL_ERROR("Invalid profiling configuration");
126  }
127  }
128 
133  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
134  Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(Seconds(intervalSeconds)));
135  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
138  appStartTime,
139  Seconds(simLength + 1),
140  MilliSeconds(10));
141 
145  Ptr<SatStatsHelperContainer> s = CreateObject<SatStatsHelperContainer>(helper);
146 
147  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
148  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_PLOT);
149  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
150  s->AddPerBeamRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
151  s->AddPerBeamRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
152  s->AddPerBeamRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
153  s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
154  s->AddPerBeamFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
155 
156  NS_LOG_INFO("--- sat-profiling-sim-tn8 ---");
157  NS_LOG_INFO(" Packet size: " << packetSize);
158  NS_LOG_INFO(" Simulation length: " << simLength);
159  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
160  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
161  NS_LOG_INFO(" ");
162 
166  std::stringstream filename;
167  filename << "tn8-profiling-output-attributes-conf-" << profilingConf << "-uts-" << utsPerBeam
168  << ".xml";
169 
170  // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
171  // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
172  // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
173  // ConfigStore outputConfig;
174  // outputConfig.ConfigureDefaults ();
175 
180  double t = 0.0;
181  while (t <= simLength)
182  {
183  Simulator::Schedule(Seconds(t), &TimeTickerCallback);
184  t = t + 1.0;
185  }
186 
190  simulationHelper->RunSimulation();
191 
192  return 0;
193 }
@ FULL
FULL Full scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
void TimeTickerCallback()