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  .AddConstructor<CoDelQueue> ()
152  .AddAttribute ("Mode",
153  "Whether to use Bytes (see MaxBytes) or Packets (see MaxPackets) as the maximum queue size metric.",
156  MakeEnumChecker (QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
157  QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
158  .AddAttribute ("MaxPackets",
159  "The maximum number of packets accepted by this CoDelQueue.",
162  MakeUintegerChecker<uint32_t> ())
163  .AddAttribute ("MaxBytes",
164  "The maximum number of bytes accepted by this CoDelQueue.",
167  MakeUintegerChecker<uint32_t> ())
168  .AddAttribute ("MinBytes",
169  "The CoDel algorithm minbytes parameter.",
170  UintegerValue (1500),
172  MakeUintegerChecker<uint32_t> ())
173  .AddAttribute ("Interval",
174  "The CoDel algorithm interval",
175  StringValue ("100ms"),
177  MakeTimeChecker ())
178  .AddAttribute ("Target",
179  "The CoDel algorithm target queue delay",
180  StringValue ("5ms"),
182  MakeTimeChecker ())
183  .AddTraceSource ("Count",
184  "CoDel count",
186  "ns3::TracedValue::Uint32Callback")
187  .AddTraceSource ("DropCount",
188  "CoDel drop count",
190  "ns3::TracedValue::Uint32Callback")
191  .AddTraceSource ("LastCount",
192  "CoDel lastcount",
194  "ns3::TracedValue::Uint32Callback")
195  .AddTraceSource ("DropState",
196  "Dropping state",
198  "ns3::TracedValue::BoolCallback")
199  .AddTraceSource ("BytesInQueue",
200  "Number of bytes in the queue",
202  "ns3::TracedValue::Uint32Callback")
203  .AddTraceSource ("Sojourn",
204  "Time in the queue",
206  "ns3::Time::TracedValueCallback")
207  .AddTraceSource ("DropNext",
208  "Time until next packet drop",
210  "ns3::TracedValue::Uint32Callback")
211  ;
212 
213  return tid;
214 }
215 
217  : Queue (),
218  m_packets (),
219  m_maxBytes (),
220  m_bytesInQueue (0),
221  m_count (0),
222  m_dropCount (0),
223  m_lastCount (0),
224  m_dropping (false),
225  m_recInvSqrt (~0U >> REC_INV_SQRT_SHIFT),
226  m_firstAboveTime (0),
227  m_dropNext (0),
228  m_state1 (0),
229  m_state2 (0),
230  m_state3 (0),
231  m_states (0),
232  m_dropOverLimit (0),
233  m_sojourn (0)
234 {
235  NS_LOG_FUNCTION (this);
236 }
237 
239 {
240  NS_LOG_FUNCTION (this);
241 }
242 
243 void
245 {
246  NS_LOG_FUNCTION (this);
247  uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT;
248  uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
249  uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2);
250 
251  val >>= 2; /* avoid overflow */
252  val = (val * invsqrt) >> (32 - 2 + 1);
254 }
255 
256 uint32_t
258 {
259  NS_LOG_FUNCTION (this);
261 }
262 
263 void
265 {
266  NS_LOG_FUNCTION (mode);
267  m_mode = mode;
268 }
269 
272 {
273  NS_LOG_FUNCTION (this);
274  return m_mode;
275 }
276 
277 bool
279 {
280  NS_LOG_FUNCTION (this << p);
281 
282  if (m_mode == QUEUE_MODE_PACKETS && (m_packets.size () + 1 > m_maxPackets))
283  {
284  NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt");
285  Drop (p);
286  ++m_dropOverLimit;
287  return false;
288  }
289 
291  {
292  NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt");
293  Drop (p);
294  ++m_dropOverLimit;
295  return false;
296  }
297 
298  // Tag packet with current time for DoDequeue() to compute sojourn time
299  CoDelTimestampTag tag;
300  p->AddPacketTag (tag);
301 
302  m_bytesInQueue += p->GetSize ();
303  m_packets.push (p);
304 
305  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
306  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
307 
308  return true;
309 }
310 
311 bool
313 {
314  NS_LOG_FUNCTION (this);
315  CoDelTimestampTag tag;
316  bool okToDrop;
317 
318  bool found = p->RemovePacketTag (tag);
319  NS_ASSERT_MSG (found, "found a packet without an input timestamp tag");
320  NS_UNUSED (found); //silence compiler warning
321  Time delta = Simulator::Now () - tag.GetTxTime ();
322  NS_LOG_INFO ("Sojourn time " << delta.GetSeconds ());
323  m_sojourn = delta;
324  uint32_t sojournTime = Time2CoDel (delta);
325 
326  if (CoDelTimeBefore (sojournTime, Time2CoDel (m_target))
328  {
329  // went below so we'll stay below for at least q->interval
330  NS_LOG_LOGIC ("Sojourn time is below target or number of bytes in queue is less than minBytes; packet should not be dropped");
331  m_firstAboveTime = 0;
332  return false;
333  }
334  okToDrop = false;
335  if (m_firstAboveTime == 0)
336  {
337  /* just went above from below. If we stay above
338  * for at least q->interval we'll say it's ok to drop
339  */
340  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. ");
342  }
343  else
344  if (CoDelTimeAfter (now, m_firstAboveTime))
345  {
346  NS_LOG_LOGIC ("Sojourn time has been above target for at least q->interval; it's OK to (possibly) drop packet.");
347  okToDrop = true;
348  ++m_state1;
349  }
350  return okToDrop;
351 }
352 
355 {
356  NS_LOG_FUNCTION (this);
357 
358  if (m_packets.empty ())
359  {
360  // Leave dropping state when queue is empty
361  m_dropping = false;
362  m_firstAboveTime = 0;
363  NS_LOG_LOGIC ("Queue empty");
364  return 0;
365  }
366  uint32_t now = CoDelGetTime ();
367  Ptr<Packet> p = m_packets.front ();
368  m_packets.pop ();
369  m_bytesInQueue -= p->GetSize ();
370 
371  NS_LOG_LOGIC ("Popped " << p);
372  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
373  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
374 
375  // Determine if p should be dropped
376  bool okToDrop = OkToDrop (p, now);
377 
378  if (m_dropping)
379  { // In the dropping state (sojourn time has gone above target and hasn't come down yet)
380  // Check if we can leave the dropping state or next drop should occur
381  NS_LOG_LOGIC ("In dropping state, check if it's OK to leave or next drop should occur");
382  if (!okToDrop)
383  {
384  /* sojourn time fell below target - leave dropping state */
385  NS_LOG_LOGIC ("Sojourn time goes below target, it's OK to leave dropping state.");
386  m_dropping = false;
387  }
388  else
389  if (CoDelTimeAfterEq (now, m_dropNext))
390  {
391  m_state2++;
392  while (m_dropping && CoDelTimeAfterEq (now, m_dropNext))
393  {
394  // It's time for the next drop. Drop the current packet and
395  // dequeue the next. The dequeue might take us out of dropping
396  // state. If not, schedule the next drop.
397  // A large amount of packets in queue might result in drop
398  // rates so high that the next drop should happen now,
399  // hence the while loop.
400  NS_LOG_LOGIC ("Sojourn time is still above target and it's time for next drop; dropping " << p);
401  Drop (p);
402  ++m_dropCount;
403  ++m_count;
404  NewtonStep ();
405  if (m_packets.empty ())
406  {
407  m_dropping = false;
408  NS_LOG_LOGIC ("Queue empty");
409  ++m_states;
410  return 0;
411  }
412  p = m_packets.front ();
413  m_packets.pop ();
414  m_bytesInQueue -= p->GetSize ();
415 
416  NS_LOG_LOGIC ("Popped " << p);
417  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
418  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
419 
420  if (!OkToDrop (p, now))
421  {
422  /* leave dropping state */
423  NS_LOG_LOGIC ("Leaving dropping state");
424  m_dropping = false;
425  }
426  else
427  {
428  /* schedule the next drop */
429  NS_LOG_LOGIC ("Running ControlLaw for input m_dropNext: " << (double)m_dropNext / 1000000);
431  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000);
432  }
433  }
434  }
435  }
436  else
437  {
438  // Not in the dropping state
439  // Decide if we have to enter the dropping state and drop the first packet
440  NS_LOG_LOGIC ("Not in dropping state; decide if we have to enter the state and drop the first packet");
441  if (okToDrop)
442  {
443  // Drop the first packet and enter dropping state unless the queue is empty
444  NS_LOG_LOGIC ("Sojourn time goes above target, dropping the first packet " << p << " and entering the dropping state");
445  ++m_dropCount;
446  Drop (p);
447  if (m_packets.empty ())
448  {
449  m_dropping = false;
450  okToDrop = false;
451  NS_LOG_LOGIC ("Queue empty");
452  ++m_states;
453  }
454  else
455  {
456  p = m_packets.front ();
457  m_packets.pop ();
458  m_bytesInQueue -= p->GetSize ();
459 
460  NS_LOG_LOGIC ("Popped " << p);
461  NS_LOG_LOGIC ("Number packets remaining " << m_packets.size ());
462  NS_LOG_LOGIC ("Number bytes remaining " << m_bytesInQueue);
463 
464  okToDrop = OkToDrop (p, now);
465  m_dropping = true;
466  }
467  ++m_state3;
468  /*
469  * if min went above target close to when we last went below it
470  * assume that the drop rate that controlled the queue on the
471  * last cycle is a good starting point to control it now.
472  */
473  int delta = m_count - m_lastCount;
474  if (delta > 1 && CoDelTimeBefore (now - m_dropNext, 16 * Time2CoDel (m_interval)))
475  {
476  m_count = delta;
477  NewtonStep ();
478  }
479  else
480  {
481  m_count = 1;
483  }
484  m_lastCount = m_count;
485  NS_LOG_LOGIC ("Running ControlLaw for input now: " << (double)now);
486  m_dropNext = ControlLaw (now);
487  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000 << " now " << (double)now / 1000000);
488  }
489  }
490  ++m_states;
491  return p;
492 }
493 
494 uint32_t
496 {
497  NS_LOG_FUNCTION (this);
498  if (GetMode () == QUEUE_MODE_BYTES)
499  {
500  return m_bytesInQueue;
501  }
502  else if (GetMode () == QUEUE_MODE_PACKETS)
503  {
504  return m_packets.size ();
505  }
506  else
507  {
508  NS_ABORT_MSG ("Unknown mode.");
509  }
510 }
511 
512 uint32_t
514 {
515  return m_dropOverLimit;
516 }
517 
518 uint32_t
520 {
521  return m_dropCount;
522 }
523 
524 Time
526 {
527  return m_target;
528 }
529 
530 Time
532 {
533  return m_interval;
534 }
535 
536 uint32_t
538 {
539  return m_dropNext;
540 }
541 
543 CoDelQueue::DoPeek (void) const
544 {
545  NS_LOG_FUNCTION (this);
546 
547  if (m_packets.empty ())
548  {
549  NS_LOG_LOGIC ("Queue empty");
550  return 0;
551  }
552 
553  Ptr<Packet> p = m_packets.front ();
554 
555  NS_LOG_LOGIC ("Number packets " << m_packets.size ());
556  NS_LOG_LOGIC ("Number bytes " << m_bytesInQueue);
557 
558  return p;
559 }
560 
561 bool
562 CoDelQueue::CoDelTimeAfter (uint32_t a, uint32_t b)
563 {
564  return ((int)(a) - (int)(b) > 0);
565 }
566 
567 bool
568 CoDelQueue::CoDelTimeAfterEq (uint32_t a, uint32_t b)
569 {
570  return ((int)(a) - (int)(b) >= 0);
571 }
572 
573 bool
574 CoDelQueue::CoDelTimeBefore (uint32_t a, uint32_t b)
575 {
576  return ((int)(a) - (int)(b) < 0);
577 }
578 
579 bool
580 CoDelQueue::CoDelTimeBeforeEq (uint32_t a, uint32_t b)
581 {
582  return ((int)(a) - (int)(b) <= 0);
583 }
584 
585 uint32_t
587 {
588  return (t.GetNanoSeconds () >> CODEL_SHIFT);
589 }
590 
591 
592 } // namespace ns3
593 
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:513
bool CoDelTimeAfter(uint32_t a, uint32_t b)
Check if CoDel time a is successive to b.
Definition: codel-queue.cc:562
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 "...
bool CoDelTimeAfterEq(uint32_t a, uint32_t b)
Check if CoDel time a is successive or equal to b.
Definition: codel-queue.cc:568
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:278
#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:836
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:766
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:519
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:257
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:439
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:525
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:327
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:271
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:312
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:495
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:574
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
CoDelQueue()
CoDelQueue Constructor.
Definition: codel-queue.cc:216
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:238
Time m_target
5 ms target queue delay
Definition: codel-queue.h:232
uint64_t ReadU64(void)
Definition: tag-buffer.cc:134
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:580
Time TimeStep(uint64_t ts)
Definition: nstime.h:916
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
Definition: codel-queue.cc:537
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:922
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:244
#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:339
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:264
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:843
uint32_t Time2CoDel(Time t)
returned unsigned 32-bit integer representation of the input Time object units are microseconds ...
Definition: codel-queue.cc:586
virtual Ptr< const Packet > DoPeek(void) const
Peek the front packet in the queue.
Definition: codel-queue.cc:543
virtual void Print(std::ostream &os) const
Definition: codel-queue.cc:135
Time GetInterval(void)
Get the interval.
Definition: codel-queue.cc:531
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
#define NS_UNUSED(x)
Definition: unused.h:5
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:354
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:51
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
void Drop(Ptr< Packet > packet)
Drop a packet.
Definition: queue.cc:194
#define REC_INV_SQRT_SHIFT
Definition: codel-queue.h:53
TracedValue< Time > m_sojourn
Time in queue.
Definition: codel-queue.h:246