satellite-per-packet-if-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: Sami Rantanen <sami.rantanen@magister.fi>
19  */
20 
27 // Include a header file from your module to test.
28 #include "ns3/applications-module.h"
29 #include "ns3/boolean.h"
30 #include "ns3/config.h"
31 #include "ns3/log.h"
32 #include "ns3/satellite-module.h"
33 #include "ns3/simulator.h"
34 #include "ns3/singleton.h"
35 #include "ns3/string.h"
36 #include "ns3/test.h"
37 #include "ns3/timer.h"
38 #include "ns3/traffic-module.h"
39 
40 #include <iomanip>
41 
42 using namespace ns3;
43 
44 static void
45 LinkBudgetTraceCb(std::string context,
46  Ptr<SatSignalParameters> params,
47  Mac48Address ownAdd,
48  Mac48Address destAdd,
49  double ifPower,
50  double cSinr)
51 {
52  // print only unicast message to prevent printing control messages like TBTP messages
53  if (!destAdd.IsBroadcast())
54  {
55  std::cout.precision(2);
56  std::cout.setf(std::cout.fixed | std::cout.showpoint);
57 
58  std::cout << "Time= " << Simulator::Now() << ", ChType= " << std::setw(17)
59  << SatEnums::GetChannelTypeName(params->m_channelType) << ", OwnAddr= " << ownAdd
60  << ", DestAddr= " << destAdd << ", Beam= " << std::setw(2) << params->m_beamId
61  << ", Freq= " << params->m_carrierFreq_hz << ", IFPwr= " << std::setw(8)
62  << SatUtils::WToDbW<double>(ifPower) << ", RXPwr= " << std::setw(8)
63  << SatUtils::WToDbW<double>(params->m_rxPower_W) << ", SINR= " << std::setw(7)
64  << SatUtils::LinearToDb<double>(params->GetSinr()) << ", CSINR= " << std::setw(7)
65  << SatUtils::LinearToDb<double>(cSinr) << std::endl;
66  }
67 }
68 
69 class SatPerPacketBaseTestCase : public TestCase
70 {
71  public:
73  SatPerPacketBaseTestCase(std::string name,
74  std::string extName,
76  bool dummyFrames,
77  StringValue ival1,
78  UintegerValue pSize1,
79  StringValue ival2,
80  UintegerValue pSize2);
81  virtual ~SatPerPacketBaseTestCase();
82 
83  protected:
84  virtual void DoRun(void) = 0;
85  void InitOutput(bool figureOutput);
86  void PrintTraceInfo();
87 
88  StringValue m_Interval1;
89  StringValue m_Interval2;
90 
91  UintegerValue m_PackageSize1;
92  UintegerValue m_PackageSize2;
93 
94  std::string m_extName;
95 
98 };
99 
101  : TestCase(""),
102  m_Interval1(),
103  m_Interval2(),
104  m_PackageSize1(),
105  m_PackageSize2(),
106  m_extName(),
107  m_fading(),
108  m_dummyFrames(false)
109 {
110 }
111 
113  std::string extName,
115  bool dummyFrames,
116  StringValue ival1,
117  UintegerValue pSize1,
118  StringValue ival2,
119  UintegerValue pSize2)
120  : TestCase(name),
121  m_Interval1(ival1),
122  m_Interval2(ival2),
123  m_PackageSize1(pSize1),
124  m_PackageSize2(pSize2),
125  m_extName(extName),
126  m_fading(fading),
127  m_dummyFrames(dummyFrames)
128 {
129 }
130 
132 {
133 }
134 
135 void
137 {
138  Ptr<SatIdMapper> ptrMapper = Singleton<SatIdMapper>::Get();
139  ptrMapper->Reset();
140 
141  Ptr<SatInterferenceOutputTraceContainer> ptrCont =
142  Singleton<SatInterferenceOutputTraceContainer>::Get();
143  ptrCont->Reset();
144 
145  std::size_t pos = m_extName.find(' ');
146 
147  while (pos != std::string::npos)
148  {
149  m_extName.replace(pos, 1, "_");
150  pos = m_extName.find(' ');
151  }
152 
153  pos = m_extName.find(',');
154 
155  while (pos != std::string::npos)
156  {
157  m_extName.replace(pos, 1, "\0");
158  pos = m_extName.find(',');
159  }
160 
161  pos = m_extName.find('.');
162 
163  while (pos != std::string::npos)
164  {
165  m_extName.replace(pos, 1, "\0");
166  pos = m_extName.find('.');
167  }
168 
169  ptrCont->EnableFigureOutput(figureOutput);
170 }
171 
172 void
174 {
175  Ptr<SatIdMapper> ptrMapper = Singleton<SatIdMapper>::Get();
176 
177  std::cout << m_extName << std::endl;
178  ptrMapper->PrintTraceMap();
179 }
180 
206 // Default name to show for SatPerPacketFwdLinkUserTestCase test. When the second constructor is
207 // used, the text to append this name can be given.
208 static const char* defFwdUserName =
209  "Test satellite per packet interference in Forward Link with user defined scenario. ";
210 
212 {
213  public:
215  SatPerPacketFwdLinkUserTestCase(std::string name,
217  bool dummyFrames);
218  SatPerPacketFwdLinkUserTestCase(std::string name,
220  bool dummyFrames,
221  StringValue ival1,
222  UintegerValue pSize1,
223  StringValue ival2,
224  UintegerValue pSize2);
225 
227 
228  private:
229  virtual void DoRun(void);
230 };
231 
234  "IfTestFwdUsr",
235  SatEnums::FADING_OFF,
236  false,
237  StringValue("0.00015s"),
238  UintegerValue(512),
239  StringValue("0.1s"),
240  UintegerValue(512))
241 {
242 }
243 
246  bool dummyFrames)
248  "IfTestFwdUsr_" + name,
249  fading,
250  dummyFrames,
251  StringValue("0.00015s"),
252  UintegerValue(512),
253  StringValue("0.1s"),
254  UintegerValue(512))
255 {
256 }
257 
260  bool dummyFrames,
261  StringValue ival1,
262  UintegerValue pSize1,
263  StringValue ival2,
264  UintegerValue pSize2)
266  "IfTestFwdUsr_" + name,
267  fading,
268  dummyFrames,
269  ival1,
270  pSize1,
271  ival2,
272  pSize2)
273 {
274 }
275 
277 {
278 }
279 
280 void
282 {
283  Singleton<SatEnvVariables>::Get()->DoInitialize();
284 
285  InitOutput(true);
286 
287  // Set simulation output details
288  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-per-packet-if",
289  m_extName,
290  true);
291 
292  // Configure a static error probability
293  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
294  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
295  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
296 
297  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(m_fading));
298  Config::SetDefault("ns3::SatFwdLinkScheduler::DummyFrameSendingEnabled",
299  BooleanValue(m_dummyFrames));
300 
301  Config::SetDefault("ns3::SatHelper::UtCount", UintegerValue(1));
302  Config::SetDefault("ns3::SatHelper::UtUsers", UintegerValue(1));
303  Config::SetDefault("ns3::SatOrbiterHelper::DaFwdLinkInterferenceModel",
304  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
305  Config::SetDefault("ns3::SatUtHelper::DaFwdLinkInterferenceModel",
306  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
307  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
308 
309  // Creating the reference system.
310  Ptr<SatHelper> helper = CreateObject<SatHelper>(
311  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E");
312 
313  // create user defined scenario with beams 1 and 5
314  SatBeamUserInfo beamInfo = SatBeamUserInfo(1, 1);
315  std::map<std::pair<uint32_t, uint32_t>, SatBeamUserInfo> beamMap;
316  beamMap[std::make_pair(0, 1)] = beamInfo;
317  beamMap[std::make_pair(0, 5)] = beamInfo;
318 
319  helper->CreateUserDefinedScenario(beamMap);
320 
321  // set callback traces where we want results out
322 
323  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
324  MakeCallback(&LinkBudgetTraceCb));
325 
326  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
327  MakeCallback(&LinkBudgetTraceCb));
328 
329  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
330  MakeCallback(&LinkBudgetTraceCb));
331 
332  NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
333  NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
334  uint16_t port = 9;
335 
336  // create Sink helper
337  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory",
338  InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
339 
340  // install Sink application on UT user 1 to receive packet
341  ApplicationContainer utSinks = sinkHelper.Install(utUsers.Get(0));
342 
343  // install Sink application on UT user 5 to receive packet
344  sinkHelper.SetAttribute(
345  "Local",
346  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(1)), port))));
347  utSinks.Add(sinkHelper.Install(utUsers.Get(1)));
348  utSinks.Start(Seconds(0.1));
349  utSinks.Stop(Seconds(0.5));
350 
351  CbrHelper cbrHelper("ns3::UdpSocketFactory",
352  InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
353 
354  // create application on GW to sent beam 1 (UT user 1)
355  cbrHelper.SetAttribute("Interval", m_Interval1);
356  cbrHelper.SetAttribute("PacketSize", m_PackageSize1);
357 
358  ApplicationContainer gw1Cbr = cbrHelper.Install(gwUsers.Get(0));
359  gw1Cbr.Start(Seconds(0.2));
360  gw1Cbr.Stop(Seconds(0.5));
361 
362  // create application on GW to sent beam 5 (UT user 5)
363  cbrHelper.SetAttribute(
364  "Remote",
365  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(1)), port))));
366  cbrHelper.SetAttribute("Interval", m_Interval2);
367  cbrHelper.SetAttribute("PacketSize", m_PackageSize2);
368 
369  ApplicationContainer gw2Cbr = cbrHelper.Install(gwUsers.Get(1));
370  gw2Cbr.Start(Seconds(0.2));
371  gw2Cbr.Stop(Seconds(1.0));
372 
373  Simulator::Stop(Seconds(1.0));
374  Simulator::Run();
375  PrintTraceInfo();
376 
377  Simulator::Destroy();
378 
379  Singleton<SatEnvVariables>::Get()->DoDispose();
380 }
381 
407 // Default name to show for SatPerPacketFwdLinkFullTestCase test. When the second constructor is
408 // used, the text to append this name can be given.
409 static const char* defFwdFullName =
410  "Test satellite per packet interference in Forward Link with fullscenario. ";
411 
413 {
414  public:
416  SatPerPacketFwdLinkFullTestCase(std::string name,
418  bool dummyFrames);
419  SatPerPacketFwdLinkFullTestCase(std::string name,
421  bool dummyFrames,
422  StringValue ival1,
423  UintegerValue pSize1,
424  StringValue ival2,
425  UintegerValue pSize2);
427 
428  private:
429  virtual void DoRun(void);
430 };
431 
434  "IfTestFwdFull",
435  SatEnums::FADING_OFF,
436  false,
437  StringValue("0.00015s"),
438  UintegerValue(512),
439  StringValue("0.1s"),
440  UintegerValue(512))
441 
442 {
443 }
444 
447  bool dummyFrames)
449  "IfTestFwdFull_" + name,
450  fading,
451  dummyFrames,
452  StringValue("0.00015s"),
453  UintegerValue(512),
454  StringValue("0.1s"),
455  UintegerValue(512))
456 {
457 }
458 
461  bool dummyFrames,
462  StringValue ival1,
463  UintegerValue pSize1,
464  StringValue ival2,
465  UintegerValue pSize2)
467  "IfTestFwdFull_" + name,
468  fading,
469  dummyFrames,
470  ival1,
471  pSize1,
472  ival2,
473  pSize2)
474 {
475 }
476 
478 {
479 }
480 
481 void
483 {
484  Singleton<SatEnvVariables>::Get()->DoInitialize();
485 
486  InitOutput(false);
487 
488  // Set simulation output details
489  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-per-packet-if",
490  m_extName,
491  true);
492 
493  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(m_fading));
494  Config::SetDefault("ns3::SatFwdLinkScheduler::DummyFrameSendingEnabled",
495  BooleanValue(m_dummyFrames));
496 
497  Config::SetDefault("ns3::SatHelper::UtCount", UintegerValue(1));
498  Config::SetDefault("ns3::SatHelper::UtUsers", UintegerValue(1));
499  Config::SetDefault("ns3::SatOrbiterHelper::DaFwdLinkInterferenceModel",
500  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
501  Config::SetDefault("ns3::SatUtHelper::DaFwdLinkInterferenceModel",
502  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
503  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
504 
505  // Creating the reference system.
506  Ptr<SatHelper> helper = CreateObject<SatHelper>(
507  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E");
508 
509  helper->CreatePredefinedScenario(SatHelper::FULL);
510 
511  // set callback traces where we want results out
512 
513  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
514  MakeCallback(&LinkBudgetTraceCb));
515 
516  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
517  MakeCallback(&LinkBudgetTraceCb));
518 
519  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
520  MakeCallback(&LinkBudgetTraceCb));
521 
522  NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
523  NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
524  uint16_t port = 9;
525 
526  // create Sink helper
527  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory",
528  InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
529 
530  // install Sink application on UT user 1 to receive packet
531  ApplicationContainer utSinks = sinkHelper.Install(utUsers.Get(0));
532 
533  // install Sink application on UT user 5 to receive packet
534  sinkHelper.SetAttribute(
535  "Local",
536  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(4)), port))));
537  utSinks.Add(sinkHelper.Install(utUsers.Get(4)));
538  utSinks.Start(Seconds(0.1));
539  utSinks.Stop(Seconds(1.0));
540 
541  CbrHelper cbrHelper("ns3::UdpSocketFactory",
542  InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
543 
544  // create application on GW to sent beam 1 (UT user 1)
545  cbrHelper.SetAttribute("Interval", m_Interval1);
546  cbrHelper.SetAttribute("PacketSize", m_PackageSize1);
547 
548  ApplicationContainer gw1Cbr = cbrHelper.Install(gwUsers.Get(0));
549  gw1Cbr.Start(Seconds(0.2));
550  gw1Cbr.Stop(Seconds(0.4));
551 
552  // create application on GW to sent beam 5 (UT user 5)
553  cbrHelper.SetAttribute(
554  "Remote",
555  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(4)), port))));
556  cbrHelper.SetAttribute("Interval", m_Interval2);
557  cbrHelper.SetAttribute("PacketSize", m_PackageSize2);
558 
559  ApplicationContainer gw2Cbr = cbrHelper.Install(gwUsers.Get(4));
560  gw2Cbr.Start(Seconds(0.2));
561  gw2Cbr.Stop(Seconds(0.4));
562 
563  Simulator::Stop(Seconds(1.0));
564  Simulator::Run();
565  PrintTraceInfo();
566 
567  Simulator::Destroy();
568 
569  Singleton<SatEnvVariables>::Get()->DoDispose();
570 }
571 
596 // Default name to show for SatPerPacketRtnLinkUserTestCase test. When the second constructor is
597 // used, the text to append this name can be given.
598 static const char* defRtnUserName =
599  "Test satellite per packet interference in Return Link with user defined scenario. ";
600 
602 {
603  public:
606  SatPerPacketRtnLinkUserTestCase(std::string name,
608  StringValue ival1,
609  UintegerValue pSize1,
610  StringValue ival2,
611  UintegerValue pSize2);
612 
614 
615  private:
616  virtual void DoRun(void);
617 };
618 
621  "IfTestRtnUsr",
622  SatEnums::FADING_OFF,
623  false,
624  StringValue("0.01s"),
625  UintegerValue(512),
626  StringValue("0.01s"),
627  UintegerValue(32))
628 {
629 }
630 
634  "IfTestRtnUsr_" + name,
635  fading,
636  false,
637  StringValue("0.01s"),
638  UintegerValue(512),
639  StringValue("0.01s"),
640  UintegerValue(32))
641 {
642 }
643 
646  StringValue ival1,
647  UintegerValue pSize1,
648  StringValue ival2,
649  UintegerValue pSize2)
651  "IfTestRtnUsr_" + name,
652  fading,
653  false,
654  ival1,
655  pSize1,
656  ival2,
657  pSize2)
658 {
659 }
660 
662 {
663 }
664 
665 void
667 {
668  Singleton<SatEnvVariables>::Get()->DoInitialize();
669 
670  InitOutput(false);
671 
672  // Set simulation output details
673  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-per-packet-if",
674  m_extName,
675  true);
676 
677  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(m_fading));
678  Config::SetDefault("ns3::SatFwdLinkScheduler::DummyFrameSendingEnabled",
679  BooleanValue(m_dummyFrames));
680 
681  Config::SetDefault("ns3::SatHelper::UtCount", UintegerValue(1));
682  Config::SetDefault("ns3::SatHelper::UtUsers", UintegerValue(1));
683  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
684  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_0));
685  Config::SetDefault("ns3::SatSuperframeConf0::FrameCount", UintegerValue(1));
686  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType",
687  EnumValue(SatSuperframeConf::CONFIG_TYPE_0));
688  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_AllocatedBandwidthHz", DoubleValue(1.25e6));
689  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_CarrierAllocatedBandwidthHz",
690  DoubleValue(1.25e6));
691  // Config::SetDefault("ns3::SatWaveformConf::DefaultWfId", UintegerValue(13));
692  Config::SetDefault("ns3::SatGwHelper::DaRtnLinkInterferenceModel",
693  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
694  Config::SetDefault("ns3::SatOrbiterHelper::DaRtnLinkInterferenceModel",
695  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
696  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
697 
698  // Creating the reference system.
699  Ptr<SatHelper> helper = CreateObject<SatHelper>(
700  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E");
701 
702  // create user defined scenario with beams 1 and 5
703  SatBeamUserInfo beamInfo = SatBeamUserInfo(1, 1);
704  std::map<std::pair<uint32_t, uint32_t>, SatBeamUserInfo> beamMap;
705  beamMap[std::make_pair(0, 1)] = beamInfo;
706  beamMap[std::make_pair(0, 5)] = beamInfo;
707 
708  helper->CreateUserDefinedScenario(beamMap);
709 
710  // set callback traces where we want results out
711 
712  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
713  MakeCallback(&LinkBudgetTraceCb));
714 
715  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
716  MakeCallback(&LinkBudgetTraceCb));
717 
718  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
719  MakeCallback(&LinkBudgetTraceCb));
720 
721  NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
722  NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
723  uint16_t port = 9;
724 
725  // create Sink helper
726  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory",
727  InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
728 
729  // install Sink application on GW user to receive packet
730  ApplicationContainer gwSink = sinkHelper.Install(gwUsers.Get(0));
731  gwSink.Start(Seconds(0.1));
732  gwSink.Stop(Seconds(0.5));
733 
734  CbrHelper cbrHelper("ns3::UdpSocketFactory",
735  InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
736 
737  // create applications on UT in beam 1
738  cbrHelper.SetAttribute("Interval", m_Interval1);
739  cbrHelper.SetAttribute("PacketSize", m_PackageSize1);
740 
741  ApplicationContainer ut1Cbr = cbrHelper.Install(utUsers.Get(0));
742  ut1Cbr.Start(Seconds(0.1));
743  ut1Cbr.Stop(Seconds(0.4));
744 
745  // create applications on UT in beam 5
746  cbrHelper.SetAttribute("Interval", m_Interval2);
747  cbrHelper.SetAttribute("PacketSize", m_PackageSize2);
748 
749  ApplicationContainer ut5Cbr = cbrHelper.Install(utUsers.Get(1));
750  ut5Cbr.Start(Seconds(0.1));
751  ut5Cbr.Stop(Seconds(0.4));
752 
753  Simulator::Stop(Seconds(1.0));
754  Simulator::Run();
755  PrintTraceInfo();
756 
757  Simulator::Destroy();
758 
759  Singleton<SatEnvVariables>::Get()->DoDispose();
760 }
761 
762 // Default name to show for test. When the second constructor is used, the text to append this name
763 // can be given.
764 static const char* defRtnFullName =
765  "Test satellite per packet interference in Return Link with full defined scenario. ";
766 
768 {
769  public:
771 
773  SatPerPacketRtnLinkFullTestCase(std::string name,
775  StringValue ival1,
776  UintegerValue pSize1,
777  StringValue ival2,
778  UintegerValue pSize2);
780 
781  private:
782  virtual void DoRun(void);
783 };
784 
787  "IfTestRtnFull",
788  SatEnums::FADING_OFF,
789  false,
790  StringValue("0.01s"),
791  UintegerValue(512),
792  StringValue("0.01s"),
793  UintegerValue(32))
794 {
795 }
796 
800  "IfTestRtnFull_" + name,
801  fading,
802  false,
803  StringValue("0.01s"),
804  UintegerValue(512),
805  StringValue("0.01s"),
806  UintegerValue(32))
807 {
808 }
809 
812  StringValue ival1,
813  UintegerValue pSize1,
814  StringValue ival2,
815  UintegerValue pSize2)
817  "IfTestRtnFull_" + name,
818  fading,
819  false,
820  ival1,
821  pSize1,
822  ival2,
823  pSize2)
824 {
825 }
826 
828 {
829 }
830 
831 void
833 {
834  Singleton<SatEnvVariables>::Get()->DoInitialize();
835 
836  InitOutput(false);
837 
838  // Set simulation output details
839  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-per-packet-if",
840  m_extName,
841  true);
842 
843  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(m_fading));
844  Config::SetDefault("ns3::SatFwdLinkScheduler::DummyFrameSendingEnabled",
845  BooleanValue(m_dummyFrames));
846 
847  Config::SetDefault("ns3::SatHelper::UtCount", UintegerValue(1));
848  Config::SetDefault("ns3::SatHelper::UtUsers", UintegerValue(1));
849  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
850  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_0));
851  Config::SetDefault("ns3::SatSuperframeConf0::FrameCount", UintegerValue(1));
852  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType",
853  EnumValue(SatSuperframeConf::CONFIG_TYPE_0));
854  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_AllocatedBandwidthHz", DoubleValue(1.25e6));
855  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_CarrierAllocatedBandwidthHz",
856  DoubleValue(1.25e6));
857  // Config::SetDefault("ns3::SatWaveformConf::DefaultWfId", UintegerValue(13));
858  Config::SetDefault("ns3::SatGwHelper::DaRtnLinkInterferenceModel",
859  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
860  Config::SetDefault("ns3::SatOrbiterHelper::DaRtnLinkInterferenceModel",
861  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
862  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
863 
864  // Creating the reference system.
865  Ptr<SatHelper> helper = CreateObject<SatHelper>(
866  Singleton<SatEnvVariables>::Get()->LocateDataDirectory() + "/scenarios/geo-33E");
867  helper->CreatePredefinedScenario(SatHelper::FULL);
868 
869  // set callback traces where we want results out
870 
871  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
872  MakeCallback(&LinkBudgetTraceCb));
873 
874  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
875  MakeCallback(&LinkBudgetTraceCb));
876 
877  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
878  MakeCallback(&LinkBudgetTraceCb));
879 
880  NodeContainer utUsers = Singleton<SatTopology>::Get()->GetUtUserNodes();
881  NodeContainer gwUsers = Singleton<SatTopology>::Get()->GetGwUserNodes();
882  uint16_t port = 9;
883 
884  // create Sink helper
885  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory",
886  InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
887 
888  // install Sink application on GW user to receive packet
889  ApplicationContainer gwSink = sinkHelper.Install(gwUsers.Get(0));
890  gwSink.Start(Seconds(0.1));
891  gwSink.Stop(Seconds(0.5));
892 
893  CbrHelper cbrHelper("ns3::UdpSocketFactory",
894  InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
895 
896  // create applications on UT in beam 1
897  cbrHelper.SetAttribute("Interval", m_Interval1);
898  cbrHelper.SetAttribute("PacketSize", m_PackageSize1);
899 
900  ApplicationContainer ut1Cbr = cbrHelper.Install(utUsers.Get(0));
901  ut1Cbr.Start(Seconds(0.1));
902  ut1Cbr.Stop(Seconds(0.4));
903 
904  // create applications on UT in beam 5
905  cbrHelper.SetAttribute("Interval", m_Interval2);
906  cbrHelper.SetAttribute("PacketSize", m_PackageSize2);
907 
908  ApplicationContainer ut5Cbr = cbrHelper.Install(utUsers.Get(4));
909  ut5Cbr.Start(Seconds(0.1));
910  ut5Cbr.Stop(Seconds(0.4));
911 
912  Simulator::Stop(Seconds(1.0));
913  Simulator::Run();
914  PrintTraceInfo();
915 
916  Simulator::Destroy();
917 
918  Singleton<SatEnvVariables>::Get()->DoDispose();
919 }
920 
925 class SatPerPacketIfTestSuite : public TestSuite
926 {
927  public:
929 };
930 
932  : TestSuite("sat-per-packet-if-test", Type::SYSTEM)
933 {
934  AddTestCase(new SatPerPacketFwdLinkUserTestCase, TestCase::Duration::QUICK);
935  AddTestCase(new SatPerPacketFwdLinkUserTestCase("DummyFrames.", SatEnums::FADING_OFF, true),
936  TestCase::Duration::QUICK);
937  AddTestCase(
938  new SatPerPacketFwdLinkUserTestCase("Markov_Fading.", SatEnums::FADING_MARKOV, false),
939  TestCase::Duration::QUICK);
940  AddTestCase(new SatPerPacketFwdLinkUserTestCase("Markov_Fading, DummyFrames.",
941  SatEnums::FADING_MARKOV,
942  true),
943  TestCase::Duration::QUICK);
944  AddTestCase(new SatPerPacketFwdLinkFullTestCase, TestCase::Duration::QUICK);
945 
946  AddTestCase(
947  new SatPerPacketFwdLinkFullTestCase("Markov_Fading.", SatEnums::FADING_MARKOV, false),
948  TestCase::Duration::QUICK);
949  AddTestCase(new SatPerPacketRtnLinkUserTestCase, TestCase::Duration::QUICK);
950  AddTestCase(new SatPerPacketRtnLinkUserTestCase("Markov_Fading.", SatEnums::FADING_MARKOV),
951  TestCase::Duration::QUICK);
952 
953  AddTestCase(new SatPerPacketRtnLinkFullTestCase, TestCase::Duration::QUICK);
954  AddTestCase(new SatPerPacketRtnLinkFullTestCase("Markov_Fading.", SatEnums::FADING_MARKOV),
955  TestCase::Duration::QUICK);
956 }
957 
958 // Do allocate an instance of this TestSuite
virtual void DoRun(void)=0
Test suite for Satellite interference unit test cases.
Class that holds information for each beam regarding UTs and their users camped in each beam.
SatEnums class is for simplifying the use of enumerators in the satellite module.
static std::string GetChannelTypeName(ChannelType_t channelType)
FadingModel_t
Fading models.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SatPerPacketIfTestSuite satSatPerPacketIfTestSuite
static const char * defRtnUserName
Per-packet interference, Return Link System test case.
static const char * defFwdUserName
Per-packet interference, Forward Link System test case.
static const char * defFwdFullName
Per-packet interference, Forward Link System test case.
static void LinkBudgetTraceCb(std::string context, Ptr< SatSignalParameters > params, Mac48Address ownAdd, Mac48Address destAdd, double ifPower, double cSinr)
static const char * defRtnFullName