Loading...
Searching...
No Matches
sat-dama-onoff-sim-tn9.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: Budiarto Herman <budiarto.herman@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
29using namespace ns3;
30
40
41NS_LOG_COMPONENT_DEFINE("sat-dama-onoff-sim-tn9");
42
43int
44main(int argc, char* argv[])
45{
46 // Spot-beam over Finland
47 uint32_t beamId = 18;
48 uint32_t endUsersPerUt(1);
49 uint32_t utsPerBeam(220); // 70% system load according to CRA 1 kbps
50 uint32_t packetSize(1280); // in bytes
51 double simLength(300.0); // in seconds
52 Time appStartTime = Seconds(0.1);
53
54 DataRate dataRate(32000); // in bps
55 uint32_t damaConf(0);
56 uint32_t crTxConf(0);
57
59 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
60
61 Ptr<SimulationHelper> simulationHelper =
62 CreateObject<SimulationHelper>("example-dama-onoff-sim-tn9");
63
64 // To read attributes from file
65 std::string inputFileNameWithPath =
66 SatEnvVariables::GetInstance()->LocateDirectory("contrib/satellite/examples") +
67 "/tn9-dama-input-attributes.xml";
68
113
114 // read command line parameters given by user
115 CommandLine cmd;
116 cmd.AddValue("simLength", "Simulation duration in seconds", simLength);
117 cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
118 cmd.AddValue("damaConf", "DAMA configuration", damaConf);
119 cmd.AddValue("crTxConf", "CR transmission configuration", crTxConf);
120 simulationHelper->AddDefaultUiArguments(cmd, inputFileNameWithPath);
121 cmd.Parse(argc, argv);
122
123 simulationHelper->SetDefaultValues();
124
125 // Set default attribute values from XML file
126 Config::SetDefault("ns3::ConfigStore::Filename", StringValue(inputFileNameWithPath));
127 Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Load"));
128 Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
129 ConfigStore inputConfig;
130 inputConfig.ConfigureDefaults();
131
132 simulationHelper->SetUtCountPerBeam(utsPerBeam);
133 simulationHelper->SetUserCountPerUt(endUsersPerUt);
134 // Set beam ID
135 simulationHelper->SetBeamSet({beamId});
136 simulationHelper->SetSimulationTime(simLength);
137
138 // NCC configuration
139 Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType", StringValue("ConfigType_2"));
140 Config::SetDefault("ns3::SatWaveformConf::AcmEnabled", BooleanValue(true));
141
142 // Rain fading
143 // Note, that the positions of the fading files do not necessarily match with the
144 // beam location, since this example is not using list position allocator!
145 Config::SetDefault("ns3::SatChannel::EnableExternalFadingInputTrace", BooleanValue(true));
146 Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtFwdDownIndexFileName",
147 StringValue("BeamId-1_256_UT_fading_fwddwn_trace_index.txt"));
148 Config::SetDefault("ns3::SatFadingExternalInputTraceContainer::UtRtnUpIndexFileName",
149 StringValue("BeamId-1_256_UT_fading_rtnup_trace_index.txt"));
150
151 // Disable Markov fading
152 Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(SatEnums::FADING_OFF));
153
154 switch (damaConf)
155 {
156 // RBDC
157 case 0: {
158 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
159 BooleanValue(false));
160 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
161 BooleanValue(true));
162 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_MinimumServiceRate",
163 UintegerValue(16));
164 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
165 BooleanValue(false));
166 break;
167 }
168 // VBDC
169 case 1: {
170 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
171 BooleanValue(false));
172 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
173 BooleanValue(false));
174 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
175 BooleanValue(true));
176 break;
177 }
178 default: {
179 NS_FATAL_ERROR("Unsupported damaConf: " << damaConf);
180 break;
181 }
182 }
183
184 switch (crTxConf)
185 {
186 // RA slotted ALOHA
187 case 0: {
188 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
190 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
191 break;
192 }
193 // CRDSA (strict RC 0)
194 case 1: {
195 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
196 EnumValue(SatEnums::RA_MODEL_CRDSA));
197 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
198 Config::SetDefault("ns3::SatUtHelper::UseCrdsaOnlyForControlPackets", BooleanValue(true));
199 break;
200 }
201 // Periodical control slots
202 case 2: {
203 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
204 EnumValue(SatEnums::RA_MODEL_OFF));
205 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(true));
206 break;
207 }
208 // CRA 1 kbps
209 case 3: {
210 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
211 BooleanValue(true));
212 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantServiceRate",
213 StringValue("ns3::ConstantRandomVariable[Constant=1]"));
214 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
215 BooleanValue(false));
216 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
217 BooleanValue(false));
218
219 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
220 EnumValue(SatEnums::RA_MODEL_OFF));
221 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
222 break;
223 }
224 default: {
225 NS_FATAL_ERROR("Unsupported crTxConf: " << crTxConf);
226 break;
227 }
228 }
229
230 simulationHelper->LoadScenario("geo-33E");
231
232 // Creating the reference system.
233 simulationHelper->CreateSatScenario();
234
238 simulationHelper->GetTrafficHelper()->AddOnOffTraffic(
241 dataRate,
242 packetSize,
243 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
244 Singleton<SatTopology>::Get()->GetUtUserNodes(),
245 "ns3::ExponentialRandomVariable[Mean=1.0|Bound=0.0]",
246 "ns3::ExponentialRandomVariable[Mean=1.0|Bound=0.0]",
247 appStartTime,
248 Seconds(simLength),
249 MilliSeconds(50));
250
254 Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
255
256 s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCATTER_PLOT);
257 s->AddPerBeamRtnAppThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
258 s->AddPerBeamRtnFeederDevThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
259 s->AddPerBeamRtnFeederMacThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
260 s->AddPerBeamRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCALAR_FILE);
261
262 s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_FILE);
263 s->AddAverageUtUserRtnAppThroughput(SatStatsHelper::OUTPUT_CDF_PLOT);
264
265 s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_CDF_FILE);
266 s->AddPerBeamRtnAppDelay(SatStatsHelper::OUTPUT_CDF_PLOT);
267
268 s->AddPerBeamRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
269 s->AddPerBeamFrameSymbolLoad(SatStatsHelper::OUTPUT_SCALAR_FILE);
270 s->AddPerBeamWaveformUsage(SatStatsHelper::OUTPUT_SCALAR_FILE);
271 s->AddPerBeamCapacityRequest(SatStatsHelper::OUTPUT_SCATTER_FILE);
272 s->AddPerBeamResourcesGranted(SatStatsHelper::OUTPUT_SCATTER_PLOT);
273
274 s->AddPerBeamFeederCrdsaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
275 s->AddPerBeamFeederCrdsaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
276 s->AddPerBeamFeederSlottedAlohaPacketCollision(SatStatsHelper::OUTPUT_SCALAR_FILE);
277 s->AddPerBeamFeederSlottedAlohaPacketError(SatStatsHelper::OUTPUT_SCALAR_FILE);
278
279 NS_LOG_INFO("--- sat-dama-onoff-sim-tn9 ---");
280 NS_LOG_INFO(" Packet size: " << packetSize);
281 NS_LOG_INFO(" Offered data rate: " << dataRate);
282 NS_LOG_INFO(" Simulation length: " << simLength);
283 NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
284 NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
285 NS_LOG_INFO(" ");
286
290
291 // std::stringstream filename;
292 // filename << "tn9-dama-onoff-output-attributes-ut" << utsPerBeam
293 // << "-conf" << crTxConf << ".xml";
294 //
295 // Config::SetDefault ("ns3::ConfigStore::Filename", StringValue (filename.str ()));
296 // Config::SetDefault ("ns3::ConfigStore::FileFormat", StringValue ("Xml"));
297 // Config::SetDefault ("ns3::ConfigStore::Mode", StringValue ("Save"));
298 // ConfigStore outputConfig;
299 // outputConfig.ConfigureDefaults ();
300
304 simulationHelper->EnableProgressLogs();
305 simulationHelper->RunSimulation();
306
307 return 0;
308}
static Ptr< SatEnvVariables > GetInstance()
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.