24 #include "ns3/codel-queue-disc.h" 
   25 #include "ns3/packet.h" 
   26 #include "ns3/uinteger.h" 
   27 #include "ns3/string.h" 
   28 #include "ns3/double.h" 
   30 #include "ns3/simulator.h" 
   35 #define REC_INV_SQRT_BITS_ns3 (8 * sizeof(uint16_t)) 
   38 #define REC_INV_SQRT_SHIFT_ns3 (32 - REC_INV_SQRT_BITS_ns3) 
   43   uint32_t invsqrt2 = ((uint64_t)invsqrt * invsqrt) >> 32;
 
   44   uint64_t val = (3LL << 32) - ((uint64_t)count * invsqrt2);
 
   47   val = (val * invsqrt) >> (32 - 2 + 1);
 
   53   return (uint32_t)(((uint64_t)val * ep_ro) >> 32);
 
   74   virtual void AddHeader (
void);
 
   75   virtual bool Mark(
void);
 
   95     m_ecnCapablePacket (ecnCapable)
 
  133   virtual void DoRun (
void);
 
  140   : 
TestCase (
"Basic enqueue and dequeue operations, and attribute setting")
 
  151   uint32_t modeSize = 0;
 
  156                          "Verify that we can actually set the attribute MinBytes");
 
  158                          "Verify that we can actually set the attribute Interval");
 
  160                          "Verify that we can actually set the attribute Target");
 
  171                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  172   queue->Initialize ();
 
  182   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 0 * modeSize, 
"There should be no packets in queue");
 
  183   queue->Enqueue (Create<CodelQueueDiscTestItem> (p1, dest, 
false));
 
  184   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 1 * modeSize, 
"There should be one packet in queue");
 
  185   queue->Enqueue (Create<CodelQueueDiscTestItem> (p2, dest, 
false));
 
  186   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 2 * modeSize, 
"There should be two packets in queue");
 
  187   queue->Enqueue (Create<CodelQueueDiscTestItem> (p3, dest, 
false));
 
  188   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 3 * modeSize, 
"There should be three packets in queue");
 
  189   queue->Enqueue (Create<CodelQueueDiscTestItem> (p4, dest, 
false));
 
  190   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 4 * modeSize, 
"There should be four packets in queue");
 
  191   queue->Enqueue (Create<CodelQueueDiscTestItem> (p5, dest, 
false));
 
  192   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 5 * modeSize, 
"There should be five packets in queue");
 
  193   queue->Enqueue (Create<CodelQueueDiscTestItem> (p6, dest, 
false));
 
  194   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 6 * modeSize, 
"There should be six packets in queue");
 
  197                          0, 
"There should be no packets being dropped due to full queue");
 
  201   item = queue->Dequeue ();
 
  203   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 5 * modeSize, 
"There should be five packets in queue");
 
  206   item = queue->Dequeue ();
 
  208   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 4 * modeSize, 
"There should be four packets in queue");
 
  211   item = queue->Dequeue ();
 
  213   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 3 * modeSize, 
"There should be three packets in queue");
 
  216   item = queue->Dequeue ();
 
  218   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 2 * modeSize, 
"There should be two packets in queue");
 
  221   item = queue->Dequeue ();
 
  223   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 1 * modeSize, 
"There should be one packet in queue");
 
  226   item = queue->Dequeue ();
 
  228   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 0 * modeSize, 
"There should be zero packet in queue");
 
  231   item = queue->Dequeue ();
 
  234   NS_TEST_EXPECT_MSG_EQ (queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
 
  235                          "There should be no packet drops according to CoDel algorithm");
 
  253   virtual void DoRun (
void);
 
  267   : 
TestCase (
"Basic overflow behavior")
 
  277   uint32_t modeSize = 0;
 
  296                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  298                          "Verify that we can actually set the attribute MinBytes");
 
  300   queue->Initialize ();
 
  303   queue->Enqueue (Create<CodelQueueDiscTestItem> (p1, dest, 
false));
 
  304   queue->Enqueue (Create<CodelQueueDiscTestItem> (p2, dest, 
false));
 
  305   queue->Enqueue (Create<CodelQueueDiscTestItem> (p3, dest, 
false));
 
  307   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 500 * modeSize, 
"There should be 500 packets in queue");
 
  309                          3, 
"There should be three packets being dropped due to full queue");
 
  316   for (uint32_t i = 0; i < nPkt; i++)
 
  318       queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest, 
false));
 
  332   virtual void DoRun (
void);
 
  336   : 
