26 #include "ns3/cobalt-queue-disc.h"
27 #include "ns3/packet.h"
28 #include "ns3/uinteger.h"
29 #include "ns3/string.h"
30 #include "ns3/double.h"
32 #include "ns3/simulator.h"
54 virtual void AddHeader (
void);
55 virtual bool Mark (
void);
75 m_ecnCapablePacket (ecnCapable)
113 virtual void DoRun (
void);
128 :
TestCase (
"Basic enqueue and dequeue operations, and attribute setting" + std::to_string (mode))
139 uint32_t modeSize = 0;
144 "Verify that we can actually set the attribute Interval");
146 "Verify that we can actually set the attribute Target");
148 "Disable Blue enhancement");
159 true,
"Verify that we can actually set the attribute MaxSize");
171 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p1, dest,0,
false));
173 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p2, dest,0,
false));
175 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p3, dest,0,
false));
177 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p4, dest,0,
false));
179 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p5, dest,0,
false));
181 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (p6, dest,0,
false));
234 virtual void DoRun (
void);
253 :
TestCase (
"Drop tests verification for both packets and bytes mode")
262 uint32_t modeSize = 0;
274 queue = CreateObject<CobaltQueueDisc> ();
276 true,
"Verify that we can actually set the attribute MaxSize");
278 "Disable Blue enhancement");
290 Simulator::Stop (
Seconds (8.0));
305 for (uint32_t i = 0; i < nPkt; i++)
315 for (uint32_t i = 0; i < nPkt; i++)
317 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0,
true));
326 Simulator::Destroy ();
344 virtual void DoRun (
void);
375 :
TestCase (
"Basic mark operations")
400 uint32_t modeSize = 0;
414 true,
"Verify that we can actually set the attribute MaxSize");
416 true,
"Verify that we can actually set the attribute UseEcn");
418 "Disable Blue enhancement");
431 Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->
GetInterval ();
435 Simulator::Destroy ();
438 queue = CreateObject<CobaltQueueDisc> ();
440 true,
"Verify that we can actually set the attribute MaxSize");
442 true,
"Verify that we can actually set the attribute UseEcn");
444 "Disable Blue enhancement");
466 Simulator::Destroy ();
469 queue = CreateObject<CobaltQueueDisc> ();
471 true,
"Verify that we can actually set the attribute MaxSize");
473 true,
"Verify that we can actually set the attribute UseEcn");
475 "Disable Blue enhancement");
499 Simulator::Destroy ();
506 for (uint32_t i = 0; i < nPkt; i++)
508 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0, ecnCapable));
519 uint32_t currentDropCount = 0;
520 uint32_t currentMarkCount = 0;
522 if (initialMarkCount > 0 && currentTime.
GetNanoSeconds () > initialDropNext && testCase == 3)
527 if (initialQSize != 0)
533 if (currentDropCount != 0)
540 if (initialMarkCount == 0 && currentTime > queue->
GetTarget ())
542 if (currentTime < queue->GetInterval ())
549 "Sojourn time has just gone above target from below."
550 "Hence, there should be no marked packets");
558 "Sojourn time has been above target for at least interval."
559 "We enter the dropping state and perform initial packet marking"
560 "So there should be only 1 more packet dequeued.");
565 else if (initialMarkCount > 0)
572 "Sojourn is still above target."
573 "There should be only 1 more packet dequeued");
576 "current dropnext is equal to current time.");
583 "It's time for packet to be marked"
584 "So there should be only 1 more packet dequeued");
588 "to number of packets in the queue before first mark as the behavior until packet N should be the same.");
592 else if (testCase == 3)
594 if (initialMarkCount == 0 && currentTime > queue->
GetTarget ())
596 if (currentTime < queue->GetInterval ())
603 "Sojourn time has just gone above target from below."
604 "Hence, there should be no marked packets");
611 "Sojourn time has been above target for at least interval."
612 "We enter the dropping state and perform initial packet marking"
613 "So there should be only 1 more packet dequeued.");
618 else if (initialMarkCount > 0)
625 "Sojourn is still above target."
626 "So there should be only 1 more packet dequeued");
629 "as dropnext is equal to current time");
636 "It's time for packet to be dropped as packets are not ecnCapable"
637 "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
659 virtual void DoRun (
void);
693 :
TestCase (
"Test CE Threshold marking")
706 for (uint32_t i = 0; i < nPkt; i++)
708 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0,
true));
715 for (uint32_t i = 0; i < nPkt; i++)
729 "mark, the delay between the enqueueing of the packets decreased after the"
730 "1st mark (packet enqueued at 11ms) and increased for the packet enqueued after 20.6ms."
731 "Queue delay remains below or equal to 1ms for the packet enqueued before 28ms");
736 "marks, the delay between the enqueueing of the packets decreased after 1st mark"
737 "(packet enqueued at 11ms) and increased for the packet enqueued after 20.6ms."
738 "Queue delay remains below 1ms for the packets enqueued before 28ms and increases"
739 "for the packets enqueued after 28ms.");
746 for (uint32_t i = 0; i < nPkt; i++)
757 uint32_t modeSize = 0;
769 true,
"Verify that we can actually set the attribute UseEcn");
771 true,
"Verify that we can actually set the attribute UseEcn");
773 "Disable Blue enhancement");
794 Time waitUntilDecreasingEnqueueDelay = waitUntilFirstMark +
MilliSeconds(9);
801 Simulator::Destroy ();
824 virtual void DoRun (
void);
848 :
TestCase (
"Enhanced Blue tests verification for both packets and bytes mode")
862 uint32_t modeSize = 0;
875 Enqueue (queue, modeSize, 200);
878 Simulator::Stop (
Seconds (8.0));
884 NS_TEST_EXPECT_MSG_EQ (queue->
GetPdrop (), 0.234375,
"Pdrop should be increased by 1/256 for every packet whose sojourn time is above 400ms."
885 " From the 41st dequeue until the last one, sojourn time is above 400ms, so 60 packets have sojourn time above 400ms"
886 "hence Pdrop should be increased 60*(1/256) which is 0.234375");
888 Simulator::Destroy ();
891 queue = CreateObject<CobaltQueueDisc> ();
893 true,
"Verify that we can actually set the attribute UseEcn");
895 "Disable Blue enhancement");
897 Enqueue (queue, modeSize, 200);
900 Simulator::Stop (
Seconds (8.0));
907 Simulator::Destroy ();
914 for (uint32_t i = 0; i < nPkt; i++)
916 queue->
Enqueue (Create<CobaltQueueDiscTestItem> (Create<Packet> (size), dest, 0,
true));
929 for (uint32_t i = 0; i < nPkt; i++)