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