TestCase (
"NewtonStep arithmetic unit test")
 
  348   for (uint16_t recInvSqrt = 0xff; recInvSqrt > 0; recInvSqrt /= 2)
 
  350       for (uint32_t count = 1; count < 0xff; count *= 2)
 
  352            result = queue->NewtonStep (recInvSqrt, count);
 
  355                          "ns-3 NewtonStep() fails to match Linux equivalent");
 
  370   virtual void DoRun (
void);
 
  381   : 
TestCase (
"ControlLaw arithmetic unit test")
 
  400   uint32_t interval = queue->Time2CoDel (
MilliSeconds (100));
 
  402   uint32_t codelTimeVal;
 
  405       for (uint16_t recInvSqrt = 0xff; recInvSqrt > 0; recInvSqrt /= 2)
 
  407           codelTimeVal = queue->Time2CoDel (timeVal);
 
  408           uint32_t ns3Result = queue->ControlLaw (codelTimeVal, interval, recInvSqrt); 
 
  410           NS_TEST_EXPECT_MSG_EQ (ns3Result, linuxResult, 
"Linux result for ControlLaw should equal ns-3 result");
 
  430   virtual void DoRun (
void);
 
  456   : 
TestCase (
"Basic drop operations")
 
  475   uint32_t modeSize = 0;
 
  487                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  489   queue->Initialize ();
 
  492   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, 
"There should be 20 packets in queue.");
 
  496   Time waitUntilFirstDequeue =  2 * queue->GetTarget ();
 
  500   Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->GetInterval ();
 
  512   Simulator::Destroy ();
 
  519   for (uint32_t i = 0; i < nPkt; i++)
 
  521       queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest, 
false));
 
  528   uint32_t initialDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  529   uint32_t initialQSize = queue->GetCurrentSize ().GetValue ();
 
  530   uint32_t initialDropNext = queue->GetDropNext ();
 
  532   uint32_t currentDropCount = 0;
 
  534   if (initialDropCount > 0 && currentTime.
GetMicroSeconds () >= initialDropNext)
 
  539   if (initialQSize != 0)
 
  542       if (initialDropCount == 0 && currentTime > queue->GetTarget ())
 
  544           if (currentTime < queue->GetInterval ())
 
  546               currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  548                                      "Sojourn time has just gone above target from below." 
  549                                      "Hence, there should be no packet drops");
 
  550               NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"There should be 1 packet dequeued.");
 
  553           else if (currentTime >= queue->GetInterval ())
 
  555               currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  556               NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - 2 * modeSize, 
"Sojourn time has been above target for at least interval." 
  557                                      "We enter the dropping state, perform initial packet drop, and dequeue the next." 
  558                                      "So there should be 2 more packets dequeued.");
 
  562       else if (initialDropCount > 0)
 
  566               currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  567               NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"We are in dropping state." 
  568                                      "Sojourn is still above target." 
  569                                      "However, it's not time for next drop." 
  570                                      "So there should be only 1 more packet dequeued");
 
  572               NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, 
"There should still be only 1 packet drop from the last dequeue");
 
  576               currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  578                                      "It's time for next drop." 
  579                                      "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
 
  601   virtual void DoRun (
void);
 
  631   : 
TestCase (
"Basic mark operations")
 
  657   uint32_t modeSize = 0;
 
  671                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  673                          true, 
"Verify that we can actually set the attribute UseEcn");
 
  675   queue->Initialize ();
 
  679   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, 
"There should be 20 packets in queue.");
 
  683   Time waitUntilFirstDequeue =  2 * queue->GetTarget ();
 
  687   Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->GetInterval ();
 
  691   Simulator::Destroy ();
 
  694   queue = CreateObject<CoDelQueueDisc> ();
 
  696                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  698                          true, 
"Verify that we can actually set the attribute UseEcn");
 
  700   queue->Initialize ();
 
  704   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, 
"There should be 20 packets in queue.");
 
  722   Simulator::Destroy ();
 
  725   queue = CreateObject<CoDelQueueDisc> ();
 
  727                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  729                          true, 
"Verify that we can actually set the attribute UseEcn");
 
  731                          true, 
"Verify that we can actually set the attribute CeThreshold");
 
  733   queue->Initialize ();
 
  739   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, 
"There should be 20 packets in queue.");
 
  757   Simulator::Destroy ();
 
  760   queue = CreateObject<CoDelQueueDisc> ();
 
  762                          true, 
"Verify that we can actually set the attribute MaxSize");
 
  764                          true, 
"Verify that we can actually set the attribute UseEcn");
 
  766                          true, 
"Verify that we can actually set the attribute CeThreshold");
 
  768   queue->Initialize ();
 
  772   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, 
