A Discrete-Event Network Simulator
API
codel-queue-disc-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 ResiliNets, ITTC, University of Kansas
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Truc Anh N Nguyen <trucanh524@gmail.com>
19  * Modified by: Pasquale Imputato <p.imputato@gmail.com>
20  *
21  */
22 
23 #include "ns3/test.h"
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"
29 #include "ns3/log.h"
30 #include "ns3/simulator.h"
31 
32 using namespace ns3;
33 
34 // The following code borrowed from Linux codel.h, for unit testing
35 #define REC_INV_SQRT_BITS_ns3 (8 * sizeof(uint16_t))
36 /* or sizeof_in_bits(rec_inv_sqrt) */
37 /* needed shift to get a Q0.32 number from rec_inv_sqrt */
38 #define REC_INV_SQRT_SHIFT_ns3 (32 - REC_INV_SQRT_BITS_ns3)
39 
40 static uint16_t _codel_Newton_step (uint16_t rec_inv_sqrt, uint32_t count)
41 {
42  uint32_t invsqrt = ((uint32_t)rec_inv_sqrt) << REC_INV_SQRT_SHIFT_ns3;
43  uint32_t invsqrt2 = ((uint64_t)invsqrt * invsqrt) >> 32;
44  uint64_t val = (3LL << 32) - ((uint64_t)count * invsqrt2);
45 
46  val >>= 2; /* avoid overflow in following multiply */
47  val = (val * invsqrt) >> (32 - 2 + 1);
48  return static_cast<uint16_t>(val >> REC_INV_SQRT_SHIFT_ns3);
49 }
50 
51 static uint32_t _reciprocal_scale (uint32_t val, uint32_t ep_ro)
52 {
53  return (uint32_t)(((uint64_t)val * ep_ro) >> 32);
54 }
55 // End Linux borrow
56 
64 public:
72  CodelQueueDiscTestItem (Ptr<Packet> p, const Address & addr, bool ecnCapable);
73  virtual ~CodelQueueDiscTestItem ();
74  virtual void AddHeader (void);
75  virtual bool Mark(void);
76 
77 private:
91 };
92 
94  : QueueDiscItem (p, addr, ecnCapable),
95  m_ecnCapablePacket (ecnCapable)
96 {
97 }
98 
100 {
101 }
102 
103 void
105 {
106 }
107 
108 bool
110 {
111  if (m_ecnCapablePacket)
112  {
113  return true;
114  }
115  return false;
116 }
117 
125 {
126 public:
133  virtual void DoRun (void);
134 
135 private:
137 };
138 
140  : TestCase ("Basic enqueue and dequeue operations, and attribute setting")
141 {
142  m_mode = mode;
143 }
144 
145 void
147 {
148  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
149 
150  uint32_t pktSize = 1000;
151  uint32_t modeSize = 0;
152 
153  Address dest;
154 
155  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (pktSize)), true,
156  "Verify that we can actually set the attribute MinBytes");
157  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Interval", StringValue ("50ms")), true,
158  "Verify that we can actually set the attribute Interval");
159  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Target", StringValue ("4ms")), true,
160  "Verify that we can actually set the attribute Target");
161 
163  {
164  modeSize = pktSize;
165  }
166  else if (m_mode == QueueSizeUnit::PACKETS)
167  {
168  modeSize = 1;
169  }
170  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 1500))),
171  true, "Verify that we can actually set the attribute MaxSize");
172  queue->Initialize ();
173 
174  Ptr<Packet> p1, p2, p3, p4, p5, p6;
175  p1 = Create<Packet> (pktSize);
176  p2 = Create<Packet> (pktSize);
177  p3 = Create<Packet> (pktSize);
178  p4 = Create<Packet> (pktSize);
179  p5 = Create<Packet> (pktSize);
180  p6 = Create<Packet> (pktSize);
181 
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");
195 
196  NS_TEST_EXPECT_MSG_EQ (queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::OVERLIMIT_DROP),
197  0, "There should be no packets being dropped due to full queue");
198 
199  Ptr<QueueDiscItem> item;
200 
201  item = queue->Dequeue ();
202  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the first packet");
203  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 5 * modeSize, "There should be five packets in queue");
204  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p1->GetUid (), "was this the first packet ?");
205 
206  item = queue->Dequeue ();
207  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the second packet");
208  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 4 * modeSize, "There should be four packets in queue");
209  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (), "Was this the second packet ?");
210 
211  item = queue->Dequeue ();
212  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the third packet");
213  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 3 * modeSize, "There should be three packets in queue");
214  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p3->GetUid (), "Was this the third packet ?");
215 
216  item = queue->Dequeue ();
217  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the forth packet");
218  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 2 * modeSize, "There should be two packets in queue");
219  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p4->GetUid (), "Was this the fourth packet ?");
220 
221  item = queue->Dequeue ();
222  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the fifth packet");
223  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 1 * modeSize, "There should be one packet in queue");
224  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p5->GetUid (), "Was this the fifth packet ?");
225 
226  item = queue->Dequeue ();
227  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the last packet");
228  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 0 * modeSize, "There should be zero packet in queue");
229  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p6->GetUid (), "Was this the sixth packet ?");
230 
231  item = queue->Dequeue ();
232  NS_TEST_EXPECT_MSG_EQ ((item == 0), true, "There are really no packets in queue");
233 
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");
236 }
237 
245 {
246 public:
253  virtual void DoRun (void);
254 
255 private:
262  void Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt);
264 };
265 
267  : TestCase ("Basic overflow behavior")
268 {
269  m_mode = mode;
270 }
271 
272 void
274 {
275  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
276  uint32_t pktSize = 1000;
277  uint32_t modeSize = 0;
278 
279  Address dest;
280 
282  {
283  modeSize = pktSize;
284  }
285  else if (m_mode == QueueSizeUnit::PACKETS)
286  {
287  modeSize = 1;
288  }
289 
290  Ptr<Packet> p1, p2, p3;
291  p1 = Create<Packet> (pktSize);
292  p2 = Create<Packet> (pktSize);
293  p3 = Create<Packet> (pktSize);
294 
295  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
296  true, "Verify that we can actually set the attribute MaxSize");
297  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (pktSize)), true,
298  "Verify that we can actually set the attribute MinBytes");
299 
300  queue->Initialize ();
301 
302  Enqueue (queue, pktSize, 500);
303  queue->Enqueue (Create<CodelQueueDiscTestItem> (p1, dest, false));
304  queue->Enqueue (Create<CodelQueueDiscTestItem> (p2, dest, false));
305  queue->Enqueue (Create<CodelQueueDiscTestItem> (p3, dest, false));
306 
307  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 500 * modeSize, "There should be 500 packets in queue");
308  NS_TEST_EXPECT_MSG_EQ (queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::OVERLIMIT_DROP),
309  3, "There should be three packets being dropped due to full queue");
310 }
311 
312 void
313 CoDelQueueDiscBasicOverflow::Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt)
314 {
315  Address dest;
316  for (uint32_t i = 0; i < nPkt; i++)
317  {
318  queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest, false));
319  }
320 }
321 
329 {
330 public:
332  virtual void DoRun (void);
333 };
334 
336  : TestCase ("NewtonStep arithmetic unit test")
337 {
338 }
339 
340 void
342 {
343  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
344 
345  // Spot check a few points in the expected operational range of
346  // CoDelQueueDisc's m_count and m_recInvSqrt variables
347  uint16_t result;
348  for (uint16_t recInvSqrt = 0xff; recInvSqrt > 0; recInvSqrt /= 2)
349  {
350  for (uint32_t count = 1; count < 0xff; count *= 2)
351  {
352  result = queue->NewtonStep (recInvSqrt, count);
353  // Test that ns-3 value is exactly the same as the Linux value
354  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (recInvSqrt, count), result,
355  "ns-3 NewtonStep() fails to match Linux equivalent");
356  }
357  }
358 }
359 
367 {
368 public:
370  virtual void DoRun (void);
378  uint32_t _codel_control_law (uint32_t t, uint32_t interval, uint32_t recInvSqrt);
379 };
380 
382  : TestCase ("ControlLaw arithmetic unit test")
383 {
384 }
385 
386 // The following code borrowed from Linux codel.h,
387 // except the addition of queue parameter
388 uint32_t
389 CoDelQueueDiscControlLawTest::_codel_control_law (uint32_t t, uint32_t interval, uint32_t recInvSqrt)
390 {
391  return t + _reciprocal_scale (interval, recInvSqrt << REC_INV_SQRT_SHIFT_ns3);
392 }
393 // End Linux borrrow
394 
395 void
397 {
398  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
399 
400  // Check a few points within the operational range of ControlLaw
401  uint32_t interval = queue->Time2CoDel (MilliSeconds (100));
402 
403  uint32_t codelTimeVal;
404  for (Time timeVal = Seconds (0); timeVal <= Seconds (20); timeVal += MilliSeconds (100))
405  {
406  for (uint16_t recInvSqrt = 0xff; recInvSqrt > 0; recInvSqrt /= 2)
407  {
408  codelTimeVal = queue->Time2CoDel (timeVal);
409  uint32_t ns3Result = queue->ControlLaw (codelTimeVal, interval, recInvSqrt);
410  uint32_t linuxResult = _codel_control_law (codelTimeVal, interval, recInvSqrt);
411  NS_TEST_EXPECT_MSG_EQ (ns3Result, linuxResult, "Linux result for ControlLaw should equal ns-3 result");
412  }
413  }
414 }
415 
423 {
424 public:
431  virtual void DoRun (void);
432 
433 private:
440  void Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt);
445  void Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize);
451  void DropNextTracer (uint32_t oldVal, uint32_t newVal);
453  uint32_t m_dropNextCount;
454 };
455 
457  : TestCase ("Basic drop operations")
458 {
459  m_mode = mode;
460  m_dropNextCount = 0;
461 }
462 
463 void
464 CoDelQueueDiscBasicDrop::DropNextTracer (uint32_t oldVal, uint32_t newVal)
465 {
466  NS_UNUSED(oldVal);
467  NS_UNUSED(newVal);
468  m_dropNextCount++;
469 }
470 
471 void
473 {
474  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
475  uint32_t pktSize = 1000;
476  uint32_t modeSize = 0;
477 
479  {
480  modeSize = pktSize;
481  }
482  else if (m_mode == QueueSizeUnit::PACKETS)
483  {
484  modeSize = 1;
485  }
486 
487  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
488  true, "Verify that we can actually set the attribute MaxSize");
489 
490  queue->Initialize ();
491 
492  Enqueue (queue, pktSize, 20);
493  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, "There should be 20 packets in queue.");
494 
495  // Although the first dequeue occurs with a sojourn time above target
496  // the dequeue should be successful in this interval
497  Time waitUntilFirstDequeue = 2 * queue->GetTarget ();
498  Simulator::Schedule (waitUntilFirstDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
499 
500  // This dequeue should cause a drop
501  Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->GetInterval ();
502  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
503 
504  // Although we are in dropping state, it's not time for next drop
505  // the dequeue should not cause a drop
506  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
507 
508  // In dropping time and it's time for next drop
509  // the dequeue should cause additional packet drops
510  Simulator::Schedule (waitUntilSecondDequeue * 2, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
511 
512  Simulator::Run ();
513  Simulator::Destroy ();
514 }
515 
516 void
517 CoDelQueueDiscBasicDrop::Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt)
518 {
519  Address dest;
520  for (uint32_t i = 0; i < nPkt; i++)
521  {
522  queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest, false));
523  }
524 }
525 
526 void
528 {
529  uint32_t initialDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
530  uint32_t initialQSize = queue->GetCurrentSize ().GetValue ();
531  uint32_t initialDropNext = queue->GetDropNext ();
532  Time currentTime = Simulator::Now ();
533  uint32_t currentDropCount = 0;
534 
535  if (initialDropCount > 0 && currentTime.GetMicroSeconds () >= initialDropNext)
536  {
538  }
539 
540  if (initialQSize != 0)
541  {
542  Ptr<QueueDiscItem> item = queue->Dequeue ();
543  if (initialDropCount == 0 && currentTime > queue->GetTarget ())
544  {
545  if (currentTime < queue->GetInterval ())
546  {
547  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
548  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "We are not in dropping state."
549  "Sojourn time has just gone above target from below."
550  "Hence, there should be no packet drops");
551  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be 1 packet dequeued.");
552 
553  }
554  else if (currentTime >= queue->GetInterval ())
555  {
556  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
557  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval."
558  "We enter the dropping state, perform initial packet drop, and dequeue the next."
559  "So there should be 2 more packets dequeued.");
560  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should be 1 packet drop");
561  }
562  }
563  else if (initialDropCount > 0)
564  { // In dropping state
565  if (currentTime.GetMicroSeconds () < initialDropNext)
566  {
567  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
568  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "We are in dropping state."
569  "Sojourn is still above target."
570  "However, it's not time for next drop."
571  "So there should be only 1 more packet dequeued");
572 
573  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should still be only 1 packet drop from the last dequeue");
574  }
575  else if (currentTime.GetMicroSeconds () >= initialDropNext)
576  {
577  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
578  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
579  "It's time for next drop."
580  "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
581  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1 + m_dropNextCount, "The number of drops equals to the number of times m_dropNext is updated plus 1 from last dequeue");
582  }
583  }
584  }
585 }
586 
594 {
595 public:
602  virtual void DoRun (void);
603 
604 private:
612  void Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt, bool ecnCapable);
618  void Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize, uint32_t testCase);
624  void DropNextTracer (uint32_t oldVal, uint32_t newVal);
626  uint32_t m_dropNextCount;
629 };
630 
632  : TestCase ("Basic mark operations")
633 {
634  m_mode = mode;
635  m_dropNextCount = 0;
636 }
637 
638 void
639 CoDelQueueDiscBasicMark::DropNextTracer (uint32_t oldVal, uint32_t newVal)
640 {
641  NS_UNUSED(oldVal);
642  NS_UNUSED(newVal);
643  m_dropNextCount++;
644 }
645 
646 void
648 {
649  // Test is divided into 4 sub test cases:
650  // 1) Packets are not ECN capable.
651  // 2) Packets are ECN capable but marking due to exceeding CE threshold disabled
652  // 3) Some packets are ECN capable, with CE threshold set to 2ms.
653  // 4) Packets are ECN capable and CE threshold set to 2ms
654 
655  // Test case 1
656  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
657  uint32_t pktSize = 1000;
658  uint32_t modeSize = 0;
661 
663  {
664  modeSize = pktSize;
665  }
666  else if (m_mode == QueueSizeUnit::PACKETS)
667  {
668  modeSize = 1;
669  }
670 
671  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
672  true, "Verify that we can actually set the attribute MaxSize");
673  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (true)),
674  true, "Verify that we can actually set the attribute UseEcn");
675 
676  queue->Initialize ();
677 
678  // Not-ECT traffic to induce packet drop
679  Enqueue (queue, pktSize, 20, false);
680  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, "There should be 20 packets in queue.");
681 
682  // Although the first dequeue occurs with a sojourn time above target
683  // there should not be any dropped packets in this interval
684  Time waitUntilFirstDequeue = 2 * queue->GetTarget ();
685  Simulator::Schedule (waitUntilFirstDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 1);
686 
687  // This dequeue should cause a packet to be dropped
688  Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->GetInterval ();
689  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 1);
690 
691  Simulator::Run ();
692  Simulator::Destroy ();
693 
694  // Test case 2, queue with ECN capable traffic for marking of packets instead of dropping
695  queue = CreateObject<CoDelQueueDisc> ();
696  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
697  true, "Verify that we can actually set the attribute MaxSize");
698  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (true)),
699  true, "Verify that we can actually set the attribute UseEcn");
700 
701  queue->Initialize ();
702 
703  // ECN capable traffic to induce packets to be marked
704  Enqueue (queue, pktSize, 20, true);
705  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, "There should be 20 packets in queue.");
706 
707  // Although the first dequeue occurs with a sojourn time above target
708  // there should not be any target exceeded marked packets in this interval
709  Simulator::Schedule (waitUntilFirstDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 2);
710 
711  // This dequeue should cause a packet to be marked
712  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 2);
713 
714  // Although we are in dropping state, it's not time for next packet to be target exceeded marked
715  // the dequeue should not cause a packet to be target exceeded marked
716  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 2);
717 
718  // In dropping time and it's time for next packet to be target exceeded marked
719  // the dequeue should cause additional packet to be target exceeded marked
720  Simulator::Schedule (waitUntilSecondDequeue * 2, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 2);
721 
722  Simulator::Run ();
723  Simulator::Destroy ();
724 
725  // Test case 3, some packets are ECN capable, with CE threshold set to 2ms
726  queue = CreateObject<CoDelQueueDisc> ();
727  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
728  true, "Verify that we can actually set the attribute MaxSize");
729  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (true)),
730  true, "Verify that we can actually set the attribute UseEcn");
731  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("CeThreshold", TimeValue (MilliSeconds (2))),
732  true, "Verify that we can actually set the attribute CeThreshold");
733 
734  queue->Initialize ();
735 
736  // First 3 packets in the queue are ecnCapable
737  Enqueue (queue, pktSize, 3, true);
738  // Rest of the packet are not ecnCapable
739  Enqueue (queue, pktSize, 17, false);
740  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, "There should be 20 packets in queue.");
741 
742  // Although the first dequeue occurs with a sojourn time above target
743  // there should not be any target exceeded marked packets in this interval
744  Simulator::Schedule (waitUntilFirstDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 3);
745 
746  // This dequeue should cause a packet to be marked
747  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 3);
748 
749  // Although we are in dropping state, it's not time for next packet to be target exceeded marked
750  // the dequeue should not cause a packet to be target exceeded marked
751  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 3);
752 
753  // In dropping time and it's time for next packet to be dropped as packets are not ECN capable
754  // the dequeue should cause packet to be dropped
755  Simulator::Schedule (waitUntilSecondDequeue * 2, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 3);
756 
757  Simulator::Run ();
758  Simulator::Destroy ();
759 
760  // Test case 4, queue with ECN capable traffic and CeThreshold set for marking of packets instead of dropping
761  queue = CreateObject<CoDelQueueDisc> ();
762  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
763  true, "Verify that we can actually set the attribute MaxSize");
764  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("UseEcn", BooleanValue (true)),
765  true, "Verify that we can actually set the attribute UseEcn");
766  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("CeThreshold", TimeValue (MilliSeconds (2))),
767  true, "Verify that we can actually set the attribute CeThreshold");
768 
769  queue->Initialize ();
770 
771  // ECN capable traffic to induce packets to be marked
772  Enqueue (queue, pktSize, 20, true);
773  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, "There should be 20 packets in queue.");
774 
775  // The first dequeue occurs with a sojourn time below CE threshold
776  // there should not any be CE threshold exceeded marked packets
777  Simulator::Schedule (MilliSeconds (1), &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 4);
778 
779  // Sojourn time above CE threshold so this dequeue should cause a packet to be CE thershold exceeded marked
780  Simulator::Schedule (MilliSeconds (3), &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 4);
781 
782  // the dequeue should cause a packet to be CE threshold exceeded marked
783  Simulator::Schedule (waitUntilFirstDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 4);
784 
785  // In dropping time and it's time for next packet to be dropped but because of using ECN, packet should be marked
786  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicMark::Dequeue, this, queue, modeSize, 4);
787 
788  Simulator::Run ();
789  Simulator::Destroy ();
790 }
791 
792 void
793 CoDelQueueDiscBasicMark::Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
794 {
795  Address dest;
796  for (uint32_t i = 0; i < nPkt; i++)
797  {
798  queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest, ecnCapable));
799  }
800 }
801 
802 void
803 CoDelQueueDiscBasicMark::Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize, uint32_t testCase)
804 {
805  uint32_t initialTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
806  uint32_t initialCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
807  uint32_t initialQSize = queue->GetCurrentSize ().GetValue ();
808  uint32_t initialDropNext = queue->GetDropNext ();
809  Time currentTime = Simulator::Now ();
810  uint32_t currentDropCount = 0;
811  uint32_t currentTargetMarkCount = 0;
812  uint32_t currentCeThreshMarkCount = 0;
813 
814  if (initialTargetMarkCount > 0 && currentTime.GetMicroSeconds () >= initialDropNext && testCase == 3)
815  {
817  }
818 
819  if (initialQSize != 0)
820  {
821  Ptr<QueueDiscItem> item = queue->Dequeue ();
822  if (testCase == 1)
823  {
824  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
825  if (currentDropCount == 1)
826  {
827  nPacketsBeforeFirstDrop = initialQSize;
828  }
829  }
830  else if (testCase == 2)
831  {
832  if (initialTargetMarkCount == 0 && currentTime > queue->GetTarget ())
833  {
834  if (currentTime < queue->GetInterval ())
835  {
836  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
837  currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
838  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
839  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be 1 packet dequeued.");
840  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
841  NS_TEST_ASSERT_MSG_EQ (currentTargetMarkCount, 0, "We are not in dropping state."
842  "Sojourn time has just gone above target from below."
843  "Hence, there should be no target exceeded marked packets");
844  NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 0, "Marking due to CE threshold is disabled"
845  "Hence, there should not be any CE threshold exceeded marked packet");
846  }
847  else if (currentTime >= queue->GetInterval ())
848  {
849  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
850  currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
851  nPacketsBeforeFirstMark = initialQSize;
852  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
853  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "Sojourn time has been above target for at least interval."
854  "We enter the dropping state and perform initial packet marking"
855  "So there should be only 1 more packet dequeued.");
856  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
857  NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, "There should be 1 target exceeded marked packet");
858  NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 0, "There should not be any CE threshold exceeded marked packet");
859  }
860  }
861  else if (initialTargetMarkCount > 0)
862  { // In dropping state
863  if (currentTime.GetMicroSeconds () < initialDropNext)
864  {
865  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
866  currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
867  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
868  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "We are in dropping state."
869  "Sojourn is still above target."
870  "However, it's not time for next target exceeded mark."
871  "So there should be only 1 more packet dequeued");
872  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
873  NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, "There should still be only 1 target exceeded marked packet from the last dequeue");
874  NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 0, "There should not be any CE threshold exceeded marked packet");
875  }
876  else if (currentTime.GetMicroSeconds () >= initialDropNext)
877  {
878  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
879  currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
880  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
881  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "We are in dropping state."
882  "It's time for packet to be marked"
883  "So there should be only 1 more packet dequeued");
884  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
885  NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 2, "There should 2 target exceeded marked packet");
886  NS_TEST_EXPECT_MSG_EQ (nPacketsBeforeFirstDrop, nPacketsBeforeFirstMark, "Number of packets in the queue before drop should be equal"
887  "to number of packets in the queue before first mark as the behavior untill packet N should be the same.");
888  NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 0, "There should not be any CE threshold exceeded marked packet");
889  }
890  }
891  }
892  else if (testCase == 3)
893  {
894  if (initialTargetMarkCount == 0 && currentTime > queue->GetTarget ())
895  {
896  if (currentTime < queue->GetInterval ())
897  {
898  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
899  currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
900  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
901  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be 1 packet dequeued.");
902  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
903  NS_TEST_ASSERT_MSG_EQ (currentTargetMarkCount, 0, "We are not in dropping state."
904  "Sojourn time has just gone above target from below."
905  "Hence, there should be no target exceeded marked packets");
906  NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 1, "Sojourn time has gone above CE threshold."
907  "Hence, there should be 1 CE threshold exceeded marked packet");
908  }
909  else if (currentTime >= queue->GetInterval ())
910  {
911  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
912  currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
913  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
914  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "Sojourn time has been above target for at least interval."
915  "We enter the dropping state and perform initial packet marking"
916  "So there should be only 1 more packet dequeued.");
917  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
918  NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, "There should be 1 target exceeded marked packet");
919  NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 1, "There should be 1 CE threshold exceeded marked packets");
920  }
921  }
922  else if (initialTargetMarkCount > 0)
923  { // In dropping state
924  if (currentTime.GetMicroSeconds () < initialDropNext)
925  {
926  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
927  currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
928  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
929  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "We are in dropping state."
930  "Sojourn is still above target."
931  "However, it's not time for next target exceeded mark."
932  "So there should be only 1 more packet dequeued");
933  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
934  NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, "There should still be only 1 target exceeded marked packet from the last dequeue");
935  NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 2, "There should be 2 CE threshold exceeded marked packets");
936  }
937  else if (currentTime.GetMicroSeconds () >= initialDropNext)
938  {
939  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
940  currentTargetMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::TARGET_EXCEEDED_MARK);
941  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
942  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
943  "It's time for packet to be dropped as packets are not ecnCapable"
944  "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
945  NS_TEST_EXPECT_MSG_EQ (currentDropCount, m_dropNextCount, "The number of drops equals to the number of times m_dropNext is updated");
946  NS_TEST_EXPECT_MSG_EQ (currentTargetMarkCount, 1, "There should still be only 1 target exceeded marked packet");
947  NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 2, "There should still be 2 CE threshold exceeded marked packet as packets are not ecnCapable");
948  }
949  }
950  }
951  else if (testCase == 4)
952  {
953  if (currentTime < queue->GetTarget ())
954  {
955  if (initialCeThreshMarkCount == 0 && currentTime < MilliSeconds (2))
956  {
957  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
958  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
959  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be 1 packet dequeued.");
960  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
961  NS_TEST_ASSERT_MSG_EQ (currentCeThreshMarkCount, 0, "Sojourn time has not gone above CE threshold."
962  "Hence, there should not be any CE threshold exceeded marked packet");
963  }
964  else
965  {
966  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
967  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
968  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be only 1 more packet dequeued.");
969  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
970  NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 1, "Sojourn time has gone above CE threshold."
971  "There should be 1 CE threshold exceeded marked packet");
972  }
973  }
974  else if (initialCeThreshMarkCount > 0 && currentTime < queue->GetInterval ())
975  {
976  if (initialCeThreshMarkCount < 2)
977  {
978  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
979  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
980  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be only 1 more packet dequeued.");
981  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
982  NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 2, "There should be 2 CE threshold exceeded marked packets");
983  }
984  else
985  { // In dropping state
986  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
987  currentCeThreshMarkCount = queue->GetStats ().GetNMarkedPackets (CoDelQueueDisc::CE_THRESHOLD_EXCEEDED_MARK);
988  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be only 1 more packet dequeued.");
989  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "There should not be any packet drops");
990  NS_TEST_EXPECT_MSG_EQ (currentCeThreshMarkCount, 3, "There should be 3 CE threshold exceeded marked packet");
991  }
992  }
993  }
994  }
995 }
996 
1003 static class CoDelQueueDiscTestSuite : public TestSuite
1004 {
1005 public:
1007  : TestSuite ("codel-queue-disc", UNIT)
1008  {
1009  // Test 1: simple enqueue/dequeue with no drops
1012  // Test 2: enqueue with drops due to queue overflow
1015  // Test 3: test NewtonStep() against explicit port of Linux implementation
1016  AddTestCase (new CoDelQueueDiscNewtonStepTest (), TestCase::QUICK);
1017  // Test 4: test ControlLaw() against explicit port of Linux implementation
1018  AddTestCase (new CoDelQueueDiscControlLawTest (), TestCase::QUICK);
1019  // Test 5: enqueue/dequeue with drops according to CoDel algorithm
1021  AddTestCase (new CoDelQueueDiscBasicDrop (QueueSizeUnit::BYTES), TestCase::QUICK);
1022  // Test 6: enqueue/dequeue with marks according to CoDel algorithm
1024  AddTestCase (new CoDelQueueDiscBasicMark (QueueSizeUnit::BYTES), TestCase::QUICK);
1025  }
CoDelQueueDiscControlLawTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: codel-queue-disc-test-suite.cc:396
ns3::QueueDiscItem
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition: queue-item.h:148
CoDelQueueDiscBasicDrop::CoDelQueueDiscBasicDrop
CoDelQueueDiscBasicDrop(QueueSizeUnit mode)
Constructor.
Definition: codel-queue-disc-test-suite.cc:456
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
CoDelQueueDiscTestSuite
CoDel Queue Disc Test Suite.
Definition: codel-queue-disc-test-suite.cc:1004
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition: boolean.h:37
CodelQueueDiscTestItem::m_ecnCapablePacket
bool m_ecnCapablePacket
ECN capable packet?
Definition: codel-queue-disc-test-suite.cc:90
CodelQueueDiscTestItem
Codel Queue Disc Test Item.
Definition: codel-queue-disc-test-suite.cc:63
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ObjectBase::SetAttributeFailSafe
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
Definition: object-base.cc:205
CoDelQueueDiscBasicOverflow::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: codel-queue-disc-test-suite.cc:273
g_coDelQueueTestSuite
CoDelQueueDiscTestSuite g_coDelQueueTestSuite
the test suite
CoDelQueueDiscBasicDrop::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: codel-queue-disc-test-suite.cc:472
CoDelQueueDiscBasicMark::Enqueue
void Enqueue(Ptr< CoDelQueueDisc > queue, uint32_t size, uint32_t nPkt, bool ecnCapable)
Enqueue function.
Definition: codel-queue-disc-test-suite.cc:793
CodelQueueDiscTestItem::CodelQueueDiscTestItem
CodelQueueDiscTestItem()
ns3::QueueDisc::Enqueue
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Definition: queue-disc.cc:861
ns3::CoDelQueueDisc::ControlLaw
static uint32_t ControlLaw(uint32_t t, uint32_t interval, uint32_t recInvSqrt)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
Definition: codel-queue-disc.cc:164
CoDelQueueDiscBasicMark::m_mode
QueueSizeUnit m_mode
mode
Definition: codel-queue-disc-test-suite.cc:625
CoDelQueueDiscTestSuite::CoDelQueueDiscTestSuite
CoDelQueueDiscTestSuite()
Definition: codel-queue-disc-test-suite.cc:1006
ns3::PACKETS
@ PACKETS
Use number of packets for queue size.
Definition: queue-size.h:44
CoDelQueueDiscBasicOverflow::Enqueue
void Enqueue(Ptr< CoDelQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
Definition: codel-queue-disc-test-suite.cc:313
REC_INV_SQRT_SHIFT_ns3
#define REC_INV_SQRT_SHIFT_ns3
Definition: codel-queue-disc-test-suite.cc:38
CoDelQueueDiscBasicDrop::DropNextTracer
void DropNextTracer(uint32_t oldVal, uint32_t newVal)
Drop next tracer function.
Definition: codel-queue-disc-test-suite.cc:464
CoDelQueueDiscBasicOverflow
Test 2: enqueue with drops due to queue overflow.
Definition: codel-queue-disc-test-suite.cc:245
CoDelQueueDiscBasicMark
Test 6: enqueue/dequeue with marks according to CoDel algorithm.
Definition: codel-queue-disc-test-suite.cc:594
CoDelQueueDiscBasicMark::nPacketsBeforeFirstMark
uint32_t nPacketsBeforeFirstMark
Number of packets in the queue before first mark.
Definition: codel-queue-disc-test-suite.cc:628
CoDelQueueDiscBasicMark::nPacketsBeforeFirstDrop
uint32_t nPacketsBeforeFirstDrop
Number of packets in the queue before first drop.
Definition: codel-queue-disc-test-suite.cc:627
CoDelQueueDiscBasicMark::CoDelQueueDiscBasicMark
CoDelQueueDiscBasicMark(QueueSizeUnit mode)
Constructor.
Definition: codel-queue-disc-test-suite.cc:631
ns3::TestCase
encapsulates test code
Definition: test.h:1154
ns3::QueueSizeValue
Definition: queue-size.h:221
ns3::CoDelQueueDisc::GetInterval
Time GetInterval(void)
Get the interval.
Definition: codel-queue-disc.cc:408
ns3::Ptr< Packet >
CoDelQueueDiscBasicDrop::m_mode
QueueSizeUnit m_mode
mode
Definition: codel-queue-disc-test-suite.cc:452
CoDelQueueDiscBasicOverflow::m_mode
QueueSizeUnit m_mode
mode
Definition: codel-queue-disc-test-suite.cc:263
ns3::CoDelQueueDisc::GetTarget
Time GetTarget(void)
Get the target queue delay.
Definition: codel-queue-disc.cc:402
CoDelQueueDiscBasicDrop::m_dropNextCount
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
Definition: codel-queue-disc-test-suite.cc:453
CoDelQueueDiscNewtonStepTest::CoDelQueueDiscNewtonStepTest
CoDelQueueDiscNewtonStepTest()
Definition: codel-queue-disc-test-suite.cc:335
ns3::QueueDisc::Stats::GetNMarkedPackets
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
Definition: queue-disc.cc:152
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
CodelQueueDiscTestItem::Mark
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification.
Definition: codel-queue-disc-test-suite.cc:109
CoDelQueueDiscBasicEnqueueDequeue::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: codel-queue-disc-test-suite.cc:146
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::Time::GetMicroSeconds
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:388
CoDelQueueDiscBasicOverflow::CoDelQueueDiscBasicOverflow
CoDelQueueDiscBasicOverflow(QueueSizeUnit mode)
Constructor.
Definition: codel-queue-disc-test-suite.cc:266
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
ns3::QueueDisc::Stats::GetNDroppedPackets
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Definition: queue-disc.cc:110
_codel_Newton_step
static uint16_t _codel_Newton_step(uint16_t rec_inv_sqrt, uint32_t count)
Definition: codel-queue-disc-test-suite.cc:40
NS_UNUSED
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
CoDelQueueDiscControlLawTest::CoDelQueueDiscControlLawTest
CoDelQueueDiscControlLawTest()
Definition: codel-queue-disc-test-suite.cc:381
NS_TEST_EXPECT_MSG_EQ
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::CoDelQueueDisc::NewtonStep
static uint16_t NewtonStep(uint16_t recInvSqrt, uint32_t count)
Calculate the reciprocal square root of m_count by using Newton's method http://en....
Definition: codel-queue-disc.cc:151
ns3::QueueDisc::GetCurrentSize
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
Definition: queue-disc.cc:523
CoDelQueueDiscBasicEnqueueDequeue
Test 1: simple enqueue/dequeue with no drops.
Definition: codel-queue-disc-test-suite.cc:125
_reciprocal_scale
static uint32_t _reciprocal_scale(uint32_t val, uint32_t ep_ro)
Definition: codel-queue-disc-test-suite.cc:51
ns3::MakeCallback
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...
Definition: callback.h:1642
CoDelQueueDiscBasicMark::m_dropNextCount
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
Definition: codel-queue-disc-test-suite.cc:626
ns3::QueueDisc::Dequeue
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any,...
Definition: queue-disc.cc:896
ns3::StringValue
Hold variables of type string.
Definition: string.h:41
CoDelQueueDiscBasicEnqueueDequeue::CoDelQueueDiscBasicEnqueueDequeue
CoDelQueueDiscBasicEnqueueDequeue(QueueSizeUnit mode)
Constructor.
Definition: codel-queue-disc-test-suite.cc:139
test-ns3.result
result
Definition: test-ns3.py:576
CoDelQueueDiscBasicMark::DropNextTracer
void DropNextTracer(uint32_t oldVal, uint32_t newVal)
Drop next tracer function.
Definition: codel-queue-disc-test-suite.cc:639
ns3::TestSuite
A suite of tests to run.
Definition: test.h:1344
NS_TEST_ASSERT_MSG_EQ
#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.
Definition: test.h:166
CodelQueueDiscTestItem::~CodelQueueDiscTestItem
virtual ~CodelQueueDiscTestItem()
Definition: codel-queue-disc-test-suite.cc:99
ns3::CoDelQueueDisc::Time2CoDel
uint32_t Time2CoDel(Time t)
Return the unsigned 32-bit integer representation of the input Time object.
Definition: codel-queue-disc.cc:444
ns3::QueueItem::GetPacket
Ptr< Packet > GetPacket(void) const
Definition: queue-item.cc:42
CoDelQueueDiscBasicDrop::Dequeue
void Dequeue(Ptr< CoDelQueueDisc > queue, uint32_t modeSize)
Dequeue function.
Definition: codel-queue-disc-test-suite.cc:527
CodelQueueDiscTestItem::AddHeader
virtual void AddHeader(void)
Add the header to the packet.
Definition: codel-queue-disc-test-suite.cc:104
ns3::TestSuite::UNIT
@ UNIT
This test suite implements a Unit Test.
Definition: test.h:1353
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
CoDelQueueDiscBasicDrop::Enqueue
void Enqueue(Ptr< CoDelQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
Definition: codel-queue-disc-test-suite.cc:517
CoDelQueueDiscNewtonStepTest::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: codel-queue-disc-test-suite.cc:341
pktSize
uint32_t pktSize
packet size used for the simulation (in bytes)
Definition: wifi-bianchi.cc:86
ns3::BYTES
@ BYTES
Use number of bytes for queue size.
Definition: queue-size.h:45
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
CoDelQueueDiscBasicMark::Dequeue
void Dequeue(Ptr< CoDelQueueDisc > queue, uint32_t modeSize, uint32_t testCase)
Dequeue function.
Definition: codel-queue-disc-test-suite.cc:803
ns3::QueueSizeUnit
QueueSizeUnit
Enumeration of the operating modes of queues.
Definition: queue-size.h:43
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
CoDelQueueDiscBasicDrop
Test 5: enqueue/dequeue with drops according to CoDel algorithm.
Definition: codel-queue-disc-test-suite.cc:423
CoDelQueueDiscControlLawTest::_codel_control_law
uint32_t _codel_control_law(uint32_t t, uint32_t interval, uint32_t recInvSqrt)
Codel control law function.
Definition: codel-queue-disc-test-suite.cc:389
CodelQueueDiscTestItem::CodelQueueDiscTestItem
CodelQueueDiscTestItem(const CodelQueueDiscTestItem &)
Copy constructor Disable default implementation to avoid misuse.
ns3::ObjectBase::TraceConnectWithoutContext
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
ns3::QueueDisc::GetStats
const Stats & GetStats(void)
Retrieve all the collected statistics.
Definition: queue-disc.cc:421
ns3::QueueSize::GetValue
uint32_t GetValue() const
Get the underlying value.
Definition: queue-size.cc:175
CoDelQueueDiscBasicEnqueueDequeue::m_mode
QueueSizeUnit m_mode
mode
Definition: codel-queue-disc-test-suite.cc:136
ns3::Object::Initialize
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
ns3::QueueSize
Class for representing queue sizes.
Definition: queue-size.h:95
CoDelQueueDiscNewtonStepTest
Test 3: NewtonStep unit test - test against explicit port of Linux implementation.
Definition: codel-queue-disc-test-suite.cc:329
ns3::CoDelQueueDisc::GetDropNext
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
Definition: codel-queue-disc.cc:414
CoDelQueueDiscControlLawTest
Test 4: ControlLaw unit test - test against explicit port of Linux implementation.
Definition: codel-queue-disc-test-suite.cc:367
CoDelQueueDiscBasicMark::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition: codel-queue-disc-test-suite.cc:647
ns3::Packet::GetUid
uint64_t GetUid(void) const
Returns the packet's Uid.
Definition: packet.cc:390