25 #include "ns3/simulator.h"
26 #include "ns3/fq-cobalt-queue-disc.h"
27 #include "ns3/cobalt-queue-disc.h"
28 #include "ns3/ipv4-header.h"
29 #include "ns3/ipv4-packet-filter.h"
30 #include "ns3/ipv4-queue-disc-item.h"
31 #include "ns3/ipv4-address.h"
32 #include "ns3/ipv6-header.h"
33 #include "ns3/ipv6-packet-filter.h"
34 #include "ns3/ipv6-queue-disc-item.h"
35 #include "ns3/tcp-header.h"
36 #include "ns3/udp-header.h"
37 #include "ns3/string.h"
38 #include "ns3/pointer.h"
55 static TypeId GetTypeId (
void);
68 static TypeId tid =
TypeId (
"ns3::Ipv4FqCobaltTestPacketFilter")
70 .SetGroupName (
"Internet")
106 virtual void DoRun (
void);
110 :
TestCase (
"Test packets that are not classified by any filter")
131 p = Create<Packet> ();
135 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
139 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
140 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
144 Simulator::Destroy ();
157 virtual void DoRun (
void);
162 :
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")
264 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
271 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
279 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
287 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
296 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
308 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
320 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
332 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
355 Simulator::Destroy ();
368 virtual void DoRun (
void);
373 :
TestCase (
"Test TCP flows separation")
413 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
419 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
426 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
435 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
441 Simulator::Destroy ();
454 virtual void DoRun (
void);
459 :
TestCase (
"Test UDP flows separation")
499 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
505 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
512 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
521 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
527 Simulator::Destroy ();
553 virtual void DoRun (
void);
576 for (uint32_t i = 0; i < nPkt; i++)
596 for (uint32_t i = 0; i < nPkt; i++)
605 for (uint32_t i = 0; i < nPkt; i++)
638 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
653 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
663 Simulator::Stop (
Seconds (8.0));
672 "As there is no CoDel minBytes parameter so all the packets apart from the first one gets marked. As q3 and q4 have"
673 "NotEct packets and the queue delay is much higher than 5ms so the queue gets empty pretty quickly so more"
674 "packets from q0 can be dequeued.");
676 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 16,
"There should be 16 marked packets"
677 "As there is no CoDel minBytes parameter so all the packets apart from the first one until no more packets are dequeued"
679 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
680 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 12,
"There should be 12 marked packets"
681 "Each packet size is 120 bytes and the quantum is 1500 bytes so in the first turn (1514/120 = 12.61) 13 packets are"
682 "dequeued and apart from the first one, all the packets are marked.");
683 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
687 "be equal to the number of times m_dropNext is updated");
688 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0,
"There should not be any marked packets");
690 "be equal to the number of times m_dropNext is updated");
691 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0,
"There should not be any marked packets");
693 Simulator::Destroy ();
696 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
703 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
716 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
726 Simulator::Stop (
Seconds (8.0));
736 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 13th packet is 1.3ms which is"
737 "less than CE threshold");
740 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 8th packet is 2.1ms which is greater"
741 "than CE threshold and subsequent packet also have sojourn time more 8th packet hence remaining packet are marked.");
744 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued and all of them have sojourn time more than CE threshold");
751 "delay for the first dequeue is greater than the target (5ms), Cobalt overloads the m_dropNext field as an activity timeout"
752 "and dropNext is to set to the current Time value so on the next dequeue a packet is dropped.");
754 Simulator::Destroy ();
757 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
764 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
777 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
790 Simulator::Stop (
Seconds (8.0));
801 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
805 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
809 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
814 "be equal to the number of times m_dropNext is updated");
817 "be equal to the number of times m_dropNext is updated");
819 Simulator::Destroy ();
850 virtual void DoRun (
void);
855 :
TestCase (
"Test credits and flows status")
910 "unexpected number of packets in the queue disc");
912 "unexpected number of packets in the first flow queue of set one");
914 "unexpected number of packets in the second flow queue of set one");
916 "unexpected number of packets in the third flow queue of set one");
918 "unexpected number of packets in the fourth flow queue of set one");
920 "unexpected number of packets in the fifth flow queue of set one");
922 "unexpected number of packets in the sixth flow queue of set one");
924 "unexpected number of packets in the seventh flow queue of set one");
926 "unexpected number of packets in the eighth flow queue of set one");
930 "unexpected number of packets in the first flow of set one");
934 "unexpected number of packets in the first flow of set two");
935 Simulator::Destroy ();
957 virtual void DoRun (
void);
978 for (uint32_t i = 0; i < nPkt; i++)
988 for (uint32_t i = 0; i < nPkt; i++)
997 for (uint32_t i = 0; i < nPkt; i++)
1006 for (uint32_t i = 0; i < nPkt; i++)
1031 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1035 double delay = 0.0005;
1039 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1047 Simulator::Stop (
Seconds (8.0));
1052 "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not greater than CE threshold"
1053 "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
1054 "greater than CE threshold so all the packets after 4th packet are marked");
1057 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 2,
"There should be 2 marked packets. Packets are dequeued"
1058 "from q0 first, which leads to delay greater than 5ms for the first dequeue from q1. Because of inactivity (started with high queue delay)"
1059 "Cobalt keeps drop_next as now and the next packet is marked. With second dequeue count increases to 2, drop_next becomes now plus around"
1060 "70ms which is less than the running time(140), and as the queue delay is persistantly higher than 5ms, second packet is marked.");
1061 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1063 Simulator::Destroy ();
1066 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
1076 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1085 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1091 Simulator::Stop (
Seconds (8.0));
1096 "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which not greater than CE threshold"
1097 "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
1098 "greater than CE threshold so all the packets after 2nd packet are marked");
1102 Simulator::Destroy ();
1113 :
TestSuite (
"fq-cobalt-queue-disc", UNIT)