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