Loading...
Searching...
No Matches
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
30using namespace ns3;
31
36
37NS_LOG_COMPONENT_DEFINE("sat-ncr-example");
38
39int
40main(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->LoadScenario("geo-33E");
133
134 simulationHelper->CreateSatScenario();
135
136 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
139 Time(interval),
140 packetSize,
141 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
142 Singleton<SatTopology>::Get()->GetUtUserNodes(),
143 Seconds(0.1),
144 Seconds(simLength),
145 Seconds(0));
146
147 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
150 Time(interval),
151 packetSize,
152 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
153 Singleton<SatTopology>::Get()->GetUtUserNodes(),
154 Seconds(0.1),
155 Seconds(simLength),
156 Seconds(0));
157
158 // To store attributes to file
159 Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
160 Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
161 Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
162 ConfigStore outputConfig;
163 outputConfig.ConfigureDefaults();
164 simulationHelper->StoreAttributesToFile("output-attributes.xml");
165
166 Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
167
168 s->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
169 s->AddGlobalFwdUserMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
170 s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
171 s->AddGlobalRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
172
173 s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
174 s->AddGlobalFwdAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
175 s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
176 s->AddGlobalRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
177
178 s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
179 s->AddPerUtRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
180
181 s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
182 s->AddGlobalFwdMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
183 s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
184 s->AddGlobalRtnMacDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
185
186 s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
187 s->AddGlobalFwdAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
188 s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCALAR_FILE);
189 s->AddGlobalRtnAppDelay(SatStatsHelper::OUTPUT_SCATTER_FILE);
190
191 simulationHelper->RunSimulation();
192
193 return 0;
194}
@ SUPER_FRAME_CONFIG_0
SUPER_FRAME_CONFIG_0.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.