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->LoadScenario("geo-33E");
169 
170  simulationHelper->CreateSatScenario();
171 
180  NS_LOG_INFO("Configuring the on-off application!");
181 
182  uint32_t packetSize(1280); // in bytes
183  DataRate dataRate(128000); // in bps
184 
185  // The application start time is varied to avoid the situation
186  // in the beginning that all applications start at the same time.
187  Time appStartTime(MilliSeconds(100));
188 
189  simulationHelper->GetTrafficHelper()->AddOnOffTraffic(
192  dataRate,
193  packetSize,
194  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
195  Singleton<SatTopology>::Get()->GetUtUserNodes(),
196  "ns3::ExponentialRandomVariable[Mean=1.0|Bound=0.0]",
197  "ns3::ExponentialRandomVariable[Mean=1.0|Bound=0.0]",
198  appStartTime,
199  Seconds(simDuration + 1),
200  MilliSeconds(25));
201 
207  NS_LOG_INFO("Setting up statistics");
208 
209  // SatStatsHelperContainer is the interface for satellite related
210  // statistics configuration.
211  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
212 
213  // Delay
214  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
215  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
216  s->AddAverageUtUserRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
217  s->AddAverageBeamRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
218 
219  // Composite SINR
220  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_FILE);
221  s->AddGlobalRtnCompositeSinr(SatStatsHelper::OUTPUT_CDF_PLOT);
222 
223  // Throughput
224  s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
225  s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_PLOT);
226  s->AddPerUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
227  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
228  s->AddPerGwRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
229 
236  NS_LOG_INFO("Storing the used attributes to XML file: training-output-attributes-ut-"
237  << utsPerBeam << ".xml");
238 
239  // std::stringstream filename;
240  // filename << "training-output-attributes-ut" << utsPerBeam << ".xml";
241  // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
242  // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
243  // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
244  // ConfigStore outputConfig;
245  // outputConfig.ConfigureDefaults ();
246 
252  NS_LOG_INFO("Running network simulator 3");
253 
254  simulationHelper->RunSimulation();
255 
256  return 0;
257 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.