Loading...
Searching...
No Matches
sat-regeneration-collisions-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: Bastien Tauran <bastien.tauran@viveris.fr>
19 *
20 */
21
22#include "ns3/applications-module.h"
23#include "ns3/config-store-module.h"
24#include "ns3/core-module.h"
25#include "ns3/internet-module.h"
26#include "ns3/network-module.h"
27#include "ns3/satellite-module.h"
28#include "ns3/traffic-module.h"
29
30using namespace ns3;
31
41
42NS_LOG_COMPONENT_DEFINE("sat-regeneration-collisions-example");
43
44int
45main(int argc, char* argv[])
46{
47 uint32_t packetSize = 512;
48 std::string interval = "1ms";
49 std::string randomAccess = "SlottedAloha";
50 std::string forwardRegeneration = "regeneration_phy";
51 std::string returnRegeneration = "regeneration_phy";
52
53 std::map<std::string, SatEnums::RegenerationMode_t> mapForwardRegeneration{
54 {"transparent", SatEnums::TRANSPARENT},
55 {"regeneration_phy", SatEnums::REGENERATION_PHY},
56 {"regeneration_network", SatEnums::REGENERATION_NETWORK}};
57 std::map<std::string, SatEnums::RegenerationMode_t> mapReturnRegeneration{
58 {"transparent", SatEnums::TRANSPARENT},
59 {"regeneration_phy", SatEnums::REGENERATION_PHY},
60 {"regeneration_link", SatEnums::REGENERATION_LINK},
61 {"regeneration_network", SatEnums::REGENERATION_NETWORK}};
62
63 Ptr<SimulationHelper> simulationHelper =
64 CreateObject<SimulationHelper>("example-regeneration-collisions");
65
66 // read command line parameters given by user
67 CommandLine cmd;
68 cmd.AddValue("packetSize", "Size of constant packet (bytes)", packetSize);
69 cmd.AddValue("interval", "Interval to sent packets in seconds, (e.g. (1s))", interval);
70 cmd.AddValue("randomAccess",
71 "Choose RA (SlottedAloha, Marsala, Crdsa, Essa) or DA.",
72 randomAccess);
73 cmd.AddValue(
74 "forwardRegeneration",
75 "Regeneration mode on forward link (transparent, regeneration_phy or regeneration_network)",
76 forwardRegeneration);
77 cmd.AddValue("returnRegeneration",
78 "Regeneration mode on forward link (transparent, regeneration_phy, "
79 "regeneration_link or regeneration_network)",
80 returnRegeneration);
81 simulationHelper->AddDefaultUiArguments(cmd);
82 cmd.Parse(argc, argv);
83
84 SatEnums::RegenerationMode_t forwardLinkRegenerationMode =
85 mapForwardRegeneration[forwardRegeneration];
86 SatEnums::RegenerationMode_t returnLinkRegenerationMode =
87 mapReturnRegeneration[returnRegeneration];
88
90 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
91 EnumValue(forwardLinkRegenerationMode));
92 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
93 EnumValue(returnLinkRegenerationMode));
94
95 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
96
98 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
99
101 Config::SetDefault("ns3::SatHelper::PacketTraceEnabled", BooleanValue(true));
102
103 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_SlottedAlohaAllowed",
104 BooleanValue(false));
105 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_CrdsaAllowed",
106 BooleanValue(false));
107 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_EssaAllowed",
108 BooleanValue(false));
109
110 // Enable Random Access
111 if (randomAccess == "SlottedAloha")
112 {
113 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
115 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_SlottedAlohaAllowed",
116 BooleanValue(true));
117 }
118 else if (randomAccess == "Crdsa")
119 {
120 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
121 EnumValue(SatEnums::RA_MODEL_CRDSA));
122 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_CrdsaAllowed",
123 BooleanValue(true));
124 }
125 else if (randomAccess == "Marsala")
126 {
127 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
128 EnumValue(SatEnums::RA_MODEL_MARSALA));
129 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_CrdsaAllowed",
130 BooleanValue(true));
131 }
132 else if (randomAccess == "Essa")
133 {
134 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
135 EnumValue(SatEnums::RA_MODEL_ESSA));
136 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_EssaAllowed",
137 BooleanValue(true));
138 }
139 else if (randomAccess == "DA")
140 {
141 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
142 EnumValue(SatEnums::RA_MODEL_OFF));
143 }
144 else
145 {
146 NS_FATAL_ERROR("Unknown random access: " << randomAccess);
147 }
148
149 // Set Random Access interference model
150 Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
152
153 // Set Random Access collision model
154 Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
156
157 // Disable periodic control slots
158 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
159
160 // Set dynamic load control parameters
161 Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
162 BooleanValue(false));
163 Config::SetDefault(
164 "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
165 UintegerValue(10));
166
167 // Set random access parameters
168 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
169 UintegerValue(3));
170 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
171 UintegerValue(6));
172 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
173 UintegerValue(2));
174 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
175 UintegerValue(250));
176 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
177 UintegerValue(1));
178 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
179 UintegerValue(1));
180 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
181 UintegerValue(3));
182 Config::SetDefault(
183 "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
184 DoubleValue(0.5));
185 Config::SetDefault("ns3::SatLowerLayerServiceConf::DefaultControlRandomizationInterval",
186 TimeValue(MilliSeconds(100)));
187 Config::SetDefault("ns3::SatRandomAccessConf::CrdsaSignalingOverheadInBytes", UintegerValue(5));
188 Config::SetDefault("ns3::SatRandomAccessConf::SlottedAlohaSignalingOverheadInBytes",
189 UintegerValue(3));
190
191 Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
192 EnumValue(SatPhyRxCarrierConf::EM_AVI));
193 Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
194 EnumValue(SatPhyRxCarrierConf::EM_AVI));
195
196 if (randomAccess == "Essa")
197 {
198 // Superframe configuration
199 Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
201 Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
203 Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz",
204 DoubleValue(15000));
205 Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
206 DoubleValue(15000));
207 Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierRollOff", DoubleValue(0.22));
208 Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierSpacing", DoubleValue(0));
209 Config::SetDefault("ns3::SatSuperframeConf4::Frame0_SpreadingFactor", UintegerValue(256));
210
211 Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
213 Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
215 Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults",
216 EnumValue(SatEnums::LR_FSIM));
217 Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
218 EnumValue(SatPhyRxCarrierConf::EM_AVI));
219
220 Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
221 Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
222 Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDelay", StringValue("0s"));
223 Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::FirstWindow", StringValue("0s"));
224 Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
225 Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::SpreadingFactor", UintegerValue(1));
226 Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::DetectionThreshold", DoubleValue(0));
227 Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
228
229 simulationHelper->LoadScenario("geo-33E-fsim");
230 }
231
232 // Disable CRA and DA if RA
233 if (randomAccess != "DA")
234 {
235 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaServiceCount", UintegerValue(4));
236 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
237 BooleanValue(false));
238 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
239 BooleanValue(false));
240 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
241 BooleanValue(false));
242 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
243 BooleanValue(false));
244 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
245 BooleanValue(false));
246 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
247 BooleanValue(false));
248 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
249 BooleanValue(false));
250 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
251 BooleanValue(false));
252 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
253 BooleanValue(false));
254 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
255 BooleanValue(false));
256 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
257 BooleanValue(false));
258 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
259 BooleanValue(false));
260
261 simulationHelper->LoadScenario("geo-33E");
262 }
263
264 simulationHelper->SetSimulationTime(Seconds(11));
265
266 LogComponentEnable("sat-regeneration-collisions-example", LOG_LEVEL_INFO);
267
268 simulationHelper->SetUserCountPerUt(1);
269 simulationHelper->SetUtCountPerBeam(50);
270 simulationHelper->SetBeamSet({1});
271
272 simulationHelper->CreateSatScenario();
273
274 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
277 Time(interval),
278 packetSize,
279 NodeContainer(Singleton<SatTopology>::Get()->GetGwUserNode(0)),
280 Singleton<SatTopology>::Get()->GetUtUserNodes(),
281 Seconds(1.0),
282 Seconds(10.0),
283 Seconds(0));
284
285 NS_LOG_INFO("--- sat-regeneration-collisions-example ---");
286 NS_LOG_INFO(" Random Access (or DA): " << randomAccess);
287 NS_LOG_INFO(" PacketSize: " << packetSize);
288 NS_LOG_INFO(" Interval: " << interval);
289 NS_LOG_INFO(" ");
290
291 // To store attributes to file
292 Config::SetDefault("ns3::ConfigStore::Filename", StringValue("output-attributes.xml"));
293 Config::SetDefault("ns3::ConfigStore::FileFormat", StringValue("Xml"));
294 Config::SetDefault("ns3::ConfigStore::Mode", StringValue("Save"));
295 ConfigStore outputConfig;
296 outputConfig.ConfigureDefaults();
297
298 Ptr<SatStatsHelperContainer> s = simulationHelper->GetStatisticsContainer();
299
300 s->AddGlobalFwdUserPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
301 s->AddGlobalRtnFeederPhyThroughput(SatStatsHelper::OUTPUT_SCATTER_FILE);
302
303 s->AddPerSatFeederSlottedAlohaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
304 s->AddPerSatUserSlottedAlohaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
305 s->AddPerSatFeederCrdsaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
306 s->AddPerSatUserCrdsaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
307 s->AddPerSatFeederEssaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
308 s->AddPerSatUserEssaPacketCollision(SatStatsHelper::OUTPUT_SCATTER_FILE);
309
310 // Error stats if no regeneration or DA regeneration
311 s->AddPerSatFeederSlottedAlohaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
312 s->AddPerSatFeederCrdsaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
313 s->AddPerSatFeederEssaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
314 s->AddPerSatFwdUserDaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
315 s->AddPerSatRtnFeederDaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
316
317 // Error stats if RA regeneration
318 s->AddPerSatUserSlottedAlohaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
319 s->AddPerSatUserCrdsaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
320 s->AddPerSatUserEssaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
321 s->AddPerSatFwdFeederDaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
322 s->AddPerSatRtnUserDaPacketError(SatStatsHelper::OUTPUT_SCATTER_FILE);
323
324 simulationHelper->EnableProgressLogs();
325 simulationHelper->RunSimulation();
326
327 return 0;
328}
RegenerationMode_t
The regeneration mode used in satellites.
@ SUPER_FRAME_CONFIG_4
SUPER_FRAME_CONFIG_4.
@ CONFIG_TYPE_4
Configuration type 4 (ESSA).
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.