sat-regeneration-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: Bastien Tauran <bastien.tauran@viveris.fr>
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-regeneration-example");
45 
46 int
47 main(int argc, char* argv[])
48 {
49  uint32_t beamIdInFullScenario = 10;
50  uint32_t packetSize = 512;
51  std::string interval = "10ms";
52  std::string scenario = "simple";
53  std::string forwardRegeneration = "regeneration_network";
54  std::string returnRegeneration = "regeneration_network";
55 
56  std::map<std::string, SatHelper::PreDefinedScenario_t> mapScenario{
57  {"simple", SatHelper::SIMPLE},
58  {"larger", SatHelper::LARGER},
59  {"full", SatHelper::FULL}};
60  std::map<std::string, SatEnums::RegenerationMode_t> mapForwardRegeneration{
61  {"transparent", SatEnums::TRANSPARENT},
62  {"regeneration_phy", SatEnums::REGENERATION_PHY},
63  {"regeneration_network", SatEnums::REGENERATION_NETWORK}};
64  std::map<std::string, SatEnums::RegenerationMode_t> mapReturnRegeneration{
65  {"transparent", SatEnums::TRANSPARENT},
66  {"regeneration_phy", SatEnums::REGENERATION_PHY},
67  {"regeneration_link", SatEnums::REGENERATION_LINK},
68  {"regeneration_network", SatEnums::REGENERATION_NETWORK}};
69 
70  Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("example-regeneration");
71 
72  // read command line parameters given by user
73  CommandLine cmd;
74  cmd.AddValue("beamIdInFullScenario",
75  "Id where Sending/Receiving UT is selected in FULL scenario. (used only when "
76  "scenario is full) ",
77  beamIdInFullScenario);
78  cmd.AddValue("packetSize", "Size of constant packet (bytes)", packetSize);
79  cmd.AddValue("interval", "Interval to sent packets in seconds, (e.g. (1s))", interval);
80  cmd.AddValue("scenario", "Test scenario to use. (simple, larger or full)", scenario);
81  cmd.AddValue(
82  "forwardRegeneration",
83  "Regeneration mode on forward link (transparent, regeneration_phy or regeneration_network)",
84  forwardRegeneration);
85  cmd.AddValue("returnRegeneration",
86  "Regeneration mode on forward link (transparent, regeneration_phy, "
87  "regeneration_link or regeneration_network)",
88  returnRegeneration);
89  simulationHelper->AddDefaultUiArguments(cmd);
90  cmd.Parse(argc, argv);
91 
92  SatHelper::PreDefinedScenario_t satScenario = mapScenario[scenario];
93  SatEnums::RegenerationMode_t forwardLinkRegenerationMode =
94  mapForwardRegeneration[forwardRegeneration];
95  SatEnums::RegenerationMode_t returnLinkRegenerationMode =
96  mapReturnRegeneration[returnRegeneration];
97 
99  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
100  EnumValue(forwardLinkRegenerationMode));
101  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
102  EnumValue(returnLinkRegenerationMode));
103  Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
104  Config::SetDefault("ns3::SatOrbiterUserPhy::QueueSize", UintegerValue(100000));
105 
107  Config::SetDefault("ns3::SatBbFrameConf::AcmEnabled", BooleanValue(true));
108 
110  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
111 
113  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
114 
115  // Set tag, if output path is not explicitly defined
116  simulationHelper->SetOutputTag(scenario);
117 
118  simulationHelper->SetSimulationTime(Seconds(30));
119 
120  // Set beam ID
121  std::stringstream beamsEnabled;
122  beamsEnabled << beamIdInFullScenario;
123  simulationHelper->SetBeams(beamsEnabled.str());
124 
125  LogComponentEnable("sat-regeneration-example", LOG_LEVEL_INFO);
126 
127  simulationHelper->LoadScenario("geo-33E");
128 
129  simulationHelper->CreateSatScenario(satScenario);
130 
131  simulationHelper->GetTrafficHelper()->AddCbrTraffic(
134  Time(interval),
135  packetSize,
136  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
137  Singleton<SatTopology>::Get()->GetUtUserNodes(),
138  Seconds(1.0),
139  Seconds(29.0),
140  Seconds(0));
141 
142  simulationHelper->GetTrafficHelper()->AddCbrTraffic(
145  Time(interval),
146  packetSize,
147  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
148  Singleton<SatTopology>::Get()->GetUtUserNodes(),
149  Seconds(1.0),
150  Seconds(29.0),
151  Seconds(0));
152 
153  NS_LOG_INFO("--- sat-regeneration-example ---");
154  NS_LOG_INFO(" Scenario used: " << scenario);
155  if (scenario == "full")
156  {
157  NS_LOG_INFO(" UT used in full scenario from beam: " << beamIdInFullScenario);
158  }
159  NS_LOG_INFO(" PacketSize: " << packetSize);
160  NS_LOG_INFO(" Interval: " << interval);
161  NS_LOG_INFO(" ");
162 
163  // To store attributes to file
164  Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
165  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
166  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
167  ConfigStore outputConfig;
168  outputConfig.ConfigureDefaults();
169 
170  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
171 
172  // Throughput statistics
173  s->AddPerUtFwdFeederPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
174  s->AddPerUtFwdUserPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
175  s->AddPerUtRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
176  s->AddPerUtRtnUserPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
177 
178  s->AddPerUtFwdFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
179  s->AddPerUtFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
180  s->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
181  s->AddPerUtRtnUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
182 
183  s->AddPerUtFwdFeederDevThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
184  s->AddPerUtFwdUserDevThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
185  s->AddPerUtRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
186  s->AddPerUtRtnUserDevThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
187 
188  s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
189  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
190  s->AddPerUtFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
191  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
192 
193  // Delay statistics
194  s->AddPerUtFwdPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
195  s->AddPerUtFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
196  s->AddPerUtFwdDevDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
197  s->AddPerUtRtnPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
198  s->AddPerUtRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
199  s->AddPerUtRtnDevDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
200 
201  // link delay statistics
202  s->AddPerUtFwdFeederPhyLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
203  s->AddPerUtFwdUserPhyLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
204  s->AddPerUtRtnFeederPhyLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
205  s->AddPerUtRtnUserPhyLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
206 
207  s->AddPerUtFwdFeederMacLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
208  s->AddPerUtFwdUserMacLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
209  s->AddPerUtRtnFeederMacLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
210  s->AddPerUtRtnUserMacLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
211 
212  s->AddPerUtFwdFeederDevLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
213  s->AddPerUtFwdUserDevLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
214  s->AddPerUtRtnFeederDevLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
215  s->AddPerUtRtnUserDevLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
216 
217  // Jitter statistics
218  s->AddPerUtFwdPhyJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
219  s->AddPerUtFwdMacJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
220  s->AddPerUtFwdDevJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
221  s->AddPerUtRtnPhyJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
222  s->AddPerUtRtnMacJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
223  s->AddPerUtRtnDevJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
224 
225  // Link jitter statistics
226  s->AddPerUtFwdFeederPhyLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
227  s->AddPerUtFwdUserPhyLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
228  s->AddPerUtRtnFeederPhyLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
229  s->AddPerUtRtnUserPhyLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
230 
231  s->AddPerUtFwdFeederMacLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
232  s->AddPerUtFwdUserMacLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
233  s->AddPerUtRtnFeederMacLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
234  s->AddPerUtRtnUserMacLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
235 
236  s->AddPerUtFwdFeederDevLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
237  s->AddPerUtFwdUserDevLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
238  s->AddPerUtRtnFeederDevLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
239  s->AddPerUtRtnUserDevLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
240 
241  // Phy RX statistics
242  s->AddPerUtFwdFeederLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
243  s->AddPerUtFwdUserLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
244  s->AddPerUtRtnFeederLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
245  s->AddPerUtRtnUserLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
246 
247  s->AddPerUtFwdFeederLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
248  s->AddPerUtFwdUserLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
249  s->AddPerUtRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
250  s->AddPerUtRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
251 
252  // Other statistics
253  s->AddPerUtFwdFeederLinkModcod(SatStatsHelper::OUTPUT_SCATTER_FILE);
254  s->AddPerUtFwdUserLinkModcod(SatStatsHelper::OUTPUT_SCATTER_FILE);
255  s->AddPerUtRtnFeederLinkModcod(SatStatsHelper::OUTPUT_SCATTER_FILE);
256  s->AddPerUtRtnUserLinkModcod(SatStatsHelper::OUTPUT_SCATTER_FILE);
257 
258  s->AddPerGwRtnFeederQueueBytes(SatStatsHelper::OUTPUT_SCATTER_FILE);
259  s->AddPerSatRtnFeederQueueBytes(SatStatsHelper::OUTPUT_SCATTER_FILE);
260  s->AddPerSatRtnFeederQueuePackets(SatStatsHelper::OUTPUT_SCATTER_FILE);
261 
262  s->AddPerGwFwdUserQueueBytes(SatStatsHelper::OUTPUT_SCATTER_FILE);
263  s->AddPerSatFwdUserQueueBytes(SatStatsHelper::OUTPUT_SCATTER_FILE);
264  s->AddPerSatFwdUserQueuePackets(SatStatsHelper::OUTPUT_SCATTER_FILE);
265 
266  simulationHelper->EnableProgressLogs();
267  simulationHelper->RunSimulation();
268 
269  return 0;
270 }
RegenerationMode_t
The regeneration mode used in satellites.
PreDefinedScenario_t
Values for pre-defined scenarios to be used by helper when building satellite network topology base.
@ LARGER
LARGER Larger scenario used as base.
@ FULL
FULL Full scenario used as base.
@ SIMPLE
SIMPLE Simple scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.