A Discrete-Event Network Simulator
API
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) 2007, 2014 University of Washington
4  * 2015 Universita' degli Studi di Napoli Federico II
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #include "ns3/log.h"
21 #include "ns3/abort.h"
22 #include "ns3/uinteger.h"
23 #include "ns3/pointer.h"
24 #include "ns3/object-vector.h"
25 #include "ns3/packet.h"
26 #include "ns3/socket.h"
27 #include "ns3/unused.h"
28 #include "queue-disc.h"
29 
30 namespace ns3 {
31 
32 NS_LOG_COMPONENT_DEFINE ("QueueDisc");
33 
34 QueueDiscItem::QueueDiscItem (Ptr<Packet> p, const Address& addr, uint16_t protocol)
35  : QueueItem (p),
36  m_address (addr),
37  m_protocol (protocol),
38  m_txq (0)
39 {
40 }
41 
43 {
44  NS_LOG_FUNCTION (this);
45 }
46 
47 Address
49 {
50  return m_address;
51 }
52 
53 uint16_t
55 {
56  return m_protocol;
57 }
58 
59 uint8_t
61 {
62  return m_txq;
63 }
64 
65 void
67 {
68  m_txq = txq;
69 }
70 
71 void
72 QueueDiscItem::Print (std::ostream& os) const
73 {
74  os << GetPacket () << " "
75  << "Dst addr " << m_address << " "
76  << "proto " << (uint16_t) m_protocol << " "
77  << "txq " << (uint8_t) m_txq
78  ;
79 }
80 
81 
83 
85 {
86  static TypeId tid = TypeId ("ns3::QueueDiscClass")
87  .SetParent<Object> ()
88  .SetGroupName ("TrafficControl")
89  .AddConstructor<QueueDiscClass> ()
90  .AddAttribute ("QueueDisc", "The queue disc attached to the class",
91  PointerValue (),
93  MakePointerChecker<QueueDisc> ())
94  ;
95  return tid;
96 }
97 
99 {
100  NS_LOG_FUNCTION (this);
101 }
102 
103 void
105 {
106  NS_LOG_FUNCTION (this);
107  m_queueDisc = 0;
109 }
110 
113 {
114  NS_LOG_FUNCTION (this);
115  return m_queueDisc;
116 }
117 
118 void
120 {
121  NS_LOG_FUNCTION (this);
122  NS_ABORT_MSG_IF (m_queueDisc, "Cannot set the queue disc on a class already having an attached queue disc");
123  m_queueDisc = qd;
124 }
125 
126 
128 
130 {
131  static TypeId tid = TypeId ("ns3::QueueDisc")
132  .SetParent<Object> ()
133  .SetGroupName ("TrafficControl")
134  .AddAttribute ("Quota", "The maximum number of packets dequeued in a qdisc run",
138  MakeUintegerChecker<uint32_t> ())
139  .AddAttribute ("InternalQueueList", "The list of internal queues.",
142  MakeObjectVectorChecker<Queue> ())
143  .AddAttribute ("PacketFilterList", "The list of packet filters.",
146  MakeObjectVectorChecker<PacketFilter> ())
147  .AddAttribute ("QueueDiscClassList", "The list of queue disc classes.",
150  MakeObjectVectorChecker<QueueDiscClass> ())
151  .AddTraceSource ("Enqueue", "Enqueue a packet in the queue disc",
153  "ns3::QueueItem::TracedCallback")
154  .AddTraceSource ("Dequeue", "Dequeue a packet from the queue disc",
156  "ns3::QueueItem::TracedCallback")
157  .AddTraceSource ("Requeue", "Requeue a packet in the queue disc",
159  "ns3::QueueItem::TracedCallback")
160  .AddTraceSource ("Drop", "Drop a packet stored in the queue disc",
162  "ns3::QueueItem::TracedCallback")
163  .AddTraceSource ("PacketsInQueue",
164  "Number of packets currently stored in the queue disc",
166  "ns3::TracedValueCallback::Uint32")
167  .AddTraceSource ("BytesInQueue",
168  "Number of bytes currently stored in the queue disc",
170  "ns3::TracedValueCallback::Uint32")
171  ;
172  return tid;
173 }
174 
176  : m_nPackets (0),
177  m_nBytes (0),
178  m_nTotalReceivedPackets (0),
179  m_nTotalReceivedBytes (0),
180  m_nTotalDroppedPackets (0),
181  m_nTotalDroppedBytes (0),
182  m_nTotalRequeuedPackets (0),
183  m_nTotalRequeuedBytes (0),
184  m_running (false)
185 {
186  NS_LOG_FUNCTION (this);
187 }
188 
189 void
191 {
192  NS_LOG_FUNCTION (this);
193  m_queues.clear ();
194  m_filters.clear ();
195  m_classes.clear ();
196  m_device = 0;
197  m_devQueueIface = 0;
198  m_requeued = 0;
200 }
201 
202 void
204 {
205  NS_LOG_FUNCTION (this);
206  // When adding a new interface, the traffic control aggregates
207  // a NetDeviceQueueInterface object to the netdevice
208  if (m_device)
209  {
211  }
212 
213  // Check the configuration and initialize the parameters of this queue disc
214  bool ok = CheckConfig ();
215  NS_ASSERT_MSG (ok, "The queue disc configuration is not correct");
216  NS_UNUSED (ok); // suppress compiler warning
217  InitializeParams ();
218 
219  // Check the configuration and initialize the parameters of the child queue discs
220  for (std::vector<Ptr<QueueDiscClass> >::iterator cl = m_classes.begin ();
221  cl != m_classes.end (); cl++)
222  {
223  (*cl)->GetQueueDisc ()->Initialize ();
224  }
225 
227 }
228 
229 uint32_t
231 {
232  NS_LOG_FUNCTION (this);
233  return m_nPackets;
234 }
235 
236 uint32_t
238 {
239  NS_LOG_FUNCTION (this);
240  return m_nBytes;
241 }
242 
243 uint32_t
245 {
246  NS_LOG_FUNCTION (this);
248 }
249 
250 uint32_t
252 {
253  NS_LOG_FUNCTION (this);
254  return m_nTotalReceivedBytes;
255 }
256 
257 uint32_t
259 {
260  NS_LOG_FUNCTION (this);
261  return m_nTotalDroppedPackets;
262 }
263 
264 uint32_t
266 {
267  NS_LOG_FUNCTION (this);
268  return m_nTotalDroppedBytes;
269 }
270 
271 uint32_t
273 {
274  NS_LOG_FUNCTION (this);
276 }
277 
278 uint32_t
280 {
281  NS_LOG_FUNCTION (this);
282  return m_nTotalRequeuedBytes;
283 }
284 
285 void
287 {
288  NS_LOG_FUNCTION (this << device);
289  m_device = device;
290 }
291 
294 {
295  NS_LOG_FUNCTION (this);
296  return m_device;
297 }
298 
299 void
300 QueueDisc::SetQuota (const uint32_t quota)
301 {
302  NS_LOG_FUNCTION (this << quota);
303  m_quota = quota;
304 }
305 
306 uint32_t
308 {
309  NS_LOG_FUNCTION (this);
310  return m_quota;
311 }
312 
313 void
315 {
316  NS_LOG_FUNCTION (this);
317  // set the drop callback on the internal queue, so that the queue disc is
318  // notified of packets dropped by the internal queue
319  queue->SetDropCallback (MakeCallback (&QueueDisc::Drop, this));
320  m_queues.push_back (queue);
321 }
322 
324 QueueDisc::GetInternalQueue (uint32_t i) const
325 {
326  NS_ASSERT (i < m_queues.size ());
327  return m_queues[i];
328 }
329 
330 uint32_t
332 {
333  return m_queues.size ();
334 }
335 
336 void
338 {
339  NS_LOG_FUNCTION (this);
340  m_filters.push_back (filter);
341 }
342 
344 QueueDisc::GetPacketFilter (uint32_t i) const
345 {
346  NS_ASSERT (i < m_filters.size ());
347  return m_filters[i];
348 }
349 
350 uint32_t
352 {
353  return m_filters.size ();
354 }
355 
356 void
358 {
359  NS_LOG_FUNCTION (this);
360  NS_ABORT_MSG_IF (qdClass->GetQueueDisc () == 0, "Cannot add a class with no attached queue disc");
361  // the child queue disc cannot be one with wake mode equal to WAKE_CHILD because
362  // such queue discs do not implement the enqueue/dequeue methods
363  NS_ABORT_MSG_IF (qdClass->GetQueueDisc ()->GetWakeMode () == WAKE_CHILD,
364  "A queue disc with WAKE_CHILD as wake mode can only be a root queue disc");
365  // set the parent drop callback on the child queue disc, so that it can notify
366  // packet drops to the parent queue disc
367  qdClass->GetQueueDisc ()->SetParentDropCallback (MakeCallback (&QueueDisc::Drop, this));
368  m_classes.push_back (qdClass);
369 }
370 
373 {
374  NS_ASSERT (i < m_classes.size ());
375  return m_classes[i];
376 }
377 
378 uint32_t
380 {
381  return m_classes.size ();
382 }
383 
384 int32_t
386 {
387  NS_LOG_FUNCTION (this << item);
388 
389  int32_t ret = PacketFilter::PF_NO_MATCH;
390  for (std::vector<Ptr<PacketFilter> >::iterator f = m_filters.begin ();
391  f != m_filters.end () && ret == PacketFilter::PF_NO_MATCH; f++)
392  {
393  ret = (*f)->Classify (item);
394  }
395  return ret;
396 }
397 
400 {
401  return WAKE_ROOT;
402 }
403 
404 void
406 {
408 }
409 
410 void
412 {
413  NS_LOG_FUNCTION (this << item);
414 
415  // if the wake mode of this queue disc is WAKE_CHILD, packets are directly
416  // enqueued/dequeued from the child queue discs, thus this queue disc does not
417  // keep valid packets/bytes counters and no actions need to be performed.
418  if (this->GetWakeMode () == WAKE_CHILD)
419  {
420  return;
421  }
422 
423  NS_ASSERT_MSG (m_nPackets >= 1u, "No packet in the queue disc, cannot drop");
424  NS_ASSERT_MSG (m_nBytes >= item->GetPacketSize (), "The size of the packet that"
425  << " is reported to be dropped is greater than the amount of bytes"
426  << "stored in the queue disc");
427 
428  m_nPackets--;
429  m_nBytes -= item->GetPacketSize ();
431  m_nTotalDroppedBytes += item->GetPacketSize ();
432 
433  NS_LOG_LOGIC ("m_traceDrop (p)");
434  m_traceDrop (item);
435 
436  NotifyParentDrop (item);
437 }
438 
439 void
441 {
442  NS_LOG_FUNCTION (this << item);
443  // the parent drop callback is clearly null on root queue discs
445  {
446  m_parentDropCallback (item);
447  }
448 }
449 
450 bool
452 {
453  NS_LOG_FUNCTION (this << item);
454 
455  m_nPackets++;
456  m_nBytes += item->GetPacketSize ();
458  m_nTotalReceivedBytes += item->GetPacketSize ();
459 
460  NS_LOG_LOGIC ("m_traceEnqueue (p)");
461  m_traceEnqueue (item);
462 
463  return DoEnqueue (item);
464 }
465 
468 {
469  NS_LOG_FUNCTION (this);
470 
471  Ptr<QueueDiscItem> item;
472  item = DoDequeue ();
473 
474  if (item != 0)
475  {
476  m_nPackets--;
477  m_nBytes -= item->GetPacketSize ();
478 
479  NS_LOG_LOGIC ("m_traceDequeue (p)");
480  m_traceDequeue (item);
481  }
482 
483  return item;
484 }
485 
487 QueueDisc::Peek (void) const
488 {
489  NS_LOG_FUNCTION (this);
490  return DoPeek ();
491 }
492 
493 void
495 {
496  NS_LOG_FUNCTION (this);
497 
498  if (RunBegin ())
499  {
500  uint32_t quota = m_quota;
501  while (Restart ())
502  {
503  quota -= 1;
504  if (quota <= 0)
505  {
507  break;
508  }
509  }
510  RunEnd ();
511  }
512 }
513 
514 bool
516 {
517  NS_LOG_FUNCTION (this);
518  if (m_running)
519  {
520  return false;
521  }
522 
523  m_running = true;
524  return true;
525 }
526 
527 void
529 {
530  NS_LOG_FUNCTION (this);
531  m_running = false;
532 }
533 
534 bool
536 {
537  NS_LOG_FUNCTION (this);
539  if (item == 0)
540  {
541  NS_LOG_LOGIC ("No packet to send");
542  return false;
543  }
544 
545  return Transmit (item);
546 }
547 
550 {
551  NS_LOG_FUNCTION (this);
553  Ptr<QueueDiscItem> item;
554 
555  // First check if there is a requeued packet
556  if (m_requeued != 0)
557  {
558  // If the queue where the requeued packet is destined to is not stopped, return
559  // the requeued packet; otherwise, return an empty packet.
560  // If the device does not support flow control, the device queue is never stopped
561  if (!m_devQueueIface->GetTxQueue (m_requeued->GetTxQueueIndex ())->IsStopped ())
562  {
563  item = m_requeued;
564  m_requeued = 0;
565 
566  m_nPackets--;
567  m_nBytes -= item->GetPacketSize ();
568 
569  NS_LOG_LOGIC ("m_traceDequeue (p)");
570  m_traceDequeue (item);
571  }
572  }
573  else
574  {
575  // If the device is multi-queue (actually, Linux checks if the queue disc has
576  // multiple queues), ask the queue disc to dequeue a packet (a multi-queue aware
577  // queue disc should try not to dequeue a packet destined to a stopped queue).
578  // Otherwise, ask the queue disc to dequeue a packet only if the (unique) queue
579  // is not stopped.
580  if (m_devQueueIface->GetNTxQueues ()>1 || !m_devQueueIface->GetTxQueue (0)->IsStopped ())
581  {
582  item = Dequeue ();
583  // If the item is not null, add the header to the packet.
584  if (item != 0)
585  {
586  item->AddHeader ();
587  }
588  // Here, Linux tries bulk dequeues
589  }
590  }
591  return item;
592 }
593 
594 void
596 {
597  NS_LOG_FUNCTION (this << item);
598  m_requeued = item;
600 
601  m_nPackets++; // it's still part of the queue
602  m_nBytes += item->GetPacketSize ();
604  m_nTotalRequeuedBytes += item->GetPacketSize ();
605 
606  NS_LOG_LOGIC ("m_traceRequeue (p)");
607  m_traceRequeue (item);
608 }
609 
610 bool
612 {
613  NS_LOG_FUNCTION (this << item);
615 
616  // if the device queue is stopped, requeue the packet and return false.
617  // Note that if the underlying device is tc-unaware, packets are never
618  // requeued because the queues of tc-unaware devices are never stopped
619  if (m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
620  {
621  Requeue (item);
622  return false;
623  }
624 
625  // a single queue device makes no use of the priority tag
626  if (m_devQueueIface->GetNTxQueues () == 1)
627  {
628  SocketPriorityTag priorityTag;
629  item->GetPacket ()->RemovePacketTag (priorityTag);
630  }
631  m_device->Send (item->GetPacket (), item->GetAddress (), item->GetProtocol ());
632 
633  // the behavior here slightly diverges from Linux. In Linux, it is advised that
634  // the function called when a packet needs to be transmitted (ndo_start_xmit)
635  // should always return NETDEV_TX_OK, which means that the packet is consumed by
636  // the device driver and thus is not requeued. However, the ndo_start_xmit function
637  // of the device driver is allowed to return NETDEV_TX_BUSY (and hence the packet
638  // is requeued) when there is no room for the received packet in the device queue,
639  // despite the queue is not stopped. This case is considered as a corner case or
640  // an hard error, and should be avoided.
641  // Here, we do not handle such corner case and always assume that the packet is
642  // consumed by the netdevice. Thus, we ignore the value returned by Send and a
643  // packet sent to a netdevice is never requeued. The reason is that the semantics
644  // of the value returned by NetDevice::Send does not match that of the value
645  // returned by ndo_start_xmit.
646 
647  // if the queue disc is empty or the device queue is now stopped, return false so
648  // that the Run method does not attempt to dequeue other packets and exits
649  if (GetNPackets () == 0 || m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
650  {
651  return false;
652  }
653 
654  return true;
655 }
656 
657 } // namespace ns3
uint8_t GetTxQueueIndex(void) const
Get the transmission queue index included in this item.
Definition: queue-disc.cc:60
TracedCallback< Ptr< const QueueItem > > m_traceRequeue
Traced callback: fired when a packet is requeued.
Definition: queue-disc.h:561
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
uint32_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
Definition: queue-disc.cc:379
Base class to represent items of packet Queues.
Definition: net-device.h:56
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Ptr< QueueDiscItem > m_requeued
The last packet that failed to be transmitted.
Definition: queue-disc.h:553
uint32_t GetTotalReceivedPackets(void) const
Get the total number of received packets.
Definition: queue-disc.cc:244
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
Definition: queue-disc.cc:357
static const int PF_NO_MATCH
Standard value used by packet filters to indicate that no match was possible.
Definition: packet-filter.h:48
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
Definition: queue-disc.cc:451
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
Ptr< Queue > GetInternalQueue(uint32_t i) const
Get the i-th internal queue.
Definition: queue-disc.cc:324
virtual ~QueueDiscItem()
Definition: queue-disc.cc:42
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
Definition: queue-disc.cc:237
uint32_t GetTotalRequeuedPackets(void) const
Get the total number of requeued packets.
Definition: queue-disc.cc:272
uint8_t m_txq
Transmission queue index.
Definition: queue-disc.h:117
Ptr< QueueDisc > m_queueDisc
Queue disc attached to this class.
Definition: queue-disc.h:159
virtual void DoDispose(void)
Dispose of the object.
Definition: queue-disc.cc:104
void SetQueueDisc(Ptr< QueueDisc > qd)
Set the queue disc attached to this class.
Definition: queue-disc.cc:119
void SetTxQueueIndex(uint8_t txq)
Set the transmission queue index to store in this item.
Definition: queue-disc.cc:66
TracedCallback< Ptr< const QueueItem > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
Definition: queue-disc.h:557
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-vector.h:81
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint32_t m_nTotalReceivedPackets
Total received packets.
Definition: queue-disc.h:543
virtual Ptr< QueueDiscItem > DoDequeue(void)=0
This function actually extracts a packet from the queue disc.
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:205
Address GetAddress(void) const
Get the MAC address included in this item.
Definition: queue-disc.cc:48
WakeMode
Used to determine whether the queue disc itself or its children must be activated when a netdevice wa...
Definition: queue-disc.h:405
void NotifyParentDrop(Ptr< QueueItem > item)
Notify the parent queue disc of a packet drop.
Definition: queue-disc.cc:440
a polymophic address class
Definition: address.h:90
ParentDropCallback m_parentDropCallback
Parent drop callback.
Definition: queue-disc.h:554
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint32_t GetTotalReceivedBytes(void) const
Get the total amount of received bytes.
Definition: queue-disc.cc:251
std::vector< Ptr< Queue > > m_queues
Internal queues.
Definition: queue-disc.h:536
uint32_t GetNInternalQueues(void) const
Get the number of internal queues.
Definition: queue-disc.cc:331
void Drop(Ptr< QueueItem > item)
Drop a packet.
Definition: queue-disc.cc:411
virtual void DoInitialize(void)
Check whether the configuration is correct and initialize parameters.
Definition: queue-disc.cc:203
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
Ptr< NetDeviceQueueInterface > m_devQueueIface
NetDevice queue interface.
Definition: queue-disc.h:551
Hold an unsigned integer type.
Definition: uinteger.h:44
uint16_t m_protocol
L3 Protocol number.
Definition: queue-disc.h:116
QueueDiscItem()
Default constructor.
void AddInternalQueue(Ptr< Queue > queue)
Add an internal queue to the tail of the list of queues.
Definition: queue-disc.cc:314
uint32_t m_nTotalReceivedBytes
Total received bytes.
Definition: queue-disc.h:544
indicates whether the socket has a priority set.
Definition: socket.h:1304
void Run(void)
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets...
Definition: queue-disc.cc:494
Ptr< PacketFilter > GetPacketFilter(uint32_t i) const
Get the i-th packet filter.
Definition: queue-disc.cc:344
uint32_t m_nTotalDroppedBytes
Total dropped bytes.
Definition: queue-disc.h:546
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)=0
This function actually enqueues a packet into the queue disc.
bool Transmit(Ptr< QueueDiscItem > item)
Modelled after the Linux function sch_direct_xmit (net/sched/sch_generic.c) Sends a packet to the dev...
Definition: queue-disc.cc:611
TracedCallback< Ptr< const QueueItem > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
Definition: queue-disc.h:559
Ptr< QueueDisc > GetQueueDisc(void) const
Get the queue disc attached to this class.
Definition: queue-disc.cc:112
int32_t Classify(Ptr< QueueDiscItem > item)
Classify a packet by calling the packet filters, one at a time, until either a filter able to classif...
Definition: queue-disc.cc:385
Network device transmission queue interface.
Definition: net-device.h:262
virtual void DoDispose(void)
Dispose of the object.
Definition: queue-disc.cc:190
uint32_t GetNPacketFilters(void) const
Get the number of packet filters.
Definition: queue-disc.cc:351
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:252
TracedCallback< Ptr< const QueueItem > > m_traceDrop
Traced callback: fired when a packet is dropped.
Definition: queue-disc.h:563
QueueDiscClass is the base class for classes that are included in a queue disc.
Definition: queue-disc.h:130
static const uint32_t DEFAULT_QUOTA
Default quota (as in /proc/sys/net/core/dev_weight)
Definition: queue-disc.h:534
Ptr< QueueDiscItem > Dequeue(void)
Request the queue discipline to extract a packet.
Definition: queue-disc.cc:467
uint32_t m_nTotalRequeuedBytes
Total requeued bytes.
Definition: queue-disc.h:548
double f(double x, void *params)
Definition: 80211b.c:60
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
Definition: pointer.h:36
uint32_t GetTotalDroppedPackets(void) const
Get the total number of dropped packets.
Definition: queue-disc.cc:258
WakeMode GetWakeMode(void)
When setting up the wake callbacks on the netdevice queues, it is necessary to determine which queue ...
Definition: queue-disc.cc:399
uint32_t m_quota
Maximum number of packets dequeued in a qdisc run.
Definition: queue-disc.h:549
uint32_t GetTotalDroppedBytes(void) const
Get the total amount of dropped bytes.
Definition: queue-disc.cc:265
bool RunBegin(void)
Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h).
Definition: queue-disc.cc:515
bool m_running
The queue disc is performing multiple dequeue operations.
Definition: queue-disc.h:552
virtual void Print(std::ostream &os) const
Print the item contents.
Definition: queue-disc.cc:72
virtual uint32_t GetQuota(void) const
Get the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:307
virtual bool CheckConfig(void)=0
Check whether the current configuration is correct.
TracedValue< uint32_t > m_nBytes
Number of bytes in the queue.
Definition: queue-disc.h:541
void Requeue(Ptr< QueueDiscItem > item)
Modelled after the Linux function dev_requeue_skb (net/sched/sch_generic.c) Requeues a packet whose t...
Definition: queue-disc.cc:595
#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
TracedValue< uint32_t > m_nPackets
Number of packets in the queue.
Definition: queue-disc.h:540
std::vector< Ptr< PacketFilter > > m_filters
Packet filters.
Definition: queue-disc.h:537
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
Ptr< NetDevice > m_device
The NetDevice on which this queue discipline is installed.
Definition: queue-disc.h:550
virtual void SetQuota(const uint32_t quota)
Set the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:300
uint32_t GetTotalRequeuedBytes(void) const
Get the total amount of requeued bytes.
Definition: queue-disc.cc:279
void AddPacketFilter(Ptr< PacketFilter > filter)
Add a packet filter to the tail of the list of filters used to classify packets.
Definition: queue-disc.cc:337
virtual void InitializeParams(void)=0
Initialize parameters (if any) before the first packet is enqueued.
virtual void SetParentDropCallback(ParentDropCallback cb)
Set the parent drop callback.
Definition: queue-disc.cc:405
static TypeId GetTypeId(void)
Get the type ID.
Definition: queue-disc.cc:129
uint16_t GetProtocol(void) const
Get the L3 protocol included in this item.
Definition: queue-disc.cc:54
A base class which provides memory management and object aggregation.
Definition: object.h:87
Container for a set of ns3::Object pointers.
virtual Ptr< const QueueDiscItem > DoPeek(void) const =0
This function returns a copy of the next packet the queue disc will extract.
bool Restart(void)
Modelled after the Linux function qdisc_restart (net/sched/sch_generic.c) Dequeue a packet (by callin...
Definition: queue-disc.cc:535
Address m_address
MAC destination address.
Definition: queue-disc.h:115
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:904
Ptr< QueueDiscItem > DequeuePacket(void)
Modelled after the Linux function dequeue_skb (net/sched/sch_generic.c)
Definition: queue-disc.cc:549
Ptr< NetDevice > GetNetDevice(void) const
Get the NetDevice on which this queue discipline is installed.
Definition: queue-disc.cc:293
static TypeId GetTypeId(void)
Get the type ID.
Definition: queue-disc.cc:84
uint32_t m_nTotalRequeuedPackets
Total requeued packets.
Definition: queue-disc.h:547
Ptr< const QueueDiscItem > Peek(void) const
Get a copy of the next packet the queue discipline will extract, without actually extracting the pack...
Definition: queue-disc.cc:487
uint32_t m_nTotalDroppedPackets
Total dropped packets.
Definition: queue-disc.h:545
void SetNetDevice(Ptr< NetDevice > device)
Set the NetDevice on which this queue discipline is installed.
Definition: queue-disc.cc:286
Ptr< QueueDiscClass > GetQueueDiscClass(uint32_t i) const
Get the i-th queue disc class.
Definition: queue-disc.cc:372
void RunEnd(void)
Modelled after the Linux function qdisc_run_end (include/net/sch_generic.h).
Definition: queue-disc.cc:528
std::vector< Ptr< QueueDiscClass > > m_classes
Classes.
Definition: queue-disc.h:538
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Definition: queue-disc.cc:230
Ptr< Packet > GetPacket(void) const
Definition: net-device.cc:45