sat-ncr-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 
37 NS_LOG_COMPONENT_DEFINE("sat-ncr-example");
38 
39 int
40 main(int argc, char* argv[])
41 {
42  uint32_t beamId = 1;
43  uint32_t endUsersPerUt = 1;
44  uint32_t utsPerBeam = 10;
45 
46  uint32_t packetSize = 512;
47  std::string interval = "100ms";
48 
49  double simLength = 60.0;
50 
51  uint32_t guardTime = 4;
52  int32_t clockDrift = 50;
53 
55  Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
56 
58  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
59  Ptr<SimulationHelper> simulationHelper = CreateObject<SimulationHelper>("example-ncr");
60 
61  // read command line parameters given by user
62  CommandLine cmd;
63  cmd.AddValue("simLength", "Simulation duration in seconds", simLength);
64  cmd.AddValue("beamId", "ID of beam used", beamId);
65  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
66  cmd.AddValue("endUsersPerUt", "Number end users per UT", endUsersPerUt);
67  cmd.AddValue("packetSize", "Constant packet size in bytes", packetSize);
68  cmd.AddValue("interval", "Interval between two UDP packets per UT", interval);
69  cmd.AddValue("guardTime", "Guard time in time slots in symbols", guardTime);
70  cmd.AddValue("clockDrift", "Drift value of UT clocks in ticks per second", clockDrift);
71  simulationHelper->AddDefaultUiArguments(cmd);
72  cmd.Parse(argc, argv);
73 
74  // Set beam ID
75  simulationHelper->SetSimulationTime(simLength);
76  simulationHelper->SetUserCountPerUt(endUsersPerUt);
77  simulationHelper->SetUtCountPerBeam(utsPerBeam);
78  simulationHelper->SetBeamSet({beamId});
79  simulationHelper->SetSimulationTime(Seconds(simLength));
80  simulationHelper->EnableProgressLogs();
81 
82  // Set 2 RA frames including one for logon
83  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
85  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
87  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
89  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
91  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_RandomAccessFrame", BooleanValue(true));
92  Config::SetDefault("ns3::SatSuperframeConf0::Frame1_RandomAccessFrame", BooleanValue(true));
93  Config::SetDefault("ns3::SatSuperframeConf0::Frame1_LogonFrame", BooleanValue(true));
94 
95  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_GuardTimeSymbols",
96  UintegerValue(guardTime));
97  Config::SetDefault("ns3::SatSuperframeConf0::Frame1_GuardTimeSymbols",
98  UintegerValue(guardTime));
99  Config::SetDefault("ns3::SatSuperframeConf0::Frame2_GuardTimeSymbols",
100  UintegerValue(guardTime));
101  Config::SetDefault("ns3::SatSuperframeConf0::Frame3_GuardTimeSymbols",
102  UintegerValue(guardTime));
103  Config::SetDefault("ns3::SatSuperframeConf0::Frame4_GuardTimeSymbols",
104  UintegerValue(guardTime));
105  Config::SetDefault("ns3::SatSuperframeConf0::Frame5_GuardTimeSymbols",
106  UintegerValue(guardTime));
107  Config::SetDefault("ns3::SatSuperframeConf0::Frame6_GuardTimeSymbols",
108  UintegerValue(guardTime));
109  Config::SetDefault("ns3::SatSuperframeConf0::Frame7_GuardTimeSymbols",
110  UintegerValue(guardTime));
111  Config::SetDefault("ns3::SatSuperframeConf0::Frame8_GuardTimeSymbols",
112  UintegerValue(guardTime));
113  Config::SetDefault("ns3::SatSuperframeConf0::Frame9_GuardTimeSymbols",
114  UintegerValue(guardTime));
115 
116  Config::SetDefault("ns3::SatUtMac::WindowInitLogon", TimeValue(Seconds(20)));
117  Config::SetDefault("ns3::SatUtMac::MaxWaitingTimeLogonResponse", TimeValue(Seconds(1)));
118 
119  Config::SetDefault("ns3::SatMac::NcrVersion2", BooleanValue(false));
120  Config::SetDefault("ns3::SatGwMac::NcrBroadcastPeriod", TimeValue(MilliSeconds(100)));
121  Config::SetDefault("ns3::SatGwMac::UseCmt", BooleanValue(true));
122  Config::SetDefault("ns3::SatUtMacState::NcrSyncTimeout", TimeValue(Seconds(1)));
123  Config::SetDefault("ns3::SatUtMacState::NcrRecoveryTimeout", TimeValue(Seconds(10)));
124  Config::SetDefault("ns3::SatNcc::UtTimeout", TimeValue(Seconds(10)));
125 
126  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
127  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotInterval", TimeValue(MilliSeconds(500)));
128 
129  Config::SetDefault("ns3::SatUtMac::ClockDrift", IntegerValue(clockDrift));
130  Config::SetDefault("ns3::SatGwMac::CmtPeriodMin", TimeValue(MilliSeconds(550)));
131 
132  simulationHelper->CreateSatScenario();
133 
134  Config::SetDefault("ns3::CbrApplication::Interval", StringValue(interval));
135  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
136 
137  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
140  Seconds(0.1),
141  Seconds(simLength));
142  simulationHelper->InstallTrafficModel(SimulationHelper::CBR,
145  Seconds(0.1),
146  Seconds(simLength));
147 
148  // To store attributes to file
149  Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
150  Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
151  Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
152  ConfigStore outputConfig;
153  outputConfig.ConfigureDefaults();
154  simulationHelper->StoreAttributesToFile("output-attributes.xml");
155 
156  Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
157 
158  s->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
159  s->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
160  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
161  s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
162 
163  s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
164  s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
165  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
166  s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
167 
168  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
169  s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
170 
171  s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
172  s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
173  s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
174  s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
175 
176  s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
177  s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
178  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
179  s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
180 
181  simulationHelper->RunSimulation();
182 
183  return 0;
184 }
@ SUPER_FRAME_CONFIG_0
SUPER_FRAME_CONFIG_0.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.