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