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