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  simulationHelper->LoadScenario("geo-33E");
96 
97  // Creating the reference system.
98  switch (profilingConf)
99  {
100  // Single beam
101  case 0: {
102  // Spot-beam over Finland
103  uint32_t beamId = 18;
104  simLength = 60.0; // in seconds
105 
106  // create user defined scenario
107  simulationHelper->SetUtCountPerBeam(utsPerBeam);
108  simulationHelper->SetUserCountPerUt(endUsersPerUt);
109  simulationHelper->SetBeamSet({beamId});
110  simulationHelper->SetSimulationTime(simLength);
111  simulationHelper->CreateSatScenario();
112  break;
113  }
114  // Full
115  case 1: {
116  simLength = 30.0; // in seconds
117 
118  simulationHelper->SetSimulationTime(simLength);
119  simulationHelper->CreateSatScenario(SatHelper::FULL);
120  break;
121  }
122  default: {
123  NS_FATAL_ERROR("Invalid profiling configuration");
124  }
125  }
126 
130  simulationHelper->GetTrafficHelper()->AddCbrTraffic(
133  Seconds(intervalSeconds),
134  packetSize,
135  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
136  Singleton<SatTopology>::Get()->GetUtUserNodes(),
137  appStartTime,
138  Seconds(simLength + 1),
139  MilliSeconds(10));
140 
144  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
145 
146  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
147  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_PLOT);
148  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
149  s->AddPerBeamRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
150  s->AddPerBeamRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
151  s->AddPerBeamRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
152  s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
153  s->AddPerBeamFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
154 
155  NS_LOG_INFO("--- sat-profiling-sim-tn8 ---");
156  NS_LOG_INFO(" Packet size: " << packetSize);
157  NS_LOG_INFO(" Simulation length: " << simLength);
158  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
159  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
160  NS_LOG_INFO(" ");
161 
165  std::stringstream filename;
166  filename << "tn8-profiling-output-attributes-conf-" << profilingConf << "-uts-" << utsPerBeam
167  << ".xml";
168 
169  // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
170  // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
171  // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
172  // ConfigStore outputConfig;
173  // outputConfig.ConfigureDefaults ();
174 
179  double t = 0.0;
180  while (t <= simLength)
181  {
182  Simulator::Schedule(Seconds(t), &TimeTickerCallback);
183  t = t + 1.0;
184  }
185 
189  simulationHelper->RunSimulation();
190 
191  return 0;
192 }
@ FULL
FULL Full scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
void TimeTickerCallback()