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 (uint32_t count, uint16_t rec_inv_sqrt)
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  uint32_t count = 2;
341  uint16_t recInvSqrt = 65535;
342  queue->m_count = count;
343  queue->m_recInvSqrt = recInvSqrt;
344  queue->NewtonStep ();
345  // Test that ns-3 value is exactly the same as the Linux value
346  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (count, recInvSqrt), queue->m_recInvSqrt,
347  "ns-3 NewtonStep() fails to match Linux equivalent");
348 
349  count = 4;
350  recInvSqrt = 36864;
351  queue->m_count = count;
352  queue->m_recInvSqrt = recInvSqrt;
353  queue->NewtonStep ();
354  // Test that ns-3 value is exactly the same as the Linux value
355  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (count, recInvSqrt), queue->m_recInvSqrt,
356  "ns-3 NewtonStep() fails to match Linux equivalent");
357 }
358 
366 {
367 public:
369  virtual void DoRun (void);
376  uint32_t _codel_control_law (Ptr<CoDelQueueDisc> queue, uint32_t t);
377 };
378 
380  : TestCase ("ControlLaw arithmetic unit test")
381 {
382 }
383 
384 // The following code borrowed from Linux codel.h,
385 // except the addition of queue parameter
386 uint32_t
388 {
389  return t + _reciprocal_scale (queue->Time2CoDel (queue->m_interval), queue->m_recInvSqrt << REC_INV_SQRT_SHIFT_ns3);
390 }
391 // End Linux borrrow
392 
393 void
395 {
396  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
397 
398  /* Spot check a few points of m_dropNext
399  The integer approximations in Linux should be within
400  2% of the true floating point value obtained in ns-3
401  */
402  uint32_t dropNextTestVals [4] = {292299, 341128, 9804717, 55885007};
403 
404  for (int i = 0; i < 4; ++i)
405  {
406  uint32_t ns3Result = queue->ControlLaw(dropNextTestVals[i]);
407  uint32_t linuxResult = _codel_control_law(queue, dropNextTestVals[i]);
408  NS_TEST_EXPECT_MSG_EQ((0.98 * ns3Result < linuxResult && linuxResult < 1.02 * ns3Result), true,
409  "Linux result should stay within 2% of ns-3 result");
410  }
411 }
412 
420 {
421 public:
428  virtual void DoRun (void);
429 
430 private:
437  void Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt);
442  void Dequeue (Ptr<CoDelQueueDisc> queue, uint32_t modeSize);
448  void DropNextTracer (uint32_t oldVal, uint32_t newVal);
450  uint32_t m_dropNextCount;
451 };
452 
454  : TestCase ("Basic drop operations")
455 {
456  m_mode = mode;
457  m_dropNextCount = 0;
458 }
459 
460 void
461 CoDelQueueDiscBasicDrop::DropNextTracer (uint32_t oldVal, uint32_t newVal)
462 {
463  NS_UNUSED(oldVal);
464  NS_UNUSED(newVal);
465  m_dropNextCount++;
466 }
467 
468 void
470 {
471  Ptr<CoDelQueueDisc> queue = CreateObject<CoDelQueueDisc> ();
472  uint32_t pktSize = 1000;
473  uint32_t modeSize = 0;
474 
476  {
477  modeSize = pktSize;
478  }
479  else if (m_mode == QueueSizeUnit::PACKETS)
480  {
481  modeSize = 1;
482  }
483 
484  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxSize", QueueSizeValue (QueueSize (m_mode, modeSize * 500))),
485  true, "Verify that we can actually set the attribute MaxSize");
486 
487  queue->Initialize ();
488 
489  Enqueue (queue, pktSize, 20);
490  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), 20 * modeSize, "There should be 20 packets in queue.");
491 
492  // Although the first dequeue occurs with a sojourn time above target
493  // the dequeue should be successful in this interval
494  Time waitUntilFirstDequeue = 2 * queue->GetTarget ();
495  Simulator::Schedule (waitUntilFirstDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
496 
497  // This dequeue should cause a drop
498  Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->GetInterval ();
499  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
500 
501  // Although we are in dropping state, it's not time for next drop
502  // the dequeue should not cause a drop
503  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
504 
505  // In dropping time and it's time for next drop
506  // the dequeue should cause additional packet drops
507  Simulator::Schedule (waitUntilSecondDequeue * 2, &CoDelQueueDiscBasicDrop::Dequeue, this, queue, modeSize);
508 
509  Simulator::Run ();
510  Simulator::Destroy ();
511 }
512 
513 void
514 CoDelQueueDiscBasicDrop::Enqueue (Ptr<CoDelQueueDisc> queue, uint32_t size, uint32_t nPkt)
515 {
516  Address dest;
517  for (uint32_t i = 0; i < nPkt; i++)
518  {
519  queue->Enqueue (Create<CodelQueueDiscTestItem> (Create<Packet> (size), dest));
520  }
521 }
522 
523 void
525 {
526  uint32_t initialDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
527  uint32_t initialQSize = queue->GetCurrentSize ().GetValue ();
528  uint32_t initialDropNext = queue->GetDropNext ();
529  Time currentTime = Simulator::Now ();
530  uint32_t currentDropCount = 0;
531 
532  if (initialDropCount > 0 && currentTime.GetMicroSeconds () >= initialDropNext)
533  {
535  }
536 
537  if (initialQSize != 0)
538  {
539  Ptr<QueueDiscItem> item = queue->Dequeue ();
540  if (initialDropCount == 0 && currentTime > queue->GetTarget ())
541  {
542  if (currentTime < queue->GetInterval ())
543  {
544  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
545  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "We are not in dropping state."
546  "Sojourn time has just gone above target from below."
547  "Hence, there should be no packet drops");
548  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "There should be 1 packet dequeued.");
549 
550  }
551  else if (currentTime >= queue->GetInterval ())
552  {
553  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
554  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval."
555  "We enter the dropping state, perform initial packet drop, and dequeue the next."
556  "So there should be 2 more packets dequeued.");
557  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should be 1 packet drop");
558  }
559  }
560  else if (initialDropCount > 0)
561  { // In dropping state
562  if (currentTime.GetMicroSeconds () < initialDropNext)
563  {
564  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
565  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - modeSize, "We are in dropping state."
566  "Sojourn is still above target."
567  "However, it's not time for next drop."
568  "So there should be only 1 more packet dequeued");
569 
570  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should still be only 1 packet drop from the last dequeue");
571  }
572  else if (currentTime.GetMicroSeconds () >= initialDropNext)
573  {
574  currentDropCount = queue->GetStats ().GetNDroppedPackets (CoDelQueueDisc::TARGET_EXCEEDED_DROP);
575  NS_TEST_EXPECT_MSG_EQ (queue->GetCurrentSize ().GetValue (), initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
576  "It's time for next drop."
577  "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
578  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");
579  }
580  }
581  }
582 }
583 
590 static class CoDelQueueDiscTestSuite : public TestSuite
591 {
592 public:
594  : TestSuite ("codel-queue-disc", UNIT)
595  {
596  // Test 1: simple enqueue/dequeue with no drops
599  // Test 2: enqueue with drops due to queue overflow
602  // Test 3: test NewtonStep() against explicit port of Linux implementation
603  AddTestCase (new CoDelQueueDiscNewtonStepTest (), TestCase::QUICK);
604  // Test 4: test ControlLaw() against explicit port of Linux implementation
605  AddTestCase (new CoDelQueueDiscControlLawTest (), TestCase::QUICK);
606  // Test 5: enqueue/dequeue with drops according to CoDel algorithm
609  }
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.
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:844
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.
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
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:1342
#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.
#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:285
#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:205
QueueDiscItem is the abstract base class for items that are stored in a queue disc.
Definition: queue-item.h:148
encapsulates test code
Definition: test.h:1155
uint32_t ControlLaw(uint32_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
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
static uint16_t _codel_Newton_step(uint32_t count, uint16_t rec_inv_sqrt)
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:113
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:168
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
virtual void AddHeader(void)
Add the header to the packet.
const Stats & GetStats(void)
Retrieve all the collected statistics.
Definition: queue-disc.cc:421
CoDelQueueDiscBasicOverflow(QueueSizeUnit mode)
Constructor.
CoDelQueueDiscBasicDrop(QueueSizeUnit mode)
Constructor.
Time m_interval
100 ms sliding minimum time window width
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:879
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:363
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t m_recInvSqrt
Reciprocal inverse square root.
uint32_t _codel_control_law(Ptr< CoDelQueueDisc > queue, uint32_t t)
Codel control law function.
Time GetTarget(void)
Get the target queue delay.
void NewtonStep(void)
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)
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 Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:365
static uint32_t _reciprocal_scale(uint32_t val, uint32_t ep_ro)
This test suite implements a Unit Test.
Definition: test.h:1352
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
Test 2: enqueue with drops due to queue overflow.
CoDelQueueDiscBasicEnqueueDequeue(QueueSizeUnit mode)
Constructor.