sat-random-access-dynamic-load-control-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: Frans Laakso <frans.laakso@magister.fi>
19  *
20  */
21 
22 #include "ns3/applications-module.h"
23 #include "ns3/core-module.h"
24 #include "ns3/internet-module.h"
25 #include "ns3/network-module.h"
26 #include "ns3/satellite-module.h"
27 #include "ns3/traffic-module.h"
28 
29 using namespace ns3;
30 
59 NS_LOG_COMPONENT_DEFINE("sat-random-access-dynamic-load-control-example");
60 
61 int
62 main(int argc, char* argv[])
63 {
64  uint32_t beamId(1);
65  uint32_t endUsersPerUt(1);
66  uint32_t utsPerBeam(30);
67  uint32_t packetSize(20);
68  Time interval(Seconds(0.01));
69  Time simLength(Seconds(5.00));
70  Time appStartTime = Seconds(0.01);
71 
72  // Enable info logs
73  LogComponentEnable("sat-random-access-dynamic-load-control-example", LOG_LEVEL_INFO);
74  // LogComponentEnable ("SatRandomAccess", LOG_LEVEL_INFO);
75  // LogComponentEnable ("SatUtMac", LOG_LEVEL_INFO);
76  LogComponentEnable("SatPhyRxCarrier", LOG_LEVEL_INFO);
77  // LogComponentEnable ("SatInterference", LOG_LEVEL_INFO);
78  LogComponentEnable("SatNcc", LOG_LEVEL_INFO);
79  // LogComponentEnable ("SatBeamScheduler", LOG_LEVEL_INFO);
80 
81  auto sh = CreateObject<SimulationHelper>("example-random-access-dynamic-load-control");
82  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
83 
84  // Read command line parameters given by user
85  CommandLine cmd;
86  cmd.AddValue("endUsersPerUt", "Number of end users per UT", endUsersPerUt);
87  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
88  sh->AddDefaultUiArguments(cmd);
89  cmd.Parse(argc, argv);
90 
91  // Configure error model
93  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
94  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
95  // Config::SetDefault ("ns3::SatUtMac::CrUpdatePeriod", TimeValue(Seconds(10.0)));
96 
97  // Disable CRA and DA
98  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
99  BooleanValue(false));
100  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
101  BooleanValue(false));
102  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
103  BooleanValue(false));
104  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
105  BooleanValue(false));
106  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
107  BooleanValue(false));
108  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
109  BooleanValue(false));
110  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
111  BooleanValue(false));
112  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
113  BooleanValue(false));
114  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
115  BooleanValue(false));
116  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
117  BooleanValue(false));
118  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
119  BooleanValue(false));
120  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
121  BooleanValue(false));
122 
123  // Enable Random Access with CRDSA
124  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
126 
127  // Set Random Access interference model
128  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
130 
131  // Set Random Access collision model
132  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
134 
135  // Disable periodic control slots
136  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
137 
138  // Set dynamic load control parameters
139  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
140  BooleanValue(true));
141  Config::SetDefault(
142  "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
143  UintegerValue(10));
144 
145  // Set random access parameters
146  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
147  UintegerValue(3));
148  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
149  UintegerValue(6));
150  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
151  UintegerValue(2));
152  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
153  UintegerValue(250));
154  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
155  UintegerValue(1));
156  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
157  UintegerValue(1));
158  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
159  UintegerValue(3));
160  Config::SetDefault(
161  "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
162  DoubleValue(0.5));
163  Config::SetDefault("ns3::SatLowerLayerServiceConf::DefaultControlRandomizationInterval",
164  TimeValue(MilliSeconds(100)));
165  Config::SetDefault("ns3::SatRandomAccessConf::CrdsaSignalingOverheadInBytes", UintegerValue(5));
166  Config::SetDefault("ns3::SatRandomAccessConf::SlottedAlohaSignalingOverheadInBytes",
167  UintegerValue(3));
168 
169  // Creating the reference system. Note, currently the satellite module supports
170  // only one reference system, which is named as "Scenario72". The string is utilized
171  // in mapping the scenario to the needed reference system configuration files. Arbitrary
172  // scenario name results in fatal error.
173  sh->SetSimulationTime(simLength);
174  sh->SetUserCountPerUt(endUsersPerUt);
175  sh->SetUtCountPerBeam(utsPerBeam);
176  sh->SetBeamSet({beamId});
177  sh->CreateSatScenario();
178 
179  Config::SetDefault("ns3::CbrApplication::Interval", TimeValue(interval));
180  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(packetSize));
181  sh->InstallTrafficModel(SimulationHelper::CBR,
184  appStartTime,
185  simLength + Seconds(1),
186  Seconds(0.05));
187 
188  NS_LOG_INFO("--- Cbr-user-defined-example ---");
189  NS_LOG_INFO(" Packet size in bytes: " << packetSize);
190  NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
191  NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
192  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
193  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
194  NS_LOG_INFO(" ");
195 
196  sh->RunSimulation();
197 
198  return 0;
199 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.