satellite-simple-unicast.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 
31 #include "../helper/satellite-helper.h"
32 #include "../utils/satellite-env-variables.h"
33 
34 #include "ns3/cbr-application.h"
35 #include "ns3/cbr-helper.h"
36 #include "ns3/config.h"
37 #include "ns3/enum.h"
38 #include "ns3/log.h"
39 #include "ns3/packet-sink-helper.h"
40 #include "ns3/packet-sink.h"
41 #include "ns3/simulator.h"
42 #include "ns3/singleton.h"
43 #include "ns3/string.h"
44 #include "ns3/test.h"
45 
46 using namespace ns3;
47 
64 class SimpleUnicast1 : public TestCase
65 {
66  public:
68  virtual ~SimpleUnicast1();
69 
70  private:
71  virtual void DoRun(void);
72 };
73 
74 // Add some help text to this case to describe what it is intended to test
76  : TestCase("'Forward Link Unicast, Simple' case tests successful transmission of a single UDP "
77  "packet from GW connected user to UT connected user in simple scenario.")
78 {
79 }
80 
81 // This destructor does nothing but we include it as a reminder that
82 // the test case should clean up after itself
84 {
85 }
86 
87 //
88 // SimpleUnicast1 TestCase implementation
89 //
90 void
92 {
93  // Set simulation output details
94  Singleton<SatEnvVariables>::Get()->DoInitialize();
95  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-simple-unicast",
96  "unicast1",
97  true);
98 
99  // Create simple scenario
100 
101  // Configure a static error probability
102  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
103  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
104  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
105 
106  // Creating the reference system.
107  Ptr<SatHelper> helper = CreateObject<SatHelper>();
108  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
109 
110  NodeContainer utUsers = helper->GetUtUsers();
111 
112  // >>> Start of actual test using Simple scenario >>>
113 
114  // Create the Cbr application to send UDP datagrams of size
115  // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 1s)
116  uint16_t port = 9; // Discard port (RFC 863)
117  CbrHelper cbr("ns3::UdpSocketFactory",
118  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
119  cbr.SetAttribute("Interval", StringValue("1s"));
120 
121  ApplicationContainer gwApps = cbr.Install(helper->GetGwUsers());
122  gwApps.Start(Seconds(1.0));
123  gwApps.Stop(Seconds(2.1));
124 
125  // Create a packet sink to receive these packets
126  PacketSinkHelper sink("ns3::UdpSocketFactory",
127  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
128 
129  ApplicationContainer utApps = sink.Install(utUsers);
130  utApps.Start(Seconds(1.0));
131  utApps.Stop(Seconds(3.0));
132 
133  Simulator::Stop(Seconds(11));
134  Simulator::Run();
135 
136  Simulator::Destroy();
137 
138  Ptr<PacketSink> receiver = DynamicCast<PacketSink>(utApps.Get(0));
139  Ptr<CbrApplication> sender = DynamicCast<CbrApplication>(gwApps.Get(0));
140 
141  // here we check that results are as expected.
142  // * Sender has sent something
143  // * Receiver got all all data sent
144  NS_TEST_ASSERT_MSG_NE(sender->GetSent(), (uint32_t)0, "Nothing sent!");
145  NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(), sender->GetSent(), "Packets were lost!");
146 
147  Singleton<SatEnvVariables>::Get()->DoDispose();
148  // <<< End of actual test using Simple scenario <<<
149 }
150 
168 class SimpleUnicast2 : public TestCase
169 {
170  public:
171  SimpleUnicast2();
172  virtual ~SimpleUnicast2();
173 
174  private:
175  virtual void DoRun(void);
176 };
177 
178 // Add some help text to this case to describe what it is intended to test
180  : TestCase("'Forward Link Unicast, Larger' case tests successful transmission of a single UDP "
181  "packet from GW connected user to UT connected users in larger scenario.")
182 {
183 }
184 
185 // This destructor does nothing but we include it as a reminder that
186 // the test case should clean up after itself
188 {
189 }
190 
191 //
192 // SimpleUnicast2 TestCase implementation
193 //
194 void
196 {
197  // Set simulation output details
198  Singleton<SatEnvVariables>::Get()->DoInitialize();
199  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-simple-unicast",
200  "unicast2",
201  true);
202 
203  // Create larger scenario
204 
205  // Configure a static error probability
206  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
207  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
208  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
209 
210  // Creating the reference system.
211  Ptr<SatHelper> helper = CreateObject<SatHelper>();
212  helper->CreatePredefinedScenario(SatHelper::LARGER);
213 
214  NodeContainer utUsers = helper->GetUtUsers();
215 
216  // >>> Start of actual test using Larger scenario >>>
217 
218  // port used for packet delivering
219  uint16_t port = 9; // Discard port (RFC 863)
220 
221  // Create the Cbr applications to send UDP datagrams of size
222  // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 1s)
223 
224  // app to send receiver 1
225  CbrHelper cbr("ns3::UdpSocketFactory",
226  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
227  cbr.SetAttribute("Interval", StringValue("1s"));
228  ApplicationContainer gwApps = cbr.Install(helper->GetGwUsers());
229 
230  // app to send receiver 2
231  cbr.SetAttribute(
232  "Remote",
233  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(4)), port))));
234  gwApps.Add(cbr.Install(helper->GetGwUsers()));
235 
236  gwApps.Start(Seconds(1.0));
237  gwApps.Stop(Seconds(2.1));
238 
239  // Create a packet sinks to receive these packets
240 
241  // receiver 1
242  PacketSinkHelper sink("ns3::UdpSocketFactory",
243  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
244  ApplicationContainer utApps = sink.Install(utUsers.Get(0));
245 
246  // receiver 2
247  sink.SetAttribute(
248  "Local",
249  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(4)), port))));
250  utApps.Add(sink.Install(utUsers.Get(4)));
251 
252  utApps.Start(Seconds(1.0));
253  utApps.Stop(Seconds(3.0));
254 
255  Simulator::Stop(Seconds(11));
256  Simulator::Run();
257 
258  Simulator::Destroy();
259 
260  Ptr<PacketSink> receiver1 = DynamicCast<PacketSink>(utApps.Get(0));
261  Ptr<CbrApplication> sender1 = DynamicCast<CbrApplication>(gwApps.Get(0));
262 
263  Ptr<PacketSink> receiver2 = DynamicCast<PacketSink>(utApps.Get(1));
264  Ptr<CbrApplication> sender2 = DynamicCast<CbrApplication>(gwApps.Get(1));
265 
266  // here we check that results are as expected.
267  // * Senders have sent something
268  // * Receivers got all all data sent
269 
270  NS_TEST_ASSERT_MSG_NE(sender1->GetSent(), (uint32_t)0, "Nothing sent by sender 1!");
271  NS_TEST_ASSERT_MSG_EQ(receiver1->GetTotalRx(),
272  sender1->GetSent(),
273  "Packets were lost between sender 1 and receiver 1!");
274 
275  NS_TEST_ASSERT_MSG_NE(sender2->GetSent(), (uint32_t)0, "Nothing sent !");
276  NS_TEST_ASSERT_MSG_EQ(receiver2->GetTotalRx(),
277  sender2->GetSent(),
278  "Packets were lost between sender 2 and receiver 2!");
279 
280  Singleton<SatEnvVariables>::Get()->DoDispose();
281  // <<< End of actual test using Larger scenario <<<
282 }
283 
301 class SimpleUnicast3 : public TestCase
302 {
303  public:
304  SimpleUnicast3();
305  virtual ~SimpleUnicast3();
306 
307  private:
308  virtual void DoRun(void);
309 };
310 
311 // Add some help text to this case to describe what it is intended to test
313  : TestCase("'Forward Link Unicast, Full' case tests successful transmission of a single UDP "
314  "packet from GW connected user to UT connected users in full scenario.")
315 {
316 }
317 
318 // This destructor does nothing but we include it as a reminder that
319 // the test case should clean up after itself
321 {
322 }
323 
324 //
325 // SimpleUnicast3 TestCase implementation
326 //
327 void
329 {
330  // Set simulation output details
331  Singleton<SatEnvVariables>::Get()->DoInitialize();
332  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-simple-unicast",
333  "unicast3",
334  true);
335 
336  // Create full scenario
337 
338  // Configure a static error probability
339  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
340  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
341  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
342 
343  // Creating the reference system.
344  Ptr<SatHelper> helper = CreateObject<SatHelper>();
345  helper->CreatePredefinedScenario(SatHelper::FULL);
346 
347  NodeContainer utUsers = helper->GetUtUsers();
348  NodeContainer gwUsers = helper->GetGwUsers();
349 
350  // >>> Start of actual test using Full scenario >>>
351 
352  // port used for packet delivering
353  uint16_t port = 9; // Discard port (RFC 863)
354 
355  // Create the Cbr applications to send UDP datagrams of size
356  // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 0.5s)
357  Time cbrInterval = Seconds(0.5);
358  CbrHelper cbr("ns3::UdpSocketFactory",
359  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
360  cbr.SetAttribute("Interval", TimeValue(cbrInterval));
361 
362  PacketSinkHelper sink("ns3::UdpSocketFactory",
363  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
364 
365  // initialized time values for simulation
366  uint32_t maxReceivers = utUsers.GetN();
367  Time cbrStartDelay = Seconds(0.01);
368  Time cbrStopDelay = Seconds(0.1);
369  Time stopTime =
370  Seconds(maxReceivers * cbrStartDelay.GetSeconds()) + cbrInterval + cbrInterval + Seconds(5);
371 
372  ApplicationContainer gwApps;
373  ApplicationContainer utApps;
374 
375  // Cbr and Sink applications creation
376  for (uint32_t i = 0; i < maxReceivers; i++)
377  {
378  cbr.SetAttribute(
379  "Remote",
380  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(i)), port))));
381  sink.SetAttribute(
382  "Local",
383  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(i)), port))));
384 
385  gwApps.Add(cbr.Install(gwUsers.Get(4)));
386  utApps.Add(sink.Install(utUsers.Get(i)));
387 
388  cbrStartDelay += Seconds(0.01);
389 
390  gwApps.Get(i)->SetStartTime(cbrStartDelay);
391  gwApps.Get(i)->SetStopTime(cbrStartDelay + cbrInterval + cbrStopDelay);
392  }
393 
394  utApps.Start(Seconds(0.00001));
395  utApps.Stop(stopTime);
396 
397  Simulator::Stop(stopTime);
398  Simulator::Run();
399 
400  Simulator::Destroy();
401 
402  // here we check that results are as expected.
403  // * Senders have sent something
404  // * Receivers got all all data sent
405 
406  for (uint32_t i = 0; i < maxReceivers; i++)
407  {
408  Ptr<PacketSink> receiver = DynamicCast<PacketSink>(utApps.Get(i));
409  Ptr<CbrApplication> sender = DynamicCast<CbrApplication>(gwApps.Get(i));
410 
411  NS_TEST_ASSERT_MSG_NE(sender->GetSent(), (uint32_t)0, "Nothing sent by sender" << i << "!");
412  NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(),
413  sender->GetSent(),
414  "Packets were lost between sender and receiver" << i << "!");
415  }
416 
417  Singleton<SatEnvVariables>::Get()->DoDispose();
418  // <<< End of actual test using Full scenario <<<
419 }
420 
437 class SimpleUnicast4 : public TestCase
438 {
439  public:
440  SimpleUnicast4();
441  virtual ~SimpleUnicast4();
442 
443  private:
444  virtual void DoRun(void);
445 };
446 
447 // Add some help text to this case to describe what it is intended to test
449  : TestCase("'Return Link Unicast, Simple' case tests successful transmission of a single UDP "
450  "packet from UT connected user to GW connected user in simple scenario.")
451 {
452 }
453 
454 // This destructor does nothing but we include it as a reminder that
455 // the test case should clean up after itself
457 {
458 }
459 
460 //
461 // SimpleUnicast4 TestCase implementation
462 //
463 void
465 {
466  // Set simulation output details
467  Singleton<SatEnvVariables>::Get()->DoInitialize();
468  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-simple-unicast",
469  "unicast4",
470  true);
471 
472  // Create simple scenario
473 
474  // Configure a static error probability
475  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
476  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
477  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
478 
479  // Creating the reference system.
480  Ptr<SatHelper> helper = CreateObject<SatHelper>();
481  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
482 
483  // >>> Start of actual test using Simple scenario >>>
484 
485  NodeContainer gwUsers = helper->GetGwUsers();
486 
487  // Create the Cbr application to send UDP datagrams of size
488  // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 1s)
489  uint16_t port = 9; // Discard port (RFC 863)
490  CbrHelper cbr("ns3::UdpSocketFactory",
491  Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
492  cbr.SetAttribute("Interval", StringValue("1s"));
493 
494  ApplicationContainer utApps = cbr.Install(helper->GetUtUsers());
495  utApps.Start(Seconds(1.0));
496  utApps.Stop(Seconds(2.1));
497 
498  // Create a packet sink to receive these packets
499  PacketSinkHelper sink("ns3::UdpSocketFactory",
500  Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
501 
502  ApplicationContainer gwApps = sink.Install(gwUsers);
503  gwApps.Start(Seconds(1.0));
504  gwApps.Stop(Seconds(3.0));
505 
506  Simulator::Stop(Seconds(11));
507  Simulator::Run();
508 
509  Simulator::Destroy();
510 
511  Ptr<PacketSink> receiver = DynamicCast<PacketSink>(gwApps.Get(0));
512  Ptr<CbrApplication> sender = DynamicCast<CbrApplication>(utApps.Get(0));
513 
514  // here we check that results are as expected.
515  // * Sender has sent something
516  // * Receiver got all all data sent
517  NS_TEST_ASSERT_MSG_NE(sender->GetSent(), (uint32_t)0, "Nothing sent !");
518  NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(), sender->GetSent(), "Packets were lost !");
519 
520  Singleton<SatEnvVariables>::Get()->DoDispose();
521  // <<< End of actual test using Simple scenario <<<
522 }
523 
541 class SimpleUnicast5 : public TestCase
542 {
543  public:
544  SimpleUnicast5();
545  virtual ~SimpleUnicast5();
546 
547  private:
548  virtual void DoRun(void);
549 };
550 
551 // Add some help text to this case to describe what it is intended to test
553  : TestCase("'Return Link Unicast, Larger' case tests successful transmission of a single UDP "
554  "packet from UT connected user to GW connected user in larger scenario.")
555 {
556 }
557 
558 // This destructor does nothing but we include it as a reminder that
559 // the test case should clean up after itself
561 {
562 }
563 
564 //
565 // SimpleUnicast5 TestCase implementation
566 //
567 void
569 {
570  // Set simulation output details
571  Singleton<SatEnvVariables>::Get()->DoInitialize();
572  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-simple-unicast",
573  "unicast5",
574  true);
575 
576  // Create larger scenario
577 
578  // Configure a static error probability
579  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
580  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
581  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
582 
583  // Creating the reference system.
584  Ptr<SatHelper> helper = CreateObject<SatHelper>();
585  helper->CreatePredefinedScenario(SatHelper::LARGER);
586 
587  // >>> Start of actual test using Larger scenario >>>
588 
589  NodeContainer gwUsers = helper->GetGwUsers();
590  NodeContainer utUsers = helper->GetUtUsers();
591 
592  // port used for packet delivering
593  uint16_t port = 9; // Discard port (RFC 863)
594 
595  // Create the Cbr applications to send UDP datagrams of size
596  // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 1s)
597 
598  // sender 1
599  CbrHelper cbr("ns3::UdpSocketFactory",
600  Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
601  cbr.SetAttribute("Interval", StringValue("1s"));
602  ApplicationContainer utApps = cbr.Install(utUsers.Get(0));
603 
604  // sender 2
605  utApps.Add(cbr.Install(utUsers.Get(4)));
606 
607  utApps.Start(Seconds(1.0));
608  utApps.Stop(Seconds(2.1));
609 
610  // Create a packet sink to receive these packets
611  PacketSinkHelper sink("ns3::UdpSocketFactory",
612  Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port)));
613 
614  ApplicationContainer gwApps = sink.Install(gwUsers);
615  gwApps.Start(Seconds(1.0));
616  gwApps.Stop(Seconds(3.0));
617 
618  Simulator::Stop(Seconds(11));
619  Simulator::Run();
620 
621  Simulator::Destroy();
622 
623  Ptr<PacketSink> receiver = DynamicCast<PacketSink>(gwApps.Get(0));
624  Ptr<CbrApplication> sender1 = DynamicCast<CbrApplication>(utApps.Get(0));
625  Ptr<CbrApplication> sender2 = DynamicCast<CbrApplication>(utApps.Get(1));
626 
627  // here we check that results are as expected.
628  // * Senders have sent something
629  // * Receiver got all all data sent
630  NS_TEST_ASSERT_MSG_NE(sender1->GetSent(), (uint32_t)0, "Nothing sent by sender 1!");
631  NS_TEST_ASSERT_MSG_NE(sender2->GetSent(), (uint32_t)0, "Nothing sent by sender 2!");
632  NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(),
633  sender1->GetSent() + sender2->GetSent(),
634  "Packets were lost!");
635 
636  Singleton<SatEnvVariables>::Get()->DoDispose();
637  // <<< End of actual test using Larger scenario <<<
638 }
639 
656 class SimpleUnicast6 : public TestCase
657 {
658  public:
659  SimpleUnicast6();
660  virtual ~SimpleUnicast6();
661 
662  private:
663  virtual void DoRun(void);
664 };
665 
666 // Add some help text to this case to describe what it is intended to test
668  : TestCase("'Return Link Unicast, Full' case tests successful transmission of a single UDP "
669  "packet from UT connected user to GW connected user in full scenario.")
670 {
671 }
672 
673 // This destructor does nothing but we include it as a reminder that
674 // the test case should clean up after itself
676 {
677 }
678 
679 //
680 // SimpleUnicast6 TestCase implementation
681 //
682 void
684 {
685  // Set simulation output details
686  Singleton<SatEnvVariables>::Get()->DoInitialize();
687  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-simple-unicast",
688  "unicast6",
689  true);
690 
691  // Create full scenario
692 
693  // Configure a static error probability
694  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
695  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
696  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
697 
698  // Creating the reference system.
699  Ptr<SatHelper> helper = CreateObject<SatHelper>();
700  helper->CreatePredefinedScenario(SatHelper::FULL);
701 
702  // >>> Start of actual test using Full scenario >>>
703 
704  NodeContainer gwUsers = helper->GetGwUsers();
705  NodeContainer utUsers = helper->GetUtUsers();
706 
707  // >>> Start of actual test using Full scenario >>>
708 
709  // port used for packet delivering
710  uint16_t port = 9; // Discard port (RFC 863)
711 
712  // Create a packet sink to receive these packets
713  PacketSinkHelper sink("ns3::UdpSocketFactory",
714  Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(3)), port)));
715 
716  // Create the Cbr applications to send UDP datagrams of size
717  // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 0.5s)
718  Time cbrInterval = Seconds(0.01);
719  CbrHelper cbr("ns3::UdpSocketFactory",
720  Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(3)), port)));
721  cbr.SetAttribute("Interval", TimeValue(cbrInterval));
722 
723  // initialized time values for simulation
724  uint32_t maxReceivers = utUsers.GetN();
725  Time cbrStartDelay = Seconds(1.0);
726  Time cbrStopDelay = Seconds(0.005);
727  Time stopTime = Seconds(maxReceivers * 0.04) + cbrStartDelay + cbrInterval + cbrStopDelay;
728 
729  ApplicationContainer utApps;
730 
731  // Cbr applications creation
732  for (uint32_t i = 0; i < maxReceivers; i++)
733  {
734  utApps.Add(cbr.Install(utUsers.Get(i)));
735 
736  cbrStartDelay += Seconds(0.03);
737 
738  utApps.Get(i)->SetStartTime(cbrStartDelay);
739  utApps.Get(i)->SetStopTime(cbrStartDelay + cbrInterval + cbrStopDelay);
740  }
741 
742  ApplicationContainer gwApps = sink.Install(gwUsers.Get(3));
743  gwApps.Start(Seconds(0.001));
744  gwApps.Stop(stopTime);
745 
746  Simulator::Stop(stopTime);
747  Simulator::Run();
748 
749  Simulator::Destroy();
750 
751  // here we check that results are as expected.
752  // * Senders have sent something
753  // * Receiver got all all data sent
754 
755  uint32_t totalTxBytes = 0;
756  Ptr<PacketSink> receiver = DynamicCast<PacketSink>(gwApps.Get(0));
757 
758  for (uint32_t i = 0; i < maxReceivers; i++)
759  {
760  Ptr<CbrApplication> sender = DynamicCast<CbrApplication>(utApps.Get(i));
761 
762  NS_TEST_ASSERT_MSG_NE(sender->GetSent(), (uint32_t)0, "Nothing sent by sender " << i + 1);
763  totalTxBytes += sender->GetSent();
764  }
765 
766  NS_TEST_ASSERT_MSG_EQ(receiver->GetTotalRx(), totalTxBytes, "Packets were lost!");
767 
768  Singleton<SatEnvVariables>::Get()->DoDispose();
769  // <<< End of actual test using Full scenario <<<
770 }
771 
789 class SimpleUnicast7 : public TestCase
790 {
791  public:
792  SimpleUnicast7();
793  virtual ~SimpleUnicast7();
794 
795  private:
796  virtual void DoRun(void);
797 };
798 
799 // Add some help text to this case to describe what it is intended to test
801  : TestCase(
802  "'Two-way Unicast, Simple' case tests successful transmission of a single TCP packet "
803  "from GW connected and UT connected users to each other's in simple scenario.")
804 {
805 }
806 
807 // This destructor does nothing but we include it as a reminder that
808 // the test case should clean up after itself
810 {
811 }
812 
813 //
814 // SimpleUnicast7 TestCase implementation
815 //
816 void
818 {
819  // Set simulation output details
820  Singleton<SatEnvVariables>::Get()->DoInitialize();
821  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-simple-unicast",
822  "unicast7",
823  true);
824 
825  // Create simple scenario
826 
827  // Configure a static error probability
828  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
829  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
830  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
831 
832  // Creating the reference system.
833  Ptr<SatHelper> helper = CreateObject<SatHelper>();
834  helper->CreatePredefinedScenario(SatHelper::SIMPLE);
835 
836  NodeContainer utUsers = helper->GetUtUsers();
837  NodeContainer gwUsers = helper->GetGwUsers();
838 
839  // >>> Start of actual test using Simple scenario >>>
840 
841  // Create the Cbr application to send UDP datagrams of size
842  // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 1s)
843  uint16_t port = 9; // Discard port (RFC 863)
844  CbrHelper cbr("ns3::TcpSocketFactory",
845  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
846 
847  cbr.SetAttribute("Interval", StringValue("1s"));
848 
849  // create CBR application in GW
850  ApplicationContainer gwCbrApp = cbr.Install(gwUsers);
851  gwCbrApp.Start(Seconds(1.0));
852  gwCbrApp.Stop(Seconds(2.9));
853 
854  // Create a packet sink to receive these packets
855  PacketSinkHelper sink("ns3::TcpSocketFactory",
856  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
857 
858  ApplicationContainer utSinkApp = sink.Install(utUsers);
859  utSinkApp.Start(Seconds(1.0));
860  utSinkApp.Stop(Seconds(9.0));
861 
862  // set sink and cbr addresses from GW user
863  sink.SetAttribute(
864  "Local",
865  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port))));
866  cbr.SetAttribute(
867  "Remote",
868  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port))));
869 
870  ApplicationContainer gwSinkApp = sink.Install(gwUsers);
871  gwSinkApp.Start(Seconds(1.0));
872  gwSinkApp.Stop(Seconds(9.0));
873 
874  ApplicationContainer utCbrApp = cbr.Install(utUsers);
875  utCbrApp.Start(Seconds(1.0));
876  utCbrApp.Stop(Seconds(2.9));
877 
878  Simulator::Stop(Seconds(15));
879  Simulator::Run();
880 
881  Simulator::Destroy();
882 
883  Ptr<PacketSink> utReceiver = DynamicCast<PacketSink>(utSinkApp.Get(0));
884  Ptr<CbrApplication> gwSender = DynamicCast<CbrApplication>(gwCbrApp.Get(0));
885 
886  Ptr<PacketSink> gwReceiver = DynamicCast<PacketSink>(gwSinkApp.Get(0));
887  Ptr<CbrApplication> utSender = DynamicCast<CbrApplication>(utCbrApp.Get(0));
888 
889  // here we check that results are as expected.
890  // * Sender has sent something
891  // * Receiver got all all data sent
892  NS_TEST_ASSERT_MSG_NE(gwSender->GetSent(), (uint32_t)0, "Nothing sent by GW app!");
893  NS_TEST_ASSERT_MSG_EQ(utReceiver->GetTotalRx(),
894  gwSender->GetSent(),
895  "Packets were lost to UT!");
896 
897  NS_TEST_ASSERT_MSG_NE(utSender->GetSent(), (uint32_t)0, "Nothing sent by UT app!");
898  NS_TEST_ASSERT_MSG_EQ(gwReceiver->GetTotalRx(),
899  utSender->GetSent(),
900  "Packets were lost to GW!");
901 
902  Singleton<SatEnvVariables>::Get()->DoDispose();
903  // <<< End of actual test using Simple scenario <<<
904 }
905 
923 class SimpleUnicast8 : public TestCase
924 {
925  public:
926  SimpleUnicast8();
927  virtual ~SimpleUnicast8();
928 
929  private:
930  virtual void DoRun(void);
931 };
932 
933 // Add some help text to this case to describe what it is intended to test
935  : TestCase(
936  "'Two-way Unicast, Larger' case tests successful transmission of a single TCP packet "
937  "from GW connected and UT connected users to each other's in larger scenario.")
938 {
939 }
940 
941 // This destructor does nothing but we include it as a reminder that
942 // the test case should clean up after itself
944 {
945 }
946 
947 //
948 // SimpleUnicast8 TestCase implementation
949 //
950 void
952 {
953  // Set simulation output details
954  Singleton<SatEnvVariables>::Get()->DoInitialize();
955  Singleton<SatEnvVariables>::Get()->SetOutputVariables("test-sat-simple-unicast",
956  "unicast8",
957  true);
958 
959  // Create Larger scenario
960 
961  // Configure a static error probability
962  SatPhyRxCarrierConf::ErrorModel em(SatPhyRxCarrierConf::EM_NONE);
963  Config::SetDefault("ns3::SatUtHelper::FwdLinkErrorModel", EnumValue(em));
964  Config::SetDefault("ns3::SatGwHelper::RtnLinkErrorModel", EnumValue(em));
965 
966  // Creating the reference system.
967  Ptr<SatHelper> helper = CreateObject<SatHelper>();
968  helper->CreatePredefinedScenario(SatHelper::LARGER);
969 
970  NodeContainer utUsers = helper->GetUtUsers();
971  NodeContainer gwUsers = helper->GetGwUsers();
972 
973  // >>> Start of actual test using Simple scenario >>>
974 
975  // Create the Cbr application to send UDP datagrams of size
976  // 512 bytes at a rate of 500 Kb/s (defaults), one packet send (interval 1s)
977  uint16_t port = 9; // Discard port (RFC 863)
978  CbrHelper cbr("ns3::TcpSocketFactory",
979  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
980 
981  cbr.SetAttribute("Interval", StringValue("1s"));
982 
983  // create CBR applications in GW
984  ApplicationContainer gwCbrApps = cbr.Install(gwUsers);
985 
986  cbr.SetAttribute(
987  "Remote",
988  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(4)), port))));
989  gwCbrApps.Add(cbr.Install(gwUsers));
990 
991  gwCbrApps.Start(Seconds(1.0));
992  gwCbrApps.Stop(Seconds(2.9));
993 
994  // Create a packet sinks to receive these packets
995  PacketSinkHelper sink("ns3::TcpSocketFactory",
996  Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(0)), port)));
997 
998  ApplicationContainer utSinkApps = sink.Install(utUsers.Get(0));
999 
1000  sink.SetAttribute(
1001  "Local",
1002  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(utUsers.Get(4)), port))));
1003  utSinkApps.Add(sink.Install(utUsers.Get(4)));
1004 
1005  utSinkApps.Start(Seconds(1.0));
1006  utSinkApps.Stop(Seconds(9.0));
1007 
1008  // set sink and cbr addresses from GW user
1009  sink.SetAttribute(
1010  "Local",
1011  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port))));
1012  cbr.SetAttribute(
1013  "Remote",
1014  AddressValue(Address(InetSocketAddress(helper->GetUserAddress(gwUsers.Get(0)), port))));
1015 
1016  // create GW sink to receive packets from UTs
1017  ApplicationContainer gwSinkApp = sink.Install(gwUsers);
1018  gwSinkApp.Start(Seconds(1.0));
1019  gwSinkApp.Stop(Seconds(9.0));
1020 
1021  // create UT cbr apps to send packets to GW
1022  ApplicationContainer utCbrApps = cbr.Install(utUsers.Get(4));
1023  utCbrApps.Add(cbr.Install(utUsers.Get(0)));
1024  utCbrApps.Start(Seconds(1.0));
1025  utCbrApps.Stop(Seconds(2.9));
1026 
1027  Simulator::Stop(Seconds(15));
1028  Simulator::Run();
1029 
1030  Simulator::Destroy();
1031 
1032  Ptr<PacketSink> utReceiver1 = DynamicCast<PacketSink>(utSinkApps.Get(0));
1033  Ptr<PacketSink> utReceiver2 = DynamicCast<PacketSink>(utSinkApps.Get(1));
1034  Ptr<CbrApplication> gwSender1 = DynamicCast<CbrApplication>(gwCbrApps.Get(0));
1035  Ptr<CbrApplication> gwSender2 = DynamicCast<CbrApplication>(gwCbrApps.Get(1));
1036 
1037  Ptr<PacketSink> gwReceiver = DynamicCast<PacketSink>(gwSinkApp.Get(0));
1038  Ptr<CbrApplication> utSender1 = DynamicCast<CbrApplication>(utCbrApps.Get(0));
1039  Ptr<CbrApplication> utSender2 = DynamicCast<CbrApplication>(utCbrApps.Get(1));
1040 
1041  // here we check that results are as expected.
1042  // * Sender has sent something
1043  // * Receiver got all all data sent
1044  NS_TEST_ASSERT_MSG_NE(gwSender1->GetSent(), (uint32_t)0, "Nothing sent by GW app 1!");
1045  NS_TEST_ASSERT_MSG_EQ(utReceiver1->GetTotalRx(),
1046  gwSender1->GetSent(),
1047  "Packets were lost to UT1!");
1048 
1049  NS_TEST_ASSERT_MSG_NE(gwSender2->GetSent(), (uint32_t)0, "Nothing sent by GW app 2!");
1050  NS_TEST_ASSERT_MSG_EQ(utReceiver2->GetTotalRx(),
1051  gwSender2->GetSent(),
1052  "Packets were lost to UT2!");
1053 
1054  NS_TEST_ASSERT_MSG_NE(utSender1->GetSent(), (uint32_t)0, "Nothing sent by UT app 1!");
1055  NS_TEST_ASSERT_MSG_NE(utSender2->GetSent(), (uint32_t)0, "Nothing sent by UT app 2!");
1056  NS_TEST_ASSERT_MSG_EQ(gwReceiver->GetTotalRx(),
1057  utSender1->GetSent() + utSender2->GetSent(),
1058  "Packets were lost to GW!");
1059 
1060  Singleton<SatEnvVariables>::Get()->DoDispose();
1061  // <<< End of actual test using Larger scenario <<<
1062 }
1063 
1064 // The TestSuite class names the TestSuite as sat-simple-unicast, identifies what type of TestSuite
1065 // (SYSTEM), and enables the TestCases to be run. Typically, only the constructor for this class
1066 // must be defined
1067 //
1068 class SimpleUnicastTestSuite : public TestSuite
1069 {
1070  public:
1072 };
1073 
1075  : TestSuite("sat-simple-unicast", SYSTEM)
1076 {
1077  // add simple-unicast-1 case to suite sat-simple-unicast
1078  AddTestCase(new SimpleUnicast1, TestCase::QUICK);
1079 
1080  // add simple-unicast-2 case to suite sat-simple-unicast
1081  AddTestCase(new SimpleUnicast2, TestCase::QUICK);
1082 
1083  // add simple_unicast-3 case to suite sat-simple-unicast
1084  AddTestCase(new SimpleUnicast3, TestCase::QUICK);
1085 
1086  // add simple-unicast-4 case to suite sat-simple-unicast
1087  AddTestCase(new SimpleUnicast4, TestCase::QUICK);
1088 
1089  // add simple-unicast-5 case to suite sat-simple-unicast
1090  AddTestCase(new SimpleUnicast5, TestCase::QUICK);
1091 
1092  // add simple-unicast-6 case to suite sat-simple-unicast
1093  AddTestCase(new SimpleUnicast6, TestCase::QUICK);
1094 
1095  // add simple-unicast-7 case to suite sat-simple-unicast
1096  AddTestCase(new SimpleUnicast7, TestCase::QUICK);
1097 
1098  // add simple-unicast-8 case to suite sat-simple-unicast
1099  AddTestCase(new SimpleUnicast8, TestCase::QUICK);
1100 }
1101 
1102 // Allocate an instance of this TestSuite
'Forward Link Unicast, Simple' test case implementation, id: simple_unicast-1 / TN4.
virtual void DoRun(void)
'Forward Link Unicast, Larger' test case implementation, id: simple_unicast-2 / TN4.
virtual void DoRun(void)
'Forward Link Unicast, Full' test case implementation, id: simple_unicast-3 / TN4.
virtual void DoRun(void)
'Return Link Unicast, Simple' test case implementation, id: simple_unicast-4 / TN4.
virtual void DoRun(void)
'Return Link Unicast, Larger' test case implementation, id: simple_unicast-5 / TN4.
virtual void DoRun(void)
'Return Link Unicast, Full' test case implementation, id: simple_unicast-6 / TN4.
virtual void DoRun(void)
'Forward Link Unicast, Simple' test case implementation, id: simple_unicast-1 / TN4.
virtual void DoRun(void)
'Forward Link Unicast, Simple' test case implementation, id: simple_unicast-1 / TN4.
virtual void DoRun(void)
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
static SimpleUnicastTestSuite simpleUnicastTestSuite