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