A Discrete-Event Network Simulator
API
codel-queue-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  *
20  */
21 
22 #include "ns3/test.h"
23 #include "ns3/codel-queue.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/string.h"
26 #include "ns3/double.h"
27 #include "ns3/log.h"
28 #include "ns3/simulator.h"
29 #include "ns3/network-module.h"
30 #include "ns3/core-module.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 (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 
57 
58 // Test 1: simple enqueue/dequeue with no drops
60 {
61 public:
62  CoDelQueueBasicEnqueueDequeue (std::string mode);
63  virtual void DoRun (void);
64 
65  void QueueTestSize (Ptr<CoDelQueue> queue, uint32_t size, std::string error)
66  {
67  if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
68  {
69  NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
70  }
71  else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
72  {
73  NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
74  }
75 
76  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
77  }
78 
79 private:
81 };
82 
84  : TestCase ("Basic enqueue and dequeue operations, and attribute setting for " + mode)
85 {
86  m_mode = StringValue (mode);
87 }
88 
89 void
91 {
92  Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
93 
94  uint32_t pktSize = 1000;
95  uint32_t modeSize = 0;
96 
97  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", m_mode), true,
98  "Verify that we can actually set the attribute Mode");
99  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (1500)), true,
100  "Verify that we can actually set the attribute MaxPackets");
101  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxBytes", UintegerValue (pktSize * 1500)), true,
102  "Verify that we can actually set the attribute MaxBytes");
103  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (pktSize)), true,
104  "Verify that we can actually set the attribute MinBytes");
105  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Interval", StringValue ("50ms")), true,
106  "Verify that we can actually set the attribute Interval");
107  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Target", StringValue ("4ms")), true,
108  "Verify that we can actually set the attribute Target");
109 
110  if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
111  {
112  modeSize = pktSize;
113  }
114  else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
115  {
116  modeSize = 1;
117  }
118 
119  Ptr<Packet> p1, p2, p3, p4, p5, p6;
120  p1 = Create<Packet> (pktSize);
121  p2 = Create<Packet> (pktSize);
122  p3 = Create<Packet> (pktSize);
123  p4 = Create<Packet> (pktSize);
124  p5 = Create<Packet> (pktSize);
125  p6 = Create<Packet> (pktSize);
126 
127  QueueTestSize (queue, 0 * modeSize, "There should be no packets in queue");
128  queue->Enqueue (p1);
129  QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue");
130  queue->Enqueue (p2);
131  QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue");
132  queue->Enqueue (p3);
133  QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue");
134  queue->Enqueue (p4);
135  QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue");
136  queue->Enqueue (p5);
137  QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue");
138  queue->Enqueue (p6);
139  QueueTestSize (queue, 6 * modeSize, "There should be six packets in queue");
140 
141  NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 0, "There should be no packets being dropped due to full queue");
142 
143  Ptr<Packet> p;
144 
145  p = queue->Dequeue ();
146  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the first packet");
147  QueueTestSize (queue, 5 * modeSize, "There should be five packets in queue");
148  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p1->GetUid (), "was this the first packet ?");
149 
150  p = queue->Dequeue ();
151  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the second packet");
152  QueueTestSize (queue, 4 * modeSize, "There should be four packets in queue");
153  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p2->GetUid (), "Was this the second packet ?");
154 
155  p = queue->Dequeue ();
156  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the third packet");
157  QueueTestSize (queue, 3 * modeSize, "There should be three packets in queue");
158  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p3->GetUid (), "Was this the third packet ?");
159 
160  p = queue->Dequeue ();
161  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the forth packet");
162  QueueTestSize (queue, 2 * modeSize, "There should be two packets in queue");
163  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p4->GetUid (), "Was this the fourth packet ?");
164 
165  p = queue->Dequeue ();
166  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the fifth packet");
167  QueueTestSize (queue, 1 * modeSize, "There should be one packet in queue");
168  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p5->GetUid (), "Was this the fifth packet ?");
169 
170  p = queue->Dequeue ();
171  NS_TEST_EXPECT_MSG_EQ ((p != 0), true, "I want to remove the last packet");
172  QueueTestSize (queue, 0 * modeSize, "There should be zero packet in queue");
173  NS_TEST_EXPECT_MSG_EQ (p->GetUid (), p6->GetUid (), "Was this the sixth packet ?");
174 
175  p = queue->Dequeue ();
176  NS_TEST_EXPECT_MSG_EQ ((p == 0), true, "There are really no packets in queue");
177 
178  NS_TEST_EXPECT_MSG_EQ (queue->GetDropCount (), 0, "There should be no packet drops according to CoDel algorithm");
179 }
180 
181 // Test 2: enqueue with drops due to queue overflow
183 {
184 public:
185  CoDelQueueBasicOverflow (std::string mode);
186  virtual void DoRun (void);
187 
188  void QueueTestSize (Ptr<CoDelQueue> queue, uint32_t size, std::string error)
189  {
190  if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
191  {
192  NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
193  }
194  else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
195  {
196  NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
197  }
198 
199  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
200  }
201 
202 private:
203  void Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt);
205 };
206 
208  : TestCase ("Basic overflow behavior for " + mode)
209 {
210  m_mode = StringValue (mode);
211 }
212 
213 void
215 {
216  Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
217  uint32_t pktSize = 1000;
218  uint32_t modeSize = 0;
219 
220  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", m_mode), true,
221  "Verify that we can actually set the attribute Mode");
222 
223  if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
224  {
225  modeSize = pktSize;
226  }
227  else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
228  {
229  modeSize = 1;
230  }
231 
232  Ptr<Packet> p1, p2, p3;
233  p1 = Create<Packet> (pktSize);
234  p2 = Create<Packet> (pktSize);
235  p3 = Create<Packet> (pktSize);
236 
237  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxPackets", UintegerValue (500)), true,
238  "Verify that we can actually set the attribute MaxPackets");
239  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MaxBytes", UintegerValue (pktSize * 500)), true,
240  "Verify that we can actually set the attribute MaxBytes");
241  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("MinBytes", UintegerValue (pktSize)), true,
242  "Verify that we can actually set the attribute MinBytes");
243 
244  Enqueue (queue, pktSize, 500);
245  queue->Enqueue (p1);
246  queue->Enqueue (p2);
247  queue->Enqueue (p3);
248 
249  QueueTestSize (queue, 500 * modeSize, "There should be 500 packets in queue");
250  NS_TEST_EXPECT_MSG_EQ (queue->GetDropOverLimit (), 3, "There should be three packets being dropped due to full queue");
251 }
252 
253 void
254 CoDelQueueBasicOverflow::Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt)
255 {
256  for (uint32_t i = 0; i < nPkt; i++)
257  {
258  queue->Enqueue (Create<Packet> (size));
259  }
260 }
261 
262 // Test 3: NewtonStep unit test
263 // test against explicit port of Linux implementation
265 {
266 public:
268  virtual void DoRun (void);
269 };
270 
272  : TestCase ("NewtonStep arithmetic unit test")
273 {
274 }
275 
276 void
278 {
279  Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
280 
281  // Spot check a few points in the expected operational range of
282  // CoDelQueue's m_count and m_recInvSqrt variables
283  uint32_t count = 2;
284  uint16_t recInvSqrt = 65535;
285  queue->m_count = count;
286  queue->m_recInvSqrt = recInvSqrt;
287  queue->NewtonStep ();
288  // Test that ns-3 value is exactly the same as the Linux value
289  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (count, recInvSqrt), queue->m_recInvSqrt,
290  "ns-3 NewtonStep() fails to match Linux equivalent");
291 
292  count = 4;
293  recInvSqrt = 36864;
294  queue->m_count = count;
295  queue->m_recInvSqrt = recInvSqrt;
296  queue->NewtonStep ();
297  // Test that ns-3 value is exactly the same as the Linux value
298  NS_TEST_ASSERT_MSG_EQ (_codel_Newton_step (count, recInvSqrt), queue->m_recInvSqrt,
299  "ns-3 NewtonStep() fails to match Linux equivalent");
300 }
301 
302 // Test 4: ControlLaw unit test
303 // test against explicit port of Linux implementation
305 {
306 public:
308  virtual void DoRun (void);
309  uint32_t _codel_control_law (Ptr<CoDelQueue> queue, uint32_t t);
310 };
311 
313  : TestCase ("ControlLaw arithmetic unit test")
314 {
315 }
316 
317 // The following code borrowed from Linux codel.h,
318 // except the addition of queue parameter
319 uint32_t
321 {
322  return t + _reciprocal_scale (queue->Time2CoDel (queue->m_interval), queue->m_recInvSqrt << REC_INV_SQRT_SHIFT_ns3);
323 }
324 // End Linux borrrow
325 
326 void
328 {
329  Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
330 
331  /* Spot check a few points of m_dropNext
332  The integer approximations in Linux should be within
333  2% of the true floating point value obtained in ns-3
334  */
335  uint32_t dropNextTestVals [4] = {292299, 341128, 9804717, 55885007};
336 
337  for (int i = 0; i < 4; ++i)
338  {
339  uint32_t ns3Result = queue->ControlLaw (dropNextTestVals[i]);
340  uint32_t upperBound = ns3Result + 0.02 * ns3Result;
341  uint32_t lowerBound = ns3Result - 0.02 * ns3Result;
342  uint32_t linuxResult = _codel_control_law (queue, dropNextTestVals[i]);
343  NS_TEST_EXPECT_MSG_EQ ((lowerBound < linuxResult || linuxResult < upperBound), true,
344  "Linux result should stay within 2% of ns-3 result");
345  }
346 }
347 
348 // Test 5: enqueue/dequeue with drops according to CoDel algorithm
350 {
351 public:
352  CoDelQueueBasicDrop (std::string mode);
353  virtual void DoRun (void);
354 
355  void QueueTestSize (Ptr<CoDelQueue> queue, uint32_t size, std::string error)
356  {
357  if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
358  {
359  NS_TEST_EXPECT_MSG_EQ (queue->GetNBytes (), size, error);
360  }
361  else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
362  {
363  NS_TEST_EXPECT_MSG_EQ (queue->GetNPackets (), size, error);
364  }
365 
366  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), size, error);
367  }
368 
369 private:
370  void Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt);
371  void Dequeue (Ptr<CoDelQueue> queue, uint32_t modeSize);
372  void DropNextTracer (uint32_t oldVal, uint32_t newVal);
374  uint32_t m_dropNextCount; //count the number of times m_dropNext is recalculated
375 };
376 
378  : TestCase ("Basic drop operations for " + mode)
379 {
380  m_mode = StringValue (mode);
381  m_dropNextCount = 0;
382 }
383 
384 void
385 CoDelQueueBasicDrop::DropNextTracer (uint32_t oldVal, uint32_t newVal)
386 {
387  m_dropNextCount++;
388 }
389 
390 void
392 {
393  Ptr<CoDelQueue> queue = CreateObject<CoDelQueue> ();
394  uint32_t pktSize = 1000;
395  uint32_t modeSize = 0;
396 
397  NS_TEST_EXPECT_MSG_EQ (queue->SetAttributeFailSafe ("Mode", m_mode), true,
398  "Verify that we can actually set the attribute Mode");
399 
400  if (queue->GetMode () == CoDelQueue::QUEUE_MODE_BYTES)
401  {
402  modeSize = pktSize;
403  }
404  else if (queue->GetMode () == CoDelQueue::QUEUE_MODE_PACKETS)
405  {
406  modeSize = 1;
407  }
408 
409  Enqueue (queue, pktSize, 20);
410  NS_TEST_EXPECT_MSG_EQ (queue->GetQueueSize (), 20 * modeSize, "There should be 20 packets in queue.");
411 
412  // Although the first dequeue occurs with a sojourn time above target
413  // the dequeue should be successful in this interval
414  Time waitUntilFirstDequeue = 2 * queue->GetTarget ();
415  Simulator::Schedule (waitUntilFirstDequeue, &CoDelQueueBasicDrop::Dequeue, this, queue, modeSize);
416 
417  // This dequeue should cause a drop
418  Time waitUntilSecondDequeue = waitUntilFirstDequeue + 2 * queue->GetInterval ();
419  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueBasicDrop::Dequeue, this, queue, modeSize);
420 
421  // Although we are in dropping state, it's not time for next drop
422  // the dequeue should not cause a drop
423  Simulator::Schedule (waitUntilSecondDequeue, &CoDelQueueBasicDrop::Dequeue, this, queue, modeSize);
424 
425  // In dropping time and it's time for next drop
426  // the dequeue should cause additional packet drops
427  Simulator::Schedule (waitUntilSecondDequeue * 2, &CoDelQueueBasicDrop::Dequeue, this, queue, modeSize);
428 
429  Simulator::Run ();
430  Simulator::Destroy ();
431 }
432 
433 void
434 CoDelQueueBasicDrop::Enqueue (Ptr<CoDelQueue> queue, uint32_t size, uint32_t nPkt)
435 {
436  for (uint32_t i = 0; i < nPkt; i++)
437  {
438  queue->Enqueue (Create<Packet> (size));
439  }
440 }
441 
442 void
444 {
445  uint32_t initialDropCount = queue->GetDropCount ();
446  uint32_t initialQSize = queue->GetQueueSize ();
447  uint32_t initialDropNext = queue->GetDropNext ();
448  Time currentTime = Simulator::Now ();
449  uint32_t currentDropCount = 0;
450 
451  if (initialDropCount > 0 && currentTime.GetMicroSeconds () >= initialDropNext)
452  {
454  }
455 
456  if (initialQSize != 0)
457  {
458  Ptr<Packet> p = queue->Dequeue ();
459  if (initialDropCount == 0 && currentTime > queue->GetTarget ())
460  {
461  if (currentTime < queue->GetInterval ())
462  {
463  currentDropCount = queue->GetDropCount ();
464  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 0, "We are not in dropping state."
465  "Sojourn time has just gone above target from below."
466  "Hence, there should be no packet drops");
467  QueueTestSize (queue, initialQSize - modeSize, "There should be 1 packet dequeued.");
468 
469  }
470  else if (currentTime >= queue->GetInterval ())
471  {
472  currentDropCount = queue->GetDropCount ();
473  QueueTestSize (queue, initialQSize - 2 * modeSize, "Sojourn time has been above target for at least interval."
474  "We enter the dropping state, perform initial packet drop, and dequeue the next."
475  "So there should be 2 more packets dequeued.");
476  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should be 1 packet drop");
477  }
478  }
479  else if (initialDropCount > 0)
480  { // In dropping state
481  if (currentTime.GetMicroSeconds () < initialDropNext)
482  {
483  currentDropCount = queue->GetDropCount ();
484  QueueTestSize (queue, initialQSize - modeSize, "We are in dropping state."
485  "Sojourn is still above target."
486  "However, it's not time for next drop."
487  "So there should be only 1 more packet dequeued");
488 
489  NS_TEST_EXPECT_MSG_EQ (currentDropCount, 1, "There should still be only 1 packet drop from the last dequeue");
490  }
491  else if (currentTime.GetMicroSeconds () >= initialDropNext)
492  {
493  currentDropCount = queue->GetDropCount ();
494  QueueTestSize (queue, initialQSize - (m_dropNextCount + 1) * modeSize, "We are in dropping state."
495  "It's time for next drop."
496  "The number of packets dequeued equals to the number of times m_dropNext is updated plus initial dequeue");
497  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");
498  }
499  }
500  }
501 }
502 
503 static class CoDelQueueTestSuite : public TestSuite
504 {
505 public:
507  : TestSuite ("codel-queue", UNIT)
508  {
509  // Test 1: simple enqueue/dequeue with no drops
510  AddTestCase (new CoDelQueueBasicEnqueueDequeue ("QUEUE_MODE_PACKETS"), TestCase::QUICK);
511  AddTestCase (new CoDelQueueBasicEnqueueDequeue ("QUEUE_MODE_BYTES"), TestCase::QUICK);
512  // Test 2: enqueue with drops due to queue overflow
513  AddTestCase (new CoDelQueueBasicOverflow ("QUEUE_MODE_PACKETS"), TestCase::QUICK);
514  AddTestCase (new CoDelQueueBasicOverflow ("QUEUE_MODE_BYTES"), TestCase::QUICK);
515  // Test 3: test NewtonStep() against explicit port of Linux implementation
516  AddTestCase (new CoDelQueueNewtonStepTest (), TestCase::QUICK);
517  // Test 4: test ControlLaw() against explicit port of Linux implementation
518  AddTestCase (new CoDelQueueControlLawTest (), TestCase::QUICK);
519  // Test 5: enqueue/dequeue with drops according to CoDel algorithm
520  AddTestCase (new CoDelQueueBasicDrop ("QUEUE_MODE_PACKETS"), TestCase::QUICK);
521  AddTestCase (new CoDelQueueBasicDrop ("QUEUE_MODE_PACKETS"), TestCase::QUICK);
522  }
uint32_t GetDropOverLimit(void)
Get the number of packets dropped when packets arrive at a full queue and cannot be enqueued...
Definition: codel-queue.cc:526
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
bool Enqueue(Ptr< Packet > p)
Place a packet into the rear of the Queue.
Definition: queue.cc:66
Hold variables of type string.
Definition: string.h:41
Use number of bytes for maximum queue size.
Definition: queue.h:129
A suite of tests to run.
Definition: test.h:1276
CoDelQueueTestSuite g_coDelQueueTestSuite
uint64_t GetUid(void) const
Returns the packet's Uid.
Definition: packet.cc:380
void QueueTestSize(Ptr< CoDelQueue > queue, uint32_t size, std::string error)
#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:273
bool SetAttributeFailSafe(std::string name, const AttributeValue &value)
Set a single attribute without raising errors.
Definition: object-base.cc:210
uint32_t GetDropCount(void)
Get the number of packets dropped according to CoDel algorithm.
Definition: codel-queue.cc:532
virtual void DoRun(void)
Implementation to actually run this TestCase.
encapsulates test code
Definition: test.h:1108
uint32_t ControlLaw(uint32_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
Definition: codel-queue.cc:258
This test suite implements a Unit Test.
Definition: test.h:1286
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint16_t m_recInvSqrt
Reciprocal inverse square root.
Definition: codel-queue.h:237
Time m_interval
100 ms sliding minimum time window width
Definition: codel-queue.h:231
Time GetTarget(void)
Get the target queue delay.
Definition: codel-queue.cc:538
virtual void DoRun(void)
Implementation to actually run this TestCase.
CoDelQueue::QueueMode GetMode(void)
Get the encapsulation mode of this device.
Definition: codel-queue.cc:272
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:342
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition: test.cc:190
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
Definition: codel-queue.cc:508
static uint32_t _reciprocal_scale(uint32_t val, uint32_t ep_ro)
Hold an unsigned integer type.
Definition: uinteger.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:158
Ptr< Packet > Dequeue(void)
Remove a packet from the front of the Queue.
Definition: queue.cc:90
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1296
uint32_t GetNPackets(void) const
Definition: queue.cc:129
#define REC_INV_SQRT_SHIFT_ns3
CoDelQueueBasicDrop(std::string mode)
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:298
void QueueTestSize(Ptr< CoDelQueue > queue, uint32_t size, std::string error)
virtual void DoRun(void)
Implementation to actually run this TestCase.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
CoDelQueueBasicEnqueueDequeue(std::string mode)
void Dequeue(Ptr< CoDelQueue > queue, uint32_t modeSize)
void DropNextTracer(uint32_t oldVal, uint32_t newVal)
uint32_t GetNBytes(void) const
Definition: queue.cc:137
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
Definition: codel-queue.cc:550
void QueueTestSize(Ptr< CoDelQueue > queue, uint32_t size, std::string error)
void NewtonStep(void)
Calculate the reciprocal square root of m_count by using Newton'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)
Definition: codel-queue.cc:245
CoDelQueueBasicOverflow(std::string mode)
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t Time2CoDel(Time t)
returned unsigned 32-bit integer representation of the input Time object units are microseconds ...
Definition: codel-queue.cc:599
void Enqueue(Ptr< CoDelQueue > queue, uint32_t size, uint32_t nPkt)
void Enqueue(Ptr< CoDelQueue > queue, uint32_t size, uint32_t nPkt)
Time GetInterval(void)
Get the interval.
Definition: codel-queue.cc:544
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:330
static uint16_t _codel_Newton_step(uint32_t count, uint16_t rec_inv_sqrt)
Use number of packets for maximum queue size.
Definition: queue.h:128
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
Definition: codel-queue.h:233
uint32_t _codel_control_law(Ptr< CoDelQueue > queue, uint32_t t)