Loading...
Searching...
No Matches
satellite-regeneration-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: Bastien Tauran <bastien.tauran@viveris.fr>
19 */
20
28
29#include "ns3/cbr-application.h"
30#include "ns3/cbr-helper.h"
31#include "ns3/config.h"
32#include "ns3/log.h"
33#include "ns3/packet-sink-helper.h"
34#include "ns3/packet-sink.h"
35#include "ns3/satellite-env-variables.h"
36#include "ns3/satellite-gw-mac.h"
37#include "ns3/satellite-helper.h"
38#include "ns3/satellite-orbiter-feeder-phy.h"
39#include "ns3/satellite-orbiter-net-device.h"
40#include "ns3/satellite-orbiter-user-phy.h"
41#include "ns3/satellite-phy-rx-carrier.h"
42#include "ns3/satellite-phy-tx.h"
43#include "ns3/satellite-topology.h"
44#include "ns3/satellite-ut-mac-state.h"
45#include "ns3/simulation-helper.h"
46#include "ns3/simulator.h"
47#include "ns3/singleton.h"
48#include "ns3/string.h"
49#include "ns3/test.h"
50
51using namespace ns3;
52
62class SatRegenerationTest1 : public TestCase
63{
64 public:
66 virtual ~SatRegenerationTest1();
67
68 private:
69 virtual void DoRun(void);
70 void PhyDelayTraceCb(std::string context, const Time& time, const Address& address);
71 void OrbiterFeederPhyTraceDelayCb(const Time& time, const Address& address);
72 void OrbiterUserPhyTraceDelayCb(const Time& time, const Address& address);
73
74 Ptr<SatHelper> m_helper;
75
76 Address m_gwAddress;
77 Address m_stAddress;
78
79 std::vector<Time> m_forwardDelay;
80 std::vector<Time> m_returnDelay;
81 std::vector<Time> m_orbiterForwardDelay;
82 std::vector<Time> m_orbiterReturnDelay;
83};
84
85// Add some help text to this case to describe what it is intended to test
87 : TestCase(
88 "This case tests that delay of packets takes into account regeneration in satellite.")
89{
90}
91
92// This destructor does nothing but we include it as a reminder that
93// the test case should clean up after itself
97
98void
99SatRegenerationTest1::PhyDelayTraceCb(std::string context, const Time& time, const Address& address)
100{
101 if (address == m_gwAddress)
102 {
103 m_forwardDelay.push_back(time);
104 }
105 if (address == m_stAddress)
106 {
107 m_returnDelay.push_back(time);
108 }
109}
110
111void
112SatRegenerationTest1::OrbiterFeederPhyTraceDelayCb(const Time& time, const Address& address)
113{
114 m_orbiterForwardDelay.push_back(time);
115}
116
117void
118SatRegenerationTest1::OrbiterUserPhyTraceDelayCb(const Time& time, const Address& address)
119{
120 m_orbiterReturnDelay.push_back(time);
121}
122
123//
124// SatRegenerationTest1 TestCase implementation
125//
126void
128{
129 Config::Reset();
130
131 // Set simulation output details
132 SatEnvVariables::GetInstance()->DoInitialize();
133 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-regeneration", "test1", true);
134
136 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
137 EnumValue(SatEnums::REGENERATION_PHY));
138 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
139 EnumValue(SatEnums::REGENERATION_PHY));
140
141 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
142
143 // Enable traces
144 Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
145 Config::SetDefault("ns3::SatNetDevice::EnableStatisticsTags", BooleanValue(true));
146
148 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
149
150 Config::SetDefault("ns3::CbrApplication::Interval", StringValue("500ms"));
151 Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(512));
152
153 // Creating the reference system.
154 m_helper = CreateObject<SatHelper>(SatEnvVariables::GetInstance()->LocateDataDirectory() +
155 "/scenarios/geo-33E");
156 m_helper->CreatePredefinedScenario(SatHelper::SIMPLE);
157
158 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
159 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
160 uint16_t port = 9;
161
162 // Install forward traffic
163 CbrHelper cbrForward(
164 "ns3::UdpSocketFactory",
165 Address(InetSocketAddress(m_helper->GetUserAddress(utUsers.Get(0)), port)));
166 ApplicationContainer gwAppsForward = cbrForward.Install(gwUsers);
167 gwAppsForward.Start(Seconds(1.0));
168 gwAppsForward.Stop(Seconds(5.0));
169
170 PacketSinkHelper sinkForward(
171 "ns3::UdpSocketFactory",
172 Address(InetSocketAddress(m_helper->GetUserAddress(utUsers.Get(0)), port)));
173 ApplicationContainer utAppsForward = sinkForward.Install(utUsers);
174 utAppsForward.Start(Seconds(1.0));
175 utAppsForward.Stop(Seconds(10.0));
176
177 // Install return traffic
178 CbrHelper cbrReturn("ns3::UdpSocketFactory",
179 Address(InetSocketAddress(m_helper->GetUserAddress(gwUsers.Get(0)), port)));
180 ApplicationContainer utAppsReturn = cbrReturn.Install(utUsers);
181 utAppsReturn.Start(Seconds(1.0));
182 utAppsReturn.Stop(Seconds(5.0));
183
184 PacketSinkHelper sinkReturn(
185 "ns3::UdpSocketFactory",
186 Address(InetSocketAddress(m_helper->GetUserAddress(gwUsers.Get(0)), port)));
187 ApplicationContainer gwAppsReturn = sinkReturn.Install(gwUsers);
188 gwAppsReturn.Start(Seconds(1.0));
189 gwAppsReturn.Stop(Seconds(10.0));
190
191 m_gwAddress = Singleton<SatTopology>::Get()->GetGwNode(0)->GetDevice(1)->GetAddress();
192 m_stAddress = Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2)->GetAddress();
193
194 Ptr<SatOrbiterFeederPhy> satOrbiterFeederPhy = DynamicCast<SatOrbiterFeederPhy>(
195 DynamicCast<SatOrbiterNetDevice>(
196 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
197 ->GetFeederPhy(8));
198 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = DynamicCast<SatOrbiterUserPhy>(
199 DynamicCast<SatOrbiterNetDevice>(
200 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
201 ->GetUserPhy(8));
202
203 satOrbiterFeederPhy->TraceConnectWithoutContext(
204 "RxLinkDelay",
206 satOrbiterUserPhy->TraceConnectWithoutContext(
207 "RxLinkDelay",
209 Config::Connect("/NodeList/*/DeviceList/*/SatPhy/RxLinkDelay",
210 MakeCallback(&SatRegenerationTest1::PhyDelayTraceCb, this));
211
212 Ptr<SatChannel> feederChannel = satOrbiterFeederPhy->GetPhyTx()->GetChannel();
213 Ptr<SatChannel> userChannel = satOrbiterUserPhy->GetPhyTx()->GetChannel();
214
215 Ptr<PropagationDelayModel> feederDelayModel = feederChannel->GetPropagationDelayModel();
216 Ptr<PropagationDelayModel> userDelayModel = userChannel->GetPropagationDelayModel();
217
218 Time feederDelay = feederDelayModel->GetDelay(
219 DynamicCast<SatNetDevice>(Singleton<SatTopology>::Get()->GetGwNode(0)->GetDevice(1))
220 ->GetPhy()
221 ->GetPhyTx()
222 ->GetMobility(),
223 satOrbiterFeederPhy->GetPhyTx()->GetMobility());
224
225 Time userDelay = userDelayModel->GetDelay(
226 DynamicCast<SatNetDevice>(Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2))
227 ->GetPhy()
228 ->GetPhyTx()
229 ->GetMobility(),
230 satOrbiterUserPhy->GetPhyTx()->GetMobility());
231
232 Simulator::Stop(Seconds(10));
233 Simulator::Run();
234
235 Simulator::Destroy();
236
237 // In default configuration, we have:
238 // - FWD transmission delay (NORMAL BBFrame = 32400 symbols, QPSK 1/2, BW = 104 MHz): 319 507
239 // ns
240 // - RTN transmission delay (frame = 536 symbols, QPSK 1/3, BW = 801 kHz): 668 928 ns
241 // We have to remove 1 us default guard time to these delays to get transmission time.
242
243 Time fwdTime = NanoSeconds(319507) - MicroSeconds(1);
244 Time rtnTime = NanoSeconds(668928) - MicroSeconds(1);
245
246 for (uint32_t i = 0; i < m_orbiterForwardDelay.size(); i++)
247 {
248 NS_TEST_ASSERT_MSG_EQ(m_orbiterForwardDelay[i] - feederDelay,
249 fwdTime,
250 "Transmission time on FWD FEEDER incorrect.");
251 }
252
253 for (uint32_t i = 0; i < m_orbiterReturnDelay.size(); i++)
254 {
255 NS_TEST_ASSERT_MSG_EQ(m_orbiterReturnDelay[i] - userDelay,
256 rtnTime,
257 "Transmission time on RTN USER incorrect.");
258 }
259
260 for (uint32_t i = 0; i < m_forwardDelay.size(); i++)
261 {
262 NS_TEST_ASSERT_MSG_EQ(m_forwardDelay[i] - userDelay,
263 fwdTime,
264 "Transmission time on FWD USER incorrect.");
265 }
266
267 for (uint32_t i = 0; i < m_returnDelay.size(); i++)
268 {
269 NS_TEST_ASSERT_MSG_EQ(m_returnDelay[i] - feederDelay,
270 rtnTime,
271 "Transmission time on RTN FEEDER incorrect.");
272 }
273}
274
287class SatRegenerationTest2 : public TestCase
288{
289 public:
291 virtual ~SatRegenerationTest2();
292
293 private:
294 virtual void DoRun(void);
295 void OrbiterPhyTraceCb(Time time,
298 uint32_t nodeId,
299 Mac48Address address,
302 std::string packetInfo);
303 void PhyTraceCb(Time time,
306 uint32_t nodeId,
307 Mac48Address address,
310 std::string packetInfo);
311
312 Ptr<SatHelper> m_helper;
313
318
323};
324
325// Add some help text to this case to describe what it is intended to test
327 : TestCase("This case tests physical regeneration on satellite. It is based on a SIMPLE "
328 "scenario, with losses on uplink, forward and return."),
337{
338}
339
340// This destructor does nothing but we include it as a reminder that
341// the test case should clean up after itself
345
346void
350 uint32_t nodeId,
351 Mac48Address address,
354 std::string packetInfo)
355{
356 switch (dir)
357 {
359 if (event == SatEnums::PACKET_RECV)
360 {
362 }
363 else if (event == SatEnums::PACKET_DROP)
364 {
366 }
367 break;
369 if (event == SatEnums::PACKET_RECV)
370 {
372 }
373 else if (event == SatEnums::PACKET_DROP)
374 {
376 }
377 break;
378 default:
379 break;
380 }
381}
382
383void
387 uint32_t nodeId,
388 Mac48Address address,
391 std::string packetInfo)
392{
393 switch (dir)
394 {
396 if (event == SatEnums::PACKET_RECV)
397 {
399 }
400 else if (event == SatEnums::PACKET_DROP)
401 {
403 }
404 break;
406 if (event == SatEnums::PACKET_RECV)
407 {
409 }
410 else if (event == SatEnums::PACKET_DROP)
411 {
413 }
414 break;
415 default:
416 break;
417 }
418}
419
420//
421// SatRegenerationTest2 TestCase implementation
422//
423void
425{
426 Config::Reset();
427
428 // Set simulation output details
429 SatEnvVariables::GetInstance()->DoInitialize();
430 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-regeneration", "test2", true);
431
433 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
434 EnumValue(SatEnums::REGENERATION_PHY));
435 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
436 EnumValue(SatEnums::REGENERATION_PHY));
437
438 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
439
441 Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
443 Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkConstantErrorRate", DoubleValue(0.1));
444 Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
446 Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkConstantErrorRate", DoubleValue(0.1));
447
448 // Enable SatMac traces
449 Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
450 Config::SetDefault("ns3::SatNetDevice::EnableStatisticsTags", BooleanValue(true));
451
453 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
454
455 Config::SetDefault("ns3::CbrApplication::Interval", StringValue("10ms"));
456 Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(512));
457
458 // Creating the reference system.
459 m_helper = CreateObject<SatHelper>(SatEnvVariables::GetInstance()->LocateDataDirectory() +
460 "/scenarios/geo-33E");
461 m_helper->CreatePredefinedScenario(SatHelper::SIMPLE);
462
463 NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
464 NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
465 uint16_t port = 9;
466
467 // Install forward traffic
468 CbrHelper cbrForward(
469 "ns3::UdpSocketFactory",
470 Address(InetSocketAddress(m_helper->GetUserAddress(utUsers.Get(0)), port)));
471 ApplicationContainer gwAppsForward = cbrForward.Install(gwUsers);
472 gwAppsForward.Start(Seconds(1.0));
473 gwAppsForward.Stop(Seconds(59.0));
474
475 PacketSinkHelper sinkForward(
476 "ns3::UdpSocketFactory",
477 Address(InetSocketAddress(m_helper->GetUserAddress(utUsers.Get(0)), port)));
478 ApplicationContainer utAppsForward = sinkForward.Install(utUsers);
479 utAppsForward.Start(Seconds(1.0));
480 utAppsForward.Stop(Seconds(60.0));
481
482 // Install return traffic
483 CbrHelper cbrReturn("ns3::UdpSocketFactory",
484 Address(InetSocketAddress(m_helper->GetUserAddress(gwUsers.Get(0)), port)));
485 ApplicationContainer utAppsReturn = cbrReturn.Install(utUsers);
486 utAppsReturn.Start(Seconds(1.0));
487 utAppsReturn.Stop(Seconds(59.0));
488
489 PacketSinkHelper sinkReturn(
490 "ns3::UdpSocketFactory",
491 Address(InetSocketAddress(m_helper->GetUserAddress(gwUsers.Get(0)), port)));
492 ApplicationContainer gwAppsReturn = sinkReturn.Install(gwUsers);
493 gwAppsReturn.Start(Seconds(1.0));
494 gwAppsReturn.Stop(Seconds(60.0));
495
496 Ptr<SatOrbiterFeederPhy> satOrbiterFeederPhy = DynamicCast<SatOrbiterFeederPhy>(
497 DynamicCast<SatOrbiterNetDevice>(
498 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
499 ->GetFeederPhy(8));
500 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = DynamicCast<SatOrbiterUserPhy>(
501 DynamicCast<SatOrbiterNetDevice>(
502 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
503 ->GetUserPhy(8));
504
505 satOrbiterFeederPhy->TraceConnectWithoutContext(
506 "PacketTrace",
507 MakeCallback(&SatRegenerationTest2::OrbiterPhyTraceCb, this));
508 satOrbiterUserPhy->TraceConnectWithoutContext(
509 "PacketTrace",
510 MakeCallback(&SatRegenerationTest2::OrbiterPhyTraceCb, this));
511
512 Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/SatPhy/PacketTrace",
513 MakeCallback(&SatRegenerationTest2::PhyTraceCb, this));
514
515 Simulator::Stop(Seconds(60));
516 Simulator::Run();
517
518 Simulator::Destroy();
519
520 double dropRateForwardFeeder =
522 double dropRateReturnUser =
524
525 double forwardDifference =
527 double returnDifference =
529
530 NS_TEST_ASSERT_MSG_GT(dropRateForwardFeeder, 8.0, "Not enough losses on FWD feeder");
531 NS_TEST_ASSERT_MSG_LT(dropRateForwardFeeder, 12.0, "Too much losses on FWD feeder");
532 NS_TEST_ASSERT_MSG_GT(dropRateReturnUser, 8.0, "Not enough losses on RTN user");
533 NS_TEST_ASSERT_MSG_LT(dropRateReturnUser, 12.0, "Too much losses on RTN user");
534
535 NS_TEST_ASSERT_MSG_NE(m_packetsReceivedGw, 0, "Packets must be received by GW");
536 NS_TEST_ASSERT_MSG_NE(m_packetsReceivedUt, 0, "Packets must be received by UT");
537 NS_TEST_ASSERT_MSG_EQ(m_packetsDroppedGw, 0, "Packets must not be dropped by GW");
538 NS_TEST_ASSERT_MSG_EQ(m_packetsDroppedUt, 0, "Packets must not be dropped by UT");
539
540 NS_TEST_ASSERT_MSG_LT(
541 forwardDifference,
542 0.01,
543 "Number of packets received on FWD should be almost the same between SAT and UT");
544 NS_TEST_ASSERT_MSG_LT(
545 returnDifference,
546 0.01,
547 "Number of packets received on RTN should be almost the same between SAT and GW");
548}
549
562class SatRegenerationTest3 : public TestCase
563{
564 public:
566 virtual ~SatRegenerationTest3();
567
568 private:
569 virtual void DoRun(void);
570 void OrbiterPhyTraceErrorCb(std::string,
571 uint32_t nPackets,
572 const Address& address,
573 bool hasError);
574 void OrbiterPhyTraceCollisionCb(std::string,
575 uint32_t nPackets,
576 const Address& address,
577 bool hasCollision);
578 void OrbiterPhyTraceCb(Time time,
581 uint32_t nodeId,
582 Mac48Address address,
585 std::string packetInfo);
586
587 Ptr<SatHelper> m_helper;
588
589 Address m_gwAddress;
590
595
600};
601
602// Add some help text to this case to describe what it is intended to test
604 : TestCase("This case tests physical regeneration on satellite. It is based on a LARGER "
605 "scenario, with collisions on return uplink."),
614{
615}
616
617// This destructor does nothing but we include it as a reminder that
618// the test case should clean up after itself
622
623void
625 uint32_t nPackets,
626 const Address& address,
627 bool hasError)
628{
629 if (!hasError)
630 {
631 return;
632 }
633 if (address == m_gwAddress)
634 {
635 m_nbErrorpacketsFwd += nPackets;
636 }
637 else
638 {
639 m_nbErrorpacketsRtn += nPackets;
640 }
641}
642
643void
645 uint32_t nPackets,
646 const Address& address,
647 bool hasCollision)
648{
649 if (!hasCollision)
650 {
651 return;
652 }
653 if (address == m_gwAddress)
654 {
655 m_nbCollisionPacketsFwd += nPackets;
656 }
657 else
658 {
659 m_nbCollisionPacketsRtn += nPackets;
660 }
661}
662
663void
667 uint32_t nodeId,
668 Mac48Address address,
671 std::string packetInfo)
672{
673 switch (dir)
674 {
676 if (event == SatEnums::PACKET_RECV)
677 {
679 }
680 else if (event == SatEnums::PACKET_DROP)
681 {
683 }
684 break;
686 if (event == SatEnums::PACKET_RECV)
687 {
689 }
690 else if (event == SatEnums::PACKET_DROP)
691 {
693 }
694 break;
695 default:
696 break;
697 }
698}
699
700//
701// SatRegenerationTest3 TestCase implementation
702//
703void
705{
706 Config::Reset();
707
708 // Set simulation output details
709 SatEnvVariables::GetInstance()->DoInitialize();
710 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-regeneration", "test3", true);
711
713 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
714 EnumValue(SatEnums::REGENERATION_PHY));
715 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
716 EnumValue(SatEnums::REGENERATION_PHY));
717
718 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
719
721 Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
722 Config::SetDefault("ns3::SatNetDevice::EnableStatisticsTags", BooleanValue(true));
723
725 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
726
727 // Enable Random Access
728 Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel",
730
731 // Set Random Access interference model
732 Config::SetDefault("ns3::SatBeamHelper::RaInterferenceModel",
734
735 // Disable periodic control slots
736 Config::SetDefault("ns3::SatBeamScheduler::ControlSlotsEnabled", BooleanValue(false));
737
738 // Set dynamic load control parameters
739 Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableRandomAccessDynamicLoadControl",
740 BooleanValue(false));
741 Config::SetDefault(
742 "ns3::SatPhyRxCarrierConf::RandomAccessAverageNormalizedOfferedLoadMeasurementWindowSize",
743 UintegerValue(10));
744
745 // Set random access parameters
746 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumUniquePayloadPerBlock",
747 UintegerValue(3));
748 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MaximumConsecutiveBlockAccessed",
749 UintegerValue(6));
750 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_MinimumIdleBlock",
751 UintegerValue(2));
752 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffTimeInMilliSeconds",
753 UintegerValue(250));
754 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_BackOffProbability",
755 UintegerValue(10000));
756 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_HighLoadBackOffProbability",
757 UintegerValue(30000));
758 Config::SetDefault("ns3::SatLowerLayerServiceConf::RaService0_NumberOfInstances",
759 UintegerValue(3));
760 Config::SetDefault(
761 "ns3::SatLowerLayerServiceConf::RaService0_AverageNormalizedOfferedLoadThreshold",
762 DoubleValue(0.5));
763 Config::SetDefault("ns3::SatLowerLayerServiceConf::DefaultControlRandomizationInterval",
764 TimeValue(MilliSeconds(100)));
765 Config::SetDefault("ns3::SatRandomAccessConf::CrdsaSignalingOverheadInBytes", UintegerValue(5));
766 Config::SetDefault("ns3::SatRandomAccessConf::SlottedAlohaSignalingOverheadInBytes",
767 UintegerValue(3));
768
769 // Disable CRA and DA
770 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
771 BooleanValue(false));
772 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_ConstantAssignmentProvided",
773 BooleanValue(false));
774 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_ConstantAssignmentProvided",
775 BooleanValue(false));
776 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_ConstantAssignmentProvided",
777 BooleanValue(false));
778 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_RbdcAllowed",
779 BooleanValue(false));
780 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_RbdcAllowed",
781 BooleanValue(false));
782 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_RbdcAllowed",
783 BooleanValue(false));
784 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
785 BooleanValue(false));
786 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_VolumeAllowed",
787 BooleanValue(false));
788 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService1_VolumeAllowed",
789 BooleanValue(false));
790 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService2_VolumeAllowed",
791 BooleanValue(false));
792 Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_VolumeAllowed",
793 BooleanValue(false));
794
795 Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
797 Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
798 EnumValue(SatPhyRxCarrierConf::EM_AVI));
799 Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
801
802 Ptr<SimulationHelper> simulationHelper =
803 CreateObject<SimulationHelper>("test-sat-regeneration");
804 simulationHelper->SetSimulationTime(Seconds(5));
805 simulationHelper->SetUserCountPerUt(1);
806 simulationHelper->SetUtCountPerBeam(50);
807 simulationHelper->SetBeamSet({1});
808
809 simulationHelper->LoadScenario("geo-33E");
810
811 simulationHelper->CreateSatScenario();
812
813 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
816 MilliSeconds(1),
817 512,
818 Singleton<SatTopology>::Get()->GetGwUserNodes(),
819 Singleton<SatTopology>::Get()->GetUtUserNodes(),
820 Seconds(0.01),
821 Seconds(5),
822 Seconds(0.01));
823
824 m_helper = simulationHelper->GetSatelliteHelper();
825
826 Ptr<SatOrbiterFeederPhy> satOrbiterFeederPhy = DynamicCast<SatOrbiterFeederPhy>(
827 DynamicCast<SatOrbiterNetDevice>(
828 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
829 ->GetFeederPhy(1));
830 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = DynamicCast<SatOrbiterUserPhy>(
831 DynamicCast<SatOrbiterNetDevice>(
832 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
833 ->GetUserPhy(1));
834
835 m_gwAddress = Singleton<SatTopology>::Get()->GetGwNode(0)->GetDevice(1)->GetAddress();
836
837 satOrbiterFeederPhy->TraceConnectWithoutContext(
838 "PacketTrace",
839 MakeCallback(&SatRegenerationTest3::OrbiterPhyTraceCb, this));
840 satOrbiterUserPhy->TraceConnectWithoutContext(
841 "PacketTrace",
842 MakeCallback(&SatRegenerationTest3::OrbiterPhyTraceCb, this));
843
844 Config::Connect(
845 "/NodeList/*/DeviceList/*/FeederPhy/1/PhyRx/RxCarrierList/*/SlottedAlohaRxError",
847 Config::Connect(
848 "/NodeList/*/DeviceList/*/FeederPhy/1/PhyRx/RxCarrierList/*/SlottedAlohaRxCollision",
850 Config::Connect("/NodeList/*/DeviceList/*/UserPhy/1/PhyRx/RxCarrierList/*/SlottedAlohaRxError",
852 Config::Connect(
853 "/NodeList/*/DeviceList/*/UserPhy/1/PhyRx/RxCarrierList/*/SlottedAlohaRxCollision",
855
856 Simulator::Stop(Seconds(5));
857 Simulator::Run();
858
859 Simulator::Destroy();
860
861 NS_TEST_ASSERT_MSG_NE(m_packetsReceivedFeeder, 0, "Packets received on FWD feeder link");
862 NS_TEST_ASSERT_MSG_NE(m_packetsReceivedUser,
863 0,
864 "Packets received on RTN user link due to collisions");
865 NS_TEST_ASSERT_MSG_EQ(m_packetsDroppedFeeder, 0, "No packets dropped on FWD feeder link");
866 NS_TEST_ASSERT_MSG_NE(m_packetsDroppedUser,
867 0,
868 "Packets dropped on RTN user link due to collisions");
869
870 NS_TEST_ASSERT_MSG_EQ(m_nbErrorpacketsFwd, 0, "No errors on FWD feeder link");
871 NS_TEST_ASSERT_MSG_EQ(m_nbCollisionPacketsFwd, 0, "No collisions on FWD feeder link");
872 NS_TEST_ASSERT_MSG_NE(m_nbErrorpacketsRtn, 0, "Need errors on RTN feeder link");
873 NS_TEST_ASSERT_MSG_NE(m_nbCollisionPacketsRtn, 0, "Need collisions on RTN feeder link");
874}
875
886class SatRegenerationTest4 : public TestCase
887{
888 public:
890 virtual ~SatRegenerationTest4();
891
892 private:
893 virtual void DoRun(void);
894 void OrbiterDevGwTxTraceCb(Ptr<const Packet> packet);
895 void OrbiterDevUtTxTraceCb(Ptr<const Packet> packet);
896 void OrbiterDevGwRxTraceCb(Ptr<const Packet> packet, const Address&);
897 void OrbiterDevUtRxTraceCb(Ptr<const Packet> packet, const Address&);
898 bool HasSinkInstalled(Ptr<Node> node, uint16_t port);
899
900 Ptr<SatHelper> m_helper;
901
906};
907
908void
910{
911 m_totalSentGw += packet->GetSize();
912}
913
914void
916{
917 m_totalSentUt += packet->GetSize();
918}
919
920void
921SatRegenerationTest4::OrbiterDevGwRxTraceCb(Ptr<const Packet> packet, const Address&)
922{
923 m_totalReceivedGw += packet->GetSize();
924}
925
926void
927SatRegenerationTest4::OrbiterDevUtRxTraceCb(Ptr<const Packet> packet, const Address& address)
928{
929 m_totalReceivedUt += packet->GetSize();
930}
931
932bool
933SatRegenerationTest4::HasSinkInstalled(Ptr<Node> node, uint16_t port)
934{
935 for (uint32_t i = 0; i < node->GetNApplications(); i++)
936 {
937 Ptr<PacketSink> sink = DynamicCast<PacketSink>(node->GetApplication(i));
938 if (sink != nullptr)
939 {
940 AddressValue av;
941 sink->GetAttribute("Local", av);
942 if (InetSocketAddress::ConvertFrom(av.Get()).GetPort() == port)
943 {
944 return true;
945 }
946 }
947 }
948 return false;
949}
950
951// Add some help text to this case to describe what it is intended to test
953 : TestCase("This case tests link regeneration on satellite. It is based on a LARGER scenario.")
954{
955 m_totalSentGw = 0;
956 m_totalSentUt = 0;
959}
960
961// This destructor does nothing but we include it as a reminder that
962// the test case should clean up after itself
966
967//
968// SatRegenerationTest4 TestCase implementation
969//
970void
972{
973 Config::Reset();
974
975 // Set simulation output details
976 SatEnvVariables::GetInstance()->DoInitialize();
977 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-regeneration", "test4", true);
978
980 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
981 EnumValue(SatEnums::REGENERATION_PHY));
982 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
983 EnumValue(SatEnums::REGENERATION_LINK));
984
985 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
986
987 // Enable SatMac traces
988 Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
989 Config::SetDefault("ns3::SatNetDevice::EnableStatisticsTags", BooleanValue(true));
990
992 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
993
994 Ptr<SimulationHelper> simulationHelper =
995 CreateObject<SimulationHelper>("test-sat-regeneration");
996 simulationHelper->SetSimulationTime(Seconds(20));
997
998 simulationHelper->LoadScenario("geo-33E");
999
1000 simulationHelper->CreateSatScenario(SatHelper::LARGER);
1001
1002 m_helper = simulationHelper->GetSatelliteHelper();
1003
1004 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1005 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1006
1007 uint32_t i;
1008 for (i = 0; i < gws.GetN(); i++)
1009 {
1010 gws.Get(i)->GetDevice(1)->TraceConnectWithoutContext(
1011 "Tx",
1012 MakeCallback(&SatRegenerationTest4::OrbiterDevGwTxTraceCb, this));
1013 gws.Get(i)->GetDevice(1)->TraceConnectWithoutContext(
1014 "Rx",
1015 MakeCallback(&SatRegenerationTest4::OrbiterDevGwRxTraceCb, this));
1016 }
1017 for (i = 0; i < uts.GetN(); i++)
1018 {
1019 uts.Get(i)->GetDevice(2)->TraceConnectWithoutContext(
1020 "Tx",
1021 MakeCallback(&SatRegenerationTest4::OrbiterDevUtTxTraceCb, this));
1022 uts.Get(i)->GetDevice(2)->TraceConnectWithoutContext(
1023 "Rx",
1024 MakeCallback(&SatRegenerationTest4::OrbiterDevUtRxTraceCb, this));
1025 }
1026
1027 std::string socketFactory = "ns3::UdpSocketFactory";
1028 uint16_t port = 9;
1029
1030 PacketSinkHelper sinkHelper(socketFactory, Address());
1031 CbrHelper cbrHelper(socketFactory, Address());
1032 ApplicationContainer sinkContainer;
1033 ApplicationContainer cbrContainer;
1034
1035 Time startTime = Seconds(1);
1036 Time stopTime = Seconds(15);
1037 Time startDelay = MilliSeconds(10);
1038 Time interval = MilliSeconds(100);
1039 uint32_t packetSize = 512;
1040
1041 for (uint32_t j = 0; j < gws.GetN(); j++)
1042 {
1043 for (uint32_t i = 0; i < uts.GetN(); i++)
1044 {
1045 InetSocketAddress gwUserAddr =
1046 InetSocketAddress(m_helper->GetUserAddress(gws.Get(j)), port);
1047 if (!HasSinkInstalled(gws.Get(j), port))
1048 {
1049 sinkHelper.SetAttribute("Local", AddressValue(Address(gwUserAddr)));
1050 sinkContainer.Add(sinkHelper.Install(gws.Get(j)));
1051 }
1052
1053 cbrHelper.SetConstantTraffic(Time(interval), packetSize);
1054 cbrHelper.SetAttribute("Remote", AddressValue(Address(gwUserAddr)));
1055 auto app = cbrHelper.Install(uts.Get(i)).Get(0);
1056 app->SetStartTime(startTime + (i + j * gws.GetN() + 1) * startDelay);
1057 app->SetStopTime(stopTime);
1058 cbrContainer.Add(app);
1059 }
1060 }
1061
1062 sinkContainer.Start(startTime);
1063 sinkContainer.Stop(stopTime + Seconds(1));
1064
1065 simulationHelper->RunSimulation();
1066
1067 Simulator::Destroy();
1068
1069 NS_TEST_ASSERT_MSG_EQ(m_totalSentGw, 0, "No packets sent on FWD link");
1070 NS_TEST_ASSERT_MSG_EQ(m_totalReceivedUt, 0, "No packets received on FWD link");
1071 NS_TEST_ASSERT_MSG_EQ(m_totalSentUt,
1073 "Same number of packets sent and received on RTN link");
1074}
1075
1089class SatRegenerationTest5 : public TestCase
1090{
1091 public:
1093 virtual ~SatRegenerationTest5();
1094
1095 private:
1096 virtual void DoRun(void);
1097 void OrbiterPhyGwModcodTraceCb(uint32_t modcod, const Address& address);
1098 void OrbiterPhyUtModcodTraceCb(uint32_t modcod, const Address& address);
1099 void OrbiterPhyFeederModcodTraceCb(uint32_t modcod, const Address& address);
1100 void OrbiterPhyUserModcodTraceCb(uint32_t modcod, const Address& address);
1101
1102 double GetAverage(std::vector<uint32_t> list, uint32_t beg, uint32_t end);
1103 double GetMostFrequent(std::vector<uint32_t> list, uint32_t beg, uint32_t end);
1104
1105 Ptr<SatHelper> m_helper;
1106
1107 std::vector<uint32_t> m_gwModcods;
1108 std::vector<uint32_t> m_utModcods;
1109 std::vector<uint32_t> m_feederModcods;
1110 std::vector<uint32_t> m_userModcods;
1111};
1112
1113void
1114SatRegenerationTest5::OrbiterPhyGwModcodTraceCb(uint32_t modcod, const Address& address)
1115{
1116 m_gwModcods.push_back(modcod);
1117}
1118
1119void
1120SatRegenerationTest5::OrbiterPhyUtModcodTraceCb(uint32_t modcod, const Address& address)
1121{
1122 m_utModcods.push_back(modcod);
1123}
1124
1125void
1126SatRegenerationTest5::OrbiterPhyFeederModcodTraceCb(uint32_t modcod, const Address& address)
1127{
1128 m_feederModcods.push_back(modcod);
1129}
1130
1131void
1132SatRegenerationTest5::OrbiterPhyUserModcodTraceCb(uint32_t modcod, const Address& address)
1133{
1134 m_userModcods.push_back(modcod);
1135}
1136
1137double
1138SatRegenerationTest5::GetAverage(std::vector<uint32_t> list, uint32_t beg, uint32_t end)
1139{
1140 uint32_t sum = 0;
1141 for (uint32_t i = beg; i < end; i++)
1142 {
1143 sum += list[i];
1144 }
1145 return 1.0 * sum / (end - beg);
1146}
1147
1148double
1149SatRegenerationTest5::GetMostFrequent(std::vector<uint32_t> list, uint32_t beg, uint32_t end)
1150{
1151 std::map<uint32_t, uint32_t> frequencies;
1152 for (uint32_t i = beg; i < end; i++)
1153 {
1154 frequencies[list[i]]++;
1155 }
1156
1157 uint32_t max_count = 0;
1158 uint32_t index = -1;
1159 for (std::pair<const uint32_t, uint32_t>& i : frequencies)
1160 {
1161 if (max_count < i.second)
1162 {
1163 index = i.first;
1164 max_count = i.second;
1165 }
1166 }
1167
1168 return index;
1169}
1170
1171// Add some help text to this case to describe what it is intended to test
1173 : TestCase("This case tests ACM on all links. It is based on a SIMPLE scenario.")
1174{
1175}
1176
1177// This destructor does nothing but we include it as a reminder that
1178// the test case should clean up after itself
1182
1183//
1184// SatRegenerationTest5 TestCase implementation
1185//
1186void
1188{
1189 Config::Reset();
1190
1191 // Set simulation output details
1192 SatEnvVariables::GetInstance()->DoInitialize();
1193 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-regeneration", "test5", true);
1194
1196 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
1197 EnumValue(SatEnums::REGENERATION_PHY));
1198 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
1199 EnumValue(SatEnums::REGENERATION_LINK));
1200
1201 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
1202
1204 Config::SetDefault("ns3::SatBbFrameConf::AcmEnabled", BooleanValue(true));
1205
1206 // Enable SatMac traces
1207 Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
1208 Config::SetDefault("ns3::SatNetDevice::EnableStatisticsTags", BooleanValue(true));
1209
1211 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
1212
1213 Ptr<SimulationHelper> simulationHelper =
1214 CreateObject<SimulationHelper>("test-sat-regeneration");
1215 simulationHelper->SetSimulationTime(Seconds(20));
1216
1217 simulationHelper->LoadScenario("geo-33E");
1218
1219 simulationHelper->CreateSatScenario(SatHelper::SIMPLE);
1220
1221 m_helper = simulationHelper->GetSatelliteHelper();
1222
1223 Ptr<Node> gwNode = Singleton<SatTopology>::Get()->GetGwNode(0);
1224 Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(0);
1225 Ptr<Node> satNode = Singleton<SatTopology>::Get()->GetOrbiterNode(0);
1226 Ptr<SatOrbiterFeederPhy> satOrbiterFeederPhy = DynamicCast<SatOrbiterFeederPhy>(
1227 DynamicCast<SatOrbiterNetDevice>(satNode->GetDevice(0))->GetFeederPhy(8));
1228 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = DynamicCast<SatOrbiterUserPhy>(
1229 DynamicCast<SatOrbiterNetDevice>(satNode->GetDevice(0))->GetUserPhy(8));
1230 Ptr<SatPhy> satGwPhy =
1231 DynamicCast<SatPhy>(DynamicCast<SatNetDevice>(gwNode->GetDevice(1))->GetPhy());
1232 Ptr<SatPhy> satUtPhy =
1233 DynamicCast<SatPhy>(DynamicCast<SatNetDevice>(utNode->GetDevice(2))->GetPhy());
1234
1235 satGwPhy->TraceConnectWithoutContext(
1236 "RxLinkModcod",
1238 satUtPhy->TraceConnectWithoutContext(
1239 "RxLinkModcod",
1241 satOrbiterFeederPhy->TraceConnectWithoutContext(
1242 "RxLinkModcod",
1244 satOrbiterUserPhy->TraceConnectWithoutContext(
1245 "RxLinkModcod",
1247
1248 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
1251 MilliSeconds(20),
1252 512,
1253 Singleton<SatTopology>::Get()->GetGwUserNodes(),
1254 Singleton<SatTopology>::Get()->GetUtUserNodes(),
1255 Seconds(1),
1256 Seconds(10),
1257 Seconds(0.01));
1258
1259 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
1262 MilliSeconds(20),
1263 512,
1264 Singleton<SatTopology>::Get()->GetGwUserNodes(),
1265 Singleton<SatTopology>::Get()->GetUtUserNodes(),
1266 Seconds(1),
1267 Seconds(10),
1268 Seconds(0.01));
1269
1270 simulationHelper->RunSimulation();
1271
1272 Simulator::Destroy();
1273
1274 double averageGwModcodsBeg = GetAverage(m_gwModcods, 0, 5);
1275 double averageUtModcodsBeg = GetAverage(m_utModcods, 0, 5);
1276 double averageFeederModcodsBeg = GetAverage(m_feederModcods, 0, 5);
1277 double averageUserModcodsBeg = GetAverage(m_userModcods, 0, 5);
1278 double averageGwModcodsEnd =
1279 GetMostFrequent(m_gwModcods, m_gwModcods.size() - 200, m_gwModcods.size());
1280 double averageUtModcodsEnd =
1281 GetMostFrequent(m_utModcods, m_utModcods.size() - 200, m_utModcods.size());
1282 double averageFeederModcodsEnd =
1284 double averageUserModcodsEnd =
1286
1287 NS_TEST_ASSERT_MSG_EQ(averageFeederModcodsBeg,
1288 2,
1289 "Most robust MODCOD on FWD feeder link at startup");
1290 NS_TEST_ASSERT_MSG_EQ(averageUtModcodsBeg, 2, "Most robust MODCOD on FWD user link at startup");
1291 NS_TEST_ASSERT_MSG_EQ(averageGwModcodsBeg,
1292 2,
1293 "Most robust MODCOD on RTN feeder link at startup");
1294 NS_TEST_ASSERT_MSG_EQ(averageUserModcodsBeg,
1295 1,
1296 "Most robust MODCOD on RTN user link at startup");
1297
1298 NS_TEST_ASSERT_MSG_LT(averageFeederModcodsEnd, 28, "Max MODCOD on FWD feeder link is 27");
1299 NS_TEST_ASSERT_MSG_LT(averageUtModcodsEnd, 28, "Max MODCOD on FWD user link is 27");
1300 NS_TEST_ASSERT_MSG_LT(averageGwModcodsEnd, 28, "Max MODCOD on RTN feeder link is 27");
1301 NS_TEST_ASSERT_MSG_LT(averageUserModcodsEnd, 24, "Max MODCOD on RTN user link is 23");
1302
1303 NS_TEST_ASSERT_MSG_GT(averageFeederModcodsEnd,
1304 2,
1305 "Most robust MODCOD on FWD feeder link not used after a few seconds");
1306 NS_TEST_ASSERT_MSG_GT(averageUtModcodsEnd,
1307 2,
1308 "Most robust MODCOD on FWD user link not used after a few seconds");
1309 NS_TEST_ASSERT_MSG_GT(averageGwModcodsEnd,
1310 2,
1311 "Most robust MODCOD on RTN feeder link not used after a few seconds");
1312 NS_TEST_ASSERT_MSG_GT(averageUserModcodsEnd,
1313 1,
1314 "Most robust MODCOD on RTN user link not used after a few seconds");
1315
1316 NS_TEST_ASSERT_MSG_EQ(averageFeederModcodsEnd,
1317 averageUtModcodsEnd,
1318 "Same MODCOD on both FWD links");
1319 NS_TEST_ASSERT_MSG_NE(averageUserModcodsEnd,
1320 averageGwModcodsEnd,
1321 "Not same MODCOD on both RTN links");
1322}
1323
1334class SatRegenerationTest6 : public TestCase
1335{
1336 public:
1338 virtual ~SatRegenerationTest6();
1339
1340 private:
1341 virtual void DoRun(void);
1342 void OrbiterDevGwTxTraceCb(Ptr<const Packet> packet);
1343 void OrbiterDevUtTxTraceCb(Ptr<const Packet> packet);
1344 void OrbiterDevGwRxTraceCb(Ptr<const Packet> packet, const Address&);
1345 void OrbiterDevUtRxTraceCb(Ptr<const Packet> packet, const Address&);
1346 bool HasSinkInstalled(Ptr<Node> node, uint16_t port);
1347
1348 Ptr<SatHelper> m_helper;
1349
1354};
1355
1356void
1358{
1359 m_totalSentGw += packet->GetSize();
1360}
1361
1362void
1364{
1365 m_totalSentUt += packet->GetSize();
1366}
1367
1368void
1369SatRegenerationTest6::OrbiterDevGwRxTraceCb(Ptr<const Packet> packet, const Address&)
1370{
1371 m_totalReceivedGw += packet->GetSize();
1372}
1373
1374void
1375SatRegenerationTest6::OrbiterDevUtRxTraceCb(Ptr<const Packet> packet, const Address& address)
1376{
1377 m_totalReceivedUt += packet->GetSize();
1378}
1379
1380bool
1381SatRegenerationTest6::HasSinkInstalled(Ptr<Node> node, uint16_t port)
1382{
1383 for (uint32_t i = 0; i < node->GetNApplications(); i++)
1384 {
1385 Ptr<PacketSink> sink = DynamicCast<PacketSink>(node->GetApplication(i));
1386 if (sink != nullptr)
1387 {
1388 AddressValue av;
1389 sink->GetAttribute("Local", av);
1390 if (InetSocketAddress::ConvertFrom(av.Get()).GetPort() == port)
1391 {
1392 return true;
1393 }
1394 }
1395 }
1396 return false;
1397}
1398
1399// Add some help text to this case to describe what it is intended to test
1401 : TestCase(
1402 "This case tests network regeneration on satellite. It is based on a LARGER scenario.")
1403{
1404 m_totalSentGw = 0;
1405 m_totalSentUt = 0;
1408}
1409
1410// This destructor does nothing but we include it as a reminder that
1411// the test case should clean up after itself
1415
1416//
1417// SatRegenerationTest6 TestCase implementation
1418//
1419void
1421{
1422 Config::Reset();
1423
1424 // Set simulation output details
1425 SatEnvVariables::GetInstance()->DoInitialize();
1426 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-regeneration", "test6", true);
1427
1429 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
1431 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
1433
1434 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
1435
1436 // Enable SatMac traces
1437 Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
1438 Config::SetDefault("ns3::SatNetDevice::EnableStatisticsTags", BooleanValue(true));
1439
1441 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
1442
1443 Ptr<SimulationHelper> simulationHelper =
1444 CreateObject<SimulationHelper>("test-sat-regeneration");
1445 simulationHelper->SetSimulationTime(Seconds(20));
1446
1447 simulationHelper->LoadScenario("geo-33E");
1448
1449 simulationHelper->CreateSatScenario(SatHelper::LARGER);
1450
1451 m_helper = simulationHelper->GetSatelliteHelper();
1452
1453 NodeContainer gws = Singleton<SatTopology>::Get()->GetGwNodes();
1454 NodeContainer uts = Singleton<SatTopology>::Get()->GetUtNodes();
1455
1456 uint32_t i;
1457 for (i = 0; i < gws.GetN(); i++)
1458 {
1459 gws.Get(i)->GetDevice(1)->TraceConnectWithoutContext(
1460 "Tx",
1461 MakeCallback(&SatRegenerationTest6::OrbiterDevGwTxTraceCb, this));
1462 gws.Get(i)->GetDevice(1)->TraceConnectWithoutContext(
1463 "Rx",
1464 MakeCallback(&SatRegenerationTest6::OrbiterDevGwRxTraceCb, this));
1465 }
1466 for (i = 0; i < uts.GetN(); i++)
1467 {
1468 uts.Get(i)->GetDevice(2)->TraceConnectWithoutContext(
1469 "Tx",
1470 MakeCallback(&SatRegenerationTest6::OrbiterDevUtTxTraceCb, this));
1471 uts.Get(i)->GetDevice(2)->TraceConnectWithoutContext(
1472 "Rx",
1473 MakeCallback(&SatRegenerationTest6::OrbiterDevUtRxTraceCb, this));
1474 }
1475
1476 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
1479 Seconds(1),
1480 512,
1481 Singleton<SatTopology>::Get()->GetGwUserNodes(),
1482 Singleton<SatTopology>::Get()->GetUtUserNodes(),
1483 Seconds(1),
1484 Seconds(15),
1485 MilliSeconds(10));
1486
1487 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
1490 Seconds(1),
1491 512,
1492 Singleton<SatTopology>::Get()->GetGwUserNodes(),
1493 Singleton<SatTopology>::Get()->GetUtUserNodes(),
1494 Seconds(1),
1495 Seconds(15),
1496 MilliSeconds(10));
1497
1498 simulationHelper->RunSimulation();
1499
1500 Simulator::Destroy();
1501
1502 NS_TEST_ASSERT_MSG_NE(m_totalReceivedGw, 0, "Packets are received on GW");
1503 NS_TEST_ASSERT_MSG_NE(m_totalReceivedUt, 0, "Packets are received on UT");
1504 NS_TEST_ASSERT_MSG_EQ(m_totalSentGw * 5,
1506 "Same number of packets sent and received on FWD link (taking into "
1507 "account 2 UTs on beam 3)");
1508 NS_TEST_ASSERT_MSG_EQ(m_totalSentUt,
1510 "Same number of packets sent and received on RTN link");
1511}
1512
1526class SatRegenerationTest7 : public TestCase
1527{
1528 public:
1530 virtual ~SatRegenerationTest7();
1531
1532 private:
1533 virtual void DoRun(void);
1534 void OrbiterPhyGwModcodTraceCb(uint32_t modcod, const Address& address);
1535 void OrbiterPhyUtModcodTraceCb(uint32_t modcod, const Address& address);
1536 void OrbiterPhyFeederModcodTraceCb(uint32_t modcod, const Address& address);
1537 void OrbiterPhyUserModcodTraceCb(uint32_t modcod, const Address& address);
1538
1539 double GetAverage(std::vector<uint32_t> list, uint32_t beg, uint32_t end);
1540 double GetMostFrequent(std::vector<uint32_t> list, uint32_t beg, uint32_t end);
1541
1542 Ptr<SatHelper> m_helper;
1543
1544 std::vector<uint32_t> m_gwModcods;
1545 std::vector<uint32_t> m_utModcods;
1546 std::vector<uint32_t> m_feederModcods;
1547 std::vector<uint32_t> m_userModcods;
1548};
1549
1550void
1551SatRegenerationTest7::OrbiterPhyGwModcodTraceCb(uint32_t modcod, const Address& address)
1552{
1553 m_gwModcods.push_back(modcod);
1554}
1555
1556void
1557SatRegenerationTest7::OrbiterPhyUtModcodTraceCb(uint32_t modcod, const Address& address)
1558{
1559 m_utModcods.push_back(modcod);
1560}
1561
1562void
1563SatRegenerationTest7::OrbiterPhyFeederModcodTraceCb(uint32_t modcod, const Address& address)
1564{
1565 m_feederModcods.push_back(modcod);
1566}
1567
1568void
1569SatRegenerationTest7::OrbiterPhyUserModcodTraceCb(uint32_t modcod, const Address& address)
1570{
1571 m_userModcods.push_back(modcod);
1572}
1573
1574double
1575SatRegenerationTest7::GetAverage(std::vector<uint32_t> list, uint32_t beg, uint32_t end)
1576{
1577 uint32_t sum = 0;
1578 for (uint32_t i = beg; i < end; i++)
1579 {
1580 sum += list[i];
1581 }
1582 return 1.0 * sum / (end - beg);
1583}
1584
1585double
1586SatRegenerationTest7::GetMostFrequent(std::vector<uint32_t> list, uint32_t beg, uint32_t end)
1587{
1588 std::map<uint32_t, uint32_t> frequencies;
1589 for (uint32_t i = beg; i < end; i++)
1590 {
1591 frequencies[list[i]]++;
1592 }
1593
1594 uint32_t max_count = 0;
1595 uint32_t index = -1;
1596 for (std::pair<const uint32_t, uint32_t>& i : frequencies)
1597 {
1598 if (max_count < i.second)
1599 {
1600 index = i.first;
1601 max_count = i.second;
1602 }
1603 }
1604
1605 return index;
1606}
1607
1608// Add some help text to this case to describe what it is intended to test
1610 : TestCase("This case tests ACM on all links. It is based on a SIMPLE scenario.")
1611{
1612}
1613
1614// This destructor does nothing but we include it as a reminder that
1615// the test case should clean up after itself
1619
1620//
1621// SatRegenerationTest7 TestCase implementation
1622//
1623void
1625{
1626 Config::Reset();
1627
1628 // Set simulation output details
1629 SatEnvVariables::GetInstance()->DoInitialize();
1630 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-regeneration", "test7", true);
1631
1633 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
1635 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
1637
1638 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
1639
1641 Config::SetDefault("ns3::SatBbFrameConf::AcmEnabled", BooleanValue(true));
1642
1643 // Enable SatMac traces
1644 Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
1645 Config::SetDefault("ns3::SatNetDevice::EnableStatisticsTags", BooleanValue(true));
1646
1648 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
1649
1650 Ptr<SimulationHelper> simulationHelper =
1651 CreateObject<SimulationHelper>("test-sat-regeneration");
1652 simulationHelper->SetSimulationTime(Seconds(20));
1653
1654 simulationHelper->LoadScenario("geo-33E");
1655
1656 simulationHelper->CreateSatScenario(SatHelper::SIMPLE);
1657
1658 m_helper = simulationHelper->GetSatelliteHelper();
1659
1660 Ptr<Node> gwNode = Singleton<SatTopology>::Get()->GetGwNode(0);
1661 Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(0);
1662 Ptr<Node> satNode = Singleton<SatTopology>::Get()->GetOrbiterNode(0);
1663 Ptr<SatOrbiterFeederPhy> satOrbiterFeederPhy = DynamicCast<SatOrbiterFeederPhy>(
1664 DynamicCast<SatOrbiterNetDevice>(satNode->GetDevice(0))->GetFeederPhy(8));
1665 Ptr<SatOrbiterUserPhy> satOrbiterUserPhy = DynamicCast<SatOrbiterUserPhy>(
1666 DynamicCast<SatOrbiterNetDevice>(satNode->GetDevice(0))->GetUserPhy(8));
1667 Ptr<SatPhy> satGwPhy =
1668 DynamicCast<SatPhy>(DynamicCast<SatNetDevice>(gwNode->GetDevice(1))->GetPhy());
1669 Ptr<SatPhy> satUtPhy =
1670 DynamicCast<SatPhy>(DynamicCast<SatNetDevice>(utNode->GetDevice(2))->GetPhy());
1671
1672 satGwPhy->TraceConnectWithoutContext(
1673 "RxLinkModcod",
1675 satUtPhy->TraceConnectWithoutContext(
1676 "RxLinkModcod",
1678 satOrbiterFeederPhy->TraceConnectWithoutContext(
1679 "RxLinkModcod",
1681 satOrbiterUserPhy->TraceConnectWithoutContext(
1682 "RxLinkModcod",
1684
1685 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
1688 MilliSeconds(20),
1689 512,
1690 Singleton<SatTopology>::Get()->GetGwUserNodes(),
1691 Singleton<SatTopology>::Get()->GetUtUserNodes(),
1692 Seconds(1),
1693 Seconds(10),
1694 Seconds(0.01));
1695
1696 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
1699 MilliSeconds(20),
1700 512,
1701 Singleton<SatTopology>::Get()->GetGwUserNodes(),
1702 Singleton<SatTopology>::Get()->GetUtUserNodes(),
1703 Seconds(1),
1704 Seconds(10),
1705 Seconds(0.01));
1706
1707 simulationHelper->RunSimulation();
1708
1709 Simulator::Destroy();
1710
1711 double averageGwModcodsBeg = GetAverage(m_gwModcods, 0, 3);
1712 double averageUtModcodsBeg = GetAverage(m_utModcods, 0, 3);
1713 double averageFeederModcodsBeg = GetAverage(m_feederModcods, 0, 3);
1714 double averageUserModcodsBeg = GetAverage(m_userModcods, 0, 3);
1715 double averageGwModcodsEnd =
1716 GetMostFrequent(m_gwModcods, m_gwModcods.size() - 200, m_gwModcods.size());
1717 double averageUtModcodsEnd =
1718 GetMostFrequent(m_utModcods, m_utModcods.size() - 200, m_utModcods.size());
1719 double averageFeederModcodsEnd =
1721 double averageUserModcodsEnd =
1723
1724 NS_TEST_ASSERT_MSG_EQ(averageFeederModcodsBeg,
1725 2,
1726 "Most robust MODCOD on FWD feeder link at startup");
1727 NS_TEST_ASSERT_MSG_EQ(averageUtModcodsBeg, 2, "Most robust MODCOD on FWD user link at startup");
1728 NS_TEST_ASSERT_MSG_EQ(averageGwModcodsBeg,
1729 2,
1730 "Most robust MODCOD on RTN feeder link at startup");
1731 NS_TEST_ASSERT_MSG_EQ(averageUserModcodsBeg,
1732 1,
1733 "Most robust MODCOD on RTN user link at startup");
1734
1735 NS_TEST_ASSERT_MSG_LT(averageFeederModcodsEnd, 28, "Max MODCOD on FWD feeder link is 27");
1736 NS_TEST_ASSERT_MSG_LT(averageUtModcodsEnd, 28, "Max MODCOD on FWD user link is 27");
1737 NS_TEST_ASSERT_MSG_LT(averageGwModcodsEnd, 28, "Max MODCOD on RTN feeder link is 27");
1738 NS_TEST_ASSERT_MSG_LT(averageUserModcodsEnd, 24, "Max MODCOD on RTN user link is 23");
1739
1740 NS_TEST_ASSERT_MSG_GT(averageFeederModcodsEnd,
1741 2,
1742 "Most robust MODCOD on FWD feeder link not used after a few seconds");
1743 NS_TEST_ASSERT_MSG_GT(averageUtModcodsEnd,
1744 2,
1745 "Most robust MODCOD on FWD user link not used after a few seconds");
1746 NS_TEST_ASSERT_MSG_GT(averageGwModcodsEnd,
1747 2,
1748 "Most robust MODCOD on RTN feeder link not used after a few seconds");
1749 NS_TEST_ASSERT_MSG_GT(averageUserModcodsEnd,
1750 1,
1751 "Most robust MODCOD on RTN user link not used after a few seconds");
1752
1753 NS_TEST_ASSERT_MSG_EQ(averageFeederModcodsEnd,
1754 averageUtModcodsEnd,
1755 "Same MODCOD on both FWD links");
1756 NS_TEST_ASSERT_MSG_NE(averageUserModcodsEnd,
1757 averageGwModcodsEnd,
1758 "Not same MODCOD on both RTN links");
1759}
1760
1776class SatRegenerationTest8 : public TestCase
1777{
1778 public:
1779 SatRegenerationTest8(SatEnums::RegenerationMode_t forwardLinkRegenerationMode,
1780 SatEnums::RegenerationMode_t returnLinkRegenerationMode);
1781 virtual ~SatRegenerationTest8();
1782
1783 private:
1784 virtual void DoRun(void);
1785
1786 void AddTraceEntry(Time now,
1787 SatEnums::SatPacketEvent_t packetEvent,
1788 SatEnums::SatNodeType_t nodeType,
1789 uint32_t nodeId,
1790 Mac48Address macAddress,
1791 SatEnums::SatLogLevel_t logLevel,
1792 SatEnums::SatLinkDir_t linkDir,
1793 std::string packetInfo);
1794
1795 Ptr<SatHelper> m_helper;
1796
1799
1803 uint32_t m_rxUserPhy;
1804 uint32_t m_rxUserMac;
1805 uint32_t m_rxUserNet;
1806};
1807
1808void
1810 SatEnums::SatPacketEvent_t packetEvent,
1811 SatEnums::SatNodeType_t nodeType,
1812 uint32_t nodeId,
1813 Mac48Address macAddress,
1814 SatEnums::SatLogLevel_t logLevel,
1815 SatEnums::SatLinkDir_t linkDir,
1816 std::string packetInfo)
1817{
1818 if (packetEvent != SatEnums::PACKET_RECV)
1819 {
1820 return;
1821 }
1822 switch (logLevel)
1823 {
1824 case SatEnums::LL_PHY: {
1825 if (linkDir == SatEnums::LD_FORWARD)
1826 {
1827 m_rxFeederPhy++;
1828 }
1829 else if (linkDir == SatEnums::LD_RETURN)
1830 {
1831 m_rxUserPhy++;
1832 }
1833 break;
1834 }
1835 case SatEnums::LL_MAC: {
1836 if (linkDir == SatEnums::LD_FORWARD)
1837 {
1838 m_rxFeederMac++;
1839 }
1840 else if (linkDir == SatEnums::LD_RETURN)
1841 {
1842 m_rxUserMac++;
1843 }
1844 break;
1845 }
1846 case SatEnums::LL_ND: {
1847 if (linkDir == SatEnums::LD_FORWARD)
1848 {
1849 m_rxFeederNet++;
1850 }
1851 else if (linkDir == SatEnums::LD_RETURN)
1852 {
1853 m_rxUserNet++;
1854 }
1855 break;
1856 }
1857 default:
1858 NS_FATAL_ERROR("Wrong log level received");
1859 }
1860}
1861
1862// Add some help text to this case to describe what it is intended to test
1864 SatEnums::RegenerationMode_t returnLinkRegenerationMode)
1865 : TestCase("This test is launched several time to test every regeneration combination.")
1866{
1867 m_forwardLinkRegenerationMode = forwardLinkRegenerationMode;
1868 m_returnLinkRegenerationMode = returnLinkRegenerationMode;
1869
1870 m_rxFeederPhy = 0;
1871 m_rxFeederMac = 0;
1872 m_rxFeederNet = 0;
1873 m_rxUserPhy = 0;
1874 m_rxUserMac = 0;
1875 m_rxUserNet = 0;
1876}
1877
1878// This destructor does nothing but we include it as a reminder that
1879// the test case should clean up after itself
1883
1884//
1885// SatRegenerationTest8 TestCase implementation
1886//
1887void
1889{
1890 Config::Reset();
1891
1892 // Set simulation output details
1893 SatEnvVariables::GetInstance()->DoInitialize();
1894 SatEnvVariables::GetInstance()->SetOutputVariables("test-sat-regeneration", "test8", true);
1895
1897 Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
1899 Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
1900 EnumValue(m_returnLinkRegenerationMode));
1901
1902 SatEnums::RegenerationMode_t maxRegeneration =
1904
1905 Config::SetDefault("ns3::SatOrbiterFeederPhy::QueueSize", UintegerValue(100000));
1906
1907 // Enable SatMac traces
1908 Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
1909 Config::SetDefault("ns3::SatNetDevice::EnableStatisticsTags", BooleanValue(true));
1910
1912 Config::SetDefault("ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(true));
1913
1914 Ptr<SimulationHelper> simulationHelper =
1915 CreateObject<SimulationHelper>("test-sat-regeneration");
1916 simulationHelper->SetSimulationTime(Seconds(20));
1917
1918 simulationHelper->LoadScenario("geo-33E");
1919
1920 simulationHelper->CreateSatScenario(SatHelper::LARGER);
1921
1922 m_helper = simulationHelper->GetSatelliteHelper();
1923
1924 std::map<uint32_t, Ptr<SatPhy>> satOrbiterFeederPhy =
1925 DynamicCast<SatOrbiterNetDevice>(
1926 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
1927 ->GetFeederPhy();
1928 std::map<uint32_t, Ptr<SatPhy>> satOrbiterUserPhy =
1929 DynamicCast<SatOrbiterNetDevice>(
1930 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
1931 ->GetUserPhy();
1932 std::map<uint32_t, Ptr<SatMac>> satOrbiterFeederMac =
1933 DynamicCast<SatOrbiterNetDevice>(
1934 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
1935 ->GetFeederMac();
1936 std::map<uint32_t, Ptr<SatMac>> satOrbiterUserMac =
1937 DynamicCast<SatOrbiterNetDevice>(
1938 Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0))
1939 ->GetUserMac();
1940
1941 Config::ConnectWithoutContext("/NodeList/0/DeviceList/0/UserPhy/*/PacketTrace",
1942 MakeCallback(&SatRegenerationTest8::AddTraceEntry, this));
1943 Config::ConnectWithoutContext("/NodeList/0/DeviceList/0/FeederPhy/*/PacketTrace",
1944 MakeCallback(&SatRegenerationTest8::AddTraceEntry, this));
1945 if (maxRegeneration == SatEnums::REGENERATION_LINK ||
1946 maxRegeneration == SatEnums::REGENERATION_NETWORK)
1947 {
1948 Config::ConnectWithoutContext("/NodeList/0/DeviceList/0/UserMac/*/PacketTrace",
1949 MakeCallback(&SatRegenerationTest8::AddTraceEntry, this));
1950 Config::ConnectWithoutContext("/NodeList/0/DeviceList/0/FeederMac/*/PacketTrace",
1951 MakeCallback(&SatRegenerationTest8::AddTraceEntry, this));
1952 }
1953 if (maxRegeneration == SatEnums::REGENERATION_NETWORK)
1954 {
1955 Config::ConnectWithoutContext("/NodeList/0/DeviceList/0/PacketTrace",
1956 MakeCallback(&SatRegenerationTest8::AddTraceEntry, this));
1957 }
1958
1959 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
1962 MilliSeconds(100),
1963 512,
1964 Singleton<SatTopology>::Get()->GetGwUserNodes(),
1965 Singleton<SatTopology>::Get()->GetUtUserNodes(),
1966 Seconds(1),
1967 Seconds(15),
1968 MilliSeconds(10));
1969
1970 simulationHelper->GetTrafficHelper()->AddCbrTraffic(
1973 MilliSeconds(100),
1974 512,
1975 Singleton<SatTopology>::Get()->GetGwUserNodes(),
1976 Singleton<SatTopology>::Get()->GetUtUserNodes(),
1977 Seconds(1),
1978 Seconds(15),
1979 MilliSeconds(10));
1980
1981 simulationHelper->RunSimulation();
1982
1983 Simulator::Destroy();
1984
1986 {
1989 NS_TEST_ASSERT_MSG_GT(m_rxFeederPhy, 1600, "Packets should be received on feeder phy");
1990 NS_TEST_ASSERT_MSG_EQ(m_rxFeederMac, 0, "Packets should not be received on feeder MAC");
1991 NS_TEST_ASSERT_MSG_EQ(m_rxFeederNet, 0, "Packets should not be received on feeder network");
1992 break;
1993 }
1995 NS_TEST_ASSERT_MSG_GT(m_rxFeederPhy, 1600, "Packets should be received on feeder phy");
1996 NS_TEST_ASSERT_MSG_GT(m_rxFeederMac, 1600, "Packets should be received on feeder MAC");
1997 NS_TEST_ASSERT_MSG_EQ(m_rxFeederNet, 0, "Packets should not be received on feeder network");
1998 break;
1999 }
2001 NS_TEST_ASSERT_MSG_GT(m_rxFeederPhy, 1600, "Packets should be received on feeder phy");
2002 NS_TEST_ASSERT_MSG_GT(m_rxFeederMac, 1600, "Packets should be received on feeder MAC");
2003 NS_TEST_ASSERT_MSG_GT(m_rxFeederNet, 1600, "Packets should be received on feeder network");
2004 break;
2005 }
2006 }
2007
2009 {
2012 NS_TEST_ASSERT_MSG_GT(m_rxUserPhy, 1600, "Packets should be received on user phy");
2013 NS_TEST_ASSERT_MSG_EQ(m_rxUserMac, 0, "Packets should not be received on user MAC");
2014 NS_TEST_ASSERT_MSG_EQ(m_rxUserNet, 0, "Packets should not be received on user network");
2015 break;
2016 }
2018 NS_TEST_ASSERT_MSG_GT(m_rxUserPhy, 1600, "Packets should be received on user phy");
2019 NS_TEST_ASSERT_MSG_GT(m_rxUserMac, 1600, "Packets should be received on user MAC");
2020 NS_TEST_ASSERT_MSG_EQ(m_rxUserNet, 0, "Packets should not be received on user network");
2021 break;
2022 }
2024 NS_TEST_ASSERT_MSG_GT(m_rxUserPhy, 1600, "Packets should be received on user phy");
2025 NS_TEST_ASSERT_MSG_GT(m_rxUserMac, 1600, "Packets should be received on user MAC");
2026 NS_TEST_ASSERT_MSG_GT(m_rxUserNet, 1600, "Packets should be received on user network");
2027 break;
2028 }
2029 }
2030}
2031
2032// The TestSuite class names the TestSuite as sat-regeneration-test, identifies what type of
2033// TestSuite (Type::SYSTEM), and enables the TestCases to be run. Typically, only the constructor
2034// for this class must be defined
2035//
2036class SatRegenerationTestSuite : public TestSuite
2037{
2038 public:
2040};
2041
2043 : TestSuite("sat-regeneration-test", Type::SYSTEM)
2044{
2045 AddTestCase(new SatRegenerationTest1,
2046 TestCase::Duration::QUICK); // Test delay with regeneration phy
2047 AddTestCase(new SatRegenerationTest2,
2048 TestCase::Duration::QUICK); // Test losses with regeneration phy
2049 AddTestCase(new SatRegenerationTest3,
2050 TestCase::Duration::QUICK); // Test collisions with regeneration phy
2051 AddTestCase(new SatRegenerationTest4, TestCase::Duration::QUICK); // Test regeneration link
2052 AddTestCase(new SatRegenerationTest5,
2053 TestCase::Duration::QUICK); // Test ACM loop on regeneration link
2054 AddTestCase(new SatRegenerationTest6, TestCase::Duration::QUICK); // Test regeneration network
2055 AddTestCase(new SatRegenerationTest7,
2056 TestCase::Duration::QUICK); // Test ACM loop on regeneration network
2057
2058 // Test all regeneration combinations, and check if packets are correctly received or not on
2059 // each satellite layer
2061 TestCase::Duration::QUICK);
2063 TestCase::Duration::QUICK);
2065 TestCase::Duration::QUICK);
2067 TestCase::Duration::QUICK);
2069 TestCase::Duration::QUICK);
2071 TestCase::Duration::QUICK);
2073 TestCase::Duration::QUICK);
2074 AddTestCase(
2076 TestCase::Duration::QUICK);
2078 TestCase::Duration::QUICK);
2079 AddTestCase(
2081 TestCase::Duration::QUICK);
2082 AddTestCase(
2084 TestCase::Duration::QUICK);
2085 AddTestCase(
2087 TestCase::Duration::QUICK);
2088}
2089
2090// Allocate an instance of this TestSuite
'Regeneration, test 1' test case implementation.
std::vector< Time > m_orbiterReturnDelay
void OrbiterUserPhyTraceDelayCb(const Time &time, const Address &address)
void PhyDelayTraceCb(std::string context, const Time &time, const Address &address)
void OrbiterFeederPhyTraceDelayCb(const Time &time, const Address &address)
std::vector< Time > m_orbiterForwardDelay
'Regeneration, test 2' test case implementation.
void PhyTraceCb(Time time, SatEnums::SatPacketEvent_t event, SatEnums::SatNodeType_t type, uint32_t nodeId, Mac48Address address, SatEnums::SatLogLevel_t level, SatEnums::SatLinkDir_t dir, std::string packetInfo)
void OrbiterPhyTraceCb(Time time, SatEnums::SatPacketEvent_t event, SatEnums::SatNodeType_t type, uint32_t nodeId, Mac48Address address, SatEnums::SatLogLevel_t level, SatEnums::SatLinkDir_t dir, std::string packetInfo)
'Regeneration, test 3' test case implementation.
void OrbiterPhyTraceCollisionCb(std::string, uint32_t nPackets, const Address &address, bool hasCollision)
void OrbiterPhyTraceCb(Time time, SatEnums::SatPacketEvent_t event, SatEnums::SatNodeType_t type, uint32_t nodeId, Mac48Address address, SatEnums::SatLogLevel_t level, SatEnums::SatLinkDir_t dir, std::string packetInfo)
void OrbiterPhyTraceErrorCb(std::string, uint32_t nPackets, const Address &address, bool hasError)
'Regeneration, test 4' test case implementation.
void OrbiterDevGwRxTraceCb(Ptr< const Packet > packet, const Address &)
void OrbiterDevUtRxTraceCb(Ptr< const Packet > packet, const Address &)
bool HasSinkInstalled(Ptr< Node > node, uint16_t port)
void OrbiterDevUtTxTraceCb(Ptr< const Packet > packet)
void OrbiterDevGwTxTraceCb(Ptr< const Packet > packet)
'Regeneration, test 5' test case implementation.
double GetAverage(std::vector< uint32_t > list, uint32_t beg, uint32_t end)
void OrbiterPhyUtModcodTraceCb(uint32_t modcod, const Address &address)
void OrbiterPhyFeederModcodTraceCb(uint32_t modcod, const Address &address)
double GetMostFrequent(std::vector< uint32_t > list, uint32_t beg, uint32_t end)
std::vector< uint32_t > m_feederModcods
std::vector< uint32_t > m_gwModcods
std::vector< uint32_t > m_userModcods
void OrbiterPhyGwModcodTraceCb(uint32_t modcod, const Address &address)
std::vector< uint32_t > m_utModcods
void OrbiterPhyUserModcodTraceCb(uint32_t modcod, const Address &address)
'Regeneration, test 6' test case implementation.
bool HasSinkInstalled(Ptr< Node > node, uint16_t port)
void OrbiterDevUtRxTraceCb(Ptr< const Packet > packet, const Address &)
void OrbiterDevGwTxTraceCb(Ptr< const Packet > packet)
void OrbiterDevGwRxTraceCb(Ptr< const Packet > packet, const Address &)
void OrbiterDevUtTxTraceCb(Ptr< const Packet > packet)
'Regeneration, test 7' test case implementation.
void OrbiterPhyUserModcodTraceCb(uint32_t modcod, const Address &address)
double GetMostFrequent(std::vector< uint32_t > list, uint32_t beg, uint32_t end)
void OrbiterPhyGwModcodTraceCb(uint32_t modcod, const Address &address)
std::vector< uint32_t > m_gwModcods
void OrbiterPhyUtModcodTraceCb(uint32_t modcod, const Address &address)
std::vector< uint32_t > m_feederModcods
std::vector< uint32_t > m_utModcods
std::vector< uint32_t > m_userModcods
double GetAverage(std::vector< uint32_t > list, uint32_t beg, uint32_t end)
void OrbiterPhyFeederModcodTraceCb(uint32_t modcod, const Address &address)
'Regeneration, test 8' test case implementation.
SatEnums::RegenerationMode_t m_forwardLinkRegenerationMode
void AddTraceEntry(Time now, SatEnums::SatPacketEvent_t packetEvent, SatEnums::SatNodeType_t nodeType, uint32_t nodeId, Mac48Address macAddress, SatEnums::SatLogLevel_t logLevel, SatEnums::SatLinkDir_t linkDir, std::string packetInfo)
SatEnums::RegenerationMode_t m_returnLinkRegenerationMode
SatRegenerationTest8(SatEnums::RegenerationMode_t forwardLinkRegenerationMode, SatEnums::RegenerationMode_t returnLinkRegenerationMode)
SatLinkDir_t
Link direction used for packet tracing.
SatNodeType_t
Node type used for packet tracing.
SatPacketEvent_t
Packet event used for packet tracing.
SatLogLevel_t
Log level used for packet tracing.
RegenerationMode_t
The regeneration mode used in satellites.
static Ptr< SatEnvVariables > GetInstance()
@ LARGER
LARGER Larger scenario used as base.
@ SIMPLE
SIMPLE Simple scenario used as base.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatRegenerationTestSuite satRegenerationTestSuite