This documentation is not the Latest Release.
A Discrete-Event Network Simulator
API
codel-queue.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2012 Andrew McGregor
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  * Codel, the COntrolled DELay Queueing discipline
19  * Based on ns2 simulation code presented by Kathie Nichols
20  *
21  * This port based on linux kernel code by
22  * Authors: Dave Täht <d@taht.net>
23  * Eric Dumazet <edumazet@google.com>
24  *
25  * Ported to ns-3 by: Andrew McGregor <andrewmcgr@gmail.com>
26 */
27 
28 #include "ns3/log.h"
29 #include "ns3/enum.h"
30 #include "ns3/uinteger.h"
31 #include "ns3/abort.h"
32 #include "codel-queue.h"
33 
34 namespace ns3 {
35 
36 NS_LOG_COMPONENT_DEFINE ("CoDelQueue");
37 
45 /* borrowed from the linux kernel */
46 static inline uint32_t ReciprocalDivide (uint32_t A, uint32_t R)
47 {
48  return (uint32_t)(((uint64_t)A * R) >> 32);
49 }
50 
51 /* end kernel borrowings */
52 
57 static uint32_t CoDelGetTime (void)
58 {
59  Time time = Simulator::Now ();
60  uint64_t ns = time.GetNanoSeconds ();
61 
62  return ns >> CODEL_SHIFT;
63 }
64 
68 class CoDelTimestampTag : public Tag
69 {
70 public:
76  static TypeId GetTypeId (void);
77  virtual TypeId GetInstanceTypeId (void) const;
78 
79  virtual uint32_t GetSerializedSize (void) const;
80  virtual void Serialize (TagBuffer i) const;
81  virtual void Deserialize (TagBuffer i);
82  virtual void Print (std::ostream &os) const;
83 
88  Time GetTxTime (void) const;
89 private:
90  uint64_t m_creationTime;
91 };
92 
94  : m_creationTime (Simulator::Now ().GetTimeStep ())
95 {
96 }
97 
98 TypeId
100 {
101  static TypeId tid = TypeId ("ns3::CoDelTimestampTag")
102  .SetParent<Tag> ()
103  .AddConstructor<CoDelTimestampTag> ()
104  .AddAttribute ("CreationTime",
105  "The time at which the timestamp was created",
106  StringValue ("0.0s"),
108  MakeTimeChecker ())
109  ;
110  return tid;
111 }
112 
113 TypeId
115 {
116  return GetTypeId ();
117 }
118 
119 uint32_t
121 {
122  return 8;
123 }
124 void
126 {
128 }
129 void
131 {
132  m_creationTime = i.ReadU64 ();
133 }
134 void
135 CoDelTimestampTag::Print (std::ostream &os) const
136 {
137  os << "CreationTime=" << m_creationTime;
138 }
139 Time
141 {
142  return TimeStep (m_creationTime);
143 }
144 
146 
148 {
149  static TypeId tid = TypeId ("ns3::CoDelQueue")
150  .SetParent<Queue> ()
151  .SetGroupName ("Internet")
152  .AddConstructor<CoDelQueue> ()
153  .AddAttribute ("Mode",
154  "Whether to use Bytes (see MaxBytes) or Packets (see MaxPackets) as the maximum queue size metric.",
157  MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
158  QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
159  .AddAttribute ("MaxPackets",
160  "The maximum number of packets accepted by this CoDelQueue.",
163  MakeUintegerChecker<uint32_t> ())
164  .AddAttribute ("MaxBytes",
165  "The maximum number of bytes accepted by this CoDelQueue.",
168  MakeUintegerChecker<uint32_t> ())
169  .AddAttribute ("MinBytes",
170  "The CoDel algorithm minbytes parameter.",
171  UintegerValue (1500),
173  MakeUintegerChecker<uint32_t> ())
174  .AddAttribute ("Interval",
175  "The CoDel algorithm interval",
176  StringValue ("100ms"),
178  MakeTimeChecker ())
179  .AddAttribute ("Target",
180  "The CoDel algorithm target queue delay",
181  StringValue ("5ms"),
183  MakeTimeChecker ())
184  .AddTraceSource ("Count",
185  "CoDel count",
187  "ns3::TracedValueCallback::Uint32")
188  .AddTraceSource ("DropCount",
189  "CoDel drop count",
191  "ns3::TracedValueCallback::Uint32")
192  .AddTraceSource ("LastCount",
193  "CoDel lastcount",
195  "ns3::TracedValueCallback::Uint32")
196  .AddTraceSource ("DropState",
197  "Dropping state",
199  "ns3::TracedValueCallback::Bool")
200  .AddTraceSource ("BytesInQueue",
201  "Number of bytes in the queue",
203  "ns3::TracedValueCallback::Uint32")
204  .AddTraceSource ("Sojourn",
205  "Time in the queue",
207  "ns3::Time::TracedValueCallback")
208  .AddTraceSource ("DropNext",
209  "Time until next packet drop",
211  "ns3::TracedValueCallback::Uint32")
212  ;
213 
214  return tid;
215 }
216 
218  : Queue (),
219  m_packets (),
220  m_maxBytes (),
221  m_bytesInQueue (0),
222  m_count (0),
223  m_dropCount (0),
224  m_lastCount (0),
225  m_dropping (false),
226  m_recInvSqrt (~0U >> REC_INV_SQRT_SHIFT),
227  m_firstAboveTime (0),
228  m_dropNext (0),
229  m_state1 (0),
230  m_state2 (0),
231  m_state3 (0),
232  m_states (0),
233  m_dropOverLimit (0),
234  m_sojourn (0)
235 {
236  NS_LOG_FUNCTION (this);
237 }
238 
240 {
241  NS_LOG_FUNCTION (this);
242 }
243 
244 void
246 {
247  NS_LOG_FUNCTION (this);
248  uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT;
249  uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
250  uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2);
251 
252  val >>= 2; /* avoid overflow */
253  val = (val * invsqrt) >> (32 - 2 + 1);
255 }
256 
257 uint32_t
259 {
260  NS_LOG_FUNCTION (this);
262 }
263 
264 void
266 {
267  NS_LOG_FUNCTION (mode);
268  m_mode = mode;
269 }
270 
273 {
274  NS_LOG_FUNCTION (this);
275  return m_mode;
276 }
277 
278 bool
280 {
281  NS_LOG_FUNCTION (this << p);
282 
283  if (m_mode == QUEUE_MODE_PACKETS && (m_packets.size () + 1 > m_maxPackets))
284  {
285  NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt");
286  Drop (p);
287  ++m_dropOverLimit;
288  return false;
289  }
290 
292  {
293  NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt");
294  Drop (p);
295  ++m_dropOverLimit;
296  return false;
297  }
298 
299  // Tag packet with current time for DoDequeue() to compute sojourn time
300  CoDelTimestampTag tag;
301  p->AddPacketTag (tag);
302 
303  m_bytesInQueue += p->GetSize ();
304  m_packets.push (p);
305 
306  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
307  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
308 
309  return true;
310 }
311 
312 bool
314 {
315  NS_LOG_FUNCTION (this);
316  CoDelTimestampTag tag;
317  bool okToDrop;
318 
319  bool found = p->RemovePacketTag (tag);
320  NS_ASSERT_MSG (found, "found a packet without an input timestamp tag");
321  NS_UNUSED (found); //silence compiler warning
322  Time delta = Simulator::Now () - tag.GetTxTime ();
323  NS_LOG_INFO ("Sojourn time " << delta.GetSeconds ());
324  m_sojourn = delta;
325  uint32_t sojournTime = Time2CoDel (delta);
326 
327  if (CoDelTimeBefore (sojournTime, Time2CoDel (m_target))
329  {
330  // went below so we'll stay below for at least q->interval
331  NS_LOG_LOGIC ("Sojourn time is below target or number of bytes in queue is less than minBytes; packet should not be dropped");
332  m_firstAboveTime = 0;
333  return false;
334  }
335  okToDrop = false;
336  if (m_firstAboveTime == 0)
337  {
338  /* just went above from below. If we stay above
339  * for at least q->interval we'll say it's ok to drop
340  */
341  NS_LOG_LOGIC ("Sojourn time has just gone above target from below, need to stay above for at least q->interval before packet can be dropped. ");
343  }
344  else
345  if (CoDelTimeAfter (now, m_firstAboveTime))
346  {
347  NS_LOG_LOGIC ("Sojourn time has been above target for at least q->interval; it's OK to (possibly) drop packet.");
348  okToDrop = true;
349  ++m_state1;
350  }
351  return okToDrop;
352 }
353 
356 {
357  NS_LOG_FUNCTION (this);
358 
359  if (m_packets.empty ())
360  {
361  // Leave dropping state when queue is empty
362  m_dropping = false;
363  m_firstAboveTime = 0;
364  NS_LOG_LOGIC ("Queue empty");
365  return 0;
366  }
367  uint32_t now = CoDelGetTime ();
368  Ptr<Packet> p = m_packets.front ();
369  m_packets.pop ();
370  m_bytesInQueue -= p->GetSize ();
371 
372  NS_LOG_LOGIC ("Popped " << p);
373  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
374  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
375 
376  // Determine if p should be dropped
377  bool okToDrop = OkToDrop (p, now);
378 
379  if (m_dropping)
380  { // In the dropping state (sojourn time has gone above target and hasn't come down yet)
381  // Check if we can leave the dropping state or next drop should occur
382  NS_LOG_LOGIC ("In dropping state, check if it's OK to leave or next drop should occur");
383  if (!okToDrop)
384  {
385  /* sojourn time fell below target - leave dropping state */
386  NS_LOG_LOGIC ("Sojourn time goes below target, it's OK to leave dropping state.");
387  m_dropping = false;
388  }
389  else
390  if (CoDelTimeAfterEq (now, m_dropNext))
391  {
392  m_state2++;
393  while (m_dropping && CoDelTimeAfterEq (now, m_dropNext))
394  {
395  // It's time for the next drop. Drop the current packet and
396  // dequeue the next. The dequeue might take us out of dropping
397  // state. If not, schedule the next drop.
398  // A large amount of packets in queue might result in drop
399  // rates so high that the next drop should happen now,
400  // hence the while loop.
401  NS_LOG_LOGIC ("Sojourn time is still above target and it's time for next drop; dropping " << p);
402  Drop (p);
403 
404  // p was in queue, trace dequeue and update stats manually
405  m_traceDequeue (p);
406  m_nBytes -= p->GetSize ();
407  m_nPackets--;
408 
409  ++m_dropCount;
410  ++m_count;
411  NewtonStep ();
412  if (m_packets.empty ())
413  {
414  m_dropping = false;
415  NS_LOG_LOGIC ("Queue empty");
416  ++m_states;
417  return 0;
418  }
419  p = m_packets.front ();
420  m_packets.pop ();
421  m_bytesInQueue -= p->GetSize ();
422 
423  NS_LOG_LOGIC ("Popped " << p);
424  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
425  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
426 
427  if (!OkToDrop (p, now))
428  {
429  /* leave dropping state */
430  NS_LOG_LOGIC ("Leaving dropping state");
431  m_dropping = false;
432  }
433  else
434  {
435  /* schedule the next drop */
436  NS_LOG_LOGIC ("Running ControlLaw for input m_dropNext: " << (double)m_dropNext / 1000000);
438  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000);
439  }
440  }
441  }
442  }
443  else
444  {
445  // Not in the dropping state
446  // Decide if we have to enter the dropping state and drop the first packet
447  NS_LOG_LOGIC ("Not in dropping state; decide if we have to enter the state and drop the first packet");
448  if (okToDrop)
449  {
450  // Drop the first packet and enter dropping state unless the queue is empty
451  NS_LOG_LOGIC ("Sojourn time goes above target, dropping the first packet " << p << " and entering the dropping state");
452  ++m_dropCount;
453  Drop (p);
454 
455  // p was in queue, trace the dequeue and update stats manually
456  m_traceDequeue (p);
457  m_nBytes -= p->GetSize ();
458  m_nPackets--;
459 
460  if (m_packets.empty ())
461  {
462  m_dropping = false;
463  okToDrop = false;
464  NS_LOG_LOGIC ("Queue empty");
465  ++m_states;
466  }
467  else
468  {
469  p = m_packets.front ();
470  m_packets.pop ();
471  m_bytesInQueue -= p->GetSize ();
472 
473  NS_LOG_LOGIC ("Popped " << p);
474  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
475  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
476 
477  okToDrop = OkToDrop (p, now);
478  m_dropping = true;
479  }
480  ++m_state3;
481  /*
482  * if min went above target close to when we last went below it
483  * assume that the drop rate that controlled the queue on the
484  * last cycle is a good starting point to control it now.
485  */
486  int delta = m_count - m_lastCount;
487  if (delta > 1 && CoDelTimeBefore (now - m_dropNext, 16 * Time2CoDel (m_interval)))
488  {
489  m_count = delta;
490  NewtonStep ();
491  }
492  else
493  {
494  m_count = 1;
496  }
497  m_lastCount = m_count;
498  NS_LOG_LOGIC ("Running ControlLaw for input now: " << (double)now);
499  m_dropNext = ControlLaw (now);
500  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000 << " now " << (double)now / 1000000);
501  }
502  }
503  ++m_states;
504  return p;
505 }
506 
507 uint32_t
509 {
510  NS_LOG_FUNCTION (this);
511  if (GetMode () == QUEUE_MODE_BYTES)
512  {
513  return m_bytesInQueue;
514  }
515  else if (GetMode () == QUEUE_MODE_PACKETS)
516  {
517  return m_packets.size ();
518  }
519  else
520  {
521  NS_ABORT_MSG ("Unknown mode.");
522  }
523 }
524 
525 uint32_t
527 {
528  return m_dropOverLimit;
529 }
530 
531 uint32_t
533 {
534  return m_dropCount;
535 }
536 
537 Time
539 {
540  return m_target;
541 }
542 
543 Time
545 {
546  return m_interval;
547 }
548 
549 uint32_t
551 {
552  return m_dropNext;
553 }
554 
556 CoDelQueue::DoPeek (void) const
557 {
558  NS_LOG_FUNCTION (this);
559 
560  if (m_packets.empty ())
561  {
562  NS_LOG_LOGIC ("Queue empty");
563  return 0;
564  }
565 
566  Ptr<Packet> p = m_packets.front ();
567 
568  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
569  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
570 
571  return p;
572 }
573 
574 bool
575 CoDelQueue::CoDelTimeAfter (uint32_t a, uint32_t b)
576 {
577  return ((int)(a) - (int)(b) > 0);
578 }
579 
580 bool
581 CoDelQueue::CoDelTimeAfterEq (uint32_t a, uint32_t b)
582 {
583  return ((int)(a) - (int)(b) >= 0);
584 }
585 
586 bool
587 CoDelQueue::CoDelTimeBefore (uint32_t a, uint32_t b)
588 {
589  return ((int)(a) - (int)(b) < 0);
590 }
591 
592 bool
593 CoDelQueue::CoDelTimeBeforeEq (uint32_t a, uint32_t b)
594 {
595  return ((int)(a) - (int)(b) <= 0);
596 }
597 
598 uint32_t
600 {
601  return (t.GetNanoSeconds () >> CODEL_SHIFT);
602 }
603 
604 
605 } // namespace ns3
606 
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
bool CoDelTimeAfter(uint32_t a, uint32_t b)
Check if CoDel time a is successive to b.
Definition: codel-queue.cc:575
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
bool CoDelTimeAfterEq(uint32_t a, uint32_t b)
Check if CoDel time a is successive or equal to b.
Definition: codel-queue.cc:581
Control the scheduling of simulation events.
Definition: simulator.h:70
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
virtual bool DoEnqueue(Ptr< Packet > p)
Add a packet to the queue.
Definition: codel-queue.cc:279
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
Hold variables of type string.
Definition: string.h:41
void WriteU64(uint64_t v)
Definition: tag-buffer.cc:102
uint32_t m_state1
Number of times packet sojourn goes above target for interval.
Definition: codel-queue.h:240
uint32_t m_minBytes
Minimum bytes in queue to allow a packet drop.
Definition: codel-queue.h:230
Use number of bytes for maximum queue size.
Definition: queue.h:129
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: enum.h:209
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:822
std::queue< Ptr< Packet > > m_packets
The packet queue.
Definition: codel-queue.h:226
TracedValue< uint32_t > m_dropNext
Time to drop next packet.
Definition: codel-queue.h:239
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
TracedValue< uint32_t > m_lastCount
Last number of packets dropped since entering drop state.
Definition: codel-queue.h:235
TracedValue< bool > m_dropping
True if in dropping state.
Definition: codel-queue.h:236
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:786
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
uint32_t m_states
Total number of times we are in state 1, state 2, or state 3.
Definition: codel-queue.h:243
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:244
uint32_t GetDropCount(void)
Get the number of packets dropped according to CoDel algorithm.
Definition: codel-queue.cc:532
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
uint32_t m_nPackets
Number of packets in the queue.
Definition: queue.h:192
uint32_t m_state2
Number of times we perform next drop while in dropping state.
Definition: codel-queue.h:241
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Abstract base class for packet Queues.
Definition: queue.h:45
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
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
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:341
virtual uint32_t GetSerializedSize(void) const
Definition: codel-queue.cc:120
QueueMode
Enumeration of the modes supported in the class.
Definition: queue.h:126
CoDelQueue::QueueMode GetMode(void)
Get the encapsulation mode of this device.
Definition: codel-queue.cc:272
static TypeId GetTypeId(void)
Get the type ID.
Definition: codel-queue.cc:99
bool OkToDrop(Ptr< Packet > p, uint32_t now)
Determine whether a packet is OK to be dropped.
Definition: codel-queue.cc:313
Hold variables of type enum.
Definition: enum.h:54
CoDel time stamp, used to carry CoDel time informations.
Definition: codel-queue.cc:68
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
Definition: codel-queue.cc:508
TracedValue< uint32_t > m_dropCount
Number of dropped packets according CoDel algorithm.
Definition: codel-queue.h:234
Hold an unsigned integer type.
Definition: uinteger.h:44
#define DEFAULT_CODEL_LIMIT
Definition: codel-queue.h:51
A CoDel packet queue.
Definition: codel-queue.h:63
bool CoDelTimeBefore(uint32_t a, uint32_t b)
Check if CoDel time a is preceding b.
Definition: codel-queue.cc:587
virtual void Deserialize(TagBuffer i)
Definition: codel-queue.cc:130
uint32_t m_dropOverLimit
The number of packets dropped due to full queue.
Definition: codel-queue.h:244
virtual void Serialize(TagBuffer i) const
Definition: codel-queue.cc:125
uint32_t m_maxBytes
Max # of bytes accepted by the queue.
Definition: codel-queue.h:228
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
uint32_t m_nBytes
Number of bytes in the queue.
Definition: queue.h:190
CoDelQueue()
CoDelQueue Constructor.
Definition: codel-queue.cc:217
tag a set of bytes in a packet
Definition: tag.h:36
uint32_t m_firstAboveTime
Time to declare sojourn time above target.
Definition: codel-queue.h:238
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual ~CoDelQueue()
Definition: codel-queue.cc:239
Time m_target
5 ms target queue delay
Definition: codel-queue.h:232
uint64_t ReadU64(void)
Definition: tag-buffer.cc:134
TracedCallback< Ptr< const Packet > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
Definition: queue.h:186
uint64_t m_creationTime
Tag creation time.
Definition: codel-queue.cc:90
uint32_t m_maxPackets
Max # of packets accepted by the queue.
Definition: codel-queue.h:227
bool CoDelTimeBeforeEq(uint32_t a, uint32_t b)
Check if CoDel time a is preceding or equal to b.
Definition: codel-queue.cc:593
Time TimeStep(uint64_t ts)
Definition: nstime.h:952
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
Definition: codel-queue.cc:550
static const int CODEL_SHIFT
Number of bits discarded from the time representation.
Definition: codel-queue.h:49
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:958
static TypeId GetTypeId(void)
Get the type ID.
Definition: codel-queue.cc:147
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
QueueMode m_mode
The operating mode (Bytes or packets)
Definition: codel-queue.h:245
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
Definition: codel-queue.cc:114
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
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:90
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:353
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.cc:184
read and write tag data
Definition: tag-buffer.h:51
static uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
Performs a reciprocal divide, similar to the Linux kernel reciprocal_divide function.
Definition: codel-queue.cc:46
void SetMode(CoDelQueue::QueueMode mode)
Set the operating mode of this device.
Definition: codel-queue.cc:265
static uint32_t CoDelGetTime(void)
Returns the current time translated in CoDel time representation.
Definition: codel-queue.cc:57
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:829
uint32_t Time2CoDel(Time t)
returned unsigned 32-bit integer representation of the input Time object units are microseconds ...
Definition: codel-queue.cc:599
virtual Ptr< const Packet > DoPeek(void) const
Peek the front packet in the queue.
Definition: codel-queue.cc:556
virtual void Print(std::ostream &os) const
Definition: codel-queue.cc:135
Time GetInterval(void)
Get the interval.
Definition: codel-queue.cc:544
uint32_t m_state3
Number of times we enter drop state and drop the fist packet.
Definition: codel-queue.h:242
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:330
Time GetTxTime(void) const
Gets the Tag creation time.
Definition: codel-queue.cc:140
Use number of packets for maximum queue size.
Definition: queue.h:128
TracedValue< uint32_t > m_bytesInQueue
The total number of bytes in queue.
Definition: codel-queue.h:229
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
Definition: codel-queue.h:233
virtual Ptr< Packet > DoDequeue(void)
Remove a packet from queue based on the current state If we are in dropping state, check if we could leave the dropping state or if we should perform next drop If we are not currently in dropping state, check if we need to enter the state and drop the first packet.
Definition: codel-queue.cc:355
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:826
void Drop(Ptr< Packet > packet)
Drop a packet.
Definition: queue.cc:195
#define REC_INV_SQRT_SHIFT
Definition: codel-queue.h:53
TracedValue< Time > m_sojourn
Time in queue.
Definition: codel-queue.h:246