sat-random-access-slotted-aloha-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 
58 NS_LOG_COMPONENT_DEFINE("sat-random-access-slotted-aloha-collision-example");
59 
60 int
61 main(int argc, char* argv[])
62 {
63  uint32_t beamId(1);
64  uint32_t endUsersPerUt(1);
65  uint32_t utsPerBeam(30);
66  uint32_t packetSize(20);
67  Time interval(Seconds(0.01));
68  Time simLength(Seconds(3.00));
69  Time appStartTime = Seconds(0.01);
70 
71  // Enable info logs
72  LogComponentEnable("sat-random-access-slotted-aloha-collision-example", LOG_LEVEL_INFO);
73  // LogComponentEnable ("SatRandomAccess", LOG_LEVEL_INFO);
74  // LogComponentEnable ("SatUtMac", LOG_LEVEL_INFO);
75  LogComponentEnable("SatPhyRxCarrier", LOG_LEVEL_INFO);
76  LogComponentEnable("SatInterference", LOG_LEVEL_INFO);
77  // LogComponentEnable ("SatBeamScheduler", LOG_LEVEL_INFO);
78 
79  auto simulationHelper =
80  CreateObject<SimulationHelper>("example-random-access-slotted-aloha-collision");
81 
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  simulationHelper->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  // Enable Random Access with CRDSA
98  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
100 
101  // Set Random Access interference model
102  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
104 
105  // Set Random Access collision model
106  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
108 
109  // Disable periodic control slots
110  Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
111 
112  // Set dynamic load control parameters
113  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
114  BooleanValue(false));
115  Config::SetDefault(
116  "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
117  UintegerValue(10));
118 
119  // Set random access parameters
120  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
121  UintegerValue(3));
122  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
123  UintegerValue(6));
124  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
125  UintegerValue(2));
126  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
127  UintegerValue(250));
128  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
129  UintegerValue(10000));
130  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
131  UintegerValue(30000));
132  Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
133  UintegerValue(3));
134  Config::SetDefault(
135  "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
136  DoubleValue(0.5));
137  Config::SetDefault("ns3::SatLowerLayerServiceConf::DefaultControlRandomizationInterval",
138  TimeValue(MilliSeconds(100)));
139  Config::SetDefault("ns3::SatRandomAccessConf::CrdsaSignalingOverheadInBytes", UintegerValue(5));
140  Config::SetDefault("ns3::SatRandomAccessConf::SlottedAlohaSignalingOverheadInBytes",
141  UintegerValue(3));
142 
143  // Disable CRA and DA
144  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
145  BooleanValue(false));
146  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
147  BooleanValue(false));
148  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
149  BooleanValue(false));
150  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
151  BooleanValue(false));
152  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
153  BooleanValue(false));
154  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
155  BooleanValue(false));
156  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
157  BooleanValue(false));
158  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
159  BooleanValue(false));
160  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
161  BooleanValue(false));
162  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
163  BooleanValue(false));
164  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
165  BooleanValue(false));
166  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
167  BooleanValue(false));
168 
169  // Creating the reference system.
170  simulationHelper->SetSimulationTime(simLength);
171  simulationHelper->SetUserCountPerUt(endUsersPerUt);
172  simulationHelper->SetUtCountPerBeam(utsPerBeam);
173  simulationHelper->SetBeamSet({beamId});
174 
175  simulationHelper->LoadScenario("geo-33E");
176 
177  simulationHelper->CreateSatScenario();
178 
179  simulationHelper->GetTrafficHelper()->AddCbrTraffic(
182  interval,
183  packetSize,
184  NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
185  Singleton<SatTopology>::Get()->GetUtUserNodes(),
186  appStartTime,
187  simLength + Seconds(1),
188  Seconds(0.05));
189 
190  NS_LOG_INFO("--- Cbr-user-defined-example ---");
191  NS_LOG_INFO(" Packet size in bytes: " << packetSize);
192  NS_LOG_INFO(" Packet sending interval: " << interval.GetSeconds());
193  NS_LOG_INFO(" Simulation length: " << simLength.GetSeconds());
194  NS_LOG_INFO(" Number of UTs: " << utsPerBeam);
195  NS_LOG_INFO(" Number of end users per UT: " << endUsersPerUt);
196  NS_LOG_INFO(" ");
197 
198  simulationHelper->RunSimulation();
199 
200  return 0;
201 }
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.