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 simulationHelper =
82  CreateObject<SimulationHelper>("example-random-access-dynamic-load-control");
83  Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
84 
85  // Read command line parameters given by user
86  CommandLine cmd;
87  cmd.AddValue("endUsersPerUt", "Number of end users per UT", endUsersPerUt);
88  cmd.AddValue("utsPerBeam", "Number of UTs per spot-beam", utsPerBeam);
89  simulationHelper->AddDefaultUiArguments(cmd);
90  cmd.Parse(argc, argv);
91 
92  // Configure error model
94  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
95  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
96  // Config::SetDefault ("ns3::SatUtMac::CrUpdatePeriod", TimeValue(Seconds(10.0)));
97 
98  // Disable CRA and DA
99  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
100  BooleanValue(false));
101  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
102  BooleanValue(false));
103  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
104  BooleanValue(false));
105  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
106  BooleanValue(false));
107  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
108  BooleanValue(false));
109  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
110  BooleanValue(false));
111  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
112  BooleanValue(false));
113  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
114  BooleanValue(false));
115  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
116  BooleanValue(false));
117  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
118  BooleanValue(false));
119  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
120  BooleanValue(false));
121  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
122  BooleanValue(false));
123 
124  // Enable Random Access with CRDSA
125  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
127 
128  // Set Random Access interference model
129  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
131 
132  // Set Random Access collision model
133  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
135 
136  // Disable periodic control slots
137  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
138 
139  // Set dynamic load control parameters
140  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
141  BooleanValue(true));
142  Config::SetDefault(
143  "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
144  UintegerValue(10));
145 
146  // Set random access parameters
147  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
148  UintegerValue(3));
149  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
150  UintegerValue(6));
151  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
152  UintegerValue(2));
153  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
154  UintegerValue(250));
155  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
156  UintegerValue(1));
157  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
158  UintegerValue(1));
159  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
160  UintegerValue(3));
161  Config::SetDefault(
162  "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
163  DoubleValue(0.5));
164  Config::SetDefault("ns3::SatLowerLayerServiceConf::DefaultControlRandomizationInterval",
165  TimeValue(MilliSeconds(100)));
166  Config::SetDefault("ns3::SatRandomAccessConf::CrdsaSignalingOverheadInBytes", UintegerValue(5));
167  Config::SetDefault("ns3::SatRandomAccessConf::SlottedAlohaSignalingOverheadInBytes",
168  UintegerValue(3));
169 
170  // Creating the reference system.
171  simulationHelper->SetSimulationTime(simLength);
172  simulationHelper->SetUserCountPerUt(endUsersPerUt);
173  simulationHelper->SetUtCountPerBeam(utsPerBeam);
174  simulationHelper->SetBeamSet({beamId});
175 
176  simulationHelper->LoadScenario("geo-33E");
177 
178  simulationHelper->CreateSatScenario();
179 
180  simulationHelper->GetTrafficHelper()->AddCbrTraffic(
183  interval,
184  packetSize,
185  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
186  Singleton<SatTopology>::Get()->GetUtUserNodes(),
187  appStartTime,
188  simLength + Seconds(1),
189  Seconds(0.05));
190 
191  NS_LOG_INFO("--- Cbr-user-defined-example ---");
192  NS_LOG_INFO(" Packet size in bytes: " << packetSize);
193  NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
194  NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
195  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
196  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
197  NS_LOG_INFO(" ");
198 
199  simulationHelper->RunSimulation();
200 
201  return 0;
202 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.