sat-training-example.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: Sami Rantanen <sami.rantanen@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 
55 NS_LOG_COMPONENT_DEFINE("sat-training-example");
56 
57 int
58 main(int argc, char* argv[])
59 {
60  // Enabling logging in this program
61  LogComponentEnable("sat-training-example", LOG_LEVEL_INFO);
62 
63  NS_LOG_INFO("--- sat-training-example ---");
64 
70  uint32_t endUsersPerUt(1);
71  uint32_t utsPerBeam(1);
72  double simDuration(10.0); // in seconds
73 
74  // All the co-channel beams enabled for user link
75  // frequency color 1
76  std::set<uint32_t> coChannelBeams = {1, 3, 5, 7, 9, 22, 24, 26, 28, 30, 44, 46, 48, 50, 59, 61};
77 
81  std::string simulationName = "example-training";
82  auto simulationHelper = CreateObject<SimulationHelper>(simulationName);
83 
84  // Find the input xml file in case example is run from other than ns-3 root directory
85  std::string pathToFile = Singleton<SatEnvVariables>::Get()->LocateFile(
86  "contrib/satellite/examples/training-input-attributes.xml");
87 
94  CommandLine cmd;
95  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
96  cmd.AddValue("simDurationInSeconds", "Simulation duration in seconds", simDuration);
97  simulationHelper->AddDefaultUiArguments(cmd, pathToFile);
98  cmd.Parse(argc, argv);
99 
105  NS_LOG_INFO("Reading the XML input: training-input-attributes.xml");
106 
107  Config::SetDefault("ns3::ConfigStore::Filename", StringValue(pathToFile));
108  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
109  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
110  ConfigStore inputConfig;
111  inputConfig.ConfigureDefaults();
112 
119  // Enable RBDC for BE
120  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
121  BooleanValue(false));
122  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed", BooleanValue(true));
123  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_MinimumServiceRate",
124  UintegerValue(40));
125  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
126  BooleanValue(false));
127  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
128  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotInterval", TimeValue(Seconds(1)));
129 
130  // Tune the superframe configuration
131  Config::SetDefault("ns3::SatSuperframeConf0::FrameCount", UintegerValue(3));
132  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_AllocatedBandwidthHz", DoubleValue(5e+06));
133  Config::SetDefault("ns3::SatSuperframeConf0::Frame1_AllocatedBandwidthHz", DoubleValue(10e+06));
134  Config::SetDefault("ns3::SatSuperframeConf0::Frame2_AllocatedBandwidthHz", DoubleValue(10e+06));
135 
136  // Enable traces
137  Config::SetDefault("ns3::SatChannel::EnableRxPowerOutputTrace", BooleanValue(true));
138  Config::SetDefault("ns3::SatChannel::EnableFadingOutputTrace", BooleanValue(true));
139  Config::SetDefault("ns3::SatPhyRxCarrier::EnableCompositeSinrOutputTrace", BooleanValue(true));
140  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
141 
142  Singleton<SatFadingOutputTraceContainer>::Get()->EnableFigureOutput(false);
143  Singleton<SatInterferenceOutputTraceContainer>::Get()->EnableFigureOutput(false);
144  Singleton<SatRxPowerOutputTraceContainer>::Get()->EnableFigureOutput(false);
145  Singleton<SatCompositeSinrOutputTraceContainer>::Get()->EnableFigureOutput(false);
146 
147  // Enable creation traces
148  Config::SetDefault("ns3::SatHelper::ScenarioCreationTraceEnabled", BooleanValue(true));
149 
150  // Enable packet traces
151  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
152 
159  NS_LOG_INFO("Creating the satellite scenario");
160  // Each beam will have 'utsPerBeam' user terminals and 'endUsersPerUt'
161  // end users per UT. Note, that this allows also different configurations
162  // per spot-beam.
163  simulationHelper->SetUserCountPerUt(endUsersPerUt);
164  simulationHelper->SetUtCountPerBeam(utsPerBeam);
165  simulationHelper->SetBeamSet(coChannelBeams);
166  simulationHelper->SetSimulationTime(simDuration);
167 
168  simulationHelper->CreateSatScenario();
169 
178  NS_LOG_INFO("Configuring the on-off application!");
179 
180  uint32_t packetSize(1280); // in bytes
181  DataRate dataRate(128000); // in bps
182 
183  // The application start time is varied to avoid the situation
184  // in the beginning that all applications start at the same time.
185  Time appStartTime(MilliSeconds(100));
186 
187  Config::SetDefault("ns3::OnOffApplication::PacketSize", UintegerValue(packetSize));
188  Config::SetDefault("ns3::OnOffApplication::DataRate", DataRateValue(dataRate));
189  Config::SetDefault("ns3::OnOffApplication::OnTime",
190  StringValue("ns3::ExponentialRandomVariable[Mean=1.0|Bound=0.0]"));
191  Config::SetDefault("ns3::OnOffApplication::OffTime",
192  StringValue("ns3::ExponentialRandomVariable[Mean=1.0|Bound=0.0]"));
193 
194  simulationHelper->InstallTrafficModel(SimulationHelper::ONOFF,
197  appStartTime,
198  Seconds(simDuration + 1),
199  MilliSeconds(25));
200 
206  NS_LOG_INFO("Setting up statistics");
207 
208  // SatStatsHelperContainer is the interface for satellite related
209  // statistics configuration.
210  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
211 
212  // Delay
213  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
214  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
215  s->AddAverageUtUserRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
216  s->AddAverageBeamRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
217 
218  // Composite SINR
219  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
220  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_PLOT);
221 
222  // Throughput
223  s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
224  s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_PLOT);
225  s->AddPerUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
226  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
227  s->AddPerGwRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
228 
235  NS_LOG_INFO("Storing the used attributes to XML file: training-output-attributes-ut-"
236  << utsPerBeam << ".xml");
237 
238  // std::stringstream filename;
239  // filename << "training-output-attributes-ut" << utsPerBeam << ".xml";
240  // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
241  // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
242  // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
243  // ConfigStore outputConfig;
244  // outputConfig.ConfigureDefaults ();
245 
251  NS_LOG_INFO("Running network simulator 3");
252 
253  simulationHelper->RunSimulation();
254 
255  return 0;
256 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.