"There should be 20 packets in queue.");
 
  788   Simulator::Destroy ();
 
  795   for (uint32_t i = 0; i < nPkt; i++)
 
  797       queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest, ecnCapable));
 
  804   uint32_t initialTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  805   uint32_t initialCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  806   uint32_t initialQSize = queue->GetCurrentSize ().GetValue ();
 
  807   uint32_t initialDropNext = queue->GetDropNext ();
 
  809   uint32_t currentDropCount = 0;
 
  810   uint32_t currentTargetMarkCount = 0;
 
  811   uint32_t currentCeThreshMarkCount = 0;
 
  813   if (initialTargetMarkCount > 0 && currentTime.
GetMicroSeconds () >= initialDropNext && testCase == 3)
 
  818   if (initialQSize != 0)
 
  823           currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  824           if (currentDropCount == 1)
 
  829       else if (testCase == 2)
 
  831           if (initialTargetMarkCount == 0 && currentTime > queue->GetTarget ())
 
  833               if (currentTime < queue->GetInterval ())
 
  835                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  836                   currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  837                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  838                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"There should be 1 packet dequeued.");
 
  841                                         "Sojourn time has just gone above target from below." 
  842                                         "Hence, there should be no target exceeded marked packets");
 
  844                                         "Hence, there should not be any CE threshold exceeded marked packet");
 
  846               else if (currentTime >= queue->GetInterval ())
 
  848                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  849                   currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  851                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  852                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"Sojourn time has been above target for at least interval." 
  853                                         "We enter the dropping state and perform initial packet marking" 
  854                                         "So there should be only 1 more packet dequeued.");
 
  856                   NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, 
"There should be 1 target exceeded marked packet");
 
  857                   NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 0, 
"There should not be any CE threshold exceeded marked packet");
 
  860           else if (initialTargetMarkCount > 0)
 
  864                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  865                   currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  866                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  867                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"We are in dropping state." 
  868                                         "Sojourn is still above target." 
  869                                         "However, it's not time for next target exceeded mark." 
  870                                         "So there should be only 1 more packet dequeued");
 
  872                   NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, 
"There should still be only 1 target exceeded marked packet from the last dequeue");
 
  873                   NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 0, 
"There should not be any CE threshold exceeded marked packet");
 
  877                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  878                   currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  879                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  880                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"We are in dropping state." 
  881                                         "It's time for packet to be marked" 
  882                                         "So there should be only 1 more packet dequeued");
 
  886                                         "to number of packets in the queue before first mark as the behavior untill packet N should be the same.");
 
  887                   NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 0, 
"There should not be any CE threshold exceeded marked packet");
 
  891       else if (testCase == 3)
 
  893           if (initialTargetMarkCount == 0 && currentTime > queue->GetTarget ())
 
  895               if (currentTime < queue->GetInterval ())
 
  897                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  898                   currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  899                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  900                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"There should be 1 packet dequeued.");
 
  903                                         "Sojourn time has just gone above target from below." 
  904                                         "Hence, there should be no target exceeded marked packets");
 
  906                                         "Hence, there should be 1 CE threshold exceeded marked packet");
 
  908               else if (currentTime >= queue->GetInterval ())
 
  910                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  911                   currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  912                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  913                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"Sojourn time has been above target for at least interval." 
  914                                         "We enter the dropping state and perform initial packet marking" 
  915                                         "So there should be only 1 more packet dequeued.");
 
  917                   NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, 
"There should be 1 target exceeded marked packet");
 
  918                   NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 1, 
"There should be 1 CE threshold exceeded marked packets");
 
  921           else if (initialTargetMarkCount > 0)
 
  925                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  926                   currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  927                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  928                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"We are in dropping state." 
  929                                         "Sojourn is still above target." 
  930                                         "However, it's not time for next target exceeded mark." 
  931                                         "So there should be only 1 more packet dequeued");
 
  933                   NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, 
"There should still be only 1 target exceeded marked packet from the last dequeue");
 
  934                   NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 2, 
"There should be 2 CE threshold exceeded marked packets");
 
  938                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  939                   currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
 
  940                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  942                                         "It's time for packet to be dropped as packets are not ecnCapable" 
  943                                         "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
 
  945                   NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, 
"There should still be only 1 target exceeded marked packet");
 
  946                   NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 2, 
"There should still be 2 CE threshold exceeded marked packet as packets are not ecnCapable");
 
  950       else if (testCase == 4)
 
  952           if (currentTime < queue->GetTarget ())
 
  954               if (initialCeThreshMarkCount == 0 && currentTime < 
MilliSeconds (2))
 
  956                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  957                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  958                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"There should be 1 packet dequeued.");
 
  961                                         "Hence, there should not be any CE threshold exceeded marked packet");
 
  965                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  966                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  967                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"There should be only 1 more packet dequeued.");
 
  970                                         "There should be 1 CE threshold exceeded marked packet");
 
  973           else if (initialCeThreshMarkCount > 0 && currentTime < queue->GetInterval ())
 
  975               if (initialCeThreshMarkCount < 2)
 
  977                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  978                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  979                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"There should be only 1 more packet dequeued.");
 
  981                   NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 2, 
"There should be 2 CE threshold exceeded marked packets");
 
  985                   currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
 
  986                   currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
 
  987                   NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, 
"There should be only 1 more packet dequeued.");
 
  989                   NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 3, 
"There should be 3 CE threshold exceeded marked packet");
 
Test 5: enqueue/dequeue with drops according to CoDel algorithm.
 
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
 
CoDelQueueDiscBasicDrop(QueueSizeUnit mode)
Constructor.
 
void Dequeue(Ptr< CoDelQueueDisc > queue, uint32_t modeSize)
Dequeue function.
 
void Enqueue(Ptr< CoDelQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
 
virtual void DoRun(void)
Implementation to actually run this TestCase.
 
void DropNextTracer(uint32_t oldVal, uint32_t newVal)
Drop next tracer function.
 
Test 1: simple enqueue/dequeue with no drops.
 
CoDelQueueDiscBasicEnqueueDequeue(QueueSizeUnit mode)
Constructor.
 
virtual void DoRun(void)
Implementation to actually run this TestCase.
 
Test 6: enqueue/dequeue with marks according to CoDel algorithm.
 
uint32_t nPacketsBeforeFirstMark
Number of packets in the queue before first mark.
 
void Enqueue(Ptr< CoDelQueueDisc > queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
Enqueue function.
 
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
 
void DropNextTracer(uint32_t oldVal, uint32_t newVal)
Drop next tracer function.
 
uint32_t nPacketsBeforeFirstDrop
Number of packets in the queue before first drop.
 
void Dequeue(Ptr< CoDelQueueDisc > queue, uint32_t modeSize, uint32_t testCase)
Dequeue function.
 
virtual void DoRun(void)
Implementation to actually run this TestCase.
 
CoDelQueueDiscBasicMark(QueueSizeUnit mode)
Constructor.
 
Test 2: enqueue with drops due to queue overflow.
 
CoDelQueueDiscBasicOverflow(QueueSizeUnit mode)
Constructor.
 
virtual void DoRun(void)
Implementation to actually run this TestCase.
 
void Enqueue(Ptr< CoDelQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
 
Test 4: ControlLaw unit test - test against explicit port of Linux implementation.
 
CoDelQueueDiscControlLawTest()
 
virtual void DoRun(void)
Implementation to actually run this TestCase.
 
uint32_t _codel_control_law(uint32_t t, uint32_t interval, uint32_t recInvSqrt)
Codel control law function.
 
Test 3: NewtonStep unit test - test against explicit port of Linux implementation.
 
virtual void DoRun(void)
Implementation to actually run this TestCase.
 
CoDelQueueDiscNewtonStepTest()
 
CoDel Queue Disc Test Suite.
 
CoDelQueueDiscTestSuite()
 
Codel Queue Disc Test Item.
 
virtual void AddHeader(void)
Add the header to the packet.
 
bool m_ecnCapablePacket
ECN capable packet?
 
CodelQueueDiscTestItem(const CodelQueueDiscTestItem &)
Copy constructor Disable default implementation to avoid misuse.
 
virtual ~CodelQueueDiscTestItem()
 
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
 
a polymophic address class
 
AttributeValue implementation for Boolean.
 
uint64_t GetUid(void) const
Returns the packet's Uid.
 
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
 
Class for representing queue sizes.
 
Hold variables of type string.
 
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
 
@ UNIT
This test suite implements a Unit Test.
 
Simulation virtual time values and global simulation resolution.
 
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
 
AttributeValue implementation for Time.
 
Hold an unsigned integer type.
 
#define REC_INV_SQRT_SHIFT_ns3
 
static uint16_t _codel_Newton_step(uint16_t rec_inv_sqrt, uint32_t count)
 
static uint32_t _reciprocal_scale(uint32_t val, uint32_t ep_ro)
 
#define NS_UNUSED(x)
Mark a local variable as unused.
 
QueueSizeUnit
Enumeration of the operating modes of queues.
 
@ BYTES
Use number of bytes for queue size.
 
@ PACKETS
Use number of packets for queue size.
 
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
 
#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.
 
CoDelQueueDiscTestSuite g_coDelQueueTestSuite
the test suite
 
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...
 
uint32_t pktSize
packet size used for the simulation (in bytes)