Loading...
Searching...
No Matches
satellite-random-access-test.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 Ltd
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
29
30#include "ns3/cbr-application.h"
31#include "ns3/cbr-helper.h"
32#include "ns3/config.h"
33#include "ns3/enum.h"
34#include "ns3/log.h"
35#include "ns3/packet-sink-helper.h"
36#include "ns3/packet-sink.h"
37#include "ns3/satellite-env-variables.h"
38#include "ns3/satellite-helper.h"
39#include "ns3/satellite-topology.h"
40#include "ns3/simulator.h"
41#include "ns3/singleton.h"
42#include "ns3/string.h"
43#include "ns3/test.h"
44
45using namespace ns3;
46
61class SatCrdsaTest1 : public TestCase
62{
63 public:
65 virtual ~SatCrdsaTest1();
66
67 private:
68 virtual void DoRun(void);
69};
70
71// Add some help text to this case to describe what it is intended to test
73 : TestCase("'CRDSA, test 1' case tests successful transmission of UDP packets from UT "
74 "connected user to GW connected user in simple scenario using only CRDSA.")
75{
76}
77
78// This destructor does nothing but we include it as a reminder that
79// the test case should clean up after itself
83
84//
85// SatCrdsaTest1 TestCase implementation
86//
87void
89{
90 // Set simulation output details
91 SatEnvVariables::GetInstance()->DoInitialize();
92 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-random-access", "crdsa", true);
93
94 // Create simple scenario
95
96 // Configure a static error probability
98 Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
99 Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
100
101 // Enable Random Access with RCS2 specification
102 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
104
105 // Set Random Access interference model
106 Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
108
109 // Set Random Access collision model
110 Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
112
113 // Disable periodic control slots
114 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
115
116 // Disable dynamic load control
117 Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
118 BooleanValue(false));
119 Config::SetDefault(
120 "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
121 UintegerValue(10));
122
123 // Set random access parameters (e.g. enable CRDSA)
124 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
125 UintegerValue(3));
126 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
127 UintegerValue(6));
128 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
129 UintegerValue(2));
130 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
131 UintegerValue(250));
132 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
133 UintegerValue(1));
134 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
135 UintegerValue(1));
136 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
137 UintegerValue(3));
138 Config::SetDefault(
139 "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
140 DoubleValue(0.5));
141 Config::SetDefault("ns3::SatLowerLayerServiceConf::DefaultControlRandomizationInterval",
142 TimeValue(MilliSeconds(100)));
143 Config::SetDefault("ns3::SatRandomAccessConf::CrdsaSignalingOverheadInBytes", UintegerValue(5));
144 Config::SetDefault("ns3::SatRandomAccessConf::SlottedAlohaSignalingOverheadInBytes",
145 UintegerValue(3));
146
147 // Disable CRA and DA
148 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
149 BooleanValue(false));
150 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
151 BooleanValue(false));
152 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
153 BooleanValue(false));
154 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
155 BooleanValue(false));
156 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
157 BooleanValue(false));
158 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
159 BooleanValue(false));
160 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
161 BooleanValue(false));
162 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
163 BooleanValue(false));
164 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
165 BooleanValue(false));
166 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
167 BooleanValue(false));
168 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
169 BooleanValue(false));
170 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
171 BooleanValue(false));
172
173 // Creating the reference system.
174 Ptr<SatHelper> helper = CreateObject<SatHelper>(
175 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/scenarios/geo-33E");
176 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
177
178 // >>> Start of actual test using Simple scenario >>>
179
180 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
181
182 // Create the Cbr application to send UDP datagrams of size
183 // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 1s)
184 uint16_t port = 9; // Discard port (RFC 863)
185 CbrHelper cbr("ns3::UdpSocketFactory",
186 Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
187 cbr.SetAttribute("Interval", StringValue("1s"));
188 cbr.SetAttribute("PacketSize", UintegerValue(64));
189
190 ApplicationContainer utApps = cbr.Install(Singleton<SatTopology>::Get()->GetUtUserNodes());
191 utApps.Start(Seconds(1.0));
192 utApps.Stop(Seconds(2.1));
193
194 // Create a packet sink to receive these packets
195 PacketSinkHelper sink("ns3::UdpSocketFactory",
196 Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
197
198 ApplicationContainer gwApps = sink.Install(gwUsers);
199 gwApps.Start(Seconds(1.0));
200 gwApps.Stop(Seconds(10.0));
201
202 Simulator::Stop(Seconds(11));
203 Simulator::Run();
204
205 Simulator::Destroy();
206
207 Ptr<PacketSink> receiver = DynamicCast<PacketSink>(gwApps.Get(0));
208 Ptr<CbrApplication> sender = DynamicCast<CbrApplication>(utApps.Get(0));
209
210 // here we check that results are as expected.
211 // * Sender has sent something
212 // * Receiver got all all data sent
213 NS_TEST_ASSERT_MSG_NE(sender->GetSent(), (uint32_t)0, "Nothing sent !");
214 NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(), sender->GetSent(), "Packets were lost !");
215
216 SatEnvVariables::GetInstance()->DoDispose();
217 // <<< End of actual test using Simple scenario <<<
218}
219
238class SatSlottedAlohaTest1 : public TestCase
239{
240 public:
242 virtual ~SatSlottedAlohaTest1();
243
244 private:
245 virtual void DoRun(void);
246};
247
248// Add some help text to this case to describe what it is intended to test
250 : TestCase("'Slotted ALOHA, test 1' case tests successful transmission of UDP packets from UT "
251 "connected user to GW connected user in simple scenario using Slotted ALOHA for "
252 "control messages and VBDC for data.")
253{
254}
255
256// This destructor does nothing but we include it as a reminder that
257// the test case should clean up after itself
261
262//
263// SatSlottedAlohaTest1 TestCase implementation
264//
265void
267{
268 // Set simulation output details
269 SatEnvVariables::GetInstance()->DoInitialize();
270 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-random-access",
271 "slottedAloha",
272 true);
273
274 // Create simple scenario
275
276 // Configure a static error probability
278 Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
279 Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
280
281 // Enable Random Access with RCS2 specification
282 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
284
285 // Set Random Access interference model
286 Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
288
289 // Set Random Access collision model
290 Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
292
293 // Disable periodic control slots
294 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
295
296 // Disable dynamic load control
297 Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
298 BooleanValue(false));
299 Config::SetDefault(
300 "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
301 UintegerValue(10));
302
303 // Set random access parameters (e.g. enable Slotted ALOHA)
304 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
305 UintegerValue(3));
306 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
307 UintegerValue(6));
308 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
309 UintegerValue(2));
310 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
311 UintegerValue(250));
312 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
313 UintegerValue(1));
314 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
315 UintegerValue(1));
316 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
317 UintegerValue(1));
318 Config::SetDefault(
319 "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
320 DoubleValue(0.5));
321 Config::SetDefault("ns3::SatLowerLayerServiceConf::DefaultControlRandomizationInterval",
322 TimeValue(MilliSeconds(100)));
323 Config::SetDefault("ns3::SatRandomAccessConf::CrdsaSignalingOverheadInBytes", UintegerValue(5));
324 Config::SetDefault("ns3::SatRandomAccessConf::SlottedAlohaSignalingOverheadInBytes",
325 UintegerValue(3));
326
327 // Disable CRA and DA
328 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
329 BooleanValue(false));
330 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
331 BooleanValue(false));
332 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
333 BooleanValue(false));
334 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
335 BooleanValue(false));
336 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
337 BooleanValue(false));
338 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
339 BooleanValue(false));
340 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
341 BooleanValue(false));
342 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
343 BooleanValue(false));
344 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
345 BooleanValue(false));
346 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
347 BooleanValue(false));
348 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
349 BooleanValue(false));
350 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
351 BooleanValue(true));
352
353 // Creating the reference system.
354 Ptr<SatHelper> helper = CreateObject<SatHelper>(
355 SatEnvVariables::GetInstance()->LocateDataDirectory() + "/scenarios/geo-33E");
356 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
357
358 // >>> Start of actual test using Simple scenario >>>
359
360 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
361
362 // Create the Cbr application to send UDP datagrams of size
363 // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 1s)
364 uint16_t port = 9; // Discard port (RFC 863)
365 CbrHelper cbr("ns3::UdpSocketFactory",
366 Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
367 cbr.SetAttribute("Interval", StringValue("1s"));
368 cbr.SetAttribute("PacketSize", UintegerValue(64));
369
370 ApplicationContainer utApps = cbr.Install(Singleton<SatTopology>::Get()->GetUtUserNodes());
371 utApps.Start(Seconds(1.0));
372 utApps.Stop(Seconds(2.1));
373
374 // Create a packet sink to receive these packets
375 PacketSinkHelper sink("ns3::UdpSocketFactory",
376 Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
377
378 ApplicationContainer gwApps = sink.Install(gwUsers);
379 gwApps.Start(Seconds(1.0));
380 gwApps.Stop(Seconds(10.0));
381
382 Simulator::Stop(Seconds(11));
383 Simulator::Run();
384
385 Simulator::Destroy();
386
387 Ptr<PacketSink> receiver = DynamicCast<PacketSink>(gwApps.Get(0));
388 Ptr<CbrApplication> sender = DynamicCast<CbrApplication>(utApps.Get(0));
389
390 // here we check that results are as expected.
391 // * Sender has sent something
392 // * Receiver got all all data sent
393 NS_TEST_ASSERT_MSG_NE(sender->GetSent(), (uint32_t)0, "Nothing sent !");
394 NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(), sender->GetSent(), "Packets were lost !");
395
396 SatEnvVariables::GetInstance()->DoDispose();
397 // <<< End of actual test using Simple scenario <<<
398}
399
400// The TestSuite class names the TestSuite as sat-random-access-test, identifies what type of
401// TestSuite (Type::SYSTEM), and enables the TestCases to be run. Typically, only the constructor
402// for this class must be defined
403//
404class SatRandomAccessTestSuite : public TestSuite
405{
406 public:
408};
409
411 : TestSuite("sat-random-access-test", Type::SYSTEM)
412{
413 AddTestCase(new SatCrdsaTest1, TestCase::Duration::QUICK);
414
415 AddTestCase(new SatSlottedAlohaTest1, TestCase::Duration::QUICK);
416}
417
418// Allocate an instance of this TestSuite
'CRDSA, test 1' test case implementation.
'Slotted ALOHA, test 1' test case implementation.
static Ptr< SatEnvVariables > GetInstance()
@ SIMPLE
SIMPLE Simple scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatRandomAccessTestSuite satRandomAccessTestSuite