28 #include "../model/satellite-mobility-model.h"
29 #include "../model/satellite-position-allocator.h"
30 #include "../utils/satellite-env-variables.h"
32 #include "ns3/boolean.h"
33 #include "ns3/config.h"
35 #include "ns3/mobility-helper.h"
36 #include "ns3/simulator.h"
37 #include "ns3/singleton.h"
38 #include "ns3/string.h"
40 #include <ns3/cbr-application.h>
41 #include <ns3/cbr-helper.h>
43 #include <ns3/lora-periodic-sender.h>
44 #include <ns3/lorawan-mac-header.h>
45 #include <ns3/packet-sink-helper.h>
46 #include <ns3/packet-sink.h>
47 #include <ns3/satellite-enums.h>
48 #include <ns3/satellite-helper.h>
49 #include <ns3/satellite-lora-conf.h>
50 #include <ns3/satellite-lorawan-net-device.h>
51 #include <ns3/uinteger.h>
73 virtual void DoRun(
void);
74 void MacTraceCb(std::string context, Ptr<const Packet> packet,
const Address& address);
84 : TestCase(
"Test satellite lorawan with acks sent in first window."),
85 m_gwReceiveDate(Seconds(0)),
86 m_edReceiveDate(Seconds(0))
96 Ptr<const Packet> packet,
97 const Address& address)
114 Singleton<SatEnvVariables>::Get()->DoInitialize();
115 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-lora",
"first-window",
true);
118 Config::SetDefault(
"ns3::SatHelper::Standard", EnumValue(SatEnums::LORA));
119 Config::SetDefault(
"ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
120 Config::SetDefault(
"ns3::LorawanMacEndDevice::MType",
121 EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
122 Config::SetDefault(
"ns3::SatLorawanNetDevice::ForwardToUtUsers", BooleanValue(
false));
123 Config::SetDefault(
"ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
125 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
126 TimeValue(MilliSeconds(1500)));
127 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
128 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
129 TimeValue(MilliSeconds(400)));
130 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
131 TimeValue(MilliSeconds(400)));
132 Config::SetDefault(
"ns3::LoraNetworkScheduler::FirstWindowAnswerDelay", TimeValue(Seconds(1)));
133 Config::SetDefault(
"ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
136 Config::SetDefault(
"ns3::SatConf::SuperFrameConfForSeq0",
137 EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
138 Config::SetDefault(
"ns3::SatSuperframeConf4::FrameConfigType",
139 EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
140 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
141 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
145 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
146 BooleanValue(
false));
147 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
148 BooleanValue(
false));
151 Config::SetDefault(
"ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
152 Config::SetDefault(
"ns3::SatBeamHelper::RaInterferenceEliminationModel",
153 EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
154 Config::SetDefault(
"ns3::SatBeamHelper::RaCollisionModel",
155 EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
156 Config::SetDefault(
"ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
157 Config::SetDefault(
"ns3::SatWaveformConf::DefaultWfId", UintegerValue(2));
158 Config::SetDefault(
"ns3::SatHelper::RtnLinkWaveformConfFileName",
159 StringValue(
"loraWaveforms.txt"));
162 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue(
"600ms"));
163 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue(
"200ms"));
164 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
165 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(
false));
167 Config::SetDefault(
"ns3::SatMac::EnableStatisticsTags", BooleanValue(
true));
170 Ptr<SatHelper> helper = CreateObject<SatHelper>();
171 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
174 Ptr<Node> utNode = helper->UtNodes().Get(0);
175 Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
177 app->SetInterval(Seconds(10));
179 app->SetStartTime(Seconds(1.0));
180 app->SetStopTime(Seconds(10.0));
181 app->SetPacketSize(24);
183 app->SetNode(utNode);
184 utNode->AddApplication(app);
186 m_gwAddress = helper->GwNodes().Get(0)->GetDevice(1)->GetAddress();
187 m_edAddress = helper->UtNodes().Get(0)->GetDevice(2)->GetAddress();
189 Config::Connect(
"/NodeList/*/DeviceList/*/SatMac/Rx",
192 Simulator::Stop(Seconds(10));
195 Simulator::Destroy();
197 Singleton<SatEnvVariables>::Get()->DoDispose();
199 NS_TEST_ASSERT_MSG_NE(
m_gwReceiveDate, Seconds(0),
"Packet should be received by Gateway.");
200 NS_TEST_ASSERT_MSG_NE(
m_edReceiveDate, Seconds(0),
"Ack should be received by End Device.");
204 Time delay = MilliSeconds(130);
206 NS_TEST_ASSERT_MSG_GT(difference, Seconds(1) + delay,
"Ack arrived too early.");
207 NS_TEST_ASSERT_MSG_LT(difference + delay,
208 MilliSeconds(1900) + delay,
209 "Ack arrived too late. First window should be closed.");
228 virtual void DoRun(
void);
229 void MacTraceCb(std::string context, Ptr<const Packet> packet,
const Address& address);
239 : TestCase(
"Test satellite lorawan with acks sent in second window."),
240 m_gwReceiveDate(Seconds(0)),
241 m_edReceiveDate(Seconds(0))
251 Ptr<const Packet> packet,
252 const Address& address)
269 Singleton<SatEnvVariables>::Get()->DoInitialize();
270 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-lora",
"second-window",
true);
273 Config::SetDefault(
"ns3::SatHelper::Standard", EnumValue(SatEnums::LORA));
274 Config::SetDefault(
"ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
275 Config::SetDefault(
"ns3::LorawanMacEndDevice::MType",
276 EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
277 Config::SetDefault(
"ns3::SatLorawanNetDevice::ForwardToUtUsers", BooleanValue(
false));
278 Config::SetDefault(
"ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
280 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
281 TimeValue(MilliSeconds(1500)));
282 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
283 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
284 TimeValue(MilliSeconds(400)));
285 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
286 TimeValue(MilliSeconds(400)));
289 Config::SetDefault(
"ns3::LoraNetworkScheduler::FirstWindowAnswerDelay",
290 TimeValue(Seconds(1) + MilliSeconds(500)));
291 Config::SetDefault(
"ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
294 Config::SetDefault(
"ns3::SatConf::SuperFrameConfForSeq0",
295 EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
296 Config::SetDefault(
"ns3::SatSuperframeConf4::FrameConfigType",
297 EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
298 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
299 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
303 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
304 BooleanValue(
false));
305 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
306 BooleanValue(
false));
309 Config::SetDefault(
"ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
310 Config::SetDefault(
"ns3::SatBeamHelper::RaInterferenceEliminationModel",
311 EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
312 Config::SetDefault(
"ns3::SatBeamHelper::RaCollisionModel",
313 EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
314 Config::SetDefault(
"ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
315 Config::SetDefault(
"ns3::SatWaveformConf::DefaultWfId", UintegerValue(2));
316 Config::SetDefault(
"ns3::SatHelper::RtnLinkWaveformConfFileName",
317 StringValue(
"loraWaveforms.txt"));
320 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue(
"600ms"));
321 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue(
"200ms"));
322 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
323 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(
false));
325 Config::SetDefault(
"ns3::SatMac::EnableStatisticsTags", BooleanValue(
true));
328 Ptr<SatHelper> helper = CreateObject<SatHelper>();
329 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
332 Ptr<Node> utNode = helper->UtNodes().Get(0);
333 Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
335 app->SetInterval(Seconds(10));
337 app->SetStartTime(Seconds(1.0));
338 app->SetStopTime(Seconds(10.0));
339 app->SetPacketSize(24);
341 app->SetNode(utNode);
342 utNode->AddApplication(app);
344 m_gwAddress = helper->GwNodes().Get(0)->GetDevice(1)->GetAddress();
345 m_edAddress = helper->UtNodes().Get(0)->GetDevice(2)->GetAddress();
347 Config::Connect(
"/NodeList/*/DeviceList/*/SatMac/Rx",
350 Simulator::Stop(Seconds(10));
353 Simulator::Destroy();
355 Singleton<SatEnvVariables>::Get()->DoDispose();
356 NS_TEST_ASSERT_MSG_NE(
m_gwReceiveDate, Seconds(0),
"Packet should be received by Gateway.");
357 NS_TEST_ASSERT_MSG_NE(
m_edReceiveDate, Seconds(0),
"Ack should be received by End Device.");
361 Time delay = MilliSeconds(130);
363 NS_TEST_ASSERT_MSG_GT(difference, Seconds(1.5) + delay,
"Ack arrived too early.");
364 NS_TEST_ASSERT_MSG_LT(difference + delay,
365 MilliSeconds(2400) + delay,
366 "Ack arrived too late. Second window should be closed.");
384 virtual void DoRun(
void);
385 void MacTraceCb(std::string context, Ptr<const Packet> packet,
const Address& address);
386 void PhyTraceCb(std::string context, Ptr<const Packet> packet,
const Address& address);
399 : TestCase(
"Test satellite lorawan with acks sent in second window."),
400 m_edReceiveDate(Seconds(0)),
401 m_phyGwReceive(false),
402 m_phyEdReceive(false)
412 Ptr<const Packet> packet,
413 const Address& address)
428 Ptr<const Packet> packet,
429 const Address& address)
446 Singleton<SatEnvVariables>::Get()->DoInitialize();
447 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-lora",
"out-of-window",
true);
450 Config::SetDefault(
"ns3::SatHelper::Standard", EnumValue(SatEnums::LORA));
451 Config::SetDefault(
"ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
452 Config::SetDefault(
"ns3::LorawanMacEndDevice::MType",
453 EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
454 Config::SetDefault(
"ns3::SatLorawanNetDevice::ForwardToUtUsers", BooleanValue(
false));
455 Config::SetDefault(
"ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
457 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
458 TimeValue(MilliSeconds(1500)));
459 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
460 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
461 TimeValue(MilliSeconds(400)));
462 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
463 TimeValue(MilliSeconds(400)));
465 Config::SetDefault(
"ns3::LoraNetworkScheduler::FirstWindowAnswerDelay",
466 TimeValue(Seconds(0.1)));
467 Config::SetDefault(
"ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
470 Config::SetDefault(
"ns3::SatConf::SuperFrameConfForSeq0",
471 EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
472 Config::SetDefault(
"ns3::SatSuperframeConf4::FrameConfigType",
473 EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
474 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
475 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
479 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
480 BooleanValue(
false));
481 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
482 BooleanValue(
false));
485 Config::SetDefault(
"ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
486 Config::SetDefault(
"ns3::SatBeamHelper::RaInterferenceEliminationModel",
487 EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
488 Config::SetDefault(
"ns3::SatBeamHelper::RaCollisionModel",
489 EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
490 Config::SetDefault(
"ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
491 Config::SetDefault(
"ns3::SatWaveformConf::DefaultWfId", UintegerValue(2));
492 Config::SetDefault(
"ns3::SatHelper::RtnLinkWaveformConfFileName",
493 StringValue(
"loraWaveforms.txt"));
496 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue(
"600ms"));
497 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue(
"200ms"));
498 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
499 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(
false));
501 Config::SetDefault(
"ns3::SatMac::EnableStatisticsTags", BooleanValue(
true));
502 Config::SetDefault(
"ns3::SatPhy::EnableStatisticsTags", BooleanValue(
true));
505 Ptr<SatHelper> helper = CreateObject<SatHelper>();
506 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
509 Ptr<Node> utNode = helper->UtNodes().Get(0);
510 Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
512 app->SetInterval(Seconds(10));
514 app->SetStartTime(Seconds(1.0));
515 app->SetStopTime(Seconds(10.0));
516 app->SetPacketSize(24);
518 app->SetNode(utNode);
519 utNode->AddApplication(app);
521 m_gwAddress = helper->GwNodes().Get(0)->GetDevice(1)->GetAddress();
522 m_edAddress = helper->UtNodes().Get(0)->GetDevice(2)->GetAddress();
524 Config::Connect(
"/NodeList/*/DeviceList/*/SatMac/Rx",
526 Config::Connect(
"/NodeList/*/DeviceList/*/SatPhy/Rx",
529 Simulator::Stop(Seconds(10));
532 Simulator::Destroy();
534 Singleton<SatEnvVariables>::Get()->DoDispose();
538 "GW should receive a packet and the first retransmission.");
539 NS_TEST_ASSERT_MSG_EQ(
m_edReceiveDate, Seconds(0),
"No ack should be received by End Device.");
543 "Phy layer should trace traffic from End Device to Gateway.");
546 "Phy layer should not trace traffic from Gateway to End Device, as phy "
547 "layer is in SLEEP state.");
566 virtual void DoRun(
void);
567 void MacTraceCb(std::string context, Ptr<const Packet> packet,
const Address& address);
568 void PhyTraceCb(std::string context, Ptr<const Packet> packet,
const Address& address);
578 : TestCase(
"Test satellite lorawan with acks sent in second window."),
579 m_edReceiveDate(Seconds(0))
590 Ptr<const Packet> packet,
591 const Address& address)
608 Singleton<SatEnvVariables>::Get()->DoInitialize();
609 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-lora",
"out-of-window",
true);
612 Config::SetDefault(
"ns3::SatHelper::Standard", EnumValue(SatEnums::LORA));
613 Config::SetDefault(
"ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
614 Config::SetDefault(
"ns3::LorawanMacEndDevice::MType",
615 EnumValue(LorawanMacHeader::UNCONFIRMED_DATA_UP));
616 Config::SetDefault(
"ns3::SatLorawanNetDevice::ForwardToUtUsers", BooleanValue(
false));
617 Config::SetDefault(
"ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
619 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
620 TimeValue(MilliSeconds(1500)));
621 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
622 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
623 TimeValue(MilliSeconds(400)));
624 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
625 TimeValue(MilliSeconds(400)));
627 Config::SetDefault(
"ns3::LoraNetworkScheduler::FirstWindowAnswerDelay",
628 TimeValue(Seconds(0.1)));
629 Config::SetDefault(
"ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
632 Config::SetDefault(
"ns3::SatConf::SuperFrameConfForSeq0",
633 EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
634 Config::SetDefault(
"ns3::SatSuperframeConf4::FrameConfigType",
635 EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
636 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
637 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
641 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
642 BooleanValue(
false));
643 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
644 BooleanValue(
false));
647 Config::SetDefault(
"ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
648 Config::SetDefault(
"ns3::SatBeamHelper::RaInterferenceEliminationModel",
649 EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
650 Config::SetDefault(
"ns3::SatBeamHelper::RaCollisionModel",
651 EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
652 Config::SetDefault(
"ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
653 Config::SetDefault(
"ns3::SatWaveformConf::DefaultWfId", UintegerValue(2));
654 Config::SetDefault(
"ns3::SatHelper::RtnLinkWaveformConfFileName",
655 StringValue(
"loraWaveforms.txt"));
658 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue(
"600ms"));
659 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue(
"200ms"));
660 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
661 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(
false));
663 Config::SetDefault(
"ns3::SatMac::EnableStatisticsTags", BooleanValue(
true));
664 Config::SetDefault(
"ns3::SatPhy::EnableStatisticsTags", BooleanValue(
true));
667 Ptr<SatHelper> helper = CreateObject<SatHelper>();
668 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
671 Ptr<Node> utNode = helper->UtNodes().Get(0);
672 Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
674 app->SetInterval(Seconds(10));
676 app->SetStartTime(Seconds(1.0));
677 app->SetStopTime(Seconds(10.0));
678 app->SetPacketSize(24);
680 app->SetNode(utNode);
681 utNode->AddApplication(app);
683 m_gwAddress = helper->GwNodes().Get(0)->GetDevice(1)->GetAddress();
684 m_edAddress = helper->UtNodes().Get(0)->GetDevice(2)->GetAddress();
687 "/NodeList/*/DeviceList/*/SatMac/Rx",
690 Simulator::Stop(Seconds(10));
693 Simulator::Destroy();
695 Singleton<SatEnvVariables>::Get()->DoDispose();
699 "GW should receive a packet but no retransmission.");
700 NS_TEST_ASSERT_MSG_EQ(
m_edReceiveDate, Seconds(0),
"No ack should be received by End Device.");
718 virtual void DoRun(
void);
719 void MacTraceCb(std::string context, Ptr<const Packet> packet,
const Address& address);
729 : TestCase(
"Test satellite lorawan with acks sent in second window."),
730 m_edReceiveDate(Seconds(0))
740 Ptr<const Packet> packet,
741 const Address& address)
758 Singleton<SatEnvVariables>::Get()->DoInitialize();
759 Singleton<SatEnvVariables>::Get()->SetOutputVariables(
"test-sat-lora",
"cbr",
true);
762 Config::SetDefault(
"ns3::SatHelper::Standard", EnumValue(SatEnums::LORA));
763 Config::SetDefault(
"ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
764 Config::SetDefault(
"ns3::LorawanMacEndDevice::MType",
765 EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
766 Config::SetDefault(
"ns3::SatLorawanNetDevice::ForwardToUtUsers", BooleanValue(
true));
767 Config::SetDefault(
"ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
769 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
770 TimeValue(MilliSeconds(1500)));
771 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
772 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
773 TimeValue(MilliSeconds(400)));
774 Config::SetDefault(
"ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
775 TimeValue(MilliSeconds(400)));
776 Config::SetDefault(
"ns3::LoraNetworkScheduler::FirstWindowAnswerDelay", TimeValue(Seconds(1)));
777 Config::SetDefault(
"ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
780 Config::SetDefault(
"ns3::SatConf::SuperFrameConfForSeq0",
781 EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
782 Config::SetDefault(
"ns3::SatSuperframeConf4::FrameConfigType",
783 EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
784 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
785 Config::SetDefault(
"ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
789 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
790 BooleanValue(
false));
791 Config::SetDefault(
"ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
792 BooleanValue(
false));
795 Config::SetDefault(
"ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
796 Config::SetDefault(
"ns3::SatBeamHelper::RaInterferenceEliminationModel",
797 EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
798 Config::SetDefault(
"ns3::SatBeamHelper::RaCollisionModel",
799 EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
800 Config::SetDefault(
"ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
801 Config::SetDefault(
"ns3::SatWaveformConf::DefaultWfId", UintegerValue(2));
802 Config::SetDefault(
"ns3::SatHelper::RtnLinkWaveformConfFileName",
803 StringValue(
"loraWaveforms.txt"));
806 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue(
"600ms"));
807 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue(
"200ms"));
808 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
809 Config::SetDefault(
"ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(
false));
811 Config::SetDefault(
"ns3::CbrApplication::Interval", StringValue(
"10s"));
812 Config::SetDefault(
"ns3::CbrApplication::PacketSize", UintegerValue(24));
814 Config::SetDefault(
"ns3::SatMac::EnableStatisticsTags", BooleanValue(
true));
816 Ptr<SatHelper> helper = CreateObject<SatHelper>();
817 helper->CreatePredefinedScenario(SatHelper::SIMPLE);
819 NodeContainer utUsers = helper->GetUtUsers();
820 NodeContainer gwUsers = helper->GetGwUsers();
821 InetSocketAddress gwUserAddr = InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), 9);
823 PacketSinkHelper sinkHelper(
"ns3::UdpSocketFactory", Address());
824 CbrHelper cbrHelper(
"ns3::UdpSocketFactory", Address());
825 ApplicationContainer sinkContainer;
826 ApplicationContainer cbrContainer;
828 sinkHelper.SetAttribute(
"Local", AddressValue(Address(gwUserAddr)));
829 sinkContainer.Add(sinkHelper.Install(gwUsers.Get(0)));
831 cbrHelper.SetAttribute(
"Remote", AddressValue(Address(gwUserAddr)));
833 auto app = cbrHelper.Install(utUsers.Get(0)).Get(0);
834 app->SetStartTime(Seconds(1));
835 cbrContainer.Add(app);
837 sinkContainer.Start(Seconds(1));
838 sinkContainer.Stop(Seconds(20));
840 m_gwAddress = helper->GwNodes().Get(0)->GetDevice(1)->GetAddress();
841 m_edAddress = helper->UtNodes().Get(0)->GetDevice(2)->GetAddress();
843 Ptr<PacketSink> receiver = DynamicCast<PacketSink>(sinkContainer.Get(0));
845 Config::Connect(
"/NodeList/*/DeviceList/*/SatMac/Rx",
848 Simulator::Stop(Seconds(20));
851 Simulator::Destroy();
853 Singleton<SatEnvVariables>::Get()->DoDispose();
855 NS_TEST_ASSERT_MSG_NE(
m_gwReceiveDate, Seconds(0),
"Packet should be received by Gateway.");
856 NS_TEST_ASSERT_MSG_NE(
m_edReceiveDate, Seconds(0),
"Ack should be received by End Device.");
860 Time delay = MilliSeconds(130);
862 NS_TEST_ASSERT_MSG_GT(difference, Seconds(1) + delay,
"Ack arrived too early.");
863 NS_TEST_ASSERT_MSG_LT(difference + delay,
864 MilliSeconds(1900) + delay,
865 "Ack arrived too late. First window should be closed.");
867 NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(), 24,
"Sink should receive one packet of 24 bytes");
881 : TestSuite(
"sat-lora-test", UNIT)
Test case to check if packet is received on App layer.
virtual ~SatLoraCbrTestCase()
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test case to check if Lora ack arrives in first reception window.
virtual ~SatLoraFirstWindowTestCase()
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
SatLoraFirstWindowTestCase()
Test case to check that packet is not retransmitted if ack outside of both windows but no retransmiss...
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
void PhyTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
std::vector< Time > m_gwReceiveDates
SatLoraOutOfWindowWindowNoRetransmissionTestCase()
virtual ~SatLoraOutOfWindowWindowNoRetransmissionTestCase()
Test case to check if packet retransmitted if ack outside of both windows.
std::vector< Time > m_gwReceiveDates
SatLoraOutOfWindowWindowTestCase()
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
virtual ~SatLoraOutOfWindowWindowTestCase()
void PhyTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test case to check if Lora ack arrives in second reception window.
virtual ~SatLoraSecondWindowTestCase()
SatLoraSecondWindowTestCase()
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test suite for Satellite mobility unit test cases.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatLoraTestSuite satLoraTestSuite