A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("CoDelQueue");
35 
36 namespace ns3 {
37 
38 /* borrowed from the linux kernel */
39 static inline uint32_t ReciprocalDivide (uint32_t A, uint32_t R)
40 {
41  return (uint32_t)(((uint64_t)A * R) >> 32);
42 }
43 
44 /* end kernel borrowings */
45 
46 static uint32_t CoDelGetTime (void)
47 {
48  Time time = Simulator::Now ();
49  uint64_t ns = time.GetNanoSeconds ();
50 
51  return ns >> CODEL_SHIFT;
52 }
53 
54 class CoDelTimestampTag : public Tag
55 {
56 public:
58  static TypeId GetTypeId (void);
59  virtual TypeId GetInstanceTypeId (void) const;
60 
61  virtual uint32_t GetSerializedSize (void) const;
62  virtual void Serialize (TagBuffer i) const;
63  virtual void Deserialize (TagBuffer i);
64  virtual void Print (std::ostream &os) const;
65 
66  Time GetTxTime (void) const;
67 private:
68  uint64_t m_creationTime;
69 };
70 
72  : m_creationTime (Simulator::Now ().GetTimeStep ())
73 {
74 }
75 
76 TypeId
78 {
79  static TypeId tid = TypeId ("ns3::CoDelTimestampTag")
80  .SetParent<Tag> ()
81  .AddConstructor<CoDelTimestampTag> ()
82  .AddAttribute ("CreationTime",
83  "The time at which the timestamp was created",
84  StringValue ("0.0s"),
85  MakeTimeAccessor (&CoDelTimestampTag::GetTxTime),
86  MakeTimeChecker ())
87  ;
88  return tid;
89 }
90 
91 TypeId
93 {
94  return GetTypeId ();
95 }
96 
97 uint32_t
99 {
100  return 8;
101 }
102 void
104 {
106 }
107 void
109 {
110  m_creationTime = i.ReadU64 ();
111 }
112 void
113 CoDelTimestampTag::Print (std::ostream &os) const
114 {
115  os << "CreationTime=" << m_creationTime;
116 }
117 Time
119 {
120  return TimeStep (m_creationTime);
121 }
122 
124 
126 {
127  static TypeId tid = TypeId ("ns3::CoDelQueue")
128  .SetParent<Queue> ()
129  .AddConstructor<CoDelQueue> ()
130  .AddAttribute ("Mode",
131  "Whether to use Bytes (see MaxBytes) or Packets (see MaxPackets) as the maximum queue size metric.",
134  MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
135  QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
136  .AddAttribute ("MaxPackets",
137  "The maximum number of packets accepted by this CoDelQueue.",
139  MakeUintegerAccessor (&CoDelQueue::m_maxPackets),
140  MakeUintegerChecker<uint32_t> ())
141  .AddAttribute ("MaxBytes",
142  "The maximum number of bytes accepted by this CoDelQueue.",
144  MakeUintegerAccessor (&CoDelQueue::m_maxBytes),
145  MakeUintegerChecker<uint32_t> ())
146  .AddAttribute ("MinBytes",
147  "The CoDel algorithm minbytes parameter.",
148  UintegerValue (1500),
149  MakeUintegerAccessor (&CoDelQueue::m_minBytes),
150  MakeUintegerChecker<uint32_t> ())
151  .AddAttribute ("Interval",
152  "The CoDel algorithm interval",
153  StringValue ("100ms"),
154  MakeTimeAccessor (&CoDelQueue::m_interval),
155  MakeTimeChecker ())
156  .AddAttribute ("Target",
157  "The CoDel algorithm target queue delay",
158  StringValue ("5ms"),
159  MakeTimeAccessor (&CoDelQueue::m_target),
160  MakeTimeChecker ())
161  .AddTraceSource ("Count",
162  "CoDel count",
164  .AddTraceSource ("DropCount",
165  "CoDel drop count",
167  .AddTraceSource ("LastCount",
168  "CoDel lastcount",
170  .AddTraceSource ("DropState",
171  "Dropping state",
173  .AddTraceSource ("BytesInQueue",
174  "Number of bytes in the queue",
176  .AddTraceSource ("Sojourn",
177  "Time in the queue",
179  .AddTraceSource ("DropNext",
180  "Time until next packet drop",
182  ;
183 
184  return tid;
185 }
186 
188  : Queue (),
189  m_packets (),
190  m_maxBytes (),
191  m_bytesInQueue (0),
192  m_count (0),
193  m_dropCount (0),
194  m_lastCount (0),
195  m_dropping (false),
196  m_recInvSqrt (~0U >> REC_INV_SQRT_SHIFT),
197  m_firstAboveTime (0),
198  m_dropNext (0),
199  m_state1 (0),
200  m_state2 (0),
201  m_state3 (0),
202  m_states (0),
203  m_dropOverLimit (0),
204  m_sojourn (0)
205 {
206  NS_LOG_FUNCTION (this);
207 }
208 
210 {
211  NS_LOG_FUNCTION (this);
212 }
213 
214 void
216 {
217  NS_LOG_FUNCTION (this);
218  uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT;
219  uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
220  uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2);
221 
222  val >>= 2; /* avoid overflow */
223  val = (val * invsqrt) >> (32 - 2 + 1);
225 }
226 
227 uint32_t
229 {
230  NS_LOG_FUNCTION (this);
232 }
233 
234 void
236 {
237  NS_LOG_FUNCTION (mode);
238  m_mode = mode;
239 }
240 
243 {
244  NS_LOG_FUNCTION (this);
245  return m_mode;
246 }
247 
248 bool
250 {
251  NS_LOG_FUNCTION (this << p);
252 
253  if (m_mode == QUEUE_MODE_PACKETS && (m_packets.size () + 1 > m_maxPackets))
254  {
255  NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt");
256  Drop (p);
257  ++m_dropOverLimit;
258  return false;
259  }
260 
262  {
263  NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt");
264  Drop (p);
265  ++m_dropOverLimit;
266  return false;
267  }
268 
269  // Tag packet with current time for DoDequeue() to compute sojourn time
270  CoDelTimestampTag tag;
271  p->AddPacketTag (tag);
272 
273  m_bytesInQueue += p->GetSize ();
274  m_packets.push (p);
275 
276  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
277  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
278 
279  return true;
280 }
281 
282 bool
284 {
285  NS_LOG_FUNCTION (this);
286  CoDelTimestampTag tag;
287  bool okToDrop;
288  p->FindFirstMatchingByteTag (tag);
289  bool found = p->RemovePacketTag (tag);
290  NS_ASSERT_MSG (found, "found a packet without an input timestamp tag");
291  NS_UNUSED (found); //silence compiler warning
292  Time delta = Simulator::Now () - tag.GetTxTime ();
293  NS_LOG_INFO ("Sojourn time " << delta.GetSeconds ());
294  m_sojourn = delta;
295  uint32_t sojournTime = Time2CoDel (delta);
296 
297  if (CoDelTimeBefore (sojournTime, Time2CoDel (m_target))
299  {
300  // went below so we'll stay below for at least q->interval
301  NS_LOG_LOGIC ("Sojourn time is below target or number of bytes in queue is less than minBytes; packet should not be dropped");
302  m_firstAboveTime = 0;
303  return false;
304  }
305  okToDrop = false;
306  if (m_firstAboveTime == 0)
307  {
308  /* just went above from below. If we stay above
309  * for at least q->interval we'll say it's ok to drop
310  */
311  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. ");
313  }
314  else
315  if (CoDelTimeAfter (now, m_firstAboveTime))
316  {
317  NS_LOG_LOGIC ("Sojourn time has been above target for at least q->interval; it's OK to (possibly) drop packet.");
318  okToDrop = true;
319  ++m_state1;
320  }
321  return okToDrop;
322 }
323 
326 {
327  NS_LOG_FUNCTION (this);
328 
329  if (m_packets.empty ())
330  {
331  // Leave dropping state when queue is empty
332  m_dropping = false;
333  m_firstAboveTime = 0;
334  NS_LOG_LOGIC ("Queue empty");
335  return 0;
336  }
337  uint32_t now = CoDelGetTime ();
338  Ptr<Packet> p = m_packets.front ();
339  m_packets.pop ();
340  m_bytesInQueue -= p->GetSize ();
341 
342  NS_LOG_LOGIC ("Popped " << p);
343  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
344  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
345 
346  // Determine if p should be dropped
347  bool okToDrop = OkToDrop (p, now);
348 
349  if (m_dropping)
350  { // In the dropping state (sojourn time has gone above target and hasn't come down yet)
351  // Check if we can leave the dropping state or next drop should occur
352  NS_LOG_LOGIC ("In dropping state, check if it's OK to leave or next drop should occur");
353  if (!okToDrop)
354  {
355  /* sojourn time fell below target - leave dropping state */
356  NS_LOG_LOGIC ("Sojourn time goes below target, it's OK to leave dropping state.");
357  m_dropping = false;
358  }
359  else
360  if (CoDelTimeAfterEq (now, m_dropNext))
361  {
362  m_state2++;
363  while (m_dropping && CoDelTimeAfterEq (now, m_dropNext))
364  {
365  // It's time for the next drop. Drop the current packet and
366  // dequeue the next. The dequeue might take us out of dropping
367  // state. If not, schedule the next drop.
368  // A large amount of packets in queue might result in drop
369  // rates so high that the next drop should happen now,
370  // hence the while loop.
371  NS_LOG_LOGIC ("Sojourn time is still above target and it's time for next drop; dropping " << p);
372  Drop (p);
373  ++m_dropCount;
374  ++m_count;
375  NewtonStep ();
376  if (m_packets.empty ())
377  {
378  m_dropping = false;
379  NS_LOG_LOGIC ("Queue empty");
380  ++m_states;
381  return 0;
382  }
383  p = m_packets.front ();
384  m_packets.pop ();
385  m_bytesInQueue -= p->GetSize ();
386 
387  NS_LOG_LOGIC ("Popped " << p);
388  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
389  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
390 
391  if (!OkToDrop (p, now))
392  {
393  /* leave dropping state */
394  NS_LOG_LOGIC ("Leaving dropping state");
395  m_dropping = false;
396  }
397  else
398  {
399  /* schedule the next drop */
400  NS_LOG_LOGIC ("Running ControlLaw for input m_dropNext: " << (double)m_dropNext / 1000000);
402  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000);
403  }
404  }
405  }
406  }
407  else
408  {
409  // Not in the dropping state
410  // Decide if we have to enter the dropping state and drop the first packet
411  NS_LOG_LOGIC ("Not in dropping state; decide if we have to enter the state and drop the first packet");
412  if (okToDrop)
413  {
414  // Drop the first packet and enter dropping state unless the queue is empty
415  NS_LOG_LOGIC ("Sojourn time goes above target, dropping the first packet " << p << " and entering the dropping state");
416  ++m_dropCount;
417  Drop (p);
418  if (m_packets.empty ())
419  {
420  m_dropping = false;
421  okToDrop = false;
422  NS_LOG_LOGIC ("Queue empty");
423  ++m_states;
424  }
425  else
426  {
427  p = m_packets.front ();
428  m_packets.pop ();
429  m_bytesInQueue -= p->GetSize ();
430 
431  NS_LOG_LOGIC ("Popped " << p);
432  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
433  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
434 
435  okToDrop = OkToDrop (p, now);
436  m_dropping = true;
437  }
438  ++m_state3;
439  /*
440  * if min went above target close to when we last went below it
441  * assume that the drop rate that controlled the queue on the
442  * last cycle is a good starting point to control it now.
443  */
444  int delta = m_count - m_lastCount;
445  if (delta > 1 && CoDelTimeBefore (now - m_dropNext, 16 * Time2CoDel (m_interval)))
446  {
447  m_count = delta;
448  NewtonStep ();
449  }
450  else
451  {
452  m_count = 1;
454  }
455  m_lastCount = m_count;
456  NS_LOG_LOGIC ("Running ControlLaw for input now: " << (double)now);
457  m_dropNext = ControlLaw (now);
458  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000 << " now " << (double)now / 1000000);
459  }
460  }
461  ++m_states;
462  return p;
463 }
464 
465 uint32_t
467 {
468  NS_LOG_FUNCTION (this);
469  if (GetMode () == QUEUE_MODE_BYTES)
470  {
471  return m_bytesInQueue;
472  }
473  else if (GetMode () == QUEUE_MODE_PACKETS)
474  {
475  return m_packets.size ();
476  }
477  else
478  {
479  NS_ABORT_MSG ("Unknown mode.");
480  }
481 }
482 
483 uint32_t
485 {
486  return m_dropOverLimit;
487 }
488 
489 uint32_t
491 {
492  return m_dropCount;
493 }
494 
495 Time
497 {
498  return m_target;
499 }
500 
501 Time
503 {
504  return m_interval;
505 }
506 
507 uint32_t
509 {
510  return m_dropNext;
511 }
512 
514 CoDelQueue::DoPeek (void) const
515 {
516  NS_LOG_FUNCTION (this);
517 
518  if (m_packets.empty ())
519  {
520  NS_LOG_LOGIC ("Queue empty");
521  return 0;
522  }
523 
524  Ptr<Packet> p = m_packets.front ();
525 
526  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
527  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
528 
529  return p;
530 }
531 
532 bool
533 CoDelQueue::CoDelTimeAfter (uint32_t a, uint32_t b)
534 {
535  return ((int)(a) - (int)(b) > 0);
536 }
537 
538 bool
539 CoDelQueue::CoDelTimeAfterEq (uint32_t a, uint32_t b)
540 {
541  return ((int)(a) - (int)(b) >= 0);
542 }
543 
544 bool
545 CoDelQueue::CoDelTimeBefore (uint32_t a, uint32_t b)
546 {
547  return ((int)(a) - (int)(b) < 0);
548 }
549 
550 bool
551 CoDelQueue::CoDelTimeBeforeEq (uint32_t a, uint32_t b)
552 {
553  return ((int)(a) - (int)(b) <= 0);
554 }
555 
556 uint32_t
558 {
559  return (t.GetNanoSeconds () >> CODEL_SHIFT);
560 }
561 
562 
563 } // namespace ns3
564 
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
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
Definition: packet.cc:824
bool CoDelTimeAfter(uint32_t a, uint32_t b)
Definition: codel-queue.cc:533
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
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)
Definition: enum.cc:178
bool CoDelTimeAfterEq(uint32_t a, uint32_t b)
Definition: codel-queue.cc:539
Control the scheduling of simulation events.
Definition: simulator.h:63
#define NS_ABORT_MSG(msg)
Abnormal program termination.
Definition: abort.h:44
virtual bool DoEnqueue(Ptr< Packet > p)
Add a packet to the queue.
Definition: codel-queue.cc:249
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
hold variables of type string
Definition: string.h:18
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:207
uint32_t m_minBytes
Minimum bytes in queue to allow a packet drop.
Definition: codel-queue.h:197
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Definition: packet.cc:841
std::queue< Ptr< Packet > > m_packets
The packet queue.
Definition: codel-queue.h:193
TracedValue< uint32_t > m_dropNext
Time to drop next packet.
Definition: codel-queue.h:206
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
TracedValue< uint32_t > m_lastCount
Definition: codel-queue.h:202
TracedValue< bool > m_dropping
True if in dropping state.
Definition: codel-queue.h:203
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:744
uint32_t m_states
Total number of times we are in state 1, state 2, or state 3.
Definition: codel-queue.h:210
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:223
uint32_t GetDropCount(void)
Get the number of packets dropped according to CoDel algorithm.
Definition: codel-queue.cc:490
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
uint32_t m_state2
Number of times we perform next drop while in dropping state.
Definition: codel-queue.h:208
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:444
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
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:322
virtual uint32_t GetSerializedSize(void) const
Definition: codel-queue.cc:98
CoDelQueue::QueueMode GetMode(void)
Get the encapsulation mode of this device.
Definition: codel-queue.cc:242
static TypeId GetTypeId(void)
Definition: codel-queue.cc:77
bool OkToDrop(Ptr< Packet > p, uint32_t now)
Determine whether a packet is OK to be dropped.
Definition: codel-queue.cc:283
hold variables of type 'enum'
Definition: enum.h:37
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
Definition: codel-queue.cc:466
TracedValue< uint32_t > m_dropCount
Number of dropped packets according CoDel algorithm.
Definition: codel-queue.h:201
Hold an unsigned integer type.
Definition: uinteger.h:46
A CoDel packet queue.
Definition: codel-queue.h:59
bool CoDelTimeBefore(uint32_t a, uint32_t b)
Definition: codel-queue.cc:545
virtual void Deserialize(TagBuffer i)
Definition: codel-queue.cc:108
uint32_t m_dropOverLimit
The number of packets dropped due to full queue.
Definition: codel-queue.h:211
virtual void Serialize(TagBuffer i) const
Definition: codel-queue.cc:103
uint32_t m_maxBytes
Max # of bytes accepted by the queue.
Definition: codel-queue.h:195
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:233
CoDelQueue()
CoDelQueue Constructor.
Definition: codel-queue.cc:187
tag a set of bytes in a packet
Definition: tag.h:36
Use number of bytes for maximum queue size.
Definition: queue.h:129
uint32_t m_firstAboveTime
Time to declare sojourn time above target.
Definition: codel-queue.h:205
virtual ~CoDelQueue()
Definition: codel-queue.cc:209
Time m_target
5 ms target queue delay
Definition: codel-queue.h:199
uint64_t ReadU64(void)
Definition: tag-buffer.cc:134
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
uint32_t m_maxPackets
Max # of packets accepted by the queue.
Definition: codel-queue.h:194
bool CoDelTimeBeforeEq(uint32_t a, uint32_t b)
Definition: codel-queue.cc:551
Time TimeStep(uint64_t ts)
Definition: nstime.h:902
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
Definition: codel-queue.cc:508
static const int CODEL_SHIFT
Definition: codel-queue.h:45
static TypeId GetTypeId(void)
Definition: codel-queue.cc:125
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
QueueMode m_mode
The operating mode (Bytes or packets)
Definition: codel-queue.h:212
QueueMode
Enumeration of the modes supported in the class.
Definition: queue.h:126
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
virtual TypeId GetInstanceTypeId(void) const
Definition: codel-queue.cc:92
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
#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:84
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:334
Use number of packets for maximum queue size.
Definition: queue.h:128
read and write tag data
Definition: tag-buffer.h:51
static uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
Definition: codel-queue.cc:39
void SetMode(CoDelQueue::QueueMode mode)
Set the operating mode of this device.
Definition: codel-queue.cc:235
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
static uint32_t CoDelGetTime(void)
Definition: codel-queue.cc:46
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:848
uint32_t Time2CoDel(Time t)
returned unsigned 32-bit integer representation of the input Time object units are microseconds ...
Definition: codel-queue.cc:557
virtual Ptr< const Packet > DoPeek(void) const
Peek the front packet in the queue.
Definition: codel-queue.cc:514
virtual void Print(std::ostream &os) const
Definition: codel-queue.cc:113
Time GetInterval(void)
Get the interval.
Definition: codel-queue.cc:502
uint32_t m_state3
Number of times we enter drop state and drop the fist packet.
Definition: codel-queue.h:209
#define NS_UNUSED(x)
Definition: unused.h:5
Time GetTxTime(void) const
Definition: codel-queue.cc:118
TracedValue< uint32_t > m_bytesInQueue
The total number of bytes in queue.
Definition: codel-queue.h:196
static const int DEFAULT_CODEL_LIMIT
Definition: codel-queue.h:46
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
Definition: codel-queue.h:200
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:325
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
void Drop(Ptr< Packet > packet)
Drop a packet.
Definition: queue.cc:191
#define REC_INV_SQRT_SHIFT
Definition: codel-queue.h:49
TracedValue< Time > m_sojourn
Time in queue.
Definition: codel-queue.h:213