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:
71  CodelQueueDiscTestItem (Ptr<Packet> p, const Address & addr);
72  virtual ~CodelQueueDiscTestItem ();
73  virtual void AddHeader (void);
74  virtual bool Mark(void);
75 
76 private:
88  CodelQueueDiscTestItem &operator = (const CodelQueueDiscTestItem &);
89 };
90 
92  : QueueDiscItem (p, addr, 0)
93 {
94 }
95 
97 {
98 }
99 
100 void
102 {
103 }
104 
105 bool
107 {
108  return false;
109 }
110 
118 {
119 public:
126  virtual void DoRun (void);
127 
128 private:
130 };
131 
133  : TestCase ("Basic enqueue and dequeue operations, and attribute setting")
134 {
135  m_mode = mode;
136 }
137 
138 void
140 {
141  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
142 
143  uint32_t pktSize = 1000;
144  uint32_t modeSize = 0;
145 
146  Address dest;
147 
148  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (pktSize)), true,
149  "Verify that we can actually set the attribute MinBytes");
150  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Interval", StringValue ("50ms")), true,
151  "Verify that we can actually set the attribute Interval");
152  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Target", StringValue ("4ms")), true,
153  "Verify that we can actually set the attribute Target");
154 
156  {
157  modeSize = pktSize;
158  }
159  else if (m_mode == QueueSizeUnit::PACKETS)
160  {
161  modeSize = 1;
162  }
163  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 1500))),
164  true, "Verify that we can actually set the attribute MaxSize");
165  queue->Initialize ();
166 
167  Ptr<Packet> p1, p2, p3, p4, p5, p6;
168  p1 = Create<Packet> (pktSize);
169  p2 = Create<Packet> (pktSize);
170  p3 = Create<Packet> (pktSize);
171  p4 = Create<Packet> (pktSize);
172  p5 = Create<Packet> (pktSize);
173  p6 = Create<Packet> (pktSize);
174 
175  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 0 * modeSize, "There should be no packets in queue");
176  queue->Enqueue (Create<CodelQueueDiscTestItem> (p1, dest));
177  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 1 * modeSize, "There should be one packet in queue");
178  queue->Enqueue (Create<CodelQueueDiscTestItem> (p2, dest));
179  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 2 * modeSize, "There should be two packets in queue");
180  queue->Enqueue (Create<CodelQueueDiscTestItem> (p3, dest));
181  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 3 * modeSize, "There should be three packets in queue");
182  queue->Enqueue (Create<CodelQueueDiscTestItem> (p4, dest));
183  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 4 * modeSize, "There should be four packets in queue");
184  queue->Enqueue (Create<CodelQueueDiscTestItem> (p5, dest));
185  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 5 * modeSize, "There should be five packets in queue");
186  queue->Enqueue (Create<CodelQueueDiscTestItem> (p6, dest));
187  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 6 * modeSize, "There should be six packets in queue");
188 
189  NS_TEST_EXPECT_MSG_EQ (queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::OVERLIMIT_DROP),
190  0, "There should be no packets being dropped due to full queue");
191 
192  Ptr<QueueDiscItem> item;
193 
194  item = queue->Dequeue ();
195  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the first packet");
196  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 5 * modeSize, "There should be five packets in queue");
197  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p1->GetUid (), "was this the first packet ?");
198 
199  item = queue->Dequeue ();
200  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the second packet");
201  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 4 * modeSize, "There should be four packets in queue");
202  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p2->GetUid (), "Was this the second packet ?");
203 
204  item = queue->Dequeue ();
205  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the third packet");
206  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 3 * modeSize, "There should be three packets in queue");
207  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p3->GetUid (), "Was this the third packet ?");
208 
209  item = queue->Dequeue ();
210  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the forth packet");
211  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 2 * modeSize, "There should be two packets in queue");
212  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p4->GetUid (), "Was this the fourth packet ?");
213 
214  item = queue->Dequeue ();
215  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the fifth packet");
216  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 1 * modeSize, "There should be one packet in queue");
217  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p5->GetUid (), "Was this the fifth packet ?");
218 
219  item = queue->Dequeue ();
220  NS_TEST_EXPECT_MSG_EQ ((item != 0), true, "I want to remove the last packet");
221  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 0 * modeSize, "There should be zero packet in queue");
222  NS_TEST_EXPECT_MSG_EQ (item->GetPacket ()->GetUid (), p6->GetUid (), "Was this the sixth packet ?");
223 
224  item = queue->Dequeue ();
225  NS_TEST_EXPECT_MSG_EQ ((item == 0), true, "There are really no packets in queue");
226 
227  NS_TEST_EXPECT_MSG_EQ (queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP), 0,
228  "There should be no packet drops according to CoDel algorithm");
229 }
230 
238 {
239 public:
246  virtual void DoRun (void);
247 
248 private:
255  void Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt);
257 };
258 
260  : TestCase ("Basic overflow behavior")
261 {
262  m_mode = mode;
263 }
264 
265 void
267 {
268  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
269  uint32_t pktSize = 1000;
270  uint32_t modeSize = 0;
271 
272  Address dest;
273 
275  {
276  modeSize = pktSize;
277  }
278  else if (m_mode == QueueSizeUnit::PACKETS)
279  {
280  modeSize = 1;
281  }
282 
283  Ptr<Packet> p1, p2, p3;
284  p1 = Create<Packet> (pktSize);
285  p2 = Create<Packet> (pktSize);
286  p3 = Create<Packet> (pktSize);
287 
288  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
289  true, "Verify that we can actually set the attribute MaxSize");
290  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (pktSize)), true,
291  "Verify that we can actually set the attribute MinBytes");
292 
293  queue->Initialize ();
294 
295  Enqueue (queue, pktSize, 500);
296  queue->Enqueue (Create<CodelQueueDiscTestItem> (p1, dest));
297  queue->Enqueue (Create<CodelQueueDiscTestItem> (p2, dest));
298  queue->Enqueue (Create<CodelQueueDiscTestItem> (p3, dest));
299 
300  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize().GetValue (), 500 * modeSize, "There should be 500 packets in queue");
301  NS_TEST_EXPECT_MSG_EQ (queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::OVERLIMIT_DROP),
302  3, "There should be three packets being dropped due to full queue");
303 }
304 
305 void
306 CoDelQueueDiscBasicOverflow::Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt)
307 {
308  Address dest;
309  for (uint32_t i = 0; i < nPkt; i++)
310  {
311  queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest));
312  }
313 }
314 
322 {
323 public:
325  virtual void DoRun (void);
326 };
327 
329  : TestCase ("NewtonStep arithmetic unit test")
330 {
331 }
332 
333 void
335 {
336  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
337 
338  // Spot check a few points in the expected operational range of
339  // CoDelQueueDisc's m_count and m_recInvSqrt variables
340  uint16_t result;
341  for (uint16_t recInvSqrt = 0xff; recInvSqrt > 0; recInvSqrt /= 2)
342  {
343  for (uint32_t count = 1; count < 0xff; count *= 2)
344  {
345  result = queue->NewtonStep (recInvSqrt, count);
346  // Test that ns-3 value is exactly the same as the Linux value
347  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (recInvSqrt, count), result,
348  "ns-3 NewtonStep() fails to match Linux equivalent");
349  }
350  }
351 }
352 
360 {
361 public:
363  virtual void DoRun (void);
370  uint32_t _codel_control_law (uint32_t t, uint32_t interval, uint32_t recInvSqrt);
371 };
372 
374  : TestCase ("ControlLaw arithmetic unit test")
375 {
376 }
377 
378 // The following code borrowed from Linux codel.h,
379 // except the addition of queue parameter
380 uint32_t
381 CoDelQueueDiscControlLawTest::_codel_control_law (uint32_t t, uint32_t interval, uint32_t recInvSqrt)
382 {
383  return t + _reciprocal_scale (interval, recInvSqrt << REC_INV_SQRT_SHIFT_ns3);
384 }
385 // End Linux borrrow
386 
387 void
389 {
390  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
391 
392  // Check a few points within the operational range of ControlLaw
393  uint32_t interval = queue->Time2CoDel (MilliSeconds (100));
394 
395  uint32_t codelTimeVal;
396  for (Time timeVal = Seconds (0); timeVal <= Seconds (20); timeVal += MilliSeconds (100))
397  {
398  for (uint16_t recInvSqrt = 0xff; recInvSqrt > 0; recInvSqrt /= 2)
399  {
400  codelTimeVal = queue->Time2CoDel (timeVal);
401  uint32_t ns3Result = queue->ControlLaw (codelTimeVal, interval, recInvSqrt);
402  uint32_t linuxResult = _codel_control_law (codelTimeVal, interval, recInvSqrt);
403  NS_TEST_EXPECT_MSG_EQ (ns3Result, linuxResult, "Linux result for ControlLaw should equal ns-3 result");
404  }
405  }
406 }
407 
415 {
416 public:
423  virtual void DoRun (void);
424 
425 private:
432  void Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt);
437  void Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize);
443  void DropNextTracer (uint32_t oldVal, uint32_t newVal);
445  uint32_t m_dropNextCount;
446 };
447 
449  : TestCase ("Basic drop operations")
450 {
451  m_mode = mode;
452  m_dropNextCount = 0;
453 }
454 
455 void
456 CoDelQueueDiscBasicDrop::DropNextTracer (uint32_t oldVal, uint32_t newVal)
457 {
458  NS_UNUSED(oldVal);
459  NS_UNUSED(newVal);
460  m_dropNextCount++;
461 }
462 
463 void
465 {
466  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
467  uint32_t pktSize = 1000;
468  uint32_t modeSize = 0;
469 
471  {
472  modeSize = pktSize;
473  }
474  else if (m_mode == QueueSizeUnit::PACKETS)
475  {
476  modeSize = 1;
477  }
478 
479  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
480  true, "Verify that we can actually set the attribute MaxSize");
481 
482  queue->Initialize ();
483 
484  Enqueue (queue, pktSize, 20);
485  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, "There should be 20 packets in queue.");
486 
487  // Although the first dequeue occurs with a sojourn time above target
488  // the dequeue should be successful in this interval
489  Time waitUntilFirstDequeue = 2 * queue->GetTarget ();
490  Simulator::Schedule (waitUntilFirstDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
491 
492  // This dequeue should cause a drop
493  Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->GetInterval ();
494  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
495 
496  // Although we are in dropping state, it's not time for next drop
497  // the dequeue should not cause a drop
498  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
499 
500  // In dropping time and it's time for next drop
501  // the dequeue should cause additional packet drops
502  Simulator::Schedule (waitUntilSecondDequeue * 2, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
503 
504  Simulator::Run ();
505  Simulator::Destroy ();
506 }
507 
508 void
509 CoDelQueueDiscBasicDrop::Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt)
510 {
511  Address dest;
512  for (uint32_t i = 0; i < nPkt; i++)
513  {
514  queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest));
515  }
516 }
517 
518 void
520 {
521  uint32_t initialDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
522  uint32_t initialQSize = queue->GetCurrentSize ().GetValue ();
523  uint32_t initialDropNext = queue->GetDropNext ();
524  Time currentTime = Simulator::Now ();
525  uint32_t currentDropCount = 0;
526 
527  if (initialDropCount > 0 && currentTime.GetMicroSeconds () >= initialDropNext)
528  {
530  }
531 
532  if (initialQSize != 0)
533  {
534  Ptr<QueueDiscItem> item = queue->Dequeue ();
535  if (initialDropCount == 0 && currentTime > queue->GetTarget ())
536  {
537  if (currentTime < queue->GetInterval ())
538  {
539  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
540  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "We are not in dropping state."
541  "Sojourn time has just gone above target from below."
542  "Hence, there should be no packet drops");
543  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be 1 packet dequeued.");
544 
545  }
546  else if (currentTime >= queue->GetInterval ())
547  {
548  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
549  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval."
550  "We enter the dropping state, perform initial packet drop, and dequeue the next."
551  "So there should be 2 more packets dequeued.");
552  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should be 1 packet drop");
553  }
554  }
555  else if (initialDropCount > 0)
556  { // In dropping state
557  if (currentTime.GetMicroSeconds () < initialDropNext)
558  {
559  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
560  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "We are in dropping state."
561  "Sojourn is still above target."
562  "However, it's not time for next drop."
563  "So there should be only 1 more packet dequeued");
564 
565  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should still be only 1 packet drop from the last dequeue");
566  }
567  else if (currentTime.GetMicroSeconds () >= initialDropNext)
568  {
569  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
570  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
571  "It's time for next drop."
572  "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
573  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");
574  }
575  }
576  }
577 }
578 
585 static class CoDelQueueDiscTestSuite : public TestSuite
586 {
587 public:
589  : TestSuite ("codel-queue-disc", UNIT)
590  {
591  // Test 1: simple enqueue/dequeue with no drops
594  // Test 2: enqueue with drops due to queue overflow
597  // Test 3: test NewtonStep() against explicit port of Linux implementation
598  AddTestCase (new CoDelQueueDiscNewtonStepTest (), TestCase::QUICK);
599  // Test 4: test ControlLaw() against explicit port of Linux implementation
600  AddTestCase (new CoDelQueueDiscControlLawTest (), TestCase::QUICK);
601  // Test 5: enqueue/dequeue with drops according to CoDel algorithm
604  }
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint64_t GetUid(void) const
Returns the packet&#39;s Uid.
Definition: packet.cc:390
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual void DoRun(void)
Implementation to actually run this TestCase.
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).
Codel Queue Disc Test Item.
Class for representing queue sizes.
Definition: queue-size.h:94
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Definition: queue-disc.cc:861
Hold variables of type string.
Definition: string.h:41
uint32_t GetValue() const
Get the underlying value.
Definition: queue-size.cc:175
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
QueueSizeUnit
Enumeration of the operating modes of queues.
Definition: queue-size.h:42
virtual void DoRun(void)
Implementation to actually run this TestCase.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
Definition: queue-disc.cc:523
A suite of tests to run.
Definition: test.h:1343
#define REC_INV_SQRT_SHIFT_ns3
Test 5: enqueue/dequeue with drops according to CoDel algorithm.
Time GetInterval(void)
Get the interval.
Test 3: NewtonStep unit test - test against explicit port of Linux implementation.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
#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
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
void Dequeue(Ptr< CoDelQueueDisc > queue, uint32_t modeSize)
Dequeue function.
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
Definition: object-base.cc:207
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition: queue-item.h:148
static uint16_t NewtonStep(uint16_t recInvSqrt, uint32_t count)
Calculate the reciprocal square root of m_count by using Newton&#39;s method http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Iterative_methods_for_reciprocal_square_roots m_recInvSqrt (new) = (m_recInvSqrt (old) / 2) * (3 - m_count * m_recInvSqrt^2)
encapsulates test code
Definition: test.h:1153
void DropNextTracer(uint32_t oldVal, uint32_t newVal)
Drop next tracer function.
void Enqueue(Ptr< CoDelQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
a polymophic address class
Definition: address.h:90
uint32_t m_dropNextCount
count the number of times m_dropNext is recalculated
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Hold an unsigned integer type.
Definition: uinteger.h:44
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Definition: queue-disc.cc:110
virtual bool Mark(void)
Marks the packet as a substitute for dropping it, such as for Explicit Congestion Notification...
Use number of packets for queue size.
Definition: queue-size.h:44
#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
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1610
virtual void AddHeader(void)
Add the header to the packet.
static uint16_t _codel_Newton_step(uint16_t rec_inv_sqrt, uint32_t count)
const Stats & GetStats(void)
Retrieve all the collected statistics.
Definition: queue-disc.cc:421
CoDelQueueDiscBasicOverflow(QueueSizeUnit mode)
Constructor.
CoDelQueueDiscBasicDrop(QueueSizeUnit mode)
Constructor.
virtual void DoRun(void)
Implementation to actually run this TestCase.
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
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:369
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:295
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time GetTarget(void)
Get the target queue delay.
void Enqueue(Ptr< CoDelQueueDisc > queue, uint32_t size, uint32_t nPkt)
Enqueue function.
CoDelQueueDiscTestSuite g_coDelQueueTestSuite
the test suite
uint32_t Time2CoDel(Time t)
Return the unsigned 32-bit integer representation of the input Time object.
CoDel Queue Disc Test Suite.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
static uint32_t _reciprocal_scale(uint32_t val, uint32_t ep_ro)
This test suite implements a Unit Test.
Definition: test.h:1353
Use number of bytes for queue size.
Definition: queue-size.h:45
Test 4: ControlLaw unit test - test against explicit port of Linux implementation.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Test 1: simple enqueue/dequeue with no drops.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
Definition: object.cc:183
uint32_t _codel_control_law(uint32_t t, uint32_t interval, uint32_t recInvSqrt)
Codel control law function.
Test 2: enqueue with drops due to queue overflow.
CoDelQueueDiscBasicEnqueueDequeue(QueueSizeUnit mode)
Constructor.