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::SatGeoHelper::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 
312  // create user defined scenario with beams 1 and 5
313  SatBeamUserInfo beamInfo = SatBeamUserInfo(1, 1);
314  std::map<std::pair<uint32_t, uint32_t>, SatBeamUserInfo> beamMap;
315  beamMap[std::make_pair(0, 1)] = beamInfo;
316  beamMap[std::make_pair(0, 5)] = beamInfo;
317 
318  helper->CreateUserDefinedScenario(beamMap);
319 
320  // set callback traces where we want results out
321 
322  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
323  MakeCallback(&LinkBudgetTraceCb));
324 
325  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
326  MakeCallback(&LinkBudgetTraceCb));
327 
328  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
329  MakeCallback(&LinkBudgetTraceCb));
330 
331  NodeContainer utUsers = helper->GetUtUsers();
332  NodeContainer gwUsers = helper->GetGwUsers();
333  uint16_t port = 9;
334 
335  // create Sink helper
336  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory",
337  InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
338 
339  // install Sink application on UT user 1 to receive packet
340  ApplicationContainer utSinks = sinkHelper.Install(utUsers.Get(0));
341 
342  // install Sink application on UT user 5 to receive packet
343  sinkHelper.SetAttribute(
344  "Local",
345  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(1)), port))));
346  utSinks.Add(sinkHelper.Install(utUsers.Get(1)));
347  utSinks.Start(Seconds(0.1));
348  utSinks.Stop(Seconds(0.5));
349 
350  CbrHelper cbrHelper("ns3::UdpSocketFactory",
351  InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
352 
353  // create application on GW to sent beam 1 (UT user 1)
354  cbrHelper.SetAttribute("Interval", m_Interval1);
355  cbrHelper.SetAttribute("PacketSize", m_PackageSize1);
356 
357  ApplicationContainer gw1Cbr = cbrHelper.Install(gwUsers.Get(0));
358  gw1Cbr.Start(Seconds(0.2));
359  gw1Cbr.Stop(Seconds(0.5));
360 
361  // create application on GW to sent beam 5 (UT user 5)
362  cbrHelper.SetAttribute(
363  "Remote",
364  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(1)), port))));
365  cbrHelper.SetAttribute("Interval", m_Interval2);
366  cbrHelper.SetAttribute("PacketSize", m_PackageSize2);
367 
368  ApplicationContainer gw2Cbr = cbrHelper.Install(gwUsers.Get(1));
369  gw2Cbr.Start(Seconds(0.2));
370  gw2Cbr.Stop(Seconds(1.0));
371 
372  Simulator::Stop(Seconds(1.0));
373  Simulator::Run();
374  PrintTraceInfo();
375 
376  Simulator::Destroy();
377 
378  Singleton<SatEnvVariables>::Get()->DoDispose();
379 }
380 
406 // Default name to show for SatPerPacketFwdLinkFullTestCase test. When the second constructor is
407 // used, the text to append this name can be given.
408 static const char* defFwdFullName =
409  "Test satellite per packet interference in Forward Link with fullscenario. ";
410 
412 {
413  public:
415  SatPerPacketFwdLinkFullTestCase(std::string name,
417  bool dummyFrames);
418  SatPerPacketFwdLinkFullTestCase(std::string name,
420  bool dummyFrames,
421  StringValue ival1,
422  UintegerValue pSize1,
423  StringValue ival2,
424  UintegerValue pSize2);
426 
427  private:
428  virtual void DoRun(void);
429 };
430 
433  "IfTestFwdFull",
434  SatEnums::FADING_OFF,
435  false,
436  StringValue("0.00015s"),
437  UintegerValue(512),
438  StringValue("0.1s"),
439  UintegerValue(512))
440 
441 {
442 }
443 
446  bool dummyFrames)
448  "IfTestFwdFull_" + name,
449  fading,
450  dummyFrames,
451  StringValue("0.00015s"),
452  UintegerValue(512),
453  StringValue("0.1s"),
454  UintegerValue(512))
455 {
456 }
457 
460  bool dummyFrames,
461  StringValue ival1,
462  UintegerValue pSize1,
463  StringValue ival2,
464  UintegerValue pSize2)
466  "IfTestFwdFull_" + name,
467  fading,
468  dummyFrames,
469  ival1,
470  pSize1,
471  ival2,
472  pSize2)
473 {
474 }
475 
477 {
478 }
479 
480 void
482 {
483  Singleton<SatEnvVariables>::Get()->DoInitialize();
484 
485  InitOutput(false);
486 
487  // Set simulation output details
488  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-per-packet-if",
489  m_extName,
490  true);
491 
492  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(m_fading));
493  Config::SetDefault("ns3::SatFwdLinkScheduler::DummyFrameSendingEnabled",
494  BooleanValue(m_dummyFrames));
495 
496  Config::SetDefault("ns3::SatHelper::UtCount", UintegerValue(1));
497  Config::SetDefault("ns3::SatHelper::UtUsers", UintegerValue(1));
498  Config::SetDefault("ns3::SatGeoHelper::DaFwdLinkInterferenceModel",
499  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
500  Config::SetDefault("ns3::SatUtHelper::DaFwdLinkInterferenceModel",
501  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
502  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
503 
504  // Creating the reference system.
505  Ptr<SatHelper> helper = CreateObject<SatHelper>();
506 
507  helper->CreatePredefinedScenario(SatHelper::FULL);
508 
509  // set callback traces where we want results out
510 
511  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
512  MakeCallback(&LinkBudgetTraceCb));
513 
514  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
515  MakeCallback(&LinkBudgetTraceCb));
516 
517  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
518  MakeCallback(&LinkBudgetTraceCb));
519 
520  NodeContainer utUsers = helper->GetUtUsers();
521  NodeContainer gwUsers = helper->GetGwUsers();
522  uint16_t port = 9;
523 
524  // create Sink helper
525  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory",
526  InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
527 
528  // install Sink application on UT user 1 to receive packet
529  ApplicationContainer utSinks = sinkHelper.Install(utUsers.Get(0));
530 
531  // install Sink application on UT user 5 to receive packet
532  sinkHelper.SetAttribute(
533  "Local",
534  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(4)), port))));
535  utSinks.Add(sinkHelper.Install(utUsers.Get(4)));
536  utSinks.Start(Seconds(0.1));
537  utSinks.Stop(Seconds(1.0));
538 
539  CbrHelper cbrHelper("ns3::UdpSocketFactory",
540  InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port));
541 
542  // create application on GW to sent beam 1 (UT user 1)
543  cbrHelper.SetAttribute("Interval", m_Interval1);
544  cbrHelper.SetAttribute("PacketSize", m_PackageSize1);
545 
546  ApplicationContainer gw1Cbr = cbrHelper.Install(gwUsers.Get(0));
547  gw1Cbr.Start(Seconds(0.2));
548  gw1Cbr.Stop(Seconds(0.4));
549 
550  // create application on GW to sent beam 5 (UT user 5)
551  cbrHelper.SetAttribute(
552  "Remote",
553  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(4)), port))));
554  cbrHelper.SetAttribute("Interval", m_Interval2);
555  cbrHelper.SetAttribute("PacketSize", m_PackageSize2);
556 
557  ApplicationContainer gw2Cbr = cbrHelper.Install(gwUsers.Get(4));
558  gw2Cbr.Start(Seconds(0.2));
559  gw2Cbr.Stop(Seconds(0.4));
560 
561  Simulator::Stop(Seconds(1.0));
562  Simulator::Run();
563  PrintTraceInfo();
564 
565  Simulator::Destroy();
566 
567  Singleton<SatEnvVariables>::Get()->DoDispose();
568 }
569 
594 // Default name to show for SatPerPacketRtnLinkUserTestCase test. When the second constructor is
595 // used, the text to append this name can be given.
596 static const char* defRtnUserName =
597  "Test satellite per packet interference in Return Link with user defined scenario. ";
598 
600 {
601  public:
604  SatPerPacketRtnLinkUserTestCase(std::string name,
606  StringValue ival1,
607  UintegerValue pSize1,
608  StringValue ival2,
609  UintegerValue pSize2);
610 
612 
613  private:
614  virtual void DoRun(void);
615 };
616 
619  "IfTestRtnUsr",
620  SatEnums::FADING_OFF,
621  false,
622  StringValue("0.01s"),
623  UintegerValue(512),
624  StringValue("0.01s"),
625  UintegerValue(32))
626 {
627 }
628 
632  "IfTestRtnUsr_" + name,
633  fading,
634  false,
635  StringValue("0.01s"),
636  UintegerValue(512),
637  StringValue("0.01s"),
638  UintegerValue(32))
639 {
640 }
641 
644  StringValue ival1,
645  UintegerValue pSize1,
646  StringValue ival2,
647  UintegerValue pSize2)
649  "IfTestRtnUsr_" + name,
650  fading,
651  false,
652  ival1,
653  pSize1,
654  ival2,
655  pSize2)
656 {
657 }
658 
660 {
661 }
662 
663 void
665 {
666  Singleton<SatEnvVariables>::Get()->DoInitialize();
667 
668  InitOutput(false);
669 
670  // Set simulation output details
671  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-per-packet-if",
672  m_extName,
673  true);
674 
675  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(m_fading));
676  Config::SetDefault("ns3::SatFwdLinkScheduler::DummyFrameSendingEnabled",
677  BooleanValue(m_dummyFrames));
678 
679  Config::SetDefault("ns3::SatHelper::UtCount", UintegerValue(1));
680  Config::SetDefault("ns3::SatHelper::UtUsers", UintegerValue(1));
681  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
682  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_0));
683  Config::SetDefault("ns3::SatSuperframeConf0::FrameCount", UintegerValue(1));
684  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType",
685  EnumValue(SatSuperframeConf::CONFIG_TYPE_0));
686  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_AllocatedBandwidthHz", DoubleValue(1.25e6));
687  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_CarrierAllocatedBandwidthHz",
688  DoubleValue(1.25e6));
689  Config::SetDefault("ns3::SatWaveformConf::DefaultWfId", UintegerValue(13));
690  Config::SetDefault("ns3::SatGwHelper::DaRtnLinkInterferenceModel",
691  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
692  Config::SetDefault("ns3::SatGeoHelper::DaRtnLinkInterferenceModel",
693  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
694  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
695 
696  // Creating the reference system.
697  Ptr<SatHelper> helper = CreateObject<SatHelper>();
698 
699  // create user defined scenario with beams 1 and 5
700  SatBeamUserInfo beamInfo = SatBeamUserInfo(1, 1);
701  std::map<std::pair<uint32_t, uint32_t>, SatBeamUserInfo> beamMap;
702  beamMap[std::make_pair(0, 1)] = beamInfo;
703  beamMap[std::make_pair(0, 5)] = beamInfo;
704 
705  helper->CreateUserDefinedScenario(beamMap);
706 
707  // set callback traces where we want results out
708 
709  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
710  MakeCallback(&LinkBudgetTraceCb));
711 
712  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
713  MakeCallback(&LinkBudgetTraceCb));
714 
715  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
716  MakeCallback(&LinkBudgetTraceCb));
717 
718  NodeContainer utUsers = helper->GetUtUsers();
719  NodeContainer gwUsers = helper->GetGwUsers();
720  uint16_t port = 9;
721 
722  // create Sink helper
723  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory",
724  InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
725 
726  // install Sink application on GW user to receive packet
727  ApplicationContainer gwSink = sinkHelper.Install(gwUsers.Get(0));
728  gwSink.Start(Seconds(0.1));
729  gwSink.Stop(Seconds(0.5));
730 
731  CbrHelper cbrHelper("ns3::UdpSocketFactory",
732  InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
733 
734  // create applications on UT in beam 1
735  cbrHelper.SetAttribute("Interval", m_Interval1);
736  cbrHelper.SetAttribute("PacketSize", m_PackageSize1);
737 
738  ApplicationContainer ut1Cbr = cbrHelper.Install(utUsers.Get(0));
739  ut1Cbr.Start(Seconds(0.1));
740  ut1Cbr.Stop(Seconds(0.4));
741 
742  // create applications on UT in beam 5
743  cbrHelper.SetAttribute("Interval", m_Interval2);
744  cbrHelper.SetAttribute("PacketSize", m_PackageSize2);
745 
746  ApplicationContainer ut5Cbr = cbrHelper.Install(utUsers.Get(1));
747  ut5Cbr.Start(Seconds(0.1));
748  ut5Cbr.Stop(Seconds(0.4));
749 
750  Simulator::Stop(Seconds(1.0));
751  Simulator::Run();
752  PrintTraceInfo();
753 
754  Simulator::Destroy();
755 
756  Singleton<SatEnvVariables>::Get()->DoDispose();
757 }
758 
759 // Default name to show for test. When the second constructor is used, the text to append this name
760 // can be given.
761 static const char* defRtnFullName =
762  "Test satellite per packet interference in Return Link with full defined scenario. ";
763 
765 {
766  public:
768 
770  SatPerPacketRtnLinkFullTestCase(std::string name,
772  StringValue ival1,
773  UintegerValue pSize1,
774  StringValue ival2,
775  UintegerValue pSize2);
777 
778  private:
779  virtual void DoRun(void);
780 };
781 
784  "IfTestRtnFull",
785  SatEnums::FADING_OFF,
786  false,
787  StringValue("0.01s"),
788  UintegerValue(512),
789  StringValue("0.01s"),
790  UintegerValue(32))
791 {
792 }
793 
797  "IfTestRtnFull_" + name,
798  fading,
799  false,
800  StringValue("0.01s"),
801  UintegerValue(512),
802  StringValue("0.01s"),
803  UintegerValue(32))
804 {
805 }
806 
809  StringValue ival1,
810  UintegerValue pSize1,
811  StringValue ival2,
812  UintegerValue pSize2)
814  "IfTestRtnFull_" + name,
815  fading,
816  false,
817  ival1,
818  pSize1,
819  ival2,
820  pSize2)
821 {
822 }
823 
825 {
826 }
827 
828 void
830 {
831  Singleton<SatEnvVariables>::Get()->DoInitialize();
832 
833  InitOutput(false);
834 
835  // Set simulation output details
836  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-per-packet-if",
837  m_extName,
838  true);
839 
840  Config::SetDefault("ns3::SatBeamHelper::FadingModel", EnumValue(m_fading));
841  Config::SetDefault("ns3::SatFwdLinkScheduler::DummyFrameSendingEnabled",
842  BooleanValue(m_dummyFrames));
843 
844  Config::SetDefault("ns3::SatHelper::UtCount", UintegerValue(1));
845  Config::SetDefault("ns3::SatHelper::UtUsers", UintegerValue(1));
846  Config::SetDefault("ns3::SatConf::SuperFrameConfForSeq0",
847  EnumValue(SatSuperframeConf::SUPER_FRAME_CONFIG_0));
848  Config::SetDefault("ns3::SatSuperframeConf0::FrameCount", UintegerValue(1));
849  Config::SetDefault("ns3::SatSuperframeConf0::FrameConfigType",
850  EnumValue(SatSuperframeConf::CONFIG_TYPE_0));
851  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_AllocatedBandwidthHz", DoubleValue(1.25e6));
852  Config::SetDefault("ns3::SatSuperframeConf0::Frame0_CarrierAllocatedBandwidthHz",
853  DoubleValue(1.25e6));
854  Config::SetDefault("ns3::SatWaveformConf::DefaultWfId", UintegerValue(13));
855  Config::SetDefault("ns3::SatGwHelper::DaRtnLinkInterferenceModel",
856  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
857  Config::SetDefault("ns3::SatGeoHelper::DaRtnLinkInterferenceModel",
858  EnumValue(SatPhyRxCarrierConf::IF_PER_PACKET));
859  Config::SetDefault("ns3::SatPhyRxCarrierConf::EnableIntfOutputTrace", BooleanValue(true));
860 
861  // Creating the reference system.
862  Ptr<SatHelper> helper = CreateObject<SatHelper>();
863  helper->CreatePredefinedScenario(SatHelper::FULL);
864 
865  // set callback traces where we want results out
866 
867  Config::Connect("/NodeList/*/DeviceList/*/SatPhy/PhyRx/RxCarrierList/*/LinkBudgetTrace",
868  MakeCallback(&LinkBudgetTraceCb));
869 
870  Config::Connect("/NodeList/*/DeviceList/*/UserPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
871  MakeCallback(&LinkBudgetTraceCb));
872 
873  Config::Connect("/NodeList/*/DeviceList/*/FeederPhy/*/PhyRx/RxCarrierList/*/LinkBudgetTrace",
874  MakeCallback(&LinkBudgetTraceCb));
875 
876  NodeContainer utUsers = helper->GetUtUsers();
877  NodeContainer gwUsers = helper->GetGwUsers();
878  uint16_t port = 9;
879 
880  // create Sink helper
881  PacketSinkHelper sinkHelper("ns3::UdpSocketFactory",
882  InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
883 
884  // install Sink application on GW user to receive packet
885  ApplicationContainer gwSink = sinkHelper.Install(gwUsers.Get(0));
886  gwSink.Start(Seconds(0.1));
887  gwSink.Stop(Seconds(0.5));
888 
889  CbrHelper cbrHelper("ns3::UdpSocketFactory",
890  InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port));
891 
892  // create applications on UT in beam 1
893  cbrHelper.SetAttribute("Interval", m_Interval1);
894  cbrHelper.SetAttribute("PacketSize", m_PackageSize1);
895 
896  ApplicationContainer ut1Cbr = cbrHelper.Install(utUsers.Get(0));
897  ut1Cbr.Start(Seconds(0.1));
898  ut1Cbr.Stop(Seconds(0.4));
899 
900  // create applications on UT in beam 5
901  cbrHelper.SetAttribute("Interval", m_Interval2);
902  cbrHelper.SetAttribute("PacketSize", m_PackageSize2);
903 
904  ApplicationContainer ut5Cbr = cbrHelper.Install(utUsers.Get(4));
905  ut5Cbr.Start(Seconds(0.1));
906  ut5Cbr.Stop(Seconds(0.4));
907 
908  Simulator::Stop(Seconds(1.0));
909  Simulator::Run();
910  PrintTraceInfo();
911 
912  Simulator::Destroy();
913 
914  Singleton<SatEnvVariables>::Get()->DoDispose();
915 }
916 
921 class SatPerPacketIfTestSuite : public TestSuite
922 {
923  public:
925 };
926 
928  : TestSuite("sat-per-packet-if-test", SYSTEM)
929 {
930  AddTestCase(new SatPerPacketFwdLinkUserTestCase, TestCase::QUICK);
931  AddTestCase(new SatPerPacketFwdLinkUserTestCase("DummyFrames.", SatEnums::FADING_OFF, true),
932  TestCase::QUICK);
933  AddTestCase(
934  new SatPerPacketFwdLinkUserTestCase("Markov_Fading.", SatEnums::FADING_MARKOV, false),
935  TestCase::QUICK);
936  AddTestCase(new SatPerPacketFwdLinkUserTestCase("Markov_Fading, DummyFrames.",
937  SatEnums::FADING_MARKOV,
938  true),
939  TestCase::QUICK);
940  AddTestCase(new SatPerPacketFwdLinkFullTestCase, TestCase::QUICK);
941 
942  AddTestCase(
943  new SatPerPacketFwdLinkFullTestCase("Markov_Fading.", SatEnums::FADING_MARKOV, false),
944  TestCase::QUICK);
945  AddTestCase(new SatPerPacketRtnLinkUserTestCase, TestCase::QUICK);
946  AddTestCase(new SatPerPacketRtnLinkUserTestCase("Markov_Fading.", SatEnums::FADING_MARKOV),
947  TestCase::QUICK);
948 
949  AddTestCase(new SatPerPacketRtnLinkFullTestCase, TestCase::QUICK);
950  AddTestCase(new SatPerPacketRtnLinkFullTestCase("Markov_Fading.", SatEnums::FADING_MARKOV),
951  TestCase::QUICK);
952 }
953 
954 // 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