sat-constellation-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 
41 NS_LOG_COMPONENT_DEFINE("sat-constellation-example");
42 
43 int
44 main(int argc, char* argv[])
45 {
46  uint32_t packetSize = 512;
47  std::string interval = "20ms";
48  std::string scenarioFolder = "constellation-eutelsat-geo-2-sats-isls";
49 
50  Ptr<SimulationHelper> simulationHelper =
51  CreateObject<SimulationHelper>("example-constellation");
52 
53  // read command line parameters given by user
54  CommandLine cmd;
55  cmd.AddValue("packetSize", "Size of constant packet (bytes)", packetSize);
56  cmd.AddValue("interval", "Interval to sent packets in seconds (e.g. (1s))", interval);
57  cmd.AddValue("scenarioFolder",
58  "Scenario folder (e.g. constellation-eutelsat-geo-2-sats-isls)",
59  scenarioFolder);
60  simulationHelper->AddDefaultUiArguments(cmd);
61  cmd.Parse(argc, argv);
62 
64  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
66  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
68  Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
69  Config::SetDefault("ns3::SatOrbiterUserPhy::QueueSize", UintegerValue(100000));
70 
72  Config::SetDefault("ns3::PointToPointIslHelper::IslDataRate",
73  DataRateValue(DataRate("100Mb/s")));
74  Config::SetDefault("ns3::SatSGP4MobilityModel::UpdatePositionEachRequest", BooleanValue(false));
75  Config::SetDefault("ns3::SatSGP4MobilityModel::UpdatePositionPeriod", TimeValue(Seconds(1)));
76  Config::SetDefault("ns3::SatHelper::GwUsers", UintegerValue(3));
77  Config::SetDefault("ns3::SatGwMac::SendNcrBroadcast", BooleanValue(false));
78 
80  Config::SetDefault("ns3::SatHelper::BeamNetworkAddress", Ipv4AddressValue("20.1.0.0"));
81  Config::SetDefault("ns3::SatHelper::GwNetworkAddress", Ipv4AddressValue("10.1.0.0"));
82  Config::SetDefault("ns3::SatHelper::UtNetworkAddress", Ipv4AddressValue("250.1.0.0"));
83 
85  Config::SetDefault("ns3::SatBbFrameConf::AcmEnabled", BooleanValue(true));
86 
88  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
89 
91  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
92 
93  simulationHelper->LoadScenario(scenarioFolder);
94 
95  simulationHelper->SetSimulationTime(Seconds(30));
96 
97  std::set<uint32_t> beamSetAll = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
98  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
99  31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
100  46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
101  61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72};
102 
103  std::set<uint32_t> beamSet = {43, 30};
104 
105  std::set<uint32_t> beamSetTelesat = {1, 43, 60, 64};
106 
107  // Set beam ID
108  if (scenarioFolder == "constellation-telesat-351-sats")
109  {
110  simulationHelper->SetBeamSet(beamSetTelesat);
111  }
112  else
113  {
114  simulationHelper->SetBeamSet(beamSet);
115  }
116  simulationHelper->SetUserCountPerUt(2);
117 
118  LogComponentEnable("sat-constellation-example", LOG_LEVEL_INFO);
119 
120  simulationHelper->CreateSatScenario();
121 
122  Singleton<SatTopology>::Get()->PrintTopology(std::cout);
123  Singleton<SatIdMapper>::Get()->ShowIslMap();
124 
125  Config::SetDefault("ns3::CbrApplication::Interval", StringValue(interval));
126  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
127 
128  Time startTime = Seconds(1.0);
129  Time stopTime = Seconds(29.0);
130  Time startDelay = Seconds(0.0);
131 
132  NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
133  NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
134  NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
135  NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes(uts);
136 
137  // Total is 3*6 = 18 flows
138  // Global App rate is pktSize*ptkPerSecond*nbFlows = 512*8*50*18 = 3686kb/s on both FWD and RTN
139  Ptr<SatTrafficHelper> trafficHelper = simulationHelper->GetTrafficHelper();
140 
141  trafficHelper->AddCbrTraffic(SatTrafficHelper::FWD_LINK,
143  Time(interval),
144  packetSize,
145  gwUsers,
146  utUsers,
147  startTime,
148  stopTime,
149  startDelay);
150 
151  trafficHelper->AddCbrTraffic(SatTrafficHelper::RTN_LINK,
153  Time(interval),
154  packetSize,
155  gwUsers,
156  utUsers,
157  startTime,
158  stopTime,
159  startDelay);
160 
161  NS_LOG_INFO("--- sat-constellation-example ---");
162  NS_LOG_INFO(" PacketSize: " << packetSize);
163  NS_LOG_INFO(" Interval: " << interval);
164  NS_LOG_INFO(" ");
165 
166  // To store attributes to file
167  Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
168  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
169  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
170  ConfigStore outputConfig;
171  outputConfig.ConfigureDefaults();
172 
173  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
174 
175  // Throughput statistics
176  s->AddPerUtFwdFeederPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
177  s->AddPerUtFwdUserPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
178  s->AddPerUtRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
179  s->AddPerUtRtnUserPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
180 
181  s->AddPerUtFwdFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
182  s->AddPerUtFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
183  s->AddPerUtRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
184  s->AddPerUtRtnUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
185 
186  s->AddPerUtFwdFeederDevThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
187  s->AddPerUtFwdUserDevThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
188  s->AddPerUtRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
189  s->AddPerUtRtnUserDevThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
190 
191  s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
192  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
193  s->AddPerGwFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
194  s->AddPerGwRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
195  s->AddPerSatFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
196  s->AddPerSatRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
197  s->AddPerBeamFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
198  s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
199  s->AddPerUtFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
200  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
201 
202  // Delay statistics
203  s->AddPerUtFwdPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
204  s->AddPerUtFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
205  s->AddPerUtFwdDevDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
206  s->AddPerUtRtnPhyDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
207  s->AddPerUtRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
208  s->AddPerUtRtnDevDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
209 
210  // link delay statistics
211  s->AddPerUtFwdFeederPhyLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
212  s->AddPerUtFwdUserPhyLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
213  s->AddPerUtRtnFeederPhyLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
214  s->AddPerUtRtnUserPhyLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
215 
216  s->AddPerUtFwdFeederMacLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
217  s->AddPerUtFwdUserMacLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
218  s->AddPerUtRtnFeederMacLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
219  s->AddPerUtRtnUserMacLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
220 
221  s->AddPerUtFwdFeederDevLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
222  s->AddPerUtFwdUserDevLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
223  s->AddPerUtRtnFeederDevLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
224  s->AddPerUtRtnUserDevLinkDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
225 
226  // Jitter statistics
227  s->AddPerUtFwdPhyJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
228  s->AddPerUtFwdMacJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
229  s->AddPerUtFwdDevJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
230  s->AddPerUtRtnPhyJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
231  s->AddPerUtRtnMacJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
232  s->AddPerUtRtnDevJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
233 
234  // Link jitter statistics
235  s->AddPerUtFwdFeederPhyLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
236  s->AddPerUtFwdUserPhyLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
237  s->AddPerUtRtnFeederPhyLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
238  s->AddPerUtRtnUserPhyLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
239 
240  s->AddPerUtFwdFeederMacLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
241  s->AddPerUtFwdUserMacLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
242  s->AddPerUtRtnFeederMacLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
243  s->AddPerUtRtnUserMacLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
244 
245  s->AddPerUtFwdFeederDevLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
246  s->AddPerUtFwdUserDevLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
247  s->AddPerUtRtnFeederDevLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
248  s->AddPerUtRtnUserDevLinkJitter(SatStatsHelper::OUTPUT_SCATTER_FILE);
249 
250  // Phy RX statistics
251  s->AddPerUtFwdFeederLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
252  s->AddPerUtFwdUserLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
253  s->AddPerUtRtnFeederLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
254  s->AddPerUtRtnUserLinkSinr(SatStatsHelper::OUTPUT_SCATTER_FILE);
255 
256  s->AddPerUtFwdFeederLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
257  s->AddPerUtFwdUserLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
258  s->AddPerUtRtnFeederLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
259  s->AddPerUtRtnUserLinkRxPower(SatStatsHelper::OUTPUT_SCATTER_FILE);
260 
261  // Other statistics
262  s->AddPerUtFwdFeederLinkModcod(SatStatsHelper::OUTPUT_SCATTER_FILE);
263  s->AddPerUtFwdUserLinkModcod(SatStatsHelper::OUTPUT_SCATTER_FILE);
264  s->AddPerUtRtnFeederLinkModcod(SatStatsHelper::OUTPUT_SCATTER_FILE);
265  s->AddPerUtRtnUserLinkModcod(SatStatsHelper::OUTPUT_SCATTER_FILE);
266 
267  s->AddPerGwRtnFeederQueueBytes(SatStatsHelper::OUTPUT_SCATTER_FILE);
268  s->AddPerSatRtnFeederQueueBytes(SatStatsHelper::OUTPUT_SCATTER_FILE);
269  s->AddPerSatRtnFeederQueuePackets(SatStatsHelper::OUTPUT_SCATTER_FILE);
270 
271  s->AddPerGwFwdUserQueueBytes(SatStatsHelper::OUTPUT_SCATTER_FILE);
272  s->AddPerSatFwdUserQueueBytes(SatStatsHelper::OUTPUT_SCATTER_FILE);
273  s->AddPerSatFwdUserQueuePackets(SatStatsHelper::OUTPUT_SCATTER_FILE);
274 
275  // ISL drop rate statistics
276  s->AddGlobalPacketDropRate(SatStatsHelper::OUTPUT_SCATTER_FILE);
277  s->AddPerIslPacketDropRate(SatStatsHelper::OUTPUT_SCATTER_FILE);
278 
279  simulationHelper->EnableProgressLogs();
280  simulationHelper->RunSimulation();
281 
282  return 0;
283 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.