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")
124 queueDisc->AddPacketFilter (filter);
127 queueDisc->SetQuantum (1500);
128 queueDisc->Initialize ();
131 p = Create<Packet> ();
135 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
136 queueDisc->Enqueue (item);
137 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetNQueueDiscClasses (), 0,
"no flow queue should have been created");
139 p = Create<Packet> (
reinterpret_cast<const uint8_t*
> (
"hello, world"), 12);
140 item = Create<Ipv6QueueDiscItem> (p, dest, 0, ipv6Header);
141 queueDisc->Enqueue (item);
142 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetNQueueDiscClasses (), 0,
"no flow queue should have been created");
144 Simulator::Destroy ();
157 virtual void DoRun (
void);
162 :
TestCase (
"Test IP flows separation and packet limit")
176 queue->Enqueue (item);
184 queueDisc->SetQuantum (1500);
185 queueDisc->Initialize ();
197 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
198 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->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
205 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the flow queue");
206 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the flow queue");
209 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
210 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the flow queue");
211 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the flow queue");
213 Simulator::Destroy ();
226 virtual void DoRun (
void);
231 :
TestCase (
"Test credits and flows status")
245 queue->Enqueue (item);
253 queueDisc->SetQuantum (90);
254 queueDisc->Initialize ();
264 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
265 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
266 Ptr<FqCobaltFlow> flow1 = StaticCast<FqCobaltFlow> (queueDisc->GetQueueDiscClass (0));
267 NS_TEST_ASSERT_MSG_EQ (flow1->GetDeficit (),
static_cast<int32_t
> (queueDisc->GetQuantum ()),
"the deficit of the first flow must equal the quantum");
268 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the first flow must be in the list of new queues");
270 queueDisc->Dequeue ();
271 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
272 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the first flow queue");
279 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
280 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
281 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the first flow must still be in the list of new queues");
287 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
288 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
289 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the second flow queue");
290 Ptr<FqCobaltFlow> flow2 = StaticCast<FqCobaltFlow> (queueDisc->GetQueueDiscClass (1));
291 NS_TEST_ASSERT_MSG_EQ (flow2->GetDeficit (),
static_cast<int32_t
> (queueDisc->GetQuantum ()),
"the deficit of the second flow must equal the quantum");
292 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
295 queueDisc->Dequeue ();
296 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
297 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the first flow queue");
298 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
301 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
304 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::NEW_FLOW,
"the second flow must be in the list of new queues");
307 queueDisc->Dequeue ();
308 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 2,
"unexpected number of packets in the queue disc");
309 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
310 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
313 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
316 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
319 queueDisc->Dequeue ();
320 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 1,
"unexpected number of packets in the queue disc");
321 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the first flow queue");
322 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the second flow queue");
325 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
328 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
331 queueDisc->Dequeue ();
332 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 0,
"unexpected number of packets in the queue disc");
333 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the first flow queue");
334 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 0,
"unexpected number of packets in the second flow queue");
337 NS_TEST_ASSERT_MSG_EQ (flow1->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the first flow must be in the list of old queues");
340 NS_TEST_ASSERT_MSG_EQ (flow2->GetStatus (), FqCobaltFlow::OLD_FLOW,
"the second flow must be in the list of new queues");
343 queueDisc->Dequeue ();
355 Simulator::Destroy ();
368 virtual void DoRun (
void);
373 :
TestCase (
"Test TCP flows separation")
388 queue->Enqueue (item);
396 queueDisc->SetQuantum (1500);
397 queueDisc->Initialize ();
413 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
414 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->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
420 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
421 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
426 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
427 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
428 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
429 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
435 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
436 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
437 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
438 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
439 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the third flow queue");
441 Simulator::Destroy ();
454 virtual void DoRun (
void);
459 :
TestCase (
"Test UDP flows separation")
474 queue->Enqueue (item);
482 queueDisc->SetQuantum (1500);
483 queueDisc->Initialize ();
499 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 3,
"unexpected number of packets in the queue disc");
500 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->QueueDisc::GetNPackets (), 4,
"unexpected number of packets in the queue disc");
506 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
507 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
512 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 5,
"unexpected number of packets in the queue disc");
513 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
514 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
515 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
521 NS_TEST_ASSERT_MSG_EQ (queueDisc->QueueDisc::GetNPackets (), 7,
"unexpected number of packets in the queue disc");
522 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetNPackets (), 3,
"unexpected number of packets in the first flow queue");
523 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the second flow queue");
524 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetNPackets (), 1,
"unexpected number of packets in the third flow queue");
525 NS_TEST_ASSERT_MSG_EQ (queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetNPackets (), 2,
"unexpected number of packets in the third flow queue");
527 Simulator::Destroy ();
553 virtual void DoRun (
void);
576 for (uint32_t i = 0; i < nPkt; i++)
579 queue->Enqueue (item);
581 NS_TEST_EXPECT_MSG_EQ (queue->GetNQueueDiscClasses (), nQueueFlows,
"unexpected number of flow queues");
582 NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), nPktEnqueued,
"unexpected number of enqueued packets");
591 if (q3->GetNPackets () == 19)
596 for (uint32_t i = 0; i < nPkt; i++)
605 for (uint32_t i = 0; i < nPkt; i++)
631 queueDisc->SetQuantum (1514);
632 queueDisc->Initialize ();
638 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
653 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
663 Simulator::Stop (
Seconds (8.0));
671 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 19,
"There should be 19 marked packets."
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.");
675 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
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),
698 queueDisc->SetQuantum (1514);
699 queueDisc->Initialize ();
703 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
716 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
726 Simulator::Stop (
Seconds (8.0));
727 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
728 q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
729 q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
730 q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
731 q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
734 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
735 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets"
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");
738 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
739 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 6,
"There should be 6 marked packets"
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.");
742 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
743 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 13,
"There should be 13 marked packets"
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");
747 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
748 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
749 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
750 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 1,
"There should 1 dropped packet. As the queue"
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),
759 queueDisc->SetQuantum (1514);
760 queueDisc->Initialize ();
764 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
777 hdr.
SetEcn (Ipv4Header::ECN_NotECT);
790 Simulator::Stop (
Seconds (8.0));
791 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
792 q1 = queueDisc->GetQueueDiscClass (1)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
793 q2 = queueDisc->GetQueueDiscClass (2)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
794 q3 = queueDisc->GetQueueDiscClass (3)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
795 q4 = queueDisc->GetQueueDiscClass (4)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
798 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
799 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
800 q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q0->GetNPackets (),
"Number of CE threshold"
801 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
802 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
803 NS_TEST_EXPECT_MSG_EQ (q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
804 q1->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q1->GetNPackets (),
"Number of CE threshold"
805 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
806 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
807 NS_TEST_EXPECT_MSG_EQ (q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK) +
808 q2->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 20 - q2->GetNPackets (),
"Number of CE threshold"
809 " exceeded marks plus Number of Target exceeded marks should be equal to total number of packets dequeued");
812 NS_TEST_EXPECT_MSG_EQ (q3->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
814 "be equal to the number of times m_dropNext is updated");
815 NS_TEST_EXPECT_MSG_EQ (q4->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 0,
"There should not be any marked packets");
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")
869 queue->Enqueue (item);
876 queueDisc->SetQuantum (90);
877 queueDisc->Initialize ();
880 queueDisc->AddPacketFilter (filter);
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++)
981 queue->Enqueue (item);
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++)
1024 queueDisc->SetQuantum (1514);
1025 queueDisc->Initialize ();
1031 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1035 double delay = 0.0005;
1039 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1047 Simulator::Stop (
Seconds (8.0));
1051 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 66,
"There should be 66 marked packets"
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");
1055 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1056 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 0,
"There should not be any marked packets");
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),
1070 queueDisc->SetQuantum (1514);
1071 queueDisc->Initialize ();
1076 hdr.
SetEcn (Ipv4Header::ECN_ECT1);
1085 hdr.
SetEcn (Ipv4Header::ECN_ECT0);
1091 Simulator::Stop (
Seconds (8.0));
1092 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
1093 q0 = queueDisc->GetQueueDiscClass (0)->GetQueueDisc ()->GetObject <
CobaltQueueDisc> ();
1095 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::CE_THRESHOLD_EXCEEDED_MARK), 68,
"There should be 68 marked packets"
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");
1099 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNDroppedPackets (CobaltQueueDisc::TARGET_EXCEEDED_DROP), 0,
"There should not be any dropped packets");
1100 NS_TEST_EXPECT_MSG_EQ (q0->GetStats ().GetNMarkedPackets (CobaltQueueDisc::FORCED_MARK), 1,
"There should be 1 marked packets");
1102 Simulator::Destroy ();
1113 :
TestSuite (
"fq-cobalt-queue-disc", UNIT)
This class tests the deficit per flow.
FqCobaltQueueDiscDeficit()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqCobaltQueueDiscDeficit()
This class tests ECN marking The test is divided into 3 sub test cases.
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
virtual ~FqCobaltQueueDiscEcnMarking()
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt, u_int32_t nPktEnqueued, u_int32_t nQueueFlows)
void DropNextTracer(int64_t oldVal, int64_t newVal)
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)
FqCobaltQueueDiscIPFlowsSeparationAndPacketLimit()
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class tests L4S mode.
virtual ~FqCobaltQueueDiscL4sMode()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, u_int32_t nPkt)
virtual void DoRun(void)
Implementation to actually run this TestCase.
void DequeueWithDelay(Ptr< FqCobaltQueueDisc > queue, double delay, uint32_t nPkt)
void Dequeue(Ptr< FqCobaltQueueDisc > queue, uint32_t nPkt)
void AddPacketWithDelay(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr, double delay, uint32_t nPkt)
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()
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual ~FqCobaltQueueDiscSetLinearProbing()
FqCobaltQueueDiscSetLinearProbing()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header hdr)
This class tests the TCP flows separation.
virtual ~FqCobaltQueueDiscTCPFlowsSeparation()
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, TcpHeader tcpHdr)
virtual void DoRun(void)
Implementation to actually run this TestCase.
FqCobaltQueueDiscTCPFlowsSeparation()
FqCobaltQueueDiscTestSuite()
This class tests the UDP flows separation.
void AddPacket(Ptr< FqCobaltQueueDisc > queue, Ipv4Header ipHdr, UdpHeader udpHdr)
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 packet.
virtual ~Ipv4FqCobaltTestPacketFilter()
Ipv4FqCobaltTestPacketFilter()
static TypeId GetTypeId(void)
Get the type ID.
virtual bool CheckProtocol(Ptr< QueueDiscItem > item) const
Checks if the filter is able to classify a kind of items.
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 fqCobaltQueueDiscTestSuite
#define NS_UNUSED(x)
Mark a local variable as unused.
@ 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...