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"
56 static TypeId GetTypeId (
void);
80 static TypeId tid =
TypeId (
"ns3::Ipv4FqCobaltTestPacketFilter")
82 .SetGroupName (
"Internet")
120 virtual void DoRun (
void);
124 :
TestCase (
"Test packets that are not classified by any filter")
138 queueDisc->AddPacketFilter (filter);
141 queueDisc->SetQuantum (1500);
142 queueDisc->Initialize ();
145 p = Create<Packet> ();
149 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
150 queueDisc->Enqueue (item);
151 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetNQueueDiscClasses (), 0,
"no flow queue should have been created");
153 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
154 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
155 queueDisc->Enqueue (item);
156 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetNQueueDiscClasses (), 0,
"no flow queue should have been created");
158 Simulator::Destroy ();
173 virtual void DoRun (
void);
183 :
TestCase (
"Test IP flows separation and packet limit")
197 queue->Enqueue (item);
205 queueDisc->SetQuantum (1500);
206 queueDisc->Initialize ();
218 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
219 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the flow queue");
225 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
226 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the flow queue");
227 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the flow queue");
230 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
231 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the flow queue");
232 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the flow queue");
234 Simulator::Destroy ();
249 virtual void DoRun (
void);
259 :
TestCase (
"Test credits and flows status")
273 queue->Enqueue (item);
281 queueDisc->SetQuantum (90);
282 queueDisc->Initialize ();
292 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
293 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
294 Ptr<FqCobaltFlow> flow1 = StaticCast<FqCobaltFlow> (queueDisc->GetQueueDiscClass (0));
295 NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (),
static_cast<int32_t
> (queueDisc->GetQuantum ()),
"the deficit of the first flow must equal the quantum");
296 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the first flow must be in the list of new queues");
298 queueDisc->Dequeue ();
299 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
300 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the first flow queue");
307 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
308 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
309 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the first flow must still be in the list of new queues");
315 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
316 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
317 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the second flow queue");
318 Ptr<FqCobaltFlow> flow2 = StaticCast<FqCobaltFlow> (queueDisc->GetQueueDiscClass (1));
319 NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (),
static_cast<int32_t
> (queueDisc->GetQuantum ()),
"the deficit of the second flow must equal the quantum");
320 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
323 queueDisc->Dequeue ();
324 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
325 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
326 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
329 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
332 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
335 queueDisc->Dequeue ();
336 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
337 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
338 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
341 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
344 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
347 queueDisc->Dequeue ();
348 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
349 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
350 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the second flow queue");
353 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
356 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
359 queueDisc->Dequeue ();
360 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
361 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the first flow queue");
362 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the second flow queue");
365 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
368 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
371 queueDisc->Dequeue ();
383 Simulator::Destroy ();
398 virtual void DoRun (
void);
409 :
TestCase (
"Test TCP flows separation")
424 queue->Enqueue (item);
432 queueDisc->SetQuantum (1500);
433 queueDisc->Initialize ();
449 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
450 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
455 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
456 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
457 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
462 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
463 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
464 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
465 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
471 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
472 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
473 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
474 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
475 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the third flow queue");
477 Simulator::Destroy ();
492 virtual void DoRun (
void);
503 :
TestCase (
"Test UDP flows separation")
518 queue->Enqueue (item);
526 queueDisc->SetQuantum (1500);
527 queueDisc->Initialize ();
543 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
544 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
549 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
550 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
551 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
556 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
557 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
558 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
559 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
565 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
566 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
567 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
568 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
569 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the third flow queue");
571 Simulator::Destroy ();
600 virtual void DoRun (
void);
647 for (uint32_t i = 0; i < nPkt; i++)
650 queue->Enqueue (item);
652 NS_TEST_EXPECT_MSG_EQ (queue->GetNQueueDiscClasses (), nQueueFlows,
"unexpected number of flow queues");
653 NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), nPktEnqueued,
"unexpected number of enqueued packets");
662 if (q3->GetNPackets () == 19)
667 for (uint32_t i = 0; i < nPkt; i++)
676 for (uint32_t i = 0; i < nPkt; i++)
700 queueDisc->SetQuantum (1514);
701 queueDisc->Initialize ();
707 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
722 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
732 Simulator::Stop (
Seconds (8.0));
740 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 19,
"There should be 19 marked packets."
741 "As there is no CoDel minBytes parameter so all the packets apart from the first one gets marked. As q3 and q4 have"
742 "NotEct packets and the queue delay is much higher than 5ms so the queue gets empty pretty quickly so more"
743 "packets from q0 can be dequeued.");
744 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
745 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 16,
"There should be 16 marked packets"
746 "As there is no CoDel minBytes parameter so all the packets apart from the first one until no more packets are dequeued"
748 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
749 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 12,
"There should be 12 marked packets"
750 "Each packet size is 120 bytes and the quantum is 1500 bytes so in the first turn (1514/120 = 12.61) 13 packets are"
751 "dequeued and apart from the first one, all the packets are marked.");
752 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
756 "be equal to the number of times m_dropNext is updated");
757 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0,
"There should not be any marked packets");
759 "be equal to the number of times m_dropNext is updated");
760 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0,
"There should not be any marked packets");
762 Simulator::Destroy ();
765 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
767 queueDisc->SetQuantum (1514);
768 queueDisc->Initialize ();
772 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
785 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
795 Simulator::Stop (
Seconds (8.0));
796 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
797 q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
798 q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
799 q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
800 q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
803 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
804 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets"
805 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 13th packet is 1.3ms which is"
806 "less than CE threshold");
807 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
808 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 6,
"There should be 6 marked packets"
809 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued. sojourn time of 8th packet is 2.1ms which is greater"
810 "than CE threshold and subsequent packet also have sojourn time more 8th packet hence remaining packet are marked.");
811 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
812 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 13,
"There should be 13 marked packets"
813 "with quantum of 1514, 13 packets of size 120 bytes can be dequeued and all of them have sojourn time more than CE threshold");
816 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
817 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
818 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
819 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 1,
"There should 1 dropped packet. As the queue"
820 "delay for the first dequeue is greater than the target (5ms), Cobalt overloads the m_dropNext field as an activity timeout"
821 "and dropNext is to set to the current Time value so on the next dequeue a packet is dropped.");
823 Simulator::Destroy ();
826 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
828 queueDisc->SetQuantum (1514);
829 queueDisc->Initialize ();
833 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
846 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
859 Simulator::Stop (
Seconds (8.0));
860 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
861 q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
862 q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
863 q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
864 q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
867 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
868 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
869 q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q0->GetNPackets (),
"Number of CE threshold"
870 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
871 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
872 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
873 q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q1->GetNPackets (),
"Number of CE threshold"
874 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
875 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
876 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
877 q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q2->GetNPackets (),
"Number of CE threshold"
878 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
881 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
883 "be equal to the number of times m_dropNext is updated");
884 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
886 "be equal to the number of times m_dropNext is updated");
888 Simulator::Destroy ();
921 virtual void DoRun (
void);
931 :
TestCase (
"Test credits and flows status")
945 queue->Enqueue (item);
952 queueDisc->SetQuantum (90);
953 queueDisc->Initialize ();
956 queueDisc->AddPacketFilter (filter);
986 "unexpected number of packets in the queue disc");
988 "unexpected number of packets in the first flow queue of set one");
990 "unexpected number of packets in the second flow queue of set one");
992 "unexpected number of packets in the third flow queue of set one");
994 "unexpected number of packets in the fourth flow queue of set one");
996 "unexpected number of packets in the fifth flow queue of set one");
998 "unexpected number of packets in the sixth flow queue of set one");
1000 "unexpected number of packets in the seventh flow queue of set one");
1002 "unexpected number of packets in the eighth flow queue of set one");
1006 "unexpected number of packets in the first flow of set one");
1010 "unexpected number of packets in the first flow of set two");
1011 Simulator::Destroy ();
1038 virtual void DoRun (
void);
1083 for (uint32_t i = 0; i < nPkt; i++)
1086 queue->Enqueue (item);
1093 for (uint32_t i = 0; i < nPkt; i++)
1102 for (uint32_t i = 0; i < nPkt; i++)
1111 for (uint32_t i = 0; i < nPkt; i++)
1129 queueDisc->SetQuantum (1514);
1130 queueDisc->Initialize ();
1136 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1140 double delay = 0.0005;
1144 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1152 Simulator::Stop (
Seconds (8.0));
1156 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 66,
"There should be 66 marked packets"
1157 "4th packet is enqueued at 2ms and dequeued at 4ms hence the delay of 2ms which not greater than CE threshold"
1158 "5th packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
1159 "greater than CE threshold so all the packets after 4th packet are marked");
1160 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1161 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0,
"There should not be any marked packets");
1162 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 2,
"There should be 2 marked packets. Packets are dequeued"
1163 "from q0 first, which leads to delay greater than 5ms for the first dequeue from q1. Because of inactivity (started with high queue delay)"
1164 "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"
1165 "70ms which is less than the running time(140), and as the queue delay is persistantly higher than 5ms, second packet is marked.");
1166 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1168 Simulator::Destroy ();
1171 queueDisc = CreateObjectWithAttributes<FqCobaltQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
1175 queueDisc->SetQuantum (1514);
1176 queueDisc->Initialize ();
1181 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1190 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1196 Simulator::Stop (
Seconds (8.0));
1197 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
1198 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
1200 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 68,
"There should be 68 marked packets"
1201 "2nd ECT1 packet is enqueued at 1.5ms and dequeued at 3ms hence the delay of 1.5ms which not greater than CE threshold"
1202 "3rd packet is enqueued at 2.5ms and dequeued at 5ms hence the delay of 2.5ms and subsequent packet also do have delay"
1203 "greater than CE threshold so all the packets after 2nd packet are marked");
1204 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1205 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 1,
"There should be 1 marked packets");
1207 Simulator::Destroy ();
1223 :
TestSuite (
"fq-cobalt-queue-disc", UNIT)
This class tests the deficit per flow.
FqCobaltQueueDiscDeficit()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqCobaltQueueDiscDeficit()
This class tests ECN marking.
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue the given number of packets at different times.
virtual ~FqCobaltQueueDiscEcnMarking()
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
Dequeue the given number of packets.
void DropNextTracer(int64_t oldVal, int64_t newVal)
Tracer for the DropNext attribute.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, uint32_t nPkt, uint32_t nPktEnqueued, uint32_t nQueueFlows)
Enqueue the given number of packets.
FqCobaltQueueDiscEcnMarking()
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class tests the IP flows separation and the packet limit.
virtual ~FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit()
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class tests L4S mode.
virtual ~FqCobaltQueueDiscL4sMode()
virtual void DoRun(void)
Implementation to actually run this TestCase.
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
Dequeue the given number of packets at different times.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, uint32_t nPkt)
Enqueue the given number of packets.
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
Dequeue the given number of packets.
void AddPacketWithDelay(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, double delay, uint32_t nPkt)
Enqueue the given number of packets at different times.
FqCobaltQueueDiscL4sMode()
This class tests packets for which there is no suitable filter.
virtual void DoRun(void)
Implementation to actually run this TestCase.
FqCobaltQueueDiscNoSuitableFilter()
virtual ~FqCobaltQueueDiscNoSuitableFilter()
This class tests linear probing, collision response, and set creation capability of set associative h...
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqCobaltQueueDiscSetLinearProbing()
FqCobaltQueueDiscSetLinearProbing()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
Enqueue a packet.
This class tests the TCP flows separation.
virtual ~FqCobaltQueueDiscTCPFlowsSeparation()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
Enqueue a packet.
virtual void DoRun(void)
Implementation to actually run this TestCase.
FqCobaltQueueDiscTCPFlowsSeparation()
FQ-COBALT queue disc test suite.
FqCobaltQueueDiscTestSuite()
This class tests the UDP flows separation.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
Enqueue a packet.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqCobaltQueueDiscUDPFlowsSeparation()
FqCobaltQueueDiscUDPFlowsSeparation()
Simple test packet filter able to classify IPv4 packets.
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a QueueDiscItem.
virtual ~Ipv4FqCobaltTestPacketFilter()
Ipv4FqCobaltTestPacketFilter()
static TypeId GetTypeId(void)
Get the type ID.
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Check the protocol.
a polymophic address class
AttributeValue implementation for Boolean.
Cobalt packet queue disc.
Ipv4 addresses are stored in host order in this class.
Ipv4PacketFilter is the abstract base class for filters defined for IPv4 packets.
void AddHeader(const Header &header)
Add header to this packet.
Smart pointer class similar to boost::intrusive_ptr.
Hold variables of type string.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
static FqCobaltQueueDiscTestSuite g_fqCobaltQueueDiscTestSuite
Do not forget to allocate an instance of this TestSuite.
static int32_t g_hash
Variable to assign g_hash to a new packet's flow.
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...