23 #include "ns3/simulator.h"
24 #include "ns3/fq-codel-queue-disc.h"
25 #include "ns3/codel-queue-disc.h"
26 #include "ns3/ipv4-header.h"
27 #include "ns3/ipv4-packet-filter.h"
28 #include "ns3/ipv4-queue-disc-item.h"
29 #include "ns3/ipv4-address.h"
30 #include "ns3/ipv6-header.h"
31 #include "ns3/ipv6-packet-filter.h"
32 #include "ns3/ipv6-queue-disc-item.h"
33 #include "ns3/tcp-header.h"
34 #include "ns3/udp-header.h"
35 #include "ns3/string.h"
36 #include "ns3/pointer.h"
53 static TypeId GetTypeId (
void);
68 .SetGroupName (
"Internet")
104 virtual void DoRun (
void);
108 :
TestCase (
"Test packets that are not classified by any filter")
129 p = Create<Packet> ();
133 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
137 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
138 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
142 Simulator::Destroy ();
155 virtual void DoRun (
void);
160 :
TestCase (
"Test IP flows separation and packet limit")
195 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
202 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
207 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
211 Simulator::Destroy ();
224 virtual void DoRun (
void);
229 :
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")
411 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
417 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
424 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
433 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
439 Simulator::Destroy ();
452 virtual void DoRun (
void);
457 :
TestCase (
"Test UDP flows separation")
497 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
503 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
510 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
519 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
525 Simulator::Destroy ();
539 virtual void DoRun (
void);
559 for (uint32_t i = 0; i < nPkt; i++)
571 for (uint32_t i = 0; i < nPkt; i++)
580 for (uint32_t i = 0; i < nPkt; i++)
605 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
620 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
630 Simulator::Stop (
Seconds (8.0));
647 "with 20 packets, total bytes in the queue = 120 * 20 = 2400. First packet dequeues at 110ms which is greater than"
648 "test's default target value 5ms. Sojourn time has just gone above target from below, need to stay above for at"
649 "least q->interval before packet can be dropped. Second packet dequeues at 220ms which is greater than last dequeue"
650 "time plus q->interval(test default 100ms) so the packet is marked. Third packet dequeues at 330ms and the sojourn"
651 "time stayed above the target and dropnext value is less than 320 hence the packet is marked. 4 subsequent packets"
652 "are marked as the sojourn time stays above the target. With 8th dequeue number of bytes in queue = 120 * 12 = 1440"
653 "which is less m_minBytes(test's default value 1500 bytes) hence the packets stop getting marked");
655 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 6,
"There should be 6 marked packets");
656 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
657 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 6,
"There should be 6 marked packets");
658 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
661 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 4,
"There should be 4 dropped packets"
662 "with 20 packets, total bytes in the queue = 120 * 20 = 2400. First packet dequeues at 110ms which is greater than"
663 "test's default target value 5ms. Sojourn time has just gone above target from below, need to stay above for at"
664 "least q->interval before packet can be dropped. Second packet dequeues at 220ms which is greater than last dequeue"
665 "time plus q->interval(test default 100ms) so packet is dropped and next is dequeued. 4th packet dequeues at 330ms"
666 "and the sojourn time stayed above the target and dropnext value is less than 320 hence the packet is dropped and next"
667 "packet is dequeued. 6th packet dequeues at 440ms and 2 more packets are dropped as dropnext value is increased twice."
668 "12 Packets remaining in the queue, total number of bytes int the queue = 120 * 12 = 1440 which is less"
669 "m_minBytes(test's default value 1500 bytes) hence the packets stop getting dropped");
670 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 0,
"There should not be any marked packets");
671 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 4,
"There should be 4 dropped packets");
672 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 0,
"There should not be any marked packets");
682 Simulator::Destroy ();
685 queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
692 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
705 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
715 Simulator::Stop (
Seconds (8.0));
732 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 13th packet is 1.3ms which is"
733 "less than CE threshold");
736 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 8th packet is 2.1ms which is greater"
737 "than CE threshold and subsequent packet also have sojourn time more 8th packet hence remaining packet are marked.");
740 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued and all of them have sojourn time more than CE threshold");
750 pktQ0 = DynamicCast<const Ipv4QueueDiscItem> (q0->
Peek ());
752 pktQ1 = DynamicCast<const Ipv4QueueDiscItem> (q1->
Peek ());
754 pktQ2 = DynamicCast<const Ipv4QueueDiscItem> (q2->
Peek ());
757 Simulator::Destroy ();
760 queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
767 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
780 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
790 Simulator::Stop (
Seconds (8.0));
808 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
812 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
816 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
821 " As queue delay is same as in test case 1, number of dropped packets should also be same");
827 pktQ0 = DynamicCast<const Ipv4QueueDiscItem> (q0->
Peek ());
829 pktQ1 = DynamicCast<const Ipv4QueueDiscItem> (q1->
Peek ());
831 pktQ2 = DynamicCast<const Ipv4QueueDiscItem> (q2->
Peek ());
834 Simulator::Destroy ();
865 virtual void DoRun (
void);
870 :
TestCase (
"Test credits and flows status")
925 "unexpected number of packets in the queue disc");
927 "unexpected number of packets in the first flow queue of set one");
929 "unexpected number of packets in the second flow queue of set one");
931 "unexpected number of packets in the third flow queue of set one");
933 "unexpected number of packets in the fourth flow queue of set one");
935 "unexpected number of packets in the fifth flow queue of set one");
937 "unexpected number of packets in the sixth flow queue of set one");
939 "unexpected number of packets in the seventh flow queue of set one");
941 "unexpected number of packets in the eighth flow queue of set one");
945 "unexpected number of packets in the first flow of set one");
949 "unexpected number of packets in the first flow of set two");
950 Simulator::Destroy ();
965 virtual void DoRun (
void);
986 for (uint32_t i = 0; i < nPkt; i++)
996 for (uint32_t i = 0; i < nPkt; i++)
1005 for (uint32_t i = 0; i < nPkt; i++)
1014 for (uint32_t i = 0; i < nPkt; i++)
1039 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1043 double delay = 0.0005;
1047 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1055 Simulator::Stop (
Seconds (8.0));
1060 "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not greater than CE threshold"
1061 "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
1062 "greater than CE threshold so all the packets after 4th packet are marked");
1065 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 1,
"There should be 1 marked packets");
1066 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1068 Simulator::Destroy ();
1071 queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
1081 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1090 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1096 Simulator::Stop (
Seconds (8.0));
1100 "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which not greater than CE threshold"
1101 "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
1102 "greater than CE threshold so all the packets after 2nd packet are marked");
1106 Simulator::Destroy ();
1116 :
TestSuite (
"fq-codel-queue-disc", UNIT)