OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "ns3/pointer.h" | 44 #include "ns3/pointer.h" |
45 #include "ns3/simple-channel.h" | 45 #include "ns3/simple-channel.h" |
46 #include "ns3/simulator.h" | 46 #include "ns3/simulator.h" |
47 #include "ns3/string.h" | 47 #include "ns3/string.h" |
48 #include "ns3/test.h" | 48 #include "ns3/test.h" |
49 #include "ns3/uinteger.h" | 49 #include "ns3/uinteger.h" |
50 #include "ns3/v4ping-helper.h" | 50 #include "ns3/v4ping-helper.h" |
51 | 51 |
52 using namespace ns3; | 52 using namespace ns3; |
53 | 53 |
| 54 /** |
| 55 * \ingroup csma-test |
| 56 * \ingroup tests |
| 57 * |
| 58 * \brief Csma Bridge Test Case |
| 59 */ |
54 class CsmaBridgeTestCase : public TestCase | 60 class CsmaBridgeTestCase : public TestCase |
55 { | 61 { |
56 public: | 62 public: |
57 CsmaBridgeTestCase (); | 63 CsmaBridgeTestCase (); |
58 virtual ~CsmaBridgeTestCase (); | 64 virtual ~CsmaBridgeTestCase (); |
59 | 65 |
60 private: | 66 private: |
61 virtual void DoRun (void); | 67 virtual void DoRun (void); |
| 68 /** |
| 69 * Receive sink |
| 70 * \param p the packet |
| 71 * \param ad the address |
| 72 */ |
62 void SinkRx (Ptr<const Packet> p, const Address &ad); | 73 void SinkRx (Ptr<const Packet> p, const Address &ad); |
63 uint32_t m_count; | 74 uint32_t m_count; ///< count |
64 }; | 75 }; |
65 | 76 |
66 // Add some help text to this case to describe what it is intended to test | 77 // Add some help text to this case to describe what it is intended to test |
67 CsmaBridgeTestCase::CsmaBridgeTestCase () | 78 CsmaBridgeTestCase::CsmaBridgeTestCase () |
68 : TestCase ("Bridge example for Carrier Sense Multiple Access (CSMA) networks"
), m_count (0) | 79 : TestCase ("Bridge example for Carrier Sense Multiple Access (CSMA) networks"
), m_count (0) |
69 { | 80 { |
70 } | 81 } |
71 | 82 |
72 CsmaBridgeTestCase::~CsmaBridgeTestCase () | 83 CsmaBridgeTestCase::~CsmaBridgeTestCase () |
73 { | 84 { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 // Trace receptions | 159 // Trace receptions |
149 Config::ConnectWithoutContext ("/NodeList/1/ApplicationList/0/$ns3::PacketSink
/Rx", MakeCallback (&CsmaBridgeTestCase::SinkRx, this)); | 160 Config::ConnectWithoutContext ("/NodeList/1/ApplicationList/0/$ns3::PacketSink
/Rx", MakeCallback (&CsmaBridgeTestCase::SinkRx, this)); |
150 | 161 |
151 Simulator::Run (); | 162 Simulator::Run (); |
152 Simulator::Destroy (); | 163 Simulator::Destroy (); |
153 | 164 |
154 // We should have sent and received 10 packets | 165 // We should have sent and received 10 packets |
155 NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Bridge should have passed 10 packets"); | 166 NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Bridge should have passed 10 packets"); |
156 } | 167 } |
157 | 168 |
| 169 /** |
| 170 * \ingroup csma-test |
| 171 * \ingroup tests |
| 172 * |
| 173 * \brief Csma Broadcast Test Case |
| 174 */ |
158 class CsmaBroadcastTestCase : public TestCase | 175 class CsmaBroadcastTestCase : public TestCase |
159 { | 176 { |
160 public: | 177 public: |
161 CsmaBroadcastTestCase (); | 178 CsmaBroadcastTestCase (); |
162 virtual ~CsmaBroadcastTestCase (); | 179 virtual ~CsmaBroadcastTestCase (); |
163 | 180 |
164 private: | 181 private: |
165 virtual void DoRun (void); | 182 virtual void DoRun (void); |
| 183 /** |
| 184 * Receive sink node 1 function |
| 185 * \param p the packet |
| 186 * \param ad the address |
| 187 */ |
166 void SinkRxNode1 (Ptr<const Packet> p, const Address &ad); | 188 void SinkRxNode1 (Ptr<const Packet> p, const Address &ad); |
| 189 /** |
| 190 * Receive sink node 2 function |
| 191 * \param p the packet |
| 192 * \param ad the address |
| 193 */ |
167 void SinkRxNode2 (Ptr<const Packet> p, const Address &ad); | 194 void SinkRxNode2 (Ptr<const Packet> p, const Address &ad); |
| 195 /** |
| 196 * Drop event function |
| 197 * \param p the packet |
| 198 */ |
168 void DropEvent (Ptr<const Packet> p); | 199 void DropEvent (Ptr<const Packet> p); |
169 uint32_t m_countNode1; | 200 uint32_t m_countNode1; ///< count for node 1 |
170 uint32_t m_countNode2; | 201 uint32_t m_countNode2; ///< count for node 2 |
171 uint32_t m_drops; | 202 uint32_t m_drops; ///< number of drops |
172 }; | 203 }; |
173 | 204 |
174 // Add some help text to this case to describe what it is intended to test | 205 // Add some help text to this case to describe what it is intended to test |
175 CsmaBroadcastTestCase::CsmaBroadcastTestCase () | 206 CsmaBroadcastTestCase::CsmaBroadcastTestCase () |
176 : TestCase ("Broadcast example for Carrier Sense Multiple Access (CSMA) networ
ks"), m_countNode1 (0), m_countNode2 (0), m_drops (0) | 207 : TestCase ("Broadcast example for Carrier Sense Multiple Access (CSMA) networ
ks"), m_countNode1 (0), m_countNode2 (0), m_drops (0) |
177 { | 208 { |
178 } | 209 } |
179 | 210 |
180 CsmaBroadcastTestCase::~CsmaBroadcastTestCase () | 211 CsmaBroadcastTestCase::~CsmaBroadcastTestCase () |
181 { | 212 { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 Config::ConnectWithoutContext ("/NodeList/2/ApplicationList/0/$ns3::PacketSink
/Rx", MakeCallback (&CsmaBroadcastTestCase::SinkRxNode2, this)); | 299 Config::ConnectWithoutContext ("/NodeList/2/ApplicationList/0/$ns3::PacketSink
/Rx", MakeCallback (&CsmaBroadcastTestCase::SinkRxNode2, this)); |
269 | 300 |
270 Simulator::Run (); | 301 Simulator::Run (); |
271 Simulator::Destroy (); | 302 Simulator::Destroy (); |
272 | 303 |
273 // We should have sent and received 10 packets | 304 // We should have sent and received 10 packets |
274 NS_TEST_ASSERT_MSG_EQ (m_countNode1, 10, "Node 1 should have received 10 packe
ts"); | 305 NS_TEST_ASSERT_MSG_EQ (m_countNode1, 10, "Node 1 should have received 10 packe
ts"); |
275 NS_TEST_ASSERT_MSG_EQ (m_countNode2, 10, "Node 2 should have received 10 packe
ts"); | 306 NS_TEST_ASSERT_MSG_EQ (m_countNode2, 10, "Node 2 should have received 10 packe
ts"); |
276 } | 307 } |
277 | 308 |
| 309 /** |
| 310 * \ingroup csma-test |
| 311 * \ingroup tests |
| 312 * |
| 313 * \brief Csma Multicast Test Case |
| 314 */ |
278 class CsmaMulticastTestCase : public TestCase | 315 class CsmaMulticastTestCase : public TestCase |
279 { | 316 { |
280 public: | 317 public: |
281 CsmaMulticastTestCase (); | 318 CsmaMulticastTestCase (); |
282 virtual ~CsmaMulticastTestCase (); | 319 virtual ~CsmaMulticastTestCase (); |
283 | 320 |
284 private: | 321 private: |
285 virtual void DoRun (void); | 322 virtual void DoRun (void); |
| 323 /** |
| 324 * Receive sink function |
| 325 * \param p the packet |
| 326 * \param ad the address |
| 327 */ |
286 void SinkRx (Ptr<const Packet> p, const Address &ad); | 328 void SinkRx (Ptr<const Packet> p, const Address &ad); |
| 329 /** |
| 330 * Drop event function |
| 331 * \param p the packet |
| 332 */ |
287 void DropEvent (Ptr<const Packet> p); | 333 void DropEvent (Ptr<const Packet> p); |
288 uint32_t m_count; | 334 uint32_t m_count; ///< count |
289 uint32_t m_drops; | 335 uint32_t m_drops; ///< number of drops |
290 }; | 336 }; |
291 | 337 |
292 // Add some help text to this case to describe what it is intended to test | 338 // Add some help text to this case to describe what it is intended to test |
293 CsmaMulticastTestCase::CsmaMulticastTestCase () | 339 CsmaMulticastTestCase::CsmaMulticastTestCase () |
294 : TestCase ("Multicast example for Carrier Sense Multiple Access (CSMA) networ
ks"), m_count (0), m_drops (0) | 340 : TestCase ("Multicast example for Carrier Sense Multiple Access (CSMA) networ
ks"), m_count (0), m_drops (0) |
295 { | 341 { |
296 } | 342 } |
297 | 343 |
298 CsmaMulticastTestCase::~CsmaMulticastTestCase () | 344 CsmaMulticastTestCase::~CsmaMulticastTestCase () |
299 { | 345 { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
428 // | 474 // |
429 // Now, do the actual simulation. | 475 // Now, do the actual simulation. |
430 // | 476 // |
431 Simulator::Run (); | 477 Simulator::Run (); |
432 Simulator::Destroy (); | 478 Simulator::Destroy (); |
433 | 479 |
434 // We should have sent and received 10 packets | 480 // We should have sent and received 10 packets |
435 NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 4 should have received 10 packets"); | 481 NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 4 should have received 10 packets"); |
436 } | 482 } |
437 | 483 |
| 484 /** |
| 485 * \ingroup csma-test |
| 486 * \ingroup tests |
| 487 * |
| 488 * \brief Csma One Subnet Test Case |
| 489 */ |
438 class CsmaOneSubnetTestCase : public TestCase | 490 class CsmaOneSubnetTestCase : public TestCase |
439 { | 491 { |
440 public: | 492 public: |
441 CsmaOneSubnetTestCase (); | 493 CsmaOneSubnetTestCase (); |
442 virtual ~CsmaOneSubnetTestCase (); | 494 virtual ~CsmaOneSubnetTestCase (); |
443 | 495 |
444 private: | 496 private: |
445 virtual void DoRun (void); | 497 virtual void DoRun (void); |
| 498 /** |
| 499 * Receive sink node 0 |
| 500 * \param p the packet |
| 501 * \param ad the address |
| 502 */ |
446 void SinkRxNode0 (Ptr<const Packet> p, const Address &ad); | 503 void SinkRxNode0 (Ptr<const Packet> p, const Address &ad); |
| 504 /** |
| 505 * Receive sink node 1 |
| 506 * \param p the packet |
| 507 * \param ad the address |
| 508 */ |
447 void SinkRxNode1 (Ptr<const Packet> p, const Address &ad); | 509 void SinkRxNode1 (Ptr<const Packet> p, const Address &ad); |
| 510 /** |
| 511 * Drop event function |
| 512 * \param p the packet |
| 513 */ |
448 void DropEvent (Ptr<const Packet> p); | 514 void DropEvent (Ptr<const Packet> p); |
449 uint32_t m_countNode0; | 515 uint32_t m_countNode0; ///< count for node 0 |
450 uint32_t m_countNode1; | 516 uint32_t m_countNode1; ///< count for node ` |
451 uint32_t m_drops; | 517 uint32_t m_drops; ///< number of drops |
452 }; | 518 }; |
453 | 519 |
454 // Add some help text to this case to describe what it is intended to test | 520 // Add some help text to this case to describe what it is intended to test |
455 CsmaOneSubnetTestCase::CsmaOneSubnetTestCase () | 521 CsmaOneSubnetTestCase::CsmaOneSubnetTestCase () |
456 : TestCase ("One subnet example for Carrier Sense Multiple Access (CSMA) netwo
rks"), m_countNode0 (0), m_countNode1 (0), m_drops (0) | 522 : TestCase ("One subnet example for Carrier Sense Multiple Access (CSMA) netwo
rks"), m_countNode0 (0), m_countNode1 (0), m_drops (0) |
457 { | 523 { |
458 } | 524 } |
459 | 525 |
460 CsmaOneSubnetTestCase::~CsmaOneSubnetTestCase () | 526 CsmaOneSubnetTestCase::~CsmaOneSubnetTestCase () |
461 { | 527 { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 // Now, do the actual simulation. | 622 // Now, do the actual simulation. |
557 // | 623 // |
558 Simulator::Run (); | 624 Simulator::Run (); |
559 Simulator::Destroy (); | 625 Simulator::Destroy (); |
560 | 626 |
561 // We should have sent and received 10 packets | 627 // We should have sent and received 10 packets |
562 NS_TEST_ASSERT_MSG_EQ (m_countNode0, 10, "Node 0 should have received 10 packe
ts"); | 628 NS_TEST_ASSERT_MSG_EQ (m_countNode0, 10, "Node 0 should have received 10 packe
ts"); |
563 NS_TEST_ASSERT_MSG_EQ (m_countNode1, 10, "Node 1 should have received 10 packe
ts"); | 629 NS_TEST_ASSERT_MSG_EQ (m_countNode1, 10, "Node 1 should have received 10 packe
ts"); |
564 } | 630 } |
565 | 631 |
| 632 /** |
| 633 * \ingroup csma-test |
| 634 * \ingroup tests |
| 635 * |
| 636 * \brief Csma Packet Socket Test Case |
| 637 */ |
566 class CsmaPacketSocketTestCase : public TestCase | 638 class CsmaPacketSocketTestCase : public TestCase |
567 { | 639 { |
568 public: | 640 public: |
569 CsmaPacketSocketTestCase (); | 641 CsmaPacketSocketTestCase (); |
570 virtual ~CsmaPacketSocketTestCase (); | 642 virtual ~CsmaPacketSocketTestCase (); |
571 | 643 |
572 private: | 644 private: |
573 virtual void DoRun (void); | 645 virtual void DoRun (void); |
| 646 /** |
| 647 * Receive sink function |
| 648 * \param path the sink path |
| 649 * \param p the packet |
| 650 * \param address the address |
| 651 */ |
574 void SinkRx (std::string path, Ptr<const Packet> p, const Address &address); | 652 void SinkRx (std::string path, Ptr<const Packet> p, const Address &address); |
| 653 /** |
| 654 * Drop event function |
| 655 * \param p the packet |
| 656 */ |
575 void DropEvent (Ptr<const Packet> p); | 657 void DropEvent (Ptr<const Packet> p); |
576 uint32_t m_count; | 658 uint32_t m_count; ///< count |
577 uint32_t m_drops; | 659 uint32_t m_drops; ///< number of drops |
578 }; | 660 }; |
579 | 661 |
580 // Add some help text to this case to describe what it is intended to test | 662 // Add some help text to this case to describe what it is intended to test |
581 CsmaPacketSocketTestCase::CsmaPacketSocketTestCase () | 663 CsmaPacketSocketTestCase::CsmaPacketSocketTestCase () |
582 : TestCase ("Packet socket example for Carrier Sense Multiple Access (CSMA) ne
tworks"), m_count (0), m_drops (0) | 664 : TestCase ("Packet socket example for Carrier Sense Multiple Access (CSMA) ne
tworks"), m_count (0), m_drops (0) |
583 { | 665 { |
584 } | 666 } |
585 | 667 |
586 CsmaPacketSocketTestCase::~CsmaPacketSocketTestCase () | 668 CsmaPacketSocketTestCase::~CsmaPacketSocketTestCase () |
587 { | 669 { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 Config::Connect ("/NodeList/0/ApplicationList/*/$ns3::PacketSink/Rx", | 744 Config::Connect ("/NodeList/0/ApplicationList/*/$ns3::PacketSink/Rx", |
663 MakeCallback (&CsmaPacketSocketTestCase::SinkRx, this)); | 745 MakeCallback (&CsmaPacketSocketTestCase::SinkRx, this)); |
664 · | 746 · |
665 Simulator::Run (); | 747 Simulator::Run (); |
666 Simulator::Destroy (); | 748 Simulator::Destroy (); |
667 | 749 |
668 // We should have received 10 packets on node 0 | 750 // We should have received 10 packets on node 0 |
669 NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 0 should have received 10 packets"); | 751 NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 0 should have received 10 packets"); |
670 } | 752 } |
671 | 753 |
| 754 /** |
| 755 * \ingroup csma-test |
| 756 * \ingroup tests |
| 757 * |
| 758 * \brief Csma Ping Test Case |
| 759 */ |
672 class CsmaPingTestCase : public TestCase | 760 class CsmaPingTestCase : public TestCase |
673 { | 761 { |
674 public: | 762 public: |
675 CsmaPingTestCase (); | 763 CsmaPingTestCase (); |
676 virtual ~CsmaPingTestCase (); | 764 virtual ~CsmaPingTestCase (); |
677 | 765 |
678 private: | 766 private: |
679 virtual void DoRun (void); | 767 virtual void DoRun (void); |
| 768 /** |
| 769 * Receive sink function |
| 770 * \param p the packet |
| 771 * \param ad the address |
| 772 */ |
680 void SinkRx (Ptr<const Packet> p, const Address &ad); | 773 void SinkRx (Ptr<const Packet> p, const Address &ad); |
| 774 /** |
| 775 * Ping RTT function |
| 776 * \param context the context |
| 777 * \param rtt the RTT |
| 778 */ |
681 void PingRtt (std::string context, Time rtt); | 779 void PingRtt (std::string context, Time rtt); |
| 780 /** |
| 781 * Drop event function |
| 782 * \param p the packet |
| 783 */ |
682 void DropEvent (Ptr<const Packet> p); | 784 void DropEvent (Ptr<const Packet> p); |
683 uint32_t m_countSinkRx; | 785 uint32_t m_countSinkRx; ///< sink receive count |
684 uint32_t m_countPingRtt; | 786 uint32_t m_countPingRtt; ///< ping receive count |
685 uint32_t m_drops; | 787 uint32_t m_drops; ///< number of drops |
686 }; | 788 }; |
687 | 789 |
688 // Add some help text to this case to describe what it is intended to test | 790 // Add some help text to this case to describe what it is intended to test |
689 CsmaPingTestCase::CsmaPingTestCase () | 791 CsmaPingTestCase::CsmaPingTestCase () |
690 : TestCase ("Ping example for Carrier Sense Multiple Access (CSMA) networks"),
m_countSinkRx (0), m_countPingRtt (0), m_drops (0) | 792 : TestCase ("Ping example for Carrier Sense Multiple Access (CSMA) networks"),
m_countSinkRx (0), m_countPingRtt (0), m_drops (0) |
691 { | 793 { |
692 } | 794 } |
693 | 795 |
694 CsmaPingTestCase::~CsmaPingTestCase () | 796 CsmaPingTestCase::~CsmaPingTestCase () |
695 { | 797 { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 Simulator::Run (); | 885 Simulator::Run (); |
784 Simulator::Destroy (); | 886 Simulator::Destroy (); |
785 | 887 |
786 // We should have sent and received 10 packets | 888 // We should have sent and received 10 packets |
787 NS_TEST_ASSERT_MSG_EQ (m_countSinkRx, 10, "Node 3 should have received 10 pack
ets"); | 889 NS_TEST_ASSERT_MSG_EQ (m_countSinkRx, 10, "Node 3 should have received 10 pack
ets"); |
788 | 890 |
789 // We should have 3 pingers that ping every second for 3 seconds. | 891 // We should have 3 pingers that ping every second for 3 seconds. |
790 NS_TEST_ASSERT_MSG_EQ (m_countPingRtt, 9, "Node 2 should have been pinged 9 ti
mes"); | 892 NS_TEST_ASSERT_MSG_EQ (m_countPingRtt, 9, "Node 2 should have been pinged 9 ti
mes"); |
791 } | 893 } |
792 | 894 |
| 895 /** |
| 896 * \ingroup csma-test |
| 897 * \ingroup tests |
| 898 * |
| 899 * \brief Csma Raw Ip Socket Test Case |
| 900 */ |
793 class CsmaRawIpSocketTestCase : public TestCase | 901 class CsmaRawIpSocketTestCase : public TestCase |
794 { | 902 { |
795 public: | 903 public: |
796 CsmaRawIpSocketTestCase (); | 904 CsmaRawIpSocketTestCase (); |
797 virtual ~CsmaRawIpSocketTestCase (); | 905 virtual ~CsmaRawIpSocketTestCase (); |
798 | 906 |
799 private: | 907 private: |
800 virtual void DoRun (void); | 908 virtual void DoRun (void); |
| 909 /** |
| 910 * Receive sink function |
| 911 * \param p the packet |
| 912 * \param ad the address |
| 913 */ |
801 void SinkRx (Ptr<const Packet> p, const Address &ad); | 914 void SinkRx (Ptr<const Packet> p, const Address &ad); |
| 915 /** |
| 916 * Drop event function |
| 917 * \param p the packet |
| 918 */ |
802 void DropEvent (Ptr<const Packet> p); | 919 void DropEvent (Ptr<const Packet> p); |
803 uint32_t m_count; | 920 uint32_t m_count; ///< receive count |
804 uint32_t m_drops; | 921 uint32_t m_drops; ///< drop count |
805 }; | 922 }; |
806 | 923 |
807 // Add some help text to this case to describe what it is intended to test | 924 // Add some help text to this case to describe what it is intended to test |
808 CsmaRawIpSocketTestCase::CsmaRawIpSocketTestCase () | 925 CsmaRawIpSocketTestCase::CsmaRawIpSocketTestCase () |
809 : TestCase ("Raw internet protocol socket example for Carrier Sense Multiple A
ccess (CSMA) networks"), m_count (0), m_drops (0) | 926 : TestCase ("Raw internet protocol socket example for Carrier Sense Multiple A
ccess (CSMA) networks"), m_count (0), m_drops (0) |
810 { | 927 { |
811 } | 928 } |
812 | 929 |
813 CsmaRawIpSocketTestCase::~CsmaRawIpSocketTestCase () | 930 CsmaRawIpSocketTestCase::~CsmaRawIpSocketTestCase () |
814 { | 931 { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink
/Rx",· | 998 Config::ConnectWithoutContext ("/NodeList/3/ApplicationList/0/$ns3::PacketSink
/Rx",· |
882 MakeCallback (&CsmaRawIpSocketTestCase::SinkRx,
this)); | 999 MakeCallback (&CsmaRawIpSocketTestCase::SinkRx,
this)); |
883 | 1000 |
884 Simulator::Run (); | 1001 Simulator::Run (); |
885 Simulator::Destroy (); | 1002 Simulator::Destroy (); |
886 | 1003 |
887 // We should have sent and received 10 packets | 1004 // We should have sent and received 10 packets |
888 NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 3 should have received 10 packets"); | 1005 NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 3 should have received 10 packets"); |
889 } | 1006 } |
890 | 1007 |
| 1008 /** |
| 1009 * \ingroup csma-test |
| 1010 * \ingroup tests |
| 1011 * |
| 1012 * \brief Csma Star Test Case |
| 1013 */ |
891 class CsmaStarTestCase : public TestCase | 1014 class CsmaStarTestCase : public TestCase |
892 { | 1015 { |
893 public: | 1016 public: |
894 CsmaStarTestCase (); | 1017 CsmaStarTestCase (); |
895 virtual ~CsmaStarTestCase (); | 1018 virtual ~CsmaStarTestCase (); |
896 | 1019 |
897 private: | 1020 private: |
898 virtual void DoRun (void); | 1021 virtual void DoRun (void); |
| 1022 /** |
| 1023 * Receive sink function |
| 1024 * \param p the packet |
| 1025 * \param ad the address |
| 1026 */ |
899 void SinkRx (Ptr<const Packet> p, const Address &ad); | 1027 void SinkRx (Ptr<const Packet> p, const Address &ad); |
| 1028 /** |
| 1029 * Drop event function |
| 1030 * \param p the packet |
| 1031 */ |
900 void DropEvent (Ptr<const Packet> p); | 1032 void DropEvent (Ptr<const Packet> p); |
901 uint32_t m_count; | 1033 uint32_t m_count; ///< receive counts |
902 uint32_t m_drops; | 1034 uint32_t m_drops; ///< drop counts |
903 }; | 1035 }; |
904 | 1036 |
905 // Add some help text to this case to describe what it is intended to test | 1037 // Add some help text to this case to describe what it is intended to test |
906 CsmaStarTestCase::CsmaStarTestCase () | 1038 CsmaStarTestCase::CsmaStarTestCase () |
907 : TestCase ("Star example for Carrier Sense Multiple Access (CSMA) networks"),
m_count (0), m_drops (0) | 1039 : TestCase ("Star example for Carrier Sense Multiple Access (CSMA) networks"),
m_count (0), m_drops (0) |
908 { | 1040 { |
909 } | 1041 } |
910 | 1042 |
911 CsmaStarTestCase::~CsmaStarTestCase () | 1043 CsmaStarTestCase::~CsmaStarTestCase () |
912 { | 1044 { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1063 MakeCallback (&CsmaStarTestCase::SinkRx, this))
; | 1195 MakeCallback (&CsmaStarTestCase::SinkRx, this))
; |
1064 | 1196 |
1065 Simulator::Run (); | 1197 Simulator::Run (); |
1066 Simulator::Destroy (); | 1198 Simulator::Destroy (); |
1067 | 1199 |
1068 // The hub node should have received 10 packets from the nFill + 1 | 1200 // The hub node should have received 10 packets from the nFill + 1 |
1069 // nodes on each spoke. | 1201 // nodes on each spoke. |
1070 NS_TEST_ASSERT_MSG_EQ (m_count, 10 * ( nSpokes * (nFill + 1)), "Hub node did n
ot receive the proper number of packets"); | 1202 NS_TEST_ASSERT_MSG_EQ (m_count, 10 * ( nSpokes * (nFill + 1)), "Hub node did n
ot receive the proper number of packets"); |
1071 } | 1203 } |
1072 | 1204 |
| 1205 /** |
| 1206 * \ingroup csma-test |
| 1207 * \ingroup tests |
| 1208 * |
| 1209 * \brief Csma System Test Suite |
| 1210 */ |
1073 class CsmaSystemTestSuite : public TestSuite | 1211 class CsmaSystemTestSuite : public TestSuite |
1074 { | 1212 { |
1075 public: | 1213 public: |
1076 CsmaSystemTestSuite (); | 1214 CsmaSystemTestSuite (); |
1077 }; | 1215 }; |
1078 | 1216 |
1079 CsmaSystemTestSuite::CsmaSystemTestSuite () | 1217 CsmaSystemTestSuite::CsmaSystemTestSuite () |
1080 : TestSuite ("csma-system", UNIT) | 1218 : TestSuite ("csma-system", UNIT) |
1081 { | 1219 { |
1082 AddTestCase (new CsmaBridgeTestCase, TestCase::QUICK); | 1220 AddTestCase (new CsmaBridgeTestCase, TestCase::QUICK); |
1083 AddTestCase (new CsmaBroadcastTestCase, TestCase::QUICK); | 1221 AddTestCase (new CsmaBroadcastTestCase, TestCase::QUICK); |
1084 AddTestCase (new CsmaMulticastTestCase, TestCase::QUICK); | 1222 AddTestCase (new CsmaMulticastTestCase, TestCase::QUICK); |
1085 AddTestCase (new CsmaOneSubnetTestCase, TestCase::QUICK); | 1223 AddTestCase (new CsmaOneSubnetTestCase, TestCase::QUICK); |
1086 AddTestCase (new CsmaPacketSocketTestCase, TestCase::QUICK); | 1224 AddTestCase (new CsmaPacketSocketTestCase, TestCase::QUICK); |
1087 AddTestCase (new CsmaPingTestCase, TestCase::QUICK); | 1225 AddTestCase (new CsmaPingTestCase, TestCase::QUICK); |
1088 AddTestCase (new CsmaRawIpSocketTestCase, TestCase::QUICK); | 1226 AddTestCase (new CsmaRawIpSocketTestCase, TestCase::QUICK); |
1089 AddTestCase (new CsmaStarTestCase, TestCase::QUICK); | 1227 AddTestCase (new CsmaStarTestCase, TestCase::QUICK); |
1090 } | 1228 } |
1091 | 1229 |
1092 // Do not forget to allocate an instance of this TestSuite | 1230 // Do not forget to allocate an instance of this TestSuite |
1093 static CsmaSystemTestSuite csmaSystemTestSuite; | 1231 static CsmaSystemTestSuite csmaSystemTestSuite; ///< the test suite |
OLD | NEW |