satellite-lora-regenerative-test.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013 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 
27 // Include a header file from your module to test.
28 #include "ns3/boolean.h"
29 #include "ns3/config.h"
30 #include "ns3/log.h"
31 #include "ns3/mobility-helper.h"
32 #include "ns3/satellite-env-variables.h"
33 #include "ns3/satellite-mobility-model.h"
34 #include "ns3/satellite-position-allocator.h"
35 #include "ns3/simulator.h"
36 #include "ns3/singleton.h"
37 #include "ns3/string.h"
38 #include "ns3/test.h"
39 #include <ns3/cbr-application.h>
40 #include <ns3/cbr-helper.h>
41 #include <ns3/enum.h>
42 #include <ns3/lora-periodic-sender.h>
43 #include <ns3/lorawan-mac-header.h>
44 #include <ns3/packet-sink-helper.h>
45 #include <ns3/packet-sink.h>
46 #include <ns3/satellite-enums.h>
47 #include <ns3/satellite-helper.h>
48 #include <ns3/satellite-lora-conf.h>
49 #include <ns3/satellite-lorawan-net-device.h>
50 #include <ns3/satellite-topology.h>
51 #include <ns3/simulation-helper.h>
52 #include <ns3/uinteger.h>
53 
54 #include <iostream>
55 #include <stdint.h>
56 
57 using namespace ns3;
58 
69 {
70  public:
73 
74  private:
75  virtual void DoRun(void);
76  void MacTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
77 
80 
81  Address m_edAddress;
83 };
84 
86  : TestCase("Test regenerative satellite lorawan with acks sent in first window."),
87  m_gwReceiveDate(Seconds(0)),
88  m_edReceiveDate(Seconds(0))
89 {
90 }
91 
93 {
94 }
95 
96 void
98  Ptr<const Packet> packet,
99  const Address& address)
100 {
101  if (address == m_edAddress)
102  {
103  m_gwReceiveDate = Simulator::Now();
104  }
105 
106  if (address == m_orbiterUserAddress)
107  {
108  m_edReceiveDate = Simulator::Now();
109  }
110 }
111 
112 void
114 {
115  // Set simulation output details
116  Singleton<SatEnvVariables>::Get()->DoInitialize();
117  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-lora-regenerative",
118  "first-window",
119  true);
120 
121  // Enable Lora
122  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
123  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
124  EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
125  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
126 
128  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
129  EnumValue(SatEnums::REGENERATION_NETWORK));
130  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
131  EnumValue(SatEnums::REGENERATION_NETWORK));
132 
133  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
134  TimeValue(MilliSeconds(1500)));
135  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
136  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
137  TimeValue(MilliSeconds(400)));
138  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
139  TimeValue(MilliSeconds(500)));
140  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay", TimeValue(Seconds(1)));
141  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
142 
143  // Superframe configuration
144  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
145  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
146  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
147  EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
148  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
149  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
150  DoubleValue(15000));
151 
152  // CRDSA only
153  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
154  BooleanValue(false));
155  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
156  BooleanValue(false));
157 
158  // Configure RA
159  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
160  EnumValue(SatPhyRxCarrierConf::EM_AVI));
161  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
162  EnumValue(SatPhyRxCarrierConf::EM_AVI));
163  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
164  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
165  EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
166  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
167  EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
168  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
169 
170  // Configure E-SSA
171  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
172  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
173  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
174  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
175 
176  Config::SetDefault("ns3::SatMac::EnableStatisticsTags", BooleanValue(true));
177 
178  // Creating the reference system.
179  Ptr<SatHelper> helper = CreateObject<SatHelper>(
180  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E-lora");
181  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
182 
183  // >>> Start of actual test using Simple scenario >>>
184  Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(0);
185  Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
186 
187  app->SetInterval(Seconds(10));
188 
189  app->SetStartTime(Seconds(1.0));
190  app->SetStopTime(Seconds(10.0));
191  app->SetPacketSize(24);
192 
193  app->SetNode(utNode);
194  utNode->AddApplication(app);
195 
196  Ptr<SatOrbiterNetDevice> orbiterNetDevice = DynamicCast<SatOrbiterNetDevice>(
197  Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0));
198  m_edAddress = Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2)->GetAddress();
199  m_orbiterUserAddress = orbiterNetDevice->GetSatelliteUserAddress(8);
200 
201  Config::Connect("/NodeList/*/DeviceList/*/SatMac/Rx",
203  Config::Connect("/NodeList/*/DeviceList/*/FeederMac/*/Rx",
205 
206  Simulator::Stop(Seconds(10));
207  Simulator::Run();
208 
209  Simulator::Destroy();
210 
211  Singleton<SatEnvVariables>::Get()->DoDispose();
212 
213  NS_TEST_ASSERT_MSG_NE(m_gwReceiveDate, Seconds(0), "Packet should be received by Gateway.");
214  NS_TEST_ASSERT_MSG_NE(m_edReceiveDate, Seconds(0), "Ack should be received by End Device.");
215  NS_TEST_ASSERT_MSG_GT(m_edReceiveDate, m_gwReceiveDate, "Ack should be received after packet.");
216 
217  Time difference = m_edReceiveDate - m_gwReceiveDate;
218  Time delay = MilliSeconds(130);
219 
220  NS_TEST_ASSERT_MSG_GT(difference, Seconds(1) + delay, "Ack arrived too early.");
221  NS_TEST_ASSERT_MSG_LT(difference + delay,
222  MilliSeconds(1900) + delay,
223  "Ack arrived too late. First window should be closed.");
224 }
225 
236 {
237  public:
240 
241  private:
242  virtual void DoRun(void);
243  void MacTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
244 
247 
248  Address m_edAddress;
250 };
251 
253  : TestCase("Test regenerative satellite lorawan with acks sent in second window."),
254  m_gwReceiveDate(Seconds(0)),
255  m_edReceiveDate(Seconds(0))
256 {
257 }
258 
260 {
261 }
262 
263 void
265  Ptr<const Packet> packet,
266  const Address& address)
267 {
268  if (address == m_edAddress)
269  {
270  m_gwReceiveDate = Simulator::Now();
271  }
272 
273  if (address == m_orbiterUserAddress)
274  {
275  m_edReceiveDate = Simulator::Now();
276  }
277 }
278 
279 void
281 {
282  // Set simulation output details
283  Singleton<SatEnvVariables>::Get()->DoInitialize();
284  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-lora-regenerative",
285  "second-window",
286  true);
287 
288  // Enable Lora
289  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
290  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
291  EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
292  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
293 
295  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
296  EnumValue(SatEnums::REGENERATION_NETWORK));
297  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
298  EnumValue(SatEnums::REGENERATION_NETWORK));
299 
300  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
301  TimeValue(MilliSeconds(1500)));
302  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
303  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
304  TimeValue(MilliSeconds(400)));
305  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
306  TimeValue(MilliSeconds(500)));
307  // Increase answer delay by 500ms compared to SatLoraRegenerativeSecondWindowTestCase to be in
308  // second window on End Device
309  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay",
310  TimeValue(Seconds(1) + MilliSeconds(500)));
311  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
312 
313  // Superframe configuration
314  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
315  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
316  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
317  EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
318  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
319  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
320  DoubleValue(15000));
321 
322  // CRDSA only
323  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
324  BooleanValue(false));
325  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
326  BooleanValue(false));
327 
328  // Configure RA
329  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
330  EnumValue(SatPhyRxCarrierConf::EM_AVI));
331  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
332  EnumValue(SatPhyRxCarrierConf::EM_AVI));
333  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
334  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
335  EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
336  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
337  EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
338  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
339 
340  // Configure E-SSA
341  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
342  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
343  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
344  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
345 
346  Config::SetDefault("ns3::SatMac::EnableStatisticsTags", BooleanValue(true));
347 
348  // Creating the reference system.
349  Ptr<SatHelper> helper = CreateObject<SatHelper>(
350  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E-lora");
351  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
352 
353  // >>> Start of actual test using Simple scenario >>>
354  Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(0);
355  Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
356 
357  app->SetInterval(Seconds(10));
358 
359  app->SetStartTime(Seconds(1.0));
360  app->SetStopTime(Seconds(10.0));
361  app->SetPacketSize(24);
362 
363  app->SetNode(utNode);
364  utNode->AddApplication(app);
365 
366  Ptr<SatOrbiterNetDevice> orbiterNetDevice = DynamicCast<SatOrbiterNetDevice>(
367  Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0));
368  m_edAddress = Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2)->GetAddress();
369  m_orbiterUserAddress = orbiterNetDevice->GetSatelliteUserAddress(8);
370 
371  Config::Connect("/NodeList/*/DeviceList/*/SatMac/Rx",
373  Config::Connect("/NodeList/*/DeviceList/*/FeederMac/*/Rx",
375 
376  Simulator::Stop(Seconds(10));
377  Simulator::Run();
378 
379  Simulator::Destroy();
380 
381  Singleton<SatEnvVariables>::Get()->DoDispose();
382  NS_TEST_ASSERT_MSG_NE(m_gwReceiveDate, Seconds(0), "Packet should be received by Gateway.");
383  NS_TEST_ASSERT_MSG_NE(m_edReceiveDate, Seconds(0), "Ack should be received by End Device.");
384  NS_TEST_ASSERT_MSG_GT(m_edReceiveDate, m_gwReceiveDate, "Ack should be received after packet.");
385 
386  Time difference = m_edReceiveDate - m_gwReceiveDate;
387  Time delay = MilliSeconds(130);
388 
389  NS_TEST_ASSERT_MSG_GT(difference, Seconds(1.5) + delay, "Ack arrived too early.");
390  NS_TEST_ASSERT_MSG_LT(difference + delay,
391  MilliSeconds(2400) + delay,
392  "Ack arrived too late. Second window should be closed.");
393 }
394 
404 {
405  public:
408 
409  private:
410  virtual void DoRun(void);
411  void MacTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
412  void PhyTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
413 
414  std::vector<Time> m_gwReceiveDates;
416 
417  Address m_edAddress;
419 
422 };
423 
425  : TestCase("Test regenerative satellite lorawan with acks sent out of reception windows."),
426  m_edReceiveDate(Seconds(0)),
427  m_phyGwReceive(false),
428  m_phyEdReceive(false)
429 {
430 }
431 
433 {
434 }
435 
436 void
438  Ptr<const Packet> packet,
439  const Address& address)
440 {
441  if (address == m_edAddress)
442  {
443  m_gwReceiveDates.push_back(Simulator::Now());
444  }
445 
446  if (address == m_orbiterUserAddress)
447  {
448  m_edReceiveDate = Simulator::Now();
449  }
450 }
451 
452 void
454  Ptr<const Packet> packet,
455  const Address& address)
456 {
457  if (address == m_edAddress)
458  {
459  m_phyGwReceive = true;
460  }
461 
462  if (address == m_orbiterUserAddress)
463  {
464  m_phyEdReceive = true;
465  }
466 }
467 
468 void
470 {
471  // Set simulation output details
472  Singleton<SatEnvVariables>::Get()->DoInitialize();
473  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-lora-regenerative",
474  "out-of-window",
475  true);
476 
477  // Enable Lora
478  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
479  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
480  EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
481  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
482 
484  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
485  EnumValue(SatEnums::REGENERATION_NETWORK));
486  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
487  EnumValue(SatEnums::REGENERATION_NETWORK));
488 
489  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
490  TimeValue(MilliSeconds(1500)));
491  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
492  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
493  TimeValue(MilliSeconds(400)));
494  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
495  TimeValue(MilliSeconds(500)));
496  // Send answer too early
497  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay",
498  TimeValue(Seconds(0.1)));
499  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
500 
501  // Superframe configuration
502  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
503  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
504  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
505  EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
506  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
507  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
508  DoubleValue(15000));
509 
510  // CRDSA only
511  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
512  BooleanValue(false));
513  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
514  BooleanValue(false));
515 
516  // Configure RA
517  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
518  EnumValue(SatPhyRxCarrierConf::EM_AVI));
519  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
520  EnumValue(SatPhyRxCarrierConf::EM_AVI));
521  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
522  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
523  EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
524  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
525  EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
526  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
527 
528  // Configure E-SSA
529  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
530  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
531  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
532  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
533 
534  Config::SetDefault("ns3::SatMac::EnableStatisticsTags", BooleanValue(true));
535  Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
536 
537  // Creating the reference system.
538  Ptr<SatHelper> helper = CreateObject<SatHelper>(
539  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E-lora");
540  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
541 
542  // >>> Start of actual test using Simple scenario >>>
543  Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(0);
544  Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
545 
546  app->SetInterval(Seconds(10));
547 
548  app->SetStartTime(Seconds(1.0));
549  app->SetStopTime(Seconds(10.0));
550  app->SetPacketSize(24);
551 
552  app->SetNode(utNode);
553  utNode->AddApplication(app);
554 
555  Ptr<SatOrbiterNetDevice> orbiterNetDevice = DynamicCast<SatOrbiterNetDevice>(
556  Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0));
557  m_edAddress = Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2)->GetAddress();
558  m_orbiterUserAddress = orbiterNetDevice->GetSatelliteUserAddress(8);
559 
560  Config::Connect("/NodeList/*/DeviceList/*/SatMac/Rx",
562  Config::Connect("/NodeList/*/DeviceList/*/FeederMac/*/Rx",
564  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/Rx",
566  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/Rx",
568  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/Rx",
570 
571  Simulator::Stop(Seconds(10));
572  Simulator::Run();
573 
574  Simulator::Destroy();
575 
576  Singleton<SatEnvVariables>::Get()->DoDispose();
577 
578  NS_TEST_ASSERT_MSG_EQ(m_gwReceiveDates.size(),
579  2,
580  "GW should receive a packet and the first retransmission.");
581  NS_TEST_ASSERT_MSG_EQ(m_edReceiveDate, Seconds(0), "No ack should be received by End Device.");
582 
583  NS_TEST_ASSERT_MSG_EQ(m_phyGwReceive,
584  true,
585  "Phy layer should trace traffic from End Device to Gateway.");
586  NS_TEST_ASSERT_MSG_EQ(m_phyEdReceive,
587  false,
588  "Phy layer should not trace traffic from Gateway to End Device, as phy "
589  "layer is in SLEEP state.");
590 }
591 
602 {
603  public:
606 
607  private:
608  virtual void DoRun(void);
609  void MacTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
610  void PhyTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
611 
612  std::vector<Time> m_gwReceiveDates;
614 
615  Address m_edAddress;
617 };
618 
621  : TestCase("Test regenerative satellite lorawan with acks sent out of reception windows and no "
622  "retransmission needed."),
623  m_edReceiveDate(Seconds(0))
624 {
625 }
626 
629 {
630 }
631 
632 void
634  Ptr<const Packet> packet,
635  const Address& address)
636 {
637  if (address == m_edAddress)
638  {
639  m_gwReceiveDates.push_back(Simulator::Now());
640  }
641 
642  if (address == m_orbiterUserAddress)
643  {
644  m_edReceiveDate = Simulator::Now();
645  }
646 }
647 
648 void
650 {
651  // Set simulation output details
652  Singleton<SatEnvVariables>::Get()->DoInitialize();
653  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-lora-regenerative",
654  "out-of-window",
655  true);
656 
657  // Enable Lora
658  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
659  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
660  EnumValue(LorawanMacHeader::UNCONFIRMED_DATA_UP));
661  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
662 
664  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
665  EnumValue(SatEnums::REGENERATION_NETWORK));
666  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
667  EnumValue(SatEnums::REGENERATION_NETWORK));
668 
669  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
670  TimeValue(MilliSeconds(1500)));
671  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
672  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
673  TimeValue(MilliSeconds(400)));
674  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
675  TimeValue(MilliSeconds(500)));
676  // Send answer too early
677  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay",
678  TimeValue(Seconds(0.1)));
679  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
680 
681  // Superframe configuration
682  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
683  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
684  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
685  EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
686  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
687  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
688  DoubleValue(15000));
689 
690  // CRDSA only
691  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
692  BooleanValue(false));
693  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
694  BooleanValue(false));
695 
696  // Configure RA
697  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
698  EnumValue(SatPhyRxCarrierConf::EM_AVI));
699  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
700  EnumValue(SatPhyRxCarrierConf::EM_AVI));
701  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
702  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
703  EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
704  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
705  EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
706  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
707 
708  // Configure E-SSA
709  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
710  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
711  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
712  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
713 
714  Config::SetDefault("ns3::SatMac::EnableStatisticsTags", BooleanValue(true));
715  Config::SetDefault("ns3::SatPhy::EnableStatisticsTags", BooleanValue(true));
716 
717  // Creating the reference system.
718  Ptr<SatHelper> helper = CreateObject<SatHelper>(
719  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E-lora");
720  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
721 
722  // >>> Start of actual test using Simple scenario >>>
723  Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(0);
724  Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
725 
726  app->SetInterval(Seconds(10));
727 
728  app->SetStartTime(Seconds(1.0));
729  app->SetStopTime(Seconds(10.0));
730  app->SetPacketSize(24);
731 
732  app->SetNode(utNode);
733  utNode->AddApplication(app);
734 
735  Ptr<SatOrbiterNetDevice> orbiterNetDevice = DynamicCast<SatOrbiterNetDevice>(
736  Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0));
737  m_edAddress = Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2)->GetAddress();
738  m_orbiterUserAddress = orbiterNetDevice->GetSatelliteUserAddress(8);
739 
740  Config::Connect(
741  "/NodeList/*/DeviceList/*/SatMac/Rx",
743  this));
744  Config::Connect(
745  "/NodeList/*/DeviceList/*/FeederMac/*/Rx",
747  this));
748 
749  Simulator::Stop(Seconds(10));
750  Simulator::Run();
751 
752  Simulator::Destroy();
753 
754  Singleton<SatEnvVariables>::Get()->DoDispose();
755 
756  NS_TEST_ASSERT_MSG_EQ(m_gwReceiveDates.size(),
757  1,
758  "GW should receive a packet but no retransmission.");
759  NS_TEST_ASSERT_MSG_EQ(m_edReceiveDate, Seconds(0), "No ack should be received by End Device.");
760 }
761 
770 class SatLoraRegenerativeCbrTestCase : public TestCase
771 {
772  public:
775 
776  private:
777  virtual void DoRun(void);
778  void MacTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
779 
782 
783  Address m_edAddress;
785 };
786 
788  : TestCase("Test regenerativesatellite lorawan with CBR traffic."),
789  m_edReceiveDate(Seconds(0))
790 {
791 }
792 
794 {
795 }
796 
797 void
799  Ptr<const Packet> packet,
800  const Address& address)
801 {
802  if (address == m_edAddress)
803  {
804  m_gwReceiveDate = Simulator::Now();
805  }
806 
807  if (address == m_orbiterUserAddress)
808  {
809  m_edReceiveDate = Simulator::Now();
810  }
811 }
812 
813 void
815 {
816  // Set simulation output details
817  Singleton<SatEnvVariables>::Get()->DoInitialize();
818  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-lora-regenerative",
819  "cbr",
820  true);
821 
822  // Enable Lora
823  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
824  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
825  EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
826  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
827 
829  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
830  EnumValue(SatEnums::REGENERATION_NETWORK));
831  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
832  EnumValue(SatEnums::REGENERATION_NETWORK));
833 
834  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
835  TimeValue(MilliSeconds(1500)));
836  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
837  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
838  TimeValue(MilliSeconds(450)));
839  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
840  TimeValue(MilliSeconds(500)));
841  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay", TimeValue(Seconds(1)));
842  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
843 
844  // Superframe configuration
845  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
846  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
847  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
848  EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
849  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
850  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
851  DoubleValue(15000));
852 
853  // CRDSA only
854  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
855  BooleanValue(false));
856  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
857  BooleanValue(false));
858 
859  // Configure RA
860  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
861  EnumValue(SatPhyRxCarrierConf::EM_AVI));
862  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
863  EnumValue(SatPhyRxCarrierConf::EM_AVI));
864  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
865  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
866  EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
867  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
868  EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
869  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
870 
871  // Configure E-SSA
872  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
873  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
874  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
875  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
876 
877  Config::SetDefault("ns3::CbrApplication::Interval", StringValue("10s"));
878  Config::SetDefault("ns3::CbrApplication::PacketSize", UintegerValue(24));
879 
880  Config::SetDefault("ns3::SatMac::EnableStatisticsTags", BooleanValue(true));
881 
882  // Creating the reference system.
883  Ptr<SatHelper> helper = CreateObject<SatHelper>(
884  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E-lora");
885  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
886 
887  NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
888  NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
889  InetSocketAddress gwUserAddr = InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), 9);
890 
891  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory", Address());
892  CbrHelper cbrHelper("ns3::UdpSocketFactory", Address());
893  ApplicationContainer sinkContainer;
894  ApplicationContainer cbrContainer;
895 
896  sinkHelper.SetAttribute("Local", AddressValue(Address(gwUserAddr)));
897  sinkContainer.Add(sinkHelper.Install(gwUsers.Get(0)));
898 
899  cbrHelper.SetAttribute("Remote", AddressValue(Address(gwUserAddr)));
900 
901  auto app = cbrHelper.Install(utUsers.Get(0)).Get(0);
902  app->SetStartTime(Seconds(1));
903  cbrContainer.Add(app);
904 
905  sinkContainer.Start(Seconds(1));
906  sinkContainer.Stop(Seconds(20));
907 
908  Ptr<SatOrbiterNetDevice> orbiterNetDevice = DynamicCast<SatOrbiterNetDevice>(
909  Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0));
910  m_edAddress = Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2)->GetAddress();
911  m_orbiterUserAddress = orbiterNetDevice->GetSatelliteUserAddress(8);
912 
913  Ptr<PacketSink> receiver = DynamicCast<PacketSink>(sinkContainer.Get(0));
914 
915  Config::Connect("/NodeList/*/DeviceList/*/SatMac/Rx",
916  MakeCallback(&SatLoraRegenerativeCbrTestCase::MacTraceCb, this));
917  Config::Connect("/NodeList/*/DeviceList/*/FeederMac/*/Rx",
918  MakeCallback(&SatLoraRegenerativeCbrTestCase::MacTraceCb, this));
919 
920  Simulator::Stop(Seconds(20));
921  Simulator::Run();
922 
923  Simulator::Destroy();
924 
925  Singleton<SatEnvVariables>::Get()->DoDispose();
926 
927  NS_TEST_ASSERT_MSG_NE(m_gwReceiveDate, Seconds(0), "Packet should be received by Gateway.");
928  NS_TEST_ASSERT_MSG_NE(m_edReceiveDate, Seconds(0), "Ack should be received by End Device.");
929  NS_TEST_ASSERT_MSG_GT(m_edReceiveDate, m_gwReceiveDate, "Ack should be received after packet.");
930 
931  Time difference = m_edReceiveDate - m_gwReceiveDate;
932  Time delay = MilliSeconds(130);
933 
934  NS_TEST_ASSERT_MSG_GT(difference, Seconds(1) + delay, "Ack arrived too early.");
935  NS_TEST_ASSERT_MSG_LT(difference + delay,
936  MilliSeconds(1900) + delay,
937  "Ack arrived too late. First window should be closed.");
938 
939  NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(), 24, "Sink should receive one packet of 24 bytes");
940 }
941 
953 {
954  public:
957 
958  private:
959  virtual void DoRun(void);
960  void MacTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
961 
964 
965  Address m_edAddress;
967 };
968 
970  : TestCase("Test constellation satellite lorawan with acks sent in first window."),
971  m_gwReceiveDate(Seconds(0)),
972  m_edReceiveDate(Seconds(0))
973 {
974 }
975 
977 {
978 }
979 
980 void
982  Ptr<const Packet> packet,
983  const Address& address)
984 {
985  if (address == m_edAddress)
986  {
987  m_gwReceiveDate = Simulator::Now();
988  }
989 
990  if (address == m_orbiterUserAddress)
991  {
992  m_edReceiveDate = Simulator::Now();
993  }
994 }
995 
996 void
998 {
999  // Set simulation output details
1000  Singleton<SatEnvVariables>::Get()->DoInitialize();
1001 
1002  Ptr<SimulationHelper> simulationHelper =
1003  CreateObject<SimulationHelper>("test-sat-lora-regenerative/constellation-first-window");
1004 
1005  // Enable Lora
1006  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
1007  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
1008  EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
1009  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
1010 
1012  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
1013  EnumValue(SatEnums::REGENERATION_NETWORK));
1014  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
1015  EnumValue(SatEnums::REGENERATION_NETWORK));
1016 
1017  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
1018  TimeValue(MilliSeconds(1500)));
1019  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
1020  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
1021  TimeValue(MilliSeconds(400)));
1022  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
1023  TimeValue(MilliSeconds(500)));
1024  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay", TimeValue(Seconds(1)));
1025  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
1026 
1027  // Superframe configuration
1028  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
1029  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
1030  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
1031  EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
1032  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
1033  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
1034  DoubleValue(15000));
1035 
1036  // CRDSA only
1037  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
1038  BooleanValue(false));
1039  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
1040  BooleanValue(false));
1041 
1042  // Configure RA
1043  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
1044  EnumValue(SatPhyRxCarrierConf::EM_AVI));
1045  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
1046  EnumValue(SatPhyRxCarrierConf::EM_AVI));
1047  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
1048  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
1049  EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
1050  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
1051  EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
1052  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
1053 
1054  // Configure E-SSA
1055  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
1056  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
1057  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
1058  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
1059 
1060  Config::SetDefault("ns3::SatMac::EnableStatisticsTags", BooleanValue(true));
1061 
1062  // Traffics
1063  simulationHelper->SetSimulationTime(Seconds(15.0));
1064 
1065  simulationHelper->SetGwUserCount(1);
1066  simulationHelper->SetUtCountPerBeam(1);
1067  simulationHelper->SetUserCountPerUt(1);
1068  simulationHelper->SetBeams("30 43");
1069 
1070  simulationHelper->LoadScenario("constellation-eutelsat-geo-2-sats-isls-lora");
1071 
1072  simulationHelper->CreateSatScenario();
1073 
1074  // >>> Start of actual test using Simple scenario >>>
1075  Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(0);
1076  Ptr<LoraPeriodicSender> app = Create<LoraPeriodicSender>();
1077 
1078  app->SetInterval(Seconds(10));
1079 
1080  app->SetStartTime(Seconds(1.0));
1081  app->SetStopTime(Seconds(10.0));
1082  app->SetPacketSize(24);
1083 
1084  app->SetNode(utNode);
1085  utNode->AddApplication(app);
1086 
1087  Ptr<SatOrbiterNetDevice> orbiterNetDevice0 = DynamicCast<SatOrbiterNetDevice>(
1088  Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0));
1089  Ptr<SatOrbiterNetDevice> orbiterNetDevice1 = DynamicCast<SatOrbiterNetDevice>(
1090  Singleton<SatTopology>::Get()->GetOrbiterNode(1)->GetDevice(0));
1091  m_edAddress = Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2)->GetAddress();
1092  m_orbiterUserAddress = orbiterNetDevice0->GetSatelliteUserAddress(43);
1093 
1094  Config::Connect("/NodeList/*/DeviceList/*/SatMac/Rx",
1096  Config::Connect("/NodeList/*/DeviceList/*/FeederMac/*/Rx",
1098 
1099  simulationHelper->RunSimulation();
1100 
1101  Simulator::Destroy();
1102 
1103  Singleton<SatEnvVariables>::Get()->DoDispose();
1104 
1105  NS_TEST_ASSERT_MSG_NE(m_gwReceiveDate, Seconds(0), "Packet should be received by Gateway.");
1106  NS_TEST_ASSERT_MSG_NE(m_edReceiveDate, Seconds(0), "Ack should be received by End Device.");
1107  NS_TEST_ASSERT_MSG_GT(m_edReceiveDate, m_gwReceiveDate, "Ack should be received after packet.");
1108 
1109  Time difference = m_edReceiveDate - m_gwReceiveDate;
1110  Time delay = MilliSeconds(130);
1111 
1112  NS_TEST_ASSERT_MSG_GT(difference, Seconds(1) + delay, "Ack arrived too early.");
1113  NS_TEST_ASSERT_MSG_LT(difference + delay,
1114  MilliSeconds(1900) + delay,
1115  "Ack arrived too late. First window should be closed.");
1116 }
1117 
1128 {
1129  public:
1132 
1133  private:
1134  virtual void DoRun(void);
1135  void MacTraceCb(std::string context, Ptr<const Packet> packet, const Address& address);
1136 
1141 
1142  Address m_edAddress;
1146 };
1147 
1149  : TestCase("Test constellation satellite lorawan with handovers."),
1150  m_gwReceiveDate(Seconds(0)),
1151  m_edReceiveDate31(Seconds(0)),
1152  m_edReceiveDate40(Seconds(0)),
1153  m_edReceiveDate41(Seconds(0))
1154 {
1155 }
1156 
1158 {
1159 }
1160 
1161 void
1163  Ptr<const Packet> packet,
1164  const Address& address)
1165 {
1166  if (address == m_edAddress)
1167  {
1168  m_gwReceiveDate = Simulator::Now();
1169  }
1170 
1171  if (address == m_orbiterUserAddress31)
1172  {
1173  m_edReceiveDate31 = Simulator::Now();
1174  }
1175 
1176  if (address == m_orbiterUserAddress40)
1177  {
1178  m_edReceiveDate40 = Simulator::Now();
1179  }
1180 
1181  if (address == m_orbiterUserAddress41)
1182  {
1183  m_edReceiveDate41 = Simulator::Now();
1184  }
1185 }
1186 
1187 void
1189 {
1190  // Set simulation output details
1191  Singleton<SatEnvVariables>::Get()->DoInitialize();
1192 
1193  Ptr<SimulationHelper> simulationHelper =
1194  CreateObject<SimulationHelper>("test-sat-lora-regenerative/constellation-handover");
1195 
1196  // Enable Lora
1197  Config::SetDefault("ns3::LorawanMacEndDevice::DataRate", UintegerValue(5));
1198  Config::SetDefault("ns3::LorawanMacEndDevice::MType",
1199  EnumValue(LorawanMacHeader::CONFIRMED_DATA_UP));
1200  Config::SetDefault("ns3::SatLoraConf::Standard", EnumValue(SatLoraConf::SATELLITE));
1201 
1203  Config::SetDefault("ns3::SatConf::ForwardLinkRegenerationMode",
1204  EnumValue(SatEnums::REGENERATION_NETWORK));
1205  Config::SetDefault("ns3::SatConf::ReturnLinkRegenerationMode",
1206  EnumValue(SatEnums::REGENERATION_NETWORK));
1207 
1208  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDelay",
1209  TimeValue(MilliSeconds(1000)));
1210  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDelay", TimeValue(Seconds(2)));
1211  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::FirstWindowDuration",
1212  TimeValue(MilliSeconds(900)));
1213  Config::SetDefault("ns3::LorawanMacEndDeviceClassA::SecondWindowDuration",
1214  TimeValue(MilliSeconds(500)));
1215  Config::SetDefault("ns3::LoraNetworkScheduler::FirstWindowAnswerDelay", TimeValue(Seconds(1)));
1216  Config::SetDefault("ns3::LoraNetworkScheduler::SecondWindowAnswerDelay", TimeValue(Seconds(2)));
1217 
1218  // Superframe configuration
1219  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
1220  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_4));
1221  Config::SetDefault("ns3::SatSuperframeConf4::FrameConfigType",
1222  EnumValue(SatSuperframeConf::CONFIG_TYPE_4));
1223  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_AllocatedBandwidthHz", DoubleValue(15000));
1224  Config::SetDefault("ns3::SatSuperframeConf4::Frame0_CarrierAllocatedBandwidthHz",
1225  DoubleValue(15000));
1226 
1227  // CRDSA only
1228  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService0_ConstantAssignmentProvided",
1229  BooleanValue(false));
1230  Config::SetDefault("ns3::SatLowerLayerServiceConf::DaService3_RbdcAllowed",
1231  BooleanValue(false));
1232 
1233  // Configure RA
1234  Config::SetDefault("ns3::SatOrbiterHelper::FwdLinkErrorModel",
1235  EnumValue(SatPhyRxCarrierConf::EM_AVI));
1236  Config::SetDefault("ns3::SatOrbiterHelper::RtnLinkErrorModel",
1237  EnumValue(SatPhyRxCarrierConf::EM_AVI));
1238  Config::SetDefault("ns3::SatBeamHelper::RandomAccessModel", EnumValue(SatEnums::RA_MODEL_ESSA));
1239  Config::SetDefault("ns3::SatBeamHelper::RaInterferenceEliminationModel",
1240  EnumValue(SatPhyRxCarrierConf::SIC_RESIDUAL));
1241  Config::SetDefault("ns3::SatBeamHelper::RaCollisionModel",
1242  EnumValue(SatPhyRxCarrierConf::RA_COLLISION_CHECK_AGAINST_SINR));
1243  Config::SetDefault("ns3::SatBeamHelper::ReturnLinkLinkResults", EnumValue(SatEnums::LR_LORA));
1244 
1245  // Configure E-SSA
1246  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowDuration", StringValue("600ms"));
1247  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowStep", StringValue("200ms"));
1248  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::WindowSICIterations", UintegerValue(5));
1249  Config::SetDefault("ns3::SatPhyRxCarrierPerWindow::EnableSIC", BooleanValue(false));
1250 
1251  Config::SetDefault("ns3::SatMac::EnableStatisticsTags", BooleanValue(true));
1252 
1253  Config::SetDefault("ns3::SatHelper::HandoversEnabled", BooleanValue(true));
1254  Config::SetDefault("ns3::SatHandoverModule::NumberClosestSats", UintegerValue(2));
1255 
1256  // Traffics
1257  Ptr<SimulationHelperConf> simulationConf = CreateObject<SimulationHelperConf>();
1258  simulationHelper->SetSimulationTime(Seconds(100));
1259  simulationHelper->SetGwUserCount(1);
1260  simulationHelper->SetUserCountPerUt(1);
1261  simulationHelper->SetBeamSet({31, 40, 41, 43});
1262  simulationHelper->LoadScenario("constellation-leo-2-satellites-lora");
1263  simulationHelper->SetUserCountPerMobileUt(simulationConf->m_utMobileUserCount);
1264  simulationHelper->CreateSatScenario(SatHelper::NONE);
1265 
1266  Ptr<Node> utNode = Singleton<SatTopology>::Get()->GetUtNode(0);
1267  simulationHelper->GetTrafficHelper()->AddLoraPeriodicTraffic(Seconds(10),
1268  24,
1269  NodeContainer(utNode),
1270  Seconds(0.001),
1271  Seconds(100),
1272  Seconds(3));
1273 
1274  Ptr<SatOrbiterNetDevice> orbiterNetDevice0 = DynamicCast<SatOrbiterNetDevice>(
1275  Singleton<SatTopology>::Get()->GetOrbiterNode(0)->GetDevice(0));
1276  Ptr<SatOrbiterNetDevice> orbiterNetDevice1 = DynamicCast<SatOrbiterNetDevice>(
1277  Singleton<SatTopology>::Get()->GetOrbiterNode(1)->GetDevice(0));
1278 
1279  m_edAddress = Singleton<SatTopology>::Get()->GetUtNode(0)->GetDevice(2)->GetAddress();
1280 
1281  m_orbiterUserAddress31 = orbiterNetDevice0->GetSatelliteUserAddress(31);
1282  m_orbiterUserAddress40 = orbiterNetDevice1->GetSatelliteUserAddress(40);
1283  m_orbiterUserAddress41 = orbiterNetDevice1->GetSatelliteUserAddress(41);
1284 
1285  Config::Connect("/NodeList/*/DeviceList/*/SatMac/Rx",
1287  Config::Connect("/NodeList/*/DeviceList/*/FeederMac/*/Rx",
1289  Config::Connect("/NodeList/*/DeviceList/*/UserMac/*/Rx",
1291 
1292  simulationHelper->RunSimulation();
1293 
1294  Simulator::Destroy();
1295 
1296  Singleton<SatEnvVariables>::Get()->DoDispose();
1297 
1298  NS_TEST_ASSERT_MSG_NE(m_gwReceiveDate, Seconds(0), "Packet should be received by Gateway.");
1299  NS_TEST_ASSERT_MSG_NE(m_edReceiveDate31,
1300  Seconds(0),
1301  "Ack should be received by End Device from satellite 0 and beam 31.");
1302  NS_TEST_ASSERT_MSG_NE(m_edReceiveDate40,
1303  Seconds(0),
1304  "Ack should be received by End Device from satellite 1 and beam 40.");
1305  NS_TEST_ASSERT_MSG_NE(m_edReceiveDate41,
1306  Seconds(0),
1307  "Ack should be received by End Device from satellite 1 and beam 41.");
1308 }
1309 
1314 class SatLoraRegenerativeTestSuite : public TestSuite
1315 {
1316  public:
1318 };
1319 
1321  : TestSuite("sat-lora-regenerative-test", Type::SYSTEM)
1322 {
1323  AddTestCase(new SatLoraRegenerativeFirstWindowTestCase, TestCase::Duration::QUICK);
1324  AddTestCase(new SatLoraRegenerativeSecondWindowTestCase, TestCase::Duration::QUICK);
1325  AddTestCase(new SatLoraRegenerativeOutOfWindowWindowTestCase, TestCase::Duration::QUICK);
1327  TestCase::Duration::QUICK);
1328  AddTestCase(new SatLoraRegenerativeCbrTestCase, TestCase::Duration::QUICK);
1329  AddTestCase(new SatLoraConstellationFirstWindowTestCase, TestCase::Duration::QUICK);
1330  AddTestCase(new SatLoraConstellationHandoverTestCase, TestCase::Duration::QUICK);
1331 }
1332 
1333 // Do allocate an instance of this TestSuite
Test case to check if Lora ack arrives in first reception window when using a constellation.
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test case to check if Lora still works after hadovers.
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test case to check if packet is received on App layer.
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test case to check if Lora ack arrives in first reception window.
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test case to check that packet is not retransmitted if ack outside of both windows but no retransmiss...
void PhyTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test case to check if packet retransmitted if ack outside of both windows.
void MacTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
void PhyTraceCb(std::string context, Ptr< const Packet > packet, const Address &address)
Test case to check if Lora ack arrives in second reception window.
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 SatLoraRegenerativeTestSuite satLoraRegenerativeTestSuite