sat-dama-verification-sim.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-verification-sim");
43 
44 int
45 main(int argc, char* argv[])
46 {
47  // LogComponentEnable ("sat-dama-verification-sim", LOG_LEVEL_INFO);
48 
49  // Spot-beam over Finland
50  uint32_t beamId = 18;
51  uint32_t endUsersPerUt(1);
52  uint32_t utsPerBeam(220);
53 
54  // CBR
55  uint32_t packetSize(1280); // in bytes
56  double intervalSeconds = 0.005;
57 
58  double simLength(50.0); // in seconds
59  Time appStartTime = Seconds(0.1);
60 
62  auto simulationHelper = CreateObject<SimulationHelper>("example-dama-verification-sim");
63  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
64 
65  // Find the input xml file in case example is run from other than ns-3 root directory
66  std::string pathToFile = Singleton<SatEnvVariables>::Get()->LocateFile(
67  "contrib/satellite/examples/tn9-dama-input-attributes.xml");
68 
69  // read command line parameters given by user
70  CommandLine cmd;
71  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
72  cmd.AddValue("packetSize", "Packet size in bytes", packetSize);
73  simulationHelper->AddDefaultUiArguments(cmd, pathToFile);
74  cmd.Parse(argc, argv);
75 
76  // To read attributes from file
77  Config::SetDefault("ns3::ConfigStore::Filename", StringValue(pathToFile));
78  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
79  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
80  ConfigStore inputConfig;
81  inputConfig.ConfigureDefaults();
82 
83  simulationHelper->SetUtCountPerBeam(utsPerBeam);
84  simulationHelper->SetUserCountPerUt(endUsersPerUt);
85  simulationHelper->SetSimulationTime(simLength);
86  simulationHelper->SetBeamSet({beamId});
87 
88  // 5 ms -> 200 packets per second
89  // 250 B -> 400 kbps
90  // 500 B -> 800 kbps
91  // 750 B -> 1200 kbps
92  // 1000 B -> 1600 kbps
93  // 1250 B -> 2000 kbps
94 
95  // RBDC + periodical control slots
96  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
97  BooleanValue(false));
98  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed", BooleanValue(true));
99  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_MinimumServiceRate",
100  UintegerValue(10));
101  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
102  BooleanValue(false));
103  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
104  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotInterval", TimeValue(Seconds(1)));
105 
106  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
107  Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
108 
109  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_OFF));
110 
117  Config::SetDefault("ns3::SatSuperframeConf0::FrameCount", UintegerValue(3));
118  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_AllocatedBandwidthHz",
119  DoubleValue(2.5e+07));
120  Config::SetDefault("ns3::SatSuperframeConf0::Frame1_AllocatedBandwidthHz", DoubleValue(5e+07));
121  Config::SetDefault("ns3::SatSuperframeConf0::Frame2_AllocatedBandwidthHz", DoubleValue(5e+07));
122 
123  // Creating the reference system. Note, currently the satellite module supports
124  // only one reference system, which is named as "Scenario72". The string is utilized
125  // in mapping the scenario to the needed reference system configuration files. Arbitrary
126  // scenario name results in fatal error.
127  simulationHelper->CreateSatScenario();
128 
132  Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(Seconds(intervalSeconds)));
133  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
134 
135  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
138  appStartTime,
139  Seconds(simLength),
140  MilliSeconds(50));
144  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
145 
146  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
147  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
148  s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
149  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
150  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_SCATTER_PLOT);
151  s->AddGlobalRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
152  s->AddGlobalFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
153  s->AddGlobalWaveformUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
154 
155  NS_LOG_INFO("--- sat-dama-verification-sim ---");
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 << "tn9-dama-output-attributes-ut" << utsPerBeam
167  // << "-packetSize" << packetSize
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 
179  simulationHelper->RunSimulation();
180 
181  return 0;
182 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.