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")
122 queueDisc->AddPacketFilter (filter);
125 queueDisc->SetQuantum (1500);
126 queueDisc->Initialize ();
129 p = Create<Packet> ();
133 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
134 queueDisc->Enqueue (item);
135 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetNQueueDiscClasses (), 0,
"no flow queue should have been created");
137 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
138 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
139 queueDisc->Enqueue (item);
140 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetNQueueDiscClasses (), 0,
"no flow queue should have been created");
142 Simulator::Destroy ();
155 virtual void DoRun (
void);
160 :
TestCase (
"Test IP flows separation and packet limit")
174 queue->Enqueue (item);
182 queueDisc->SetQuantum (1500);
183 queueDisc->Initialize ();
195 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
196 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the flow queue");
202 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
203 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the flow queue");
204 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the flow queue");
207 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
208 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the flow queue");
209 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the flow queue");
211 Simulator::Destroy ();
224 virtual void DoRun (
void);
229 :
TestCase (
"Test credits and flows status")
243 queue->Enqueue (item);
251 queueDisc->SetQuantum (90);
252 queueDisc->Initialize ();
262 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
263 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
264 Ptr<FqCoDelFlow> flow1 = StaticCast<FqCoDelFlow> (queueDisc->GetQueueDiscClass (0));
265 NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (),
static_cast<int32_t
> (queueDisc->GetQuantum ()),
"the deficit of the first flow must equal the quantum");
266 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the first flow must be in the list of new queues");
268 queueDisc->Dequeue ();
269 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
270 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the first flow queue");
277 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
278 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
279 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the first flow must still be in the list of new queues");
285 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
286 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
287 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the second flow queue");
288 Ptr<FqCoDelFlow> flow2 = StaticCast<FqCoDelFlow> (queueDisc->GetQueueDiscClass (1));
289 NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (),
static_cast<int32_t
> (queueDisc->GetQuantum ()),
"the deficit of the second flow must equal the quantum");
290 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
293 queueDisc->Dequeue ();
294 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
295 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
296 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
299 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
302 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
305 queueDisc->Dequeue ();
306 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
307 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
308 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
311 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
314 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
317 queueDisc->Dequeue ();
318 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
319 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
320 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the second flow queue");
323 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
326 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
329 queueDisc->Dequeue ();
330 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
331 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the first flow queue");
332 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the second flow queue");
335 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
338 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCoDelFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
341 queueDisc->Dequeue ();
353 Simulator::Destroy ();
366 virtual void DoRun (
void);
371 :
TestCase (
"Test TCP flows separation")
386 queue->Enqueue (item);
394 queueDisc->SetQuantum (1500);
395 queueDisc->Initialize ();
411 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
412 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
417 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
418 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
419 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
424 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
425 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
426 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
427 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
433 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
434 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
435 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
436 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
437 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the third flow queue");
439 Simulator::Destroy ();
452 virtual void DoRun (
void);
457 :
TestCase (
"Test UDP flows separation")
472 queue->Enqueue (item);
480 queueDisc->SetQuantum (1500);
481 queueDisc->Initialize ();
497 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
498 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
503 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
504 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
505 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
510 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
511 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
512 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
513 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
519 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
520 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
521 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
522 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
523 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the third flow queue");
525 Simulator::Destroy ();
539 virtual void DoRun (
void);
559 for (uint32_t i = 0; i < nPkt; i++)
562 queue->Enqueue (item);
564 NS_TEST_EXPECT_MSG_EQ (queue->GetNQueueDiscClasses (), nQueueFlows,
"unexpected number of flow queues");
565 NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), nPktEnqueued,
"unexpected number of enqueued packets");
571 for (uint32_t i = 0; i < nPkt; i++)
580 for (uint32_t i = 0; i < nPkt; i++)
598 queueDisc->SetQuantum (1514);
599 queueDisc->Initialize ();
605 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
620 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
630 Simulator::Stop (
Seconds (8.0));
639 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
640 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
641 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
642 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
643 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
646 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 6,
"There should be 6 marked packets"
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");
654 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
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");
676 NS_TEST_EXPECT_MSG_NE (pktQ0->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
678 NS_TEST_EXPECT_MSG_NE (pktQ1->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
680 NS_TEST_EXPECT_MSG_NE (pktQ2->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
682 Simulator::Destroy ();
685 queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
687 queueDisc->SetQuantum (1514);
688 queueDisc->Initialize ();
692 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
705 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
715 Simulator::Stop (
Seconds (8.0));
716 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
717 q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
718 q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
719 q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
720 q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
723 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
724 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
725 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
726 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
727 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
730 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
731 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets"
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");
734 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
735 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 6,
"There should be 6 marked packets"
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.");
738 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
739 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 13,
"There should be 13 marked packets"
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");
743 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
744 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
745 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
746 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
750 pktQ0 = DynamicCast<const Ipv4QueueDiscItem> (q0->Peek ());
751 NS_TEST_EXPECT_MSG_NE (pktQ0->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
752 pktQ1 = DynamicCast<const Ipv4QueueDiscItem> (q1->Peek ());
753 NS_TEST_EXPECT_MSG_NE (pktQ1->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
754 pktQ2 = DynamicCast<const Ipv4QueueDiscItem> (q2->Peek ());
755 NS_TEST_EXPECT_MSG_NE (pktQ2->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
757 Simulator::Destroy ();
760 queueDisc = CreateObjectWithAttributes<FqCoDelQueueDisc> (
"MaxSize",
StringValue (
"10240p"),
"UseEcn",
BooleanValue (
true),
762 queueDisc->SetQuantum (1514);
763 queueDisc->Initialize ();
767 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
780 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
790 Simulator::Stop (
Seconds (8.0));
791 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
792 q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
793 q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
794 q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
795 q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
798 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
799 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
800 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
801 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
802 NS_TEST_EXPECT_MSG_NE (queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetNPackets (), 0,
"There should be some remaining packets");
805 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
806 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
807 q0->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 20 - q0->GetNPackets (),
"Number of CE threshold"
808 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
809 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
810 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
811 q1->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 20 - q1->GetNPackets (),
"Number of CE threshold"
812 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
813 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
814 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
815 q2->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 20 - q2->GetNPackets (),
"Number of CE threshold"
816 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
819 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
820 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 4,
"There should be 4 dropped packets"
821 " As queue delay is same as in test case 1, number of dropped packets should also be same");
822 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
823 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 4,
"There should be 4 dropped packets");
827 pktQ0 = DynamicCast<const Ipv4QueueDiscItem> (q0->Peek ());
828 NS_TEST_EXPECT_MSG_NE (pktQ0->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
829 pktQ1 = DynamicCast<const Ipv4QueueDiscItem> (q1->Peek ());
830 NS_TEST_EXPECT_MSG_NE (pktQ1->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
831 pktQ2 = DynamicCast<const Ipv4QueueDiscItem> (q2->Peek ());
832 NS_TEST_EXPECT_MSG_NE (pktQ2->GetHeader ().GetEcn (), Ipv4Header::ECN_NotECT,
"flow queue should have ECT0 packets");
834 Simulator::Destroy ();
865 virtual void DoRun (
void);
870 :
TestCase (
"Test credits and flows status")
884 queue->Enqueue (item);
891 queueDisc->SetQuantum (90);
892 queueDisc->Initialize ();
895 queueDisc->AddPacketFilter (filter);
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++)
989 queue->Enqueue (item);
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++)
1032 queueDisc->SetQuantum (1514);
1033 queueDisc->Initialize ();
1039 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1043 double delay = 0.0005;
1047 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1055 Simulator::Stop (
Seconds (8.0));
1059 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 66,
"There should be 66 marked packets"
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");
1063 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1064 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 0,
"There should not be any marked packets");
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),
1075 queueDisc->SetQuantum (1514);
1076 queueDisc->Initialize ();
1081 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1090 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1096 Simulator::Stop (
Seconds (8.0));
1097 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CoDelQueueDisc> ();
1099 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 68,
"There should be 68 marked packets"
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");
1103 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1104 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK), 1,
"There should be 1 marked packets");
1106 Simulator::Destroy ();
1116 :
TestSuite (
"fq-codel-queue-disc", UNIT)
This class tests the deficit per flow.
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr)
virtual ~FqCoDelQueueDiscDeficit()
virtual void DoRun(void)
Implementation to actually run this TestCase.
FqCoDelQueueDiscDeficit()
This class tests ECN marking Any future classifier options (e.g.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqCoDelQueueDiscECNMarking()
void Dequeue(Ptr< FqCoDelQueueDisc > queue, uint32_t nPkt)
FqCoDelQueueDiscECNMarking()
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows)
void DequeueWithDelay(Ptr< FqCoDelQueueDisc > queue, double delay, uint32_t nPkt)
This class tests the IP flows separation and the packet limit.
virtual ~FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit()
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr)
FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit()
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class tests L4S mode Any future classifier options (e.g.
FqCoDelQueueDiscL4sMode()
virtual ~FqCoDelQueueDiscL4sMode()
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt)
virtual void DoRun(void)
Implementation to actually run this TestCase.
void AddPacketWithDelay(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr, double delay, uint32_t nPkt)
void DequeueWithDelay(Ptr< FqCoDelQueueDisc > queue, double delay, uint32_t nPkt)
void Dequeue(Ptr< FqCoDelQueueDisc > queue, uint32_t nPkt)
This class tests packets for which there is no suitable filter.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqCoDelQueueDiscNoSuitableFilter()
FqCoDelQueueDiscNoSuitableFilter()
virtual ~FqCoDelQueueDiscSetLinearProbing()
virtual void DoRun(void)
Implementation to actually run this TestCase.
FqCoDelQueueDiscSetLinearProbing()
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header hdr)
This class tests the TCP flows separation.
virtual ~FqCoDelQueueDiscTCPFlowsSeparation()
FqCoDelQueueDiscTCPFlowsSeparation()
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
virtual void DoRun(void)
Implementation to actually run this TestCase.
FqCoDelQueueDiscTestSuite()
This class tests the UDP flows separation.
void AddPacket(Ptr< FqCoDelQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqCoDelQueueDiscUDPFlowsSeparation()
FqCoDelQueueDiscUDPFlowsSeparation()
Simple test packet filter able to classify IPv4 packets.
virtual ~Ipv4TestPacketFilter()
virtual int32_t DoClassify(Ptr< QueueDiscItem > item) const
Classify a packet.
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Checks if the filter is able to classify a kind of items.
static TypeId GetTypeId(void)
Get the type ID.
a polymophic address class
AttributeValue implementation for Boolean.
A CoDel 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 FqCoDelQueueDiscTestSuite fqCoDelQueueDiscTestSuite
@ 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_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report 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.