30 #include "ns3/simulator.h"
31 #include "ns3/fq-pie-queue-disc.h"
32 #include "ns3/pie-queue-disc.h"
33 #include "ns3/ipv4-header.h"
34 #include "ns3/ipv4-packet-filter.h"
35 #include "ns3/ipv4-queue-disc-item.h"
36 #include "ns3/ipv4-address.h"
37 #include "ns3/ipv6-header.h"
38 #include "ns3/ipv6-packet-filter.h"
39 #include "ns3/ipv6-queue-disc-item.h"
40 #include "ns3/tcp-header.h"
41 #include "ns3/udp-header.h"
42 #include "ns3/string.h"
43 #include "ns3/pointer.h"
61 static TypeId GetTypeId (
void);
74 static TypeId tid =
TypeId (
"ns3::Ipv4FqPieTestPacketFilter")
76 .SetGroupName (
"Internet")
110 virtual void DoRun (
void);
114 :
TestCase (
"Test packets that are not classified by any filter")
133 p = Create<Packet> ();
137 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
141 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
142 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
146 Simulator::Destroy ();
159 virtual void DoRun (
void);
164 :
TestCase (
"Test IP flows separation and packet limit")
197 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
204 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
209 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
213 Simulator::Destroy ();
226 virtual void DoRun (
void);
231 :
TestCase (
"Test credits and flows status")
262 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
269 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
277 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
285 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
294 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
306 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
318 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
330 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
353 Simulator::Destroy ();
366 virtual void DoRun (
void);
371 :
TestCase (
"Test TCP flows separation")
409 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
415 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
422 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
431 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
437 Simulator::Destroy ();
450 virtual void DoRun (
void);
455 :
TestCase (
"Test UDP flows separation")
493 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
499 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
506 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
515 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
521 Simulator::Destroy ();
554 virtual void DoRun (
void);
559 :
TestCase (
"Test credits and flows status")
612 "unexpected number of packets in the queue disc");
614 "unexpected number of packets in the first flow queue of set one");
616 "unexpected number of packets in the second flow queue of set one");
618 "unexpected number of packets in the third flow queue of set one");
620 "unexpected number of packets in the fourth flow queue of set one");
622 "unexpected number of packets in the fifth flow queue of set one");
624 "unexpected number of packets in the sixth flow queue of set one");
626 "unexpected number of packets in the seventh flow queue of set one");
628 "unexpected number of packets in the eighth flow queue of set one");
632 "unexpected number of packets in the first flow of set one");
636 "unexpected number of packets in the first flow of set two");
637 Simulator::Destroy ();
659 virtual void DoRun (
void);
678 for (uint32_t i = 0; i < nPkt; i++)
688 for (uint32_t i = 0; i < nPkt; i++)
697 for (uint32_t i = 0; i < nPkt; i++)
706 for (uint32_t i = 0; i < nPkt; i++)
731 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
735 double delay = 0.0005;
739 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
746 Simulator::Stop (
Seconds (10.0));
753 "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not greater than CE threshold"
754 "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
755 "greater than CE threshold so all the packets after 4th packet are marked");
757 "There should not be any dropped packets");
759 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (PieQueueDisc::UNFORCED_MARK), 0,
"There should not be marked packets.");
760 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (PieQueueDisc::UNFORCED_DROP), 0,
"There should not be any dropped packets");
762 Simulator::Destroy ();
765 queueDisc = CreateObjectWithAttributes<FqPieQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
775 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
784 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
789 Simulator::Stop (
Seconds (1.0));
795 "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which not greater than CE threshold"
796 "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
797 "greater than CE threshold so all the packets after 2nd packet are marked");
799 "There should not be any dropped packets");
802 Simulator::Destroy ();