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 
36 namespace ns3 {
37 
38 NS_LOG_COMPONENT_DEFINE ("CoDelQueueDisc");
39 
47 /* borrowed from the linux kernel */
48 static inline uint32_t ReciprocalDivide (uint32_t A, uint32_t R)
49 {
50  return (uint32_t)(((uint64_t)A * R) >> 32);
51 }
52 
53 /* end kernel borrowings */
54 
59 static uint32_t CoDelGetTime (void)
60 {
61  Time time = Simulator::Now ();
62  uint64_t ns = time.GetNanoSeconds ();
63 
64  return ns >> CODEL_SHIFT;
65 }
66 
70 class CoDelTimestampTag : public Tag
71 {
72 public:
78  static TypeId GetTypeId (void);
79  virtual TypeId GetInstanceTypeId (void) const;
80 
81  virtual uint32_t GetSerializedSize (void) const;
82  virtual void Serialize (TagBuffer i) const;
83  virtual void Deserialize (TagBuffer i);
84  virtual void Print (std::ostream &os) const;
85 
90  Time GetTxTime (void) const;
91 private:
92  uint64_t m_creationTime;
93 };
94 
96  : m_creationTime (Simulator::Now ().GetTimeStep ())
97 {
98 }
99 
100 TypeId
102 {
103  static TypeId tid = TypeId ("ns3::CoDelTimestampTag")
104  .SetParent<Tag> ()
105  .AddConstructor<CoDelTimestampTag> ()
106  .AddAttribute ("CreationTime",
107  "The time at which the timestamp was created",
108  StringValue ("0.0s"),
110  MakeTimeChecker ())
111  ;
112  return tid;
113 }
114 
115 TypeId
117 {
118  return GetTypeId ();
119 }
120 
121 uint32_t
123 {
124  return 8;
125 }
126 void
128 {
130 }
131 void
133 {
134  m_creationTime = i.ReadU64 ();
135 }
136 void
137 CoDelTimestampTag::Print (std::ostream &os) const
138 {
139  os << "CreationTime=" << m_creationTime;
140 }
141 Time
143 {
144  return TimeStep (m_creationTime);
145 }
146 
148 
150 {
151  static TypeId tid = TypeId ("ns3::CoDelQueueDisc")
152  .SetParent<QueueDisc> ()
153  .SetGroupName ("TrafficControl")
154  .AddConstructor<CoDelQueueDisc> ()
155  .AddAttribute ("Mode",
156  "Whether to use Bytes (see MaxBytes) or Packets (see MaxPackets) as the maximum queue size metric.",
159  MakeEnumChecker (Queue::QUEUE_MODE_BYTES, "QUEUE_MODE_BYTES",
160  Queue::QUEUE_MODE_PACKETS, "QUEUE_MODE_PACKETS"))
161  .AddAttribute ("MaxPackets",
162  "The maximum number of packets accepted by this CoDelQueueDisc.",
165  MakeUintegerChecker<uint32_t> ())
166  .AddAttribute ("MaxBytes",
167  "The maximum number of bytes accepted by this CoDelQueueDisc.",
170  MakeUintegerChecker<uint32_t> ())
171  .AddAttribute ("MinBytes",
172  "The CoDel algorithm minbytes parameter.",
173  UintegerValue (1500),
175  MakeUintegerChecker<uint32_t> ())
176  .AddAttribute ("Interval",
177  "The CoDel algorithm interval",
178  StringValue ("100ms"),
180  MakeTimeChecker ())
181  .AddAttribute ("Target",
182  "The CoDel algorithm target queue delay",
183  StringValue ("5ms"),
185  MakeTimeChecker ())
186  .AddTraceSource ("Count",
187  "CoDel count",
189  "ns3::TracedValueCallback::Uint32")
190  .AddTraceSource ("DropCount",
191  "CoDel drop count",
193  "ns3::TracedValueCallback::Uint32")
194  .AddTraceSource ("LastCount",
195  "CoDel lastcount",
197  "ns3::TracedValueCallback::Uint32")
198  .AddTraceSource ("DropState",
199  "Dropping state",
201  "ns3::TracedValueCallback::Bool")
202  .AddTraceSource ("Sojourn",
203  "Time in the queue",
205  "ns3::Time::TracedValueCallback")
206  .AddTraceSource ("DropNext",
207  "Time until next packet drop",
209  "ns3::TracedValueCallback::Uint32")
210  ;
211 
212  return tid;
213 }
214 
216  : QueueDisc (),
217  m_maxBytes (),
218  m_count (0),
219  m_dropCount (0),
220  m_lastCount (0),
221  m_dropping (false),
222  m_recInvSqrt (~0U >> REC_INV_SQRT_SHIFT),
223  m_firstAboveTime (0),
224  m_dropNext (0),
225  m_state1 (0),
226  m_state2 (0),
227  m_state3 (0),
228  m_states (0),
229  m_dropOverLimit (0),
230  m_sojourn (0)
231 {
232  NS_LOG_FUNCTION (this);
233 }
234 
236 {
237  NS_LOG_FUNCTION (this);
238 }
239 
240 void
242 {
243  NS_LOG_FUNCTION (this);
244  uint32_t invsqrt = ((uint32_t) m_recInvSqrt) << REC_INV_SQRT_SHIFT;
245  uint32_t invsqrt2 = ((uint64_t) invsqrt * invsqrt) >> 32;
246  uint64_t val = (3ll << 32) - ((uint64_t) m_count * invsqrt2);
247 
248  val >>= 2; /* avoid overflow */
249  val = (val * invsqrt) >> (32 - 2 + 1);
251 }
252 
253 uint32_t
255 {
256  NS_LOG_FUNCTION (this);
258 }
259 
260 void
262 {
263  NS_LOG_FUNCTION (mode);
264  m_mode = mode;
265 }
266 
269 {
270  NS_LOG_FUNCTION (this);
271  return m_mode;
272 }
273 
274 bool
276 {
277  NS_LOG_FUNCTION (this << item);
278  Ptr<Packet> p = item->GetPacket ();
279 
281  {
282  NS_LOG_LOGIC ("Queue full (at max packets) -- droppping pkt");
283  Drop (item);
284  ++m_dropOverLimit;
285  return false;
286  }
287 
288  if (m_mode == Queue::QUEUE_MODE_BYTES && (GetInternalQueue (0)->GetNBytes () + item->GetPacketSize () > m_maxBytes))
289  {
290  NS_LOG_LOGIC ("Queue full (packet would exceed max bytes) -- droppping pkt");
291  Drop (item);
292  ++m_dropOverLimit;
293  return false;
294  }
295 
296  // Tag packet with current time for DoDequeue() to compute sojourn time
297  CoDelTimestampTag tag;
298  p->AddPacketTag (tag);
299 
300  GetInternalQueue (0)->Enqueue (item);
301 
302  NS_LOG_LOGIC ("Number packets " << GetInternalQueue (0)->GetNPackets ());
303  NS_LOG_LOGIC ("Number bytes " << GetInternalQueue (0)->GetNBytes ());
304 
305  return true;
306 }
307 
308 bool
310 {
311  NS_LOG_FUNCTION (this);
312  CoDelTimestampTag tag;
313  bool okToDrop;
314 
315  bool found = p->RemovePacketTag (tag);
316  NS_ASSERT_MSG (found, "found a packet without an input timestamp tag");
317  NS_UNUSED (found); //silence compiler warning
318  Time delta = Simulator::Now () - tag.GetTxTime ();
319  NS_LOG_INFO ("Sojourn time " << delta.GetSeconds ());
320  m_sojourn = delta;
321  uint32_t sojournTime = Time2CoDel (delta);
322 
323  if (CoDelTimeBefore (sojournTime, Time2CoDel (m_target))
325  {
326  // went below so we'll stay below for at least q->interval
327  NS_LOG_LOGIC ("Sojourn time is below target or number of bytes in queue is less than minBytes; packet should not be dropped");
328  m_firstAboveTime = 0;
329  return false;
330  }
331  okToDrop = false;
332  if (m_firstAboveTime == 0)
333  {
334  /* just went above from below. If we stay above
335  * for at least q->interval we'll say it's ok to drop
336  */
337  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. ");
339  }
340  else
341  if (CoDelTimeAfter (now, m_firstAboveTime))
342  {
343  NS_LOG_LOGIC ("Sojourn time has been above target for at least q->interval; it's OK to (possibly) drop packet.");
344  okToDrop = true;
345  ++m_state1;
346  }
347  return okToDrop;
348 }
349 
352 {
353  NS_LOG_FUNCTION (this);
354 
355  if (GetInternalQueue (0)->IsEmpty ())
356  {
357  // Leave dropping state when queue is empty
358  m_dropping = false;
359  m_firstAboveTime = 0;
360  NS_LOG_LOGIC ("Queue empty");
361  return 0;
362  }
363  uint32_t now = CoDelGetTime ();
364  Ptr<QueueDiscItem> item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
365  Ptr<Packet> p = item->GetPacket ();
366 
367  NS_LOG_LOGIC ("Popped " << item);
368  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
369  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
370 
371  // Determine if p should be dropped
372  bool okToDrop = OkToDrop (p, now);
373 
374  if (m_dropping)
375  { // In the dropping state (sojourn time has gone above target and hasn't come down yet)
376  // Check if we can leave the dropping state or next drop should occur
377  NS_LOG_LOGIC ("In dropping state, check if it's OK to leave or next drop should occur");
378  if (!okToDrop)
379  {
380  /* sojourn time fell below target - leave dropping state */
381  NS_LOG_LOGIC ("Sojourn time goes below target, it's OK to leave dropping state.");
382  m_dropping = false;
383  }
384  else
385  if (CoDelTimeAfterEq (now, m_dropNext))
386  {
387  m_state2++;
388  while (m_dropping && CoDelTimeAfterEq (now, m_dropNext))
389  {
390  // It's time for the next drop. Drop the current packet and
391  // dequeue the next. The dequeue might take us out of dropping
392  // state. If not, schedule the next drop.
393  // A large amount of packets in queue might result in drop
394  // rates so high that the next drop should happen now,
395  // hence the while loop.
396  NS_LOG_LOGIC ("Sojourn time is still above target and it's time for next drop; dropping " << p);
397  Drop (item);
398 
399  ++m_dropCount;
400  ++m_count;
401  NewtonStep ();
402  if (GetInternalQueue (0)->IsEmpty ())
403  {
404  m_dropping = false;
405  NS_LOG_LOGIC ("Queue empty");
406  ++m_states;
407  return 0;
408  }
409  item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
410  p = item ->GetPacket ();
411 
412  NS_LOG_LOGIC ("Popped " << item);
413  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
414  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
415 
416  if (!OkToDrop (p, now))
417  {
418  /* leave dropping state */
419  NS_LOG_LOGIC ("Leaving dropping state");
420  m_dropping = false;
421  }
422  else
423  {
424  /* schedule the next drop */
425  NS_LOG_LOGIC ("Running ControlLaw for input m_dropNext: " << (double)m_dropNext / 1000000);
427  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000);
428  }
429  }
430  }
431  }
432  else
433  {
434  // Not in the dropping state
435  // Decide if we have to enter the dropping state and drop the first packet
436  NS_LOG_LOGIC ("Not in dropping state; decide if we have to enter the state and drop the first packet");
437  if (okToDrop)
438  {
439  // Drop the first packet and enter dropping state unless the queue is empty
440  NS_LOG_LOGIC ("Sojourn time goes above target, dropping the first packet " << p << " and entering the dropping state");
441  ++m_dropCount;
442  Drop (item);
443 
444  if (GetInternalQueue (0)->IsEmpty ())
445  {
446  m_dropping = false;
447  okToDrop = false;
448  NS_LOG_LOGIC ("Queue empty");
449  ++m_states;
450  }
451  else
452  {
453  item = StaticCast<QueueDiscItem> (GetInternalQueue (0)->Dequeue ());
454  p = item->GetPacket ();
455 
456  NS_LOG_LOGIC ("Popped " << item);
457  NS_LOG_LOGIC ("Number packets remaining " << GetInternalQueue (0)->GetNPackets ());
458  NS_LOG_LOGIC ("Number bytes remaining " << GetInternalQueue (0)->GetNBytes ());
459 
460  okToDrop = OkToDrop (p, now);
461  m_dropping = true;
462  }
463  ++m_state3;
464  /*
465  * if min went above target close to when we last went below it
466  * assume that the drop rate that controlled the queue on the
467  * last cycle is a good starting point to control it now.
468  */
469  int delta = m_count - m_lastCount;
470  if (delta > 1 && CoDelTimeBefore (now - m_dropNext, 16 * Time2CoDel (m_interval)))
471  {
472  m_count = delta;
473  NewtonStep ();
474  }
475  else
476  {
477  m_count = 1;
479  }
480  m_lastCount = m_count;
481  NS_LOG_LOGIC ("Running ControlLaw for input now: " << (double)now);
482  m_dropNext = ControlLaw (now);
483  NS_LOG_LOGIC ("Scheduled next drop at " << (double)m_dropNext / 1000000 << " now " << (double)now / 1000000);
484  }
485  }
486  ++m_states;
487  return item;
488 }
489 
490 uint32_t
492 {
493  NS_LOG_FUNCTION (this);
495  {
496  return GetInternalQueue (0)->GetNBytes ();
497  }
498  else if (GetMode () == Queue::QUEUE_MODE_PACKETS)
499  {
500  return GetInternalQueue (0)->GetNPackets ();
501  }
502  else
503  {
504  NS_ABORT_MSG ("Unknown mode.");
505  }
506 }
507 
508 uint32_t
510 {
511  return m_dropOverLimit;
512 }
513 
514 uint32_t
516 {
517  return m_dropCount;
518 }
519 
520 Time
522 {
523  return m_target;
524 }
525 
526 Time
528 {
529  return m_interval;
530 }
531 
532 uint32_t
534 {
535  return m_dropNext;
536 }
537 
540 {
541  NS_LOG_FUNCTION (this);
542 
543  if (GetInternalQueue (0)->IsEmpty ())
544  {
545  NS_LOG_LOGIC ("Queue empty");
546  return 0;
547  }
548 
549  Ptr<const QueueDiscItem> item = StaticCast<const QueueDiscItem> (GetInternalQueue (0)->Peek ());
550 
551  NS_LOG_LOGIC ("Number packets " << GetInternalQueue (0)->GetNPackets ());
552  NS_LOG_LOGIC ("Number bytes " << GetInternalQueue (0)->GetNBytes ());
553 
554  return item;
555 }
556 
557 bool
558 CoDelQueueDisc::CoDelTimeAfter (uint32_t a, uint32_t b)
559 {
560  return ((int)(a) - (int)(b) > 0);
561 }
562 
563 bool
564 CoDelQueueDisc::CoDelTimeAfterEq (uint32_t a, uint32_t b)
565 {
566  return ((int)(a) - (int)(b) >= 0);
567 }
568 
569 bool
570 CoDelQueueDisc::CoDelTimeBefore (uint32_t a, uint32_t b)
571 {
572  return ((int)(a) - (int)(b) < 0);
573 }
574 
575 bool
576 CoDelQueueDisc::CoDelTimeBeforeEq (uint32_t a, uint32_t b)
577 {
578  return ((int)(a) - (int)(b) <= 0);
579 }
580 
581 uint32_t
583 {
584  return (t.GetNanoSeconds () >> CODEL_SHIFT);
585 }
586 
587 bool
589 {
590  NS_LOG_FUNCTION (this);
591  if (GetNQueueDiscClasses () > 0)
592  {
593  NS_LOG_ERROR ("CoDelQueueDisc cannot have classes");
594  return false;
595  }
596 
597  if (GetNPacketFilters () > 0)
598  {
599  NS_LOG_ERROR ("CoDelQueueDisc cannot have packet filters");
600  return false;
601  }
602 
603  if (GetNInternalQueues () == 0)
604  {
605  // create a DropTail queue
606  Ptr<Queue> queue = CreateObjectWithAttributes<DropTailQueue> ("Mode", EnumValue (m_mode));
608  {
609  queue->SetMaxPackets (m_maxPackets);
610  }
611  else
612  {
613  queue->SetMaxBytes (m_maxBytes);
614  }
615  AddInternalQueue (queue);
616  }
617 
618  if (GetNInternalQueues () != 1)
619  {
620  NS_LOG_ERROR ("CoDelQueueDisc needs 1 internal queue");
621  return false;
622  }
623 
624  if (GetInternalQueue (0)->GetMode () != m_mode)
625  {
626  NS_LOG_ERROR ("The mode of the provided queue does not match the mode set on the CoDelQueueDisc");
627  return false;
628  }
629 
630  if ((m_mode == Queue::QUEUE_MODE_PACKETS && GetInternalQueue (0)->GetMaxPackets () < m_maxPackets) ||
631  (m_mode == Queue::QUEUE_MODE_BYTES && GetInternalQueue (0)->GetMaxBytes () < m_maxBytes))
632  {
633  NS_LOG_ERROR ("The size of the internal queue is less than the queue disc limit");
634  return false;
635  }
636 
637  return true;
638 }
639 
640 void
642 {
643  NS_LOG_FUNCTION (this);
644 }
645 
646 } // namespace ns3
647 
virtual void InitializeParams(void)
Initialize parameters (if any) before the first packet is enqueued.
virtual Ptr< const QueueDiscItem > DoPeek(void) const
This function returns a copy of the next packet the queue disc will extract.
Queue::QueueMode m_mode
The operating mode (Bytes or packets)
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:367
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 "...
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
TracedValue< uint32_t > m_dropCount
Number of dropped packets according CoDel algorithm.
uint32_t m_maxPackets
Max # of packets accepted by the queue.
uint32_t GetDropOverLimit(void)
Get the number of packets dropped when packets arrive at a full queue and cannot be enqueued...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
TracedValue< Time > m_sojourn
Time in queue.
Hold variables of type string.
Definition: string.h:41
void WriteU64(uint64_t v)
Definition: tag-buffer.cc:102
uint32_t GetDropNext(void)
Get the time for next packet drop while in the dropping state.
Ptr< Queue > GetInternalQueue(uint32_t i) const
Get the i-th internal queue.
Definition: queue-disc.cc:319
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
Definition: queue-disc.cc:235
Use number of bytes for maximum queue size.
Definition: queue.h:128
TracedValue< uint32_t > m_count
Number of packets dropped since entering drop state.
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:824
virtual bool CheckConfig(void)
Check whether the current configuration is correct.
bool OkToDrop(Ptr< Packet > p, uint32_t now)
Determine whether a packet is OK to be dropped.
Time GetInterval(void)
Get the interval.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
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:244
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:205
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< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
TracedValue< bool > m_dropping
True if in dropping state.
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
QueueMode
Enumeration of the modes supported in the class.
Definition: queue.h:125
static TypeId GetTypeId(void)
Get the type ID.
uint32_t GetNInternalQueues(void) const
Get the number of internal queues.
Definition: queue-disc.cc:326
uint32_t m_dropOverLimit
The number of packets dropped due to full queue.
Queue::QueueMode GetMode(void)
Get the encapsulation mode of this device.
Hold variables of type enum.
Definition: enum.h:54
CoDel time stamp, used to carry CoDel time informations.
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
void AddInternalQueue(Ptr< Queue > queue)
Add an internal queue to the tail of the list of queues.
Definition: queue-disc.cc:312
Time m_target
5 ms target queue delay
virtual void Deserialize(TagBuffer i)
CoDelQueueDisc()
CoDelQueueDisc Constructor.
uint32_t GetQueueSize(void)
Get the current value of the queue in bytes or packets.
virtual void Serialize(TagBuffer i) const
uint32_t GetDropCount(void)
Get the number of packets dropped according to CoDel algorithm.
uint32_t GetNPacketFilters(void) const
Get the number of packet filters.
Definition: queue-disc.cc:346
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
TracedValue< uint32_t > m_lastCount
Last number of packets dropped since entering drop state.
Time m_interval
100 ms sliding minimum time window width
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.
tag a set of bytes in a packet
Definition: tag.h:36
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t m_recInvSqrt
Reciprocal inverse square root.
uint64_t ReadU64(void)
Definition: tag-buffer.cc:134
#define REC_INV_SQRT_SHIFT
uint64_t m_creationTime
Tag creation time.
Time GetTarget(void)
Get the target queue delay.
#define DEFAULT_CODEL_LIMIT
Time TimeStep(uint64_t ts)
Definition: nstime.h:952
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:958
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:223
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint32_t m_state3
Number of times we enter drop state and drop the fist packet.
#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
uint32_t Time2CoDel(Time t)
returned unsigned 32-bit integer representation of the input Time object units are microseconds ...
void Drop(Ptr< QueueDiscItem > item)
Drop a packet.
Definition: queue-disc.cc:393
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:353
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.
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
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.
static uint32_t CoDelGetTime(void)
Returns the current time translated in CoDel time representation.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Definition: packet.cc:831
void SetMode(Queue::QueueMode mode)
Set the operating mode of this device.
virtual void Print(std::ostream &os) const
uint32_t m_state1
Number of times packet sojourn goes above target for interval.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:330
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Definition: log.h:220
Time GetTxTime(void) const
Gets the Tag creation time.
Use number of packets for maximum queue size.
Definition: queue.h:127
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
TracedValue< uint32_t > m_dropNext
Time to drop next packet.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Definition: queue-disc.cc:228