A Discrete-Event Network Simulator
API
codel-queue-disc.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-disc.h"
33 #include "ns3/object-factory.h"
34 #include "ns3/drop-tail-queue.h"
35 #include "ns3/net-device-queue-interface.h"
36 
37 namespace ns3 {
38 
39 NS_LOG_COMPONENT_DEFINE ("CoDelQueueDisc");
40 
48 /* borrowed from the linux kernel */
49 static inline uint32_t ReciprocalDivide (uint32_t A, uint32_t R)
50 {
51  return (uint32_t)(((uint64_t)A * R) >> 32);
52 }
53 
54 /* end kernel borrowings */
55 
60 static uint32_t CoDelGetTime (void)
61 {
62  Time time = Simulator::Now ();
63  uint64_t ns = time.GetNanoSeconds ();
64 
65  return static_cast<uint32_t>(ns >> CODEL_SHIFT);
66 }
67 
68 
69 NS_OBJECT_ENSURE_REGISTERED (CoDelQueueDisc);
70 
72 {
73  static TypeId tid = TypeId ("ns3::CoDelQueueDisc")
74  .SetParent<QueueDisc> ()
75  .SetGroupName ("TrafficControl")
76  .AddConstructor<CoDelQueueDisc> ()
77  .AddAttribute ("Mode",
78  "Whether to use Bytes (see MaxBytes) or Packets (see MaxPackets) as the maximum queue size metric.",
82  MakeEnumChecker (QUEUE_DISC_MODE_BYTES, "QUEUE_DISC_MODE_BYTES",
83  QUEUE_DISC_MODE_PACKETS, "QUEUE_DISC_MODE_PACKETS"),
85  "Use the MaxSize attribute instead")
86  .AddAttribute ("MaxPackets",
87  "The maximum number of packets accepted by this CoDelQueueDisc.",
91  MakeUintegerChecker<uint32_t> (),
93  "Use the MaxSize attribute instead")
94  .AddAttribute ("MaxBytes",
95  "The maximum number of bytes accepted by this CoDelQueueDisc.",
99  MakeUintegerChecker<uint32_t> (),
101  "Use the MaxSize attribute instead")
102  .AddAttribute ("MaxSize",
103  "The maximum number of packets/bytes accepted by this queue disc.",
104  QueueSizeValue (QueueSize ("0p")),
108  .AddAttribute ("MinBytes",
109  "The CoDel algorithm minbytes parameter.",
110  UintegerValue (1500),
112  MakeUintegerChecker<uint32_t> ())
113  .AddAttribute ("Interval",
114  "The CoDel algorithm interval",
115  StringValue ("100ms"),
117  MakeTimeChecker ())
118  .AddAttribute ("Target",
119  "The CoDel algorithm target queue delay",
120  StringValue ("5ms"),
122  MakeTimeChecker ())
123  .AddTraceSource ("Count",
124  "CoDel count",
126  "ns3::TracedValueCallback::Uint32")
127  .AddTraceSource ("LastCount",
128  "CoDel lastcount",
130  "ns3::TracedValueCallback::Uint32")
131  .AddTraceSource ("DropState",
132  "Dropping state",
134  "ns3::TracedValueCallback::Bool")
135  .AddTraceSource ("DropNext",
136  "Time until next packet drop",
138  "ns3::TracedValueCallback::Uint32")
139  ;
140 
141  return tid;
142 }
143 
146  m_maxPackets (1), // to avoid that setting the mode at construction time is ignored
147  m_maxBytes (1), // to avoid that setting the mode at construction time is ignored
148  m_count (0),
149  m_lastCount (0),
150  m_dropping (false),
151  m_recInvSqrt (~0U >> REC_INV_SQRT_SHIFT),
152  m_firstAboveTime (0),
153  m_dropNext (0),
154  m_state1 (0),
155  m_state2 (0),
156  m_state3 (0),
157  m_states (0)
158 {
159  NS_LOG_FUNCTION (this);
160 }
161 
163 {
164  NS_LOG_FUNCTION (this);
165 }
166 
167 void
169 {
170  NS_LOG_FUNCTION (this);
171  uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT;
172  uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
173  uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2);
174 
175  val >>= 2; /* avoid overflow */
176  val = (val * invsqrt) >> (32 - 2 + 1);
177  m_recInvSqrt = static_cast<uint16_t>(val >> REC_INV_SQRT_SHIFT);
178 }
179 
180 uint32_t
182 {
183  NS_LOG_FUNCTION (this);
185 }
186 
187 void
189 {
190  NS_LOG_FUNCTION (this << mode);
191 
192  if (mode == QUEUE_DISC_MODE_BYTES)
193  {
195  }
196  else if (mode == QUEUE_DISC_MODE_PACKETS)
197  {
199  }
200  else
201  {
202  NS_ABORT_MSG ("Unknown queue size unit");
203  }
204 }
205 
208 {
209  NS_LOG_FUNCTION (this);
211 }
212 
213 void
214 CoDelQueueDisc::SetMaxPackets (uint32_t maxPackets)
215 {
216  NS_LOG_FUNCTION (this << maxPackets);
217 
218  m_maxPackets = maxPackets;
219 
220  if (GetMaxSize ().GetUnit () == QueueSizeUnit::PACKETS)
221  {
223  }
224 }
225 
226 uint32_t
228 {
229  NS_LOG_FUNCTION (this);
230  return m_maxPackets;
231 }
232 
233 void
234 CoDelQueueDisc::SetMaxBytes (uint32_t maxBytes)
235 {
236  NS_LOG_FUNCTION (this << maxBytes);
237 
238  m_maxBytes = maxBytes;
239 
240  if (GetMaxSize ().GetUnit () == QueueSizeUnit::BYTES)
241  {
243  }
244 }
245 
246 uint32_t
248 {
249  NS_LOG_FUNCTION (this);
250  return m_maxBytes;
251 }
252 
253 bool
255 {
256  NS_LOG_FUNCTION (this << item);
257 
258  if (GetCurrentSize () + item > GetMaxSize ())
259  {
260  NS_LOG_LOGIC ("Queue full -- dropping pkt");
262  return false;
263  }
264 
265  bool retval = GetInternalQueue (0)->Enqueue (item);
266 
267  // If Queue::Enqueue fails, QueueDisc::DropBeforeEnqueue is called by the
268  // internal queue because QueueDisc::AddInternalQueue sets the trace callback
269 
270  NS_LOG_LOGIC ("Number packets " << GetInternalQueue (0)->GetNPackets ());
271  NS_LOG_LOGIC ("Number bytes " << GetInternalQueue (0)->GetNBytes ());
272 
273  return retval;
274 }
275 
276 bool
278 {
279  NS_LOG_FUNCTION (this);
280  bool okToDrop;
281 
282  if (!item)
283  {
284  m_firstAboveTime = 0;
285  return false;
286  }
287 
288  Time delta = Simulator::Now () - item->GetTimeStamp ();
289  NS_LOG_INFO ("Sojourn time " << delta.ToDouble (Time::MS) << "ms");
290  uint32_t sojournTime = Time2CoDel (delta);
291 
292  if (CoDelTimeBefore (sojournTime, Time2CoDel (m_target))
294  {
295  // went below so we'll stay below for at least q->interval
296  NS_LOG_LOGIC ("Sojourn time is below target or number of bytes in queue is less than minBytes; packet should not be dropped");
297  m_firstAboveTime = 0;
298  return false;
299  }
300  okToDrop = false;
301  if (m_firstAboveTime == 0)
302  {
303  /* just went above from below. If we stay above
304  * for at least q->interval we'll say it's ok to drop
305  */
306  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. ");
308  }
309  else if (CoDelTimeAfter (now, m_firstAboveTime))
310  {
311  NS_LOG_LOGIC ("Sojourn time has been above target for at least q->interval; it's OK to (possibly) drop packet.");
312  okToDrop = true;
313  ++m_state1;
314  }
315  return okToDrop;
316 }
317 
320 {
321  NS_LOG_FUNCTION (this);
322 
323  Ptr<QueueDiscItem> item = GetInternalQueue (0)->Dequeue ();
324  if (!item)
325  {
326  // Leave dropping state when queue is empty
327  m_dropping = false;
328  NS_LOG_LOGIC ("Queue empty");
329  return 0;
330  }
331  uint32_t now = CoDelGetTime ();
332 
333  NS_LOG_LOGIC ("Popped " << item);
334  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
335  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
336 
337  // Determine if item should be dropped
338  bool okToDrop = OkToDrop (item, now);
339 
340  if (m_dropping)
341  { // In the dropping state (sojourn time has gone above target and hasn't come down yet)
342  // Check if we can leave the dropping state or next drop should occur
343  NS_LOG_LOGIC ("In dropping state, check if it's OK to leave or next drop should occur");
344  if (!okToDrop)
345  {
346  /* sojourn time fell below target - leave dropping state */
347  NS_LOG_LOGIC ("Sojourn time goes below target, it's OK to leave dropping state.");
348  m_dropping = false;
349  }
350  else if (CoDelTimeAfterEq (now, m_dropNext))
351  {
352  m_state2++;
353  while (m_dropping && CoDelTimeAfterEq (now, m_dropNext))
354  {
355  // It's time for the next drop. Drop the current packet and
356  // dequeue the next. The dequeue might take us out of dropping
357  // state. If not, schedule the next drop.
358  // A large amount of packets in queue might result in drop
359  // rates so high that the next drop should happen now,
360  // hence the while loop.
361  NS_LOG_LOGIC ("Sojourn time is still above target and it's time for next drop; dropping " << item);
363 
364  ++m_count;
365  NewtonStep ();
366  item = GetInternalQueue (0)->Dequeue ();
367 
368  if (item)
369  {
370  NS_LOG_LOGIC ("Popped " << item);
371  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
372  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
373  }
374 
375  if (!OkToDrop (item, now))
376  {
377  /* leave dropping state */
378  NS_LOG_LOGIC ("Leaving dropping state");
379  m_dropping = false;
380  }
381  else
382  {
383  /* schedule the next drop */
384  NS_LOG_LOGIC ("Running ControlLaw for input m_dropNext: " << (double)m_dropNext / 1000000);
386  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000);
387  }
388  }
389  }
390  }
391  else
392  {
393  // Not in the dropping state
394  // Decide if we have to enter the dropping state and drop the first packet
395  NS_LOG_LOGIC ("Not in dropping state; decide if we have to enter the state and drop the first packet");
396  if (okToDrop)
397  {
398  // Drop the first packet and enter dropping state unless the queue is empty
399  NS_LOG_LOGIC ("Sojourn time goes above target, dropping the first packet " << item << " and entering the dropping state");
401 
402  item = GetInternalQueue (0)->Dequeue ();
403 
404  if (item)
405  {
406  NS_LOG_LOGIC ("Popped " << item);
407  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
408  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
409  }
410 
411  OkToDrop (item, now);
412  m_dropping = true;
413  ++m_state3;
414  /*
415  * if min went above target close to when we last went below it
416  * assume that the drop rate that controlled the queue on the
417  * last cycle is a good starting point to control it now.
418  */
419  int delta = m_count - m_lastCount;
420  if (delta > 1 && CoDelTimeBefore (now - m_dropNext, 16 * Time2CoDel (m_interval)))
421  {
422  m_count = delta;
423  NewtonStep ();
424  }
425  else
426  {
427  m_count = 1;
429  }
430  m_lastCount = m_count;
431  NS_LOG_LOGIC ("Running ControlLaw for input now: " << (double)now);
432  m_dropNext = ControlLaw (now);
433  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000 << " now " << (double)now / 1000000);
434  }
435  }
436  ++m_states;
437  return item;
438 }
439 
440 uint32_t
442 {
443  NS_LOG_FUNCTION (this);
444  if (GetMode () == QUEUE_DISC_MODE_BYTES)
445  {
446  return GetInternalQueue (0)->GetNBytes ();
447  }
448  else if (GetMode () == QUEUE_DISC_MODE_PACKETS)
449  {
450  return GetInternalQueue (0)->GetNPackets ();
451  }
452  else
453  {
454  NS_ABORT_MSG ("Unknown mode.");
455  }
456 }
457 
458 Time
460 {
461  return m_target;
462 }
463 
464 Time
466 {
467  return m_interval;
468 }
469 
470 uint32_t
472 {
473  return m_dropNext;
474 }
475 
478 {
479  NS_LOG_FUNCTION (this);
480 
482 
483  if (!item)
484  {
485  NS_LOG_LOGIC ("Queue empty");
486  return 0;
487  }
488 
489  NS_LOG_LOGIC ("Number packets " << GetInternalQueue (0)->GetNPackets ());
490  NS_LOG_LOGIC ("Number bytes " << GetInternalQueue (0)->GetNBytes ());
491 
492  return item;
493 }
494 
495 bool
496 CoDelQueueDisc::CoDelTimeAfter (uint32_t a, uint32_t b)
497 {
498  return ((int)(a) - (int)(b) > 0);
499 }
500 
501 bool
502 CoDelQueueDisc::CoDelTimeAfterEq (uint32_t a, uint32_t b)
503 {
504  return ((int)(a) - (int)(b) >= 0);
505 }
506 
507 bool
508 CoDelQueueDisc::CoDelTimeBefore (uint32_t a, uint32_t b)
509 {
510  return ((int)(a) - (int)(b) < 0);
511 }
512 
513 bool
514 CoDelQueueDisc::CoDelTimeBeforeEq (uint32_t a, uint32_t b)
515 {
516  return ((int)(a) - (int)(b) <= 0);
517 }
518 
519 uint32_t
521 {
522  return static_cast<uint32_t>(t.GetNanoSeconds () >> CODEL_SHIFT);
523 }
524 
525 bool
527 {
528  NS_LOG_FUNCTION (this);
529  if (GetNQueueDiscClasses () > 0)
530  {
531  NS_LOG_ERROR ("CoDelQueueDisc cannot have classes");
532  return false;
533  }
534 
535  if (GetNPacketFilters () > 0)
536  {
537  NS_LOG_ERROR ("CoDelQueueDisc cannot have packet filters");
538  return false;
539  }
540 
541  if (GetNInternalQueues () == 0)
542  {
543  // add a DropTail queue
545  ("MaxSize", QueueSizeValue (GetMaxSize ())));
546  }
547 
548  if (GetNInternalQueues () != 1)
549  {
550  NS_LOG_ERROR ("CoDelQueueDisc needs 1 internal queue");
551  return false;
552  }
553 
554  return true;
555 }
556 
557 void
559 {
560  NS_LOG_FUNCTION (this);
561 }
562 
563 } // namespace ns3
564 
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint32_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
Definition: queue-disc.cc:652
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)
Add a packet to the queue.
uint32_t m_maxBytes
Max # of bytes accepted by the queue.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static constexpr const char * TARGET_EXCEEDED_DROP
Sojourn time above target.
Class for representing queue sizes.
Definition: queue-size.h:94
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
void DropBeforeEnqueue(Ptr< const QueueDiscItem > item, const char *reason)
Perform the actions required when the queue disc is notified of a packet dropped before enqueue...
Definition: queue-disc.cc:704
uint32_t m_maxPackets
Max # of packets accepted by the queue.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Hold variables of type string.
Definition: string.h:41
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
Definition: queue-disc.cc:447
QueueDiscMode GetMode(void) const
Get the operating mode of this queue disc.
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
QueueSize GetCurrentSize(void)
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise.
Definition: queue-disc.cc:523
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
static constexpr const char * OVERLIMIT_DROP
Overlimit dropped packet.
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
Time GetInterval(void)
Get the interval.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
bool CoDelTimeAfterEq(uint32_t a, uint32_t b)
Check if CoDel time a is successive or equal to b.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:277
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:181
millisecond
Definition: nstime.h:115
uint32_t ControlLaw(uint32_t t)
Determine the time for next drop CoDel control law is t + m_interval/sqrt(m_count).
bool CoDelTimeAfter(uint32_t a, uint32_t b)
Check if CoDel time a is successive to b.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< InternalQueue > GetInternalQueue(uint32_t i) const
Get the i-th internal queue.
Definition: queue-disc.cc:587
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
virtual Ptr< const QueueDiscItem > DoPeek(void)
This function returns a copy of the next packet the queue disc will extract.
TracedValue< bool > m_dropping
True if in dropping state.
bool OkToDrop(Ptr< QueueDiscItem > item, uint32_t now)
Determine whether a packet is OK to be dropped.
void SetMaxPackets(uint32_t maxPackets)
Set the maximum amount of packets that can be stored in this queue.
uint32_t GetNInternalQueues(void) const
Get the number of internal queues.
Definition: queue-disc.cc:594
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
Definition: queue-disc.cc:567
Ptr< T > CreateObjectWithAttributes(std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
Allocate an Object on the heap and initialize with a set of attributes.
void SetMaxBytes(uint32_t maxBytes)
Set the maximum amount of bytes that can be stored in this queue.
Hold variables of type enum.
Definition: enum.h:54
uint32_t m_states
Total number of times we are in state 1, state 2, or state 3.
uint32_t m_firstAboveTime
Time to declare sojourn time above target.
uint32_t m_state2
Number of times we perform next drop while in dropping state.
bool CoDelTimeBefore(uint32_t a, uint32_t b)
Check if CoDel time a is preceding b.
Hold an unsigned integer type.
Definition: uinteger.h:44
Use number of packets for queue size.
Definition: queue-size.h:44
double ToDouble(enum Unit unit) const
Get the Time value expressed in a particular unit.
Definition: nstime.h:505
Time m_target
5 ms target queue delay
CoDelQueueDisc()
CoDelQueueDisc Constructor.
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
Ptr< const AttributeAccessor > MakeQueueSizeAccessor(T1 a1)
Definition: queue-size.h:221
Attribute or trace source is deprecated; user is warned.
Definition: type-id.h:72
uint32_t GetNPacketFilters(void) const
Get the number of packet filters.
Definition: queue-disc.cc:614
TracedValue< uint32_t > m_lastCount
Last number of packets dropped since entering drop state.
Time m_interval
100 ms sliding minimum time window width
Introspection did not find any typical Config paths.
Ptr< const AttributeChecker > MakeQueueSizeChecker(void)
Definition: queue-size.cc:29
virtual Ptr< QueueDiscItem > 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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t m_recInvSqrt
Reciprocal inverse square root.
#define REC_INV_SQRT_SHIFT
Time GetTarget(void)
Get the target queue delay.
#define DEFAULT_CODEL_LIMIT
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)
A CoDel packet queue disc.
static const int CODEL_SHIFT
Number of bits discarded from the time representation.
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:1070
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
uint32_t GetMaxBytes(void) const
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint32_t m_state3
Number of times we enter drop state and drop the fist packet.
uint32_t Time2CoDel(Time t)
Return the unsigned 32-bit integer representation of the input Time object.
uint32_t GetMaxPackets(void) const
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
Definition: queue-disc.h:103
static TypeId GetTypeId(void)
Get the type ID.
bool CoDelTimeBeforeEq(uint32_t a, uint32_t b)
Check if CoDel time a is preceding or equal to b.
void SetMode(QueueDiscMode mode)
Set the operating mode of this queue disc.
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
Ptr< const QueueDiscItem > PeekDequeued(void)
Dequeue a packet and retain it in the queue disc as a requeued packet.
Definition: queue-disc.cc:880
Used by queue discs with single internal queue.
Definition: queue-disc.h:105
uint32_t m_minBytes
Minimum bytes in queue to allow a packet drop.
static uint32_t ReciprocalDivide(uint32_t A, uint32_t R)
Performs a reciprocal divide, similar to the Linux kernel reciprocal_divide function.
Use number of bytes for maximum queue disc size.
static uint32_t CoDelGetTime(void)
Returns the current time translated in CoDel time representation.
QueueDiscMode
Enumeration of the modes supported in the class.
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
Definition: queue-disc.cc:482
void DropAfterDequeue(Ptr< const QueueDiscItem > item, const char *reason)
Perform the actions required when the queue disc is notified of a packet dropped after dequeue...
Definition: queue-disc.cc:743
Use number of packets for maximum queue disc size.
uint32_t m_state1
Number of times packet sojourn goes above target for interval.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:253
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
Use number of bytes for queue size.
Definition: queue-size.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:914
TracedValue< uint32_t > m_dropNext
Time to drop next packet.
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
Definition: queue-disc.cc:454
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Definition: queue-disc.cc:440