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 "ns3/simulator.h"
29 #include "queue-disc.h"
30 #include <ns3/drop-tail-queue.h>
31 #include "ns3/net-device-queue-interface.h"
32 
33 namespace ns3 {
34 
35 NS_OBJECT_TEMPLATE_CLASS_DEFINE (Queue,QueueDiscItem);
36 NS_OBJECT_TEMPLATE_CLASS_DEFINE (DropTailQueue,QueueDiscItem);
37 
38 NS_LOG_COMPONENT_DEFINE ("QueueDisc");
39 
40 
41 NS_OBJECT_ENSURE_REGISTERED (QueueDiscClass);
42 
44 {
45  static TypeId tid = TypeId ("ns3::QueueDiscClass")
46  .SetParent<Object> ()
47  .SetGroupName ("TrafficControl")
48  .AddConstructor<QueueDiscClass> ()
49  .AddAttribute ("QueueDisc", "The queue disc attached to the class",
50  PointerValue (),
52  MakePointerChecker<QueueDisc> ())
53  ;
54  return tid;
55 }
56 
58 {
59  NS_LOG_FUNCTION (this);
60 }
61 
63 {
64  NS_LOG_FUNCTION (this);
65 }
66 
67 void
69 {
70  NS_LOG_FUNCTION (this);
71  m_queueDisc = 0;
73 }
74 
77 {
78  NS_LOG_FUNCTION (this);
79  return m_queueDisc;
80 }
81 
82 void
84 {
85  NS_LOG_FUNCTION (this);
86  NS_ABORT_MSG_IF (m_queueDisc, "Cannot set the queue disc on a class already having an attached queue disc");
87  m_queueDisc = qd;
88 }
89 
91  : nTotalReceivedPackets (0),
92  nTotalReceivedBytes (0),
93  nTotalSentPackets (0),
94  nTotalSentBytes (0),
95  nTotalEnqueuedPackets (0),
96  nTotalEnqueuedBytes (0),
97  nTotalDequeuedPackets (0),
98  nTotalDequeuedBytes (0),
99  nTotalDroppedPackets (0),
100  nTotalDroppedPacketsBeforeEnqueue (0),
101  nTotalDroppedPacketsAfterDequeue (0),
102  nTotalDroppedBytes (0),
103  nTotalDroppedBytesBeforeEnqueue (0),
104  nTotalDroppedBytesAfterDequeue (0),
105  nTotalRequeuedPackets (0),
106  nTotalRequeuedBytes (0),
107  nTotalMarkedPackets (0),
108  nTotalMarkedBytes (0)
109 {
110 }
111 
112 uint32_t
113 QueueDisc::Stats::GetNDroppedPackets (std::string reason) const
114 {
115  uint32_t count = 0;
116  auto it = nDroppedPacketsBeforeEnqueue.find (reason);
117 
118  if (it != nDroppedPacketsBeforeEnqueue.end ())
119  {
120  count += it->second;
121  }
122 
123  it = nDroppedPacketsAfterDequeue.find (reason);
124 
125  if (it != nDroppedPacketsAfterDequeue.end ())
126  {
127  count += it->second;
128  }
129 
130  return count;
131 }
132 
133 uint64_t
134 QueueDisc::Stats::GetNDroppedBytes (std::string reason) const
135 {
136  uint64_t count = 0;
137  auto it = nDroppedBytesBeforeEnqueue.find (reason);
138 
139  if (it != nDroppedBytesBeforeEnqueue.end ())
140  {
141  count += it->second;
142  }
143 
144  it = nDroppedBytesAfterDequeue.find (reason);
145 
146  if (it != nDroppedBytesAfterDequeue.end ())
147  {
148  count += it->second;
149  }
150 
151  return count;
152 }
153 
154 uint32_t
155 QueueDisc::Stats::GetNMarkedPackets (std::string reason) const
156 {
157  auto it = nMarkedPackets.find (reason);
158 
159  if (it != nMarkedPackets.end ())
160  {
161  return it->second;
162  }
163 
164  return 0;
165 }
166 
167 uint64_t
168 QueueDisc::Stats::GetNMarkedBytes (std::string reason) const
169 {
170  auto it = nMarkedBytes.find (reason);
171 
172  if (it != nMarkedBytes.end ())
173  {
174  return it->second;
175  }
176 
177  return 0;
178 }
179 
180 void
181 QueueDisc::Stats::Print (std::ostream &os) const
182 {
183  std::map<std::string, uint32_t>::const_iterator itp;
184  std::map<std::string, uint64_t>::const_iterator itb;
185 
186  os << std::endl << "Packets/Bytes received: "
187  << nTotalReceivedPackets << " / "
188  << nTotalReceivedBytes
189  << std::endl << "Packets/Bytes enqueued: "
190  << nTotalEnqueuedPackets << " / "
191  << nTotalEnqueuedBytes
192  << std::endl << "Packets/Bytes dequeued: "
193  << nTotalDequeuedPackets << " / "
194  << nTotalDequeuedBytes
195  << std::endl << "Packets/Bytes requeued: "
196  << nTotalRequeuedPackets << " / "
197  << nTotalRequeuedBytes
198  << std::endl << "Packets/Bytes dropped: "
199  << nTotalDroppedPackets << " / "
200  << nTotalDroppedBytes
201  << std::endl << "Packets/Bytes dropped before enqueue: "
202  << nTotalDroppedPacketsBeforeEnqueue << " / "
203  << nTotalDroppedBytesBeforeEnqueue;
204 
205  itp = nDroppedPacketsBeforeEnqueue.begin ();
206  itb = nDroppedBytesBeforeEnqueue.begin ();
207 
208  while (itp != nDroppedPacketsBeforeEnqueue.end () &&
209  itb != nDroppedBytesBeforeEnqueue.end ())
210  {
211  NS_ASSERT (itp->first.compare (itb->first) == 0);
212  os << std::endl << " " << itp->first << ": "
213  << itp->second << " / " << itb->second;
214  itp++;
215  itb++;
216  }
217 
218  os << std::endl << "Packets/Bytes dropped after dequeue: "
219  << nTotalDroppedPacketsAfterDequeue << " / "
220  << nTotalDroppedBytesAfterDequeue;
221 
222  itp = nDroppedPacketsAfterDequeue.begin ();
223  itb = nDroppedBytesAfterDequeue.begin ();
224 
225  while (itp != nDroppedPacketsAfterDequeue.end () &&
226  itb != nDroppedBytesAfterDequeue.end ())
227  {
228  NS_ASSERT (itp->first.compare (itb->first) == 0);
229  os << std::endl << " " << itp->first << ": "
230  << itp->second << " / " << itb->second;
231  itp++;
232  itb++;
233  }
234 
235  os << std::endl << "Packets/Bytes sent: "
236  << nTotalSentPackets << " / "
237  << nTotalSentBytes
238  << std::endl << "Packets/Bytes marked: "
239  << nTotalMarkedPackets << " / "
240  << nTotalMarkedBytes;
241 
242  itp = nMarkedPackets.begin ();
243  itb = nMarkedBytes.begin ();
244 
245  while (itp != nMarkedPackets.end () &&
246  itb != nMarkedBytes.end ())
247  {
248  NS_ASSERT (itp->first.compare (itb->first) == 0);
249  os << std::endl << " " << itp->first << ": "
250  << itp->second << " / " << itb->second;
251  itp++;
252  itb++;
253  }
254 
255  os << std::endl;
256 }
257 
258 std::ostream & operator << (std::ostream &os, const QueueDisc::Stats &stats)
259 {
260  stats.Print (os);
261  return os;
262 }
263 
265 
267 {
268  static TypeId tid = TypeId ("ns3::QueueDisc")
269  .SetParent<Object> ()
270  .SetGroupName ("TrafficControl")
271  .AddAttribute ("Quota", "The maximum number of packets dequeued in a qdisc run",
275  MakeUintegerChecker<uint32_t> ())
276  .AddAttribute ("InternalQueueList", "The list of internal queues.",
279  MakeObjectVectorChecker<InternalQueue> ())
280  .AddAttribute ("PacketFilterList", "The list of packet filters.",
283  MakeObjectVectorChecker<PacketFilter> ())
284  .AddAttribute ("QueueDiscClassList", "The list of queue disc classes.",
287  MakeObjectVectorChecker<QueueDiscClass> ())
288  .AddTraceSource ("Enqueue", "Enqueue a packet in the queue disc",
290  "ns3::QueueDiscItem::TracedCallback")
291  .AddTraceSource ("Dequeue", "Dequeue a packet from the queue disc",
293  "ns3::QueueDiscItem::TracedCallback")
294  .AddTraceSource ("Requeue", "Requeue a packet in the queue disc",
296  "ns3::QueueDiscItem::TracedCallback")
297  .AddTraceSource ("Drop", "Drop a packet stored in the queue disc",
299  "ns3::QueueDiscItem::TracedCallback")
300  .AddTraceSource ("DropBeforeEnqueue", "Drop a packet before enqueue",
302  "ns3::QueueDiscItem::TracedCallback")
303  .AddTraceSource ("DropAfterDequeue", "Drop a packet after dequeue",
305  "ns3::QueueDiscItem::TracedCallback")
306  .AddTraceSource ("Mark", "Mark a packet stored in the queue disc",
308  "ns3::QueueDiscItem::TracedCallback")
309  .AddTraceSource ("PacketsInQueue",
310  "Number of packets currently stored in the queue disc",
312  "ns3::TracedValueCallback::Uint32")
313  .AddTraceSource ("BytesInQueue",
314  "Number of bytes currently stored in the queue disc",
316  "ns3::TracedValueCallback::Uint32")
317  .AddTraceSource ("SojournTime",
318  "Sojourn time of the last packet dequeued from the queue disc",
320  "ns3::TracedValueCallback::Time")
321  ;
322  return tid;
323 }
324 
326  : m_nPackets (0),
327  m_nBytes (0),
328  m_sojourn (0),
329  m_maxSize (QueueSize ("1p")), // to avoid that setting the mode at construction time is ignored
330  m_running (false),
331  m_sizePolicy (policy),
332  m_prohibitChangeMode (false)
333 {
334  NS_LOG_FUNCTION (this << (uint16_t)policy);
335 
336  // These lambdas call the DropBeforeEnqueue or DropAfterDequeue methods of this
337  // QueueDisc object. Given that a callback to the operator() of these lambdas
338  // is connected to the DropBeforeEnqueue and DropAfterDequeue traces of the
339  // internal queues, the INTERNAL_QUEUE_DROP constant is passed as the reason
340  // why the packet is dropped.
342  {
343  return DropBeforeEnqueue (item, INTERNAL_QUEUE_DROP);
344  };
346  {
347  return DropAfterDequeue (item, INTERNAL_QUEUE_DROP);
348  };
349 
350  // These lambdas call the DropBeforeEnqueue or DropAfterDequeue methods of this
351  // QueueDisc object. Given that a callback to the operator() of these lambdas
352  // is connected to the DropBeforeEnqueue and DropAfterDequeue traces of the
353  // child queue discs, the concatenation of the CHILD_QUEUE_DISC_DROP constant
354  // and the second argument provided by such traces is passed as the reason why
355  // the packet is dropped.
356  m_childQueueDiscDbeFunctor = [this] (Ptr<const QueueDiscItem> item, const char* r)
357  {
358  return DropBeforeEnqueue (item,
359  m_childQueueDiscDropMsg.assign (CHILD_QUEUE_DISC_DROP).append (r).data ());
360  };
361  m_childQueueDiscDadFunctor = [this] (Ptr<const QueueDiscItem> item, const char* r)
362  {
363  return DropAfterDequeue (item,
364  m_childQueueDiscDropMsg.assign (CHILD_QUEUE_DISC_DROP).append (r).data ());
365  };
366 }
367 
369  : QueueDisc (policy)
370 {
371  m_maxSize = QueueSize (unit, 0);
372  m_prohibitChangeMode = true;
373 }
374 
376 {
377  NS_LOG_FUNCTION (this);
378 }
379 
380 void
382 {
383  NS_LOG_FUNCTION (this);
384  m_queues.clear ();
385  m_filters.clear ();
386  m_classes.clear ();
387  m_device = 0;
388  m_devQueueIface = 0;
389  m_requeued = 0;
391 }
392 
393 void
395 {
396  NS_LOG_FUNCTION (this);
397  // When adding a new interface, the traffic control aggregates
398  // a NetDeviceQueueInterface object to the netdevice
399  if (m_device)
400  {
402  }
403 
404  // Check the configuration and initialize the parameters of this queue disc
405  bool ok = CheckConfig ();
406  NS_ASSERT_MSG (ok, "The queue disc configuration is not correct");
407  NS_UNUSED (ok); // suppress compiler warning
408  InitializeParams ();
409 
410  // Check the configuration and initialize the parameters of the child queue discs
411  for (std::vector<Ptr<QueueDiscClass> >::iterator cl = m_classes.begin ();
412  cl != m_classes.end (); cl++)
413  {
414  (*cl)->GetQueueDisc ()->Initialize ();
415  }
416 
418 }
419 
420 const QueueDisc::Stats&
422 {
427 
428  // the total number of sent packets is only updated here to avoid to increase it
429  // after a dequeue and then having to decrease it if the packet is dropped after
430  // dequeue or requeued
435 
436  return m_stats;
437 }
438 
439 uint32_t
441 {
442  NS_LOG_FUNCTION (this);
443  return m_nPackets;
444 }
445 
446 uint32_t
448 {
449  NS_LOG_FUNCTION (this);
450  return m_nBytes;
451 }
452 
453 QueueSize
455 {
456  NS_LOG_FUNCTION (this);
457 
458  switch (m_sizePolicy)
459  {
461  NS_FATAL_ERROR ("The size of this queue disc is not limited");
462 
464  if (GetNInternalQueues ())
465  {
466  return GetInternalQueue (0)->GetMaxSize ();
467  }
468 
470  if (GetNQueueDiscClasses ())
471  {
472  return GetQueueDiscClass (0)->GetQueueDisc ()->GetMaxSize ();
473  }
474 
476  default:
477  return m_maxSize;
478  }
479 }
480 
481 bool
483 {
484  NS_LOG_FUNCTION (this << size);
485 
486  // do nothing if the limit is null
487  if (!size.GetValue ())
488  {
489  return false;
490  }
491 
492  if (m_prohibitChangeMode && size.GetUnit () != m_maxSize.GetUnit ())
493  {
494  NS_LOG_DEBUG ("Changing the mode of this queue disc is prohibited");
495  return false;
496  }
497 
498  switch (m_sizePolicy)
499  {
501  NS_FATAL_ERROR ("The size of this queue disc is not limited");
502 
504  if (GetNInternalQueues ())
505  {
506  GetInternalQueue (0)->SetMaxSize (size);
507  }
508 
510  if (GetNQueueDiscClasses ())
511  {
512  GetQueueDiscClass (0)->GetQueueDisc ()->SetMaxSize (size);
513  }
514 
516  default:
517  m_maxSize = size;
518  }
519  return true;
520 }
521 
522 QueueSize
524 {
525  NS_LOG_FUNCTION (this);
526 
527  if (GetMaxSize ().GetUnit () == QueueSizeUnit::PACKETS)
528  {
530  }
531  if (GetMaxSize ().GetUnit () == QueueSizeUnit::BYTES)
532  {
534  }
535  NS_ABORT_MSG ("Unknown queue size unit");
536 }
537 
538 void
540 {
541  NS_LOG_FUNCTION (this << device);
542  m_device = device;
543 }
544 
547 {
548  NS_LOG_FUNCTION (this);
549  return m_device;
550 }
551 
552 void
553 QueueDisc::SetQuota (const uint32_t quota)
554 {
555  NS_LOG_FUNCTION (this << quota);
556  m_quota = quota;
557 }
558 
559 uint32_t
561 {
562  NS_LOG_FUNCTION (this);
563  return m_quota;
564 }
565 
566 void
568 {
569  NS_LOG_FUNCTION (this);
570 
571  // set various callbacks on the internal queue, so that the queue disc is
572  // notified of packets enqueued, dequeued or dropped by the internal queue
573  queue->TraceConnectWithoutContext ("Enqueue",
575  queue->TraceConnectWithoutContext ("Dequeue",
577  queue->TraceConnectWithoutContext ("DropBeforeEnqueue",
578  MakeCallback (&InternalQueueDropFunctor::operator(),
580  queue->TraceConnectWithoutContext ("DropAfterDequeue",
581  MakeCallback (&InternalQueueDropFunctor::operator(),
583  m_queues.push_back (queue);
584 }
585 
587 QueueDisc::GetInternalQueue (uint32_t i) const
588 {
589  NS_ASSERT (i < m_queues.size ());
590  return m_queues[i];
591 }
592 
593 uint32_t
595 {
596  return static_cast<uint32_t>(m_queues.size ());
597 }
598 
599 void
601 {
602  NS_LOG_FUNCTION (this);
603  m_filters.push_back (filter);
604 }
605 
607 QueueDisc::GetPacketFilter (uint32_t i) const
608 {
609  NS_ASSERT (i < m_filters.size ());
610  return m_filters[i];
611 }
612 
613 uint32_t
615 {
616  return static_cast<uint32_t>(m_filters.size ());
617 }
618 
619 void
621 {
622  NS_LOG_FUNCTION (this);
623  NS_ABORT_MSG_IF (qdClass->GetQueueDisc () == 0, "Cannot add a class with no attached queue disc");
624  // the child queue disc cannot be one with wake mode equal to WAKE_CHILD because
625  // such queue discs do not implement the enqueue/dequeue methods
626  NS_ABORT_MSG_IF (qdClass->GetQueueDisc ()->GetWakeMode () == WAKE_CHILD,
627  "A queue disc with WAKE_CHILD as wake mode can only be a root queue disc");
628 
629  // set the parent callbacks on the child queue disc, so that it can notify
630  // the parent queue disc of packets enqueued, dequeued or dropped
631  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("Enqueue",
633  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("Dequeue",
635  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("DropBeforeEnqueue",
636  MakeCallback (&ChildQueueDiscDropFunctor::operator(),
638  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("DropAfterDequeue",
639  MakeCallback (&ChildQueueDiscDropFunctor::operator(),
641  m_classes.push_back (qdClass);
642 }
643 
646 {
647  NS_ASSERT (i < m_classes.size ());
648  return m_classes[i];
649 }
650 
651 uint32_t
653 {
654  return static_cast<uint32_t>(m_classes.size ());
655 }
656 
657 int32_t
659 {
660  NS_LOG_FUNCTION (this << item);
661 
662  int32_t ret = PacketFilter::PF_NO_MATCH;
663  for (std::vector<Ptr<PacketFilter> >::iterator f = m_filters.begin ();
664  f != m_filters.end () && ret == PacketFilter::PF_NO_MATCH; f++)
665  {
666  ret = (*f)->Classify (item);
667  }
668  return ret;
669 }
670 
673 {
674  return WAKE_ROOT;
675 }
676 
677 void
679 {
680  m_nPackets++;
681  m_nBytes += item->GetSize ();
683  m_stats.nTotalEnqueuedBytes += item->GetSize ();
684 
685  NS_LOG_LOGIC ("m_traceEnqueue (p)");
686  m_traceEnqueue (item);
687 }
688 
689 void
691 {
692  m_nPackets--;
693  m_nBytes -= item->GetSize ();
695  m_stats.nTotalDequeuedBytes += item->GetSize ();
696 
697  m_sojourn = Simulator::Now () - item->GetTimeStamp ();
698 
699  NS_LOG_LOGIC ("m_traceDequeue (p)");
700  m_traceDequeue (item);
701 }
702 
703 void
705 {
706  NS_LOG_FUNCTION (this << item << reason);
707 
709  m_stats.nTotalDroppedBytes += item->GetSize ();
711  m_stats.nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
712 
713  // update the number of packets dropped for the given reason
714  std::map<std::string, uint32_t>::iterator itp = m_stats.nDroppedPacketsBeforeEnqueue.find (reason);
715  if (itp != m_stats.nDroppedPacketsBeforeEnqueue.end ())
716  {
717  itp->second++;
718  }
719  else
720  {
722  }
723  // update the amount of bytes dropped for the given reason
724  std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesBeforeEnqueue.find (reason);
725  if (itb != m_stats.nDroppedBytesBeforeEnqueue.end ())
726  {
727  itb->second += item->GetSize ();
728  }
729  else
730  {
731  m_stats.nDroppedBytesBeforeEnqueue[reason] = item->GetSize ();
732  }
733 
734  NS_LOG_DEBUG ("Total packets/bytes dropped before enqueue: "
737  NS_LOG_LOGIC ("m_traceDropBeforeEnqueue (p)");
738  m_traceDrop (item);
739  m_traceDropBeforeEnqueue (item, reason);
740 }
741 
742 void
744 {
745  NS_LOG_FUNCTION (this << item << reason);
746 
748  m_stats.nTotalDroppedBytes += item->GetSize ();
750  m_stats.nTotalDroppedBytesAfterDequeue += item->GetSize ();
751 
752  // update the number of packets dropped for the given reason
753  std::map<std::string, uint32_t>::iterator itp = m_stats.nDroppedPacketsAfterDequeue.find (reason);
754  if (itp != m_stats.nDroppedPacketsAfterDequeue.end ())
755  {
756  itp->second++;
757  }
758  else
759  {
761  }
762  // update the amount of bytes dropped for the given reason
763  std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesAfterDequeue.find (reason);
764  if (itb != m_stats.nDroppedBytesAfterDequeue.end ())
765  {
766  itb->second += item->GetSize ();
767  }
768  else
769  {
770  m_stats.nDroppedBytesAfterDequeue[reason] = item->GetSize ();
771  }
772 
773  NS_LOG_DEBUG ("Total packets/bytes dropped after dequeue: "
776  NS_LOG_LOGIC ("m_traceDropAfterDequeue (p)");
777  m_traceDrop (item);
778  m_traceDropAfterDequeue (item, reason);
779 }
780 
781 bool
782 QueueDisc::Mark (Ptr<QueueDiscItem> item, const char* reason)
783 {
784  NS_LOG_FUNCTION (this << item << reason);
785 
786  bool retval = item->Mark ();
787 
788  if (!retval)
789  {
790  return false;
791  }
792 
794  m_stats.nTotalMarkedBytes += item->GetSize ();
795 
796  // update the number of packets marked for the given reason
797  std::map<std::string, uint32_t>::iterator itp = m_stats.nMarkedPackets.find (reason);
798  if (itp != m_stats.nMarkedPackets.end ())
799  {
800  itp->second++;
801  }
802  else
803  {
804  m_stats.nMarkedPackets[reason] = 1;
805  }
806  // update the amount of bytes marked for the given reason
807  std::map<std::string, uint64_t>::iterator itb = m_stats.nMarkedBytes.find (reason);
808  if (itb != m_stats.nMarkedBytes.end ())
809  {
810  itb->second += item->GetSize ();
811  }
812  else
813  {
814  m_stats.nMarkedBytes[reason] = item->GetSize ();
815  }
816 
817  NS_LOG_DEBUG ("Total packets/bytes marked: "
818  << m_stats.nTotalMarkedPackets << " / "
820  m_traceMark (item, reason);
821  return true;
822 }
823 
824 bool
826 {
827  NS_LOG_FUNCTION (this << item);
828 
830  m_stats.nTotalReceivedBytes += item->GetSize ();
831 
832  bool retval = DoEnqueue (item);
833 
834  if (retval)
835  {
836  item->SetTimeStamp (Simulator::Now ());
837  }
838 
839  // DoEnqueue may return false because:
840  // 1) the internal queue is full
841  // -> the DropBeforeEnqueue method of this queue disc is automatically called
842  // because QueueDisc::AddInternalQueue sets the trace callback
843  // 2) the child queue disc dropped the packet
844  // -> the DropBeforeEnqueue method of this queue disc is automatically called
845  // because QueueDisc::AddQueueDiscClass sets the trace callback
846  // 3) it dropped the packet
847  // -> DoEnqueue has to explicitly call DropBeforeEnqueue
848  // Thus, we do not have to call DropBeforeEnqueue here.
849 
850  // check that the received packet was either enqueued or dropped
855 
856  return retval;
857 }
858 
861 {
862  NS_LOG_FUNCTION (this);
863 
864  Ptr<QueueDiscItem> item = DoDequeue ();
865 
868 
869  return item;
870 }
871 
874 {
875  NS_LOG_FUNCTION (this);
876  return DoPeek ();
877 }
878 
881 {
882  NS_LOG_FUNCTION (this);
883 
884  if (!m_requeued)
885  {
886  m_requeued = Dequeue ();
887  }
888  return m_requeued;
889 }
890 
893 {
894  NS_LOG_FUNCTION (this);
895 
897 
898  if (item)
899  {
900  m_requeued = 0;
901  }
902  else
903  {
904  item = Dequeue ();
905  }
906 
907  return item;
908 }
909 
910 void
912 {
913  NS_LOG_FUNCTION (this);
914 
915  if (RunBegin ())
916  {
917  uint32_t quota = m_quota;
918  while (Restart ())
919  {
920  quota -= 1;
921  if (quota <= 0)
922  {
924  break;
925  }
926  }
927  RunEnd ();
928  }
929 }
930 
931 bool
933 {
934  NS_LOG_FUNCTION (this);
935  if (m_running)
936  {
937  return false;
938  }
939 
940  m_running = true;
941  return true;
942 }
943 
944 void
946 {
947  NS_LOG_FUNCTION (this);
948  m_running = false;
949 }
950 
951 bool
953 {
954  NS_LOG_FUNCTION (this);
956  if (item == 0)
957  {
958  NS_LOG_LOGIC ("No packet to send");
959  return false;
960  }
961 
962  return Transmit (item);
963 }
964 
967 {
968  NS_LOG_FUNCTION (this);
970  Ptr<QueueDiscItem> item;
971 
972  // First check if there is a requeued packet
973  if (m_requeued != 0)
974  {
975  // If the queue where the requeued packet is destined to is not stopped, return
976  // the requeued packet; otherwise, return an empty packet.
977  // If the device does not support flow control, the device queue is never stopped
978  if (!m_devQueueIface->GetTxQueue (m_requeued->GetTxQueueIndex ())->IsStopped ())
979  {
980  item = m_requeued;
981  m_requeued = 0;
982  }
983  }
984  else
985  {
986  // If the device is multi-queue (actually, Linux checks if the queue disc has
987  // multiple queues), ask the queue disc to dequeue a packet (a multi-queue aware
988  // queue disc should try not to dequeue a packet destined to a stopped queue).
989  // Otherwise, ask the queue disc to dequeue a packet only if the (unique) queue
990  // is not stopped.
991  if (m_devQueueIface->GetNTxQueues ()>1 || !m_devQueueIface->GetTxQueue (0)->IsStopped ())
992  {
993  item = Dequeue ();
994  // If the item is not null, add the header to the packet.
995  if (item != 0)
996  {
997  item->AddHeader ();
998  }
999  // Here, Linux tries bulk dequeues
1000  }
1001  }
1002  return item;
1003 }
1004 
1005 void
1007 {
1008  NS_LOG_FUNCTION (this << item);
1009  m_requeued = item;
1011 
1013  m_stats.nTotalRequeuedBytes += item->GetSize ();
1014 
1015  NS_LOG_LOGIC ("m_traceRequeue (p)");
1016  m_traceRequeue (item);
1017 }
1018 
1019 bool
1021 {
1022  NS_LOG_FUNCTION (this << item);
1024 
1025  // if the device queue is stopped, requeue the packet and return false.
1026  // Note that if the underlying device is tc-unaware, packets are never
1027  // requeued because the queues of tc-unaware devices are never stopped
1028  if (m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
1029  {
1030  Requeue (item);
1031  return false;
1032  }
1033 
1034  // a single queue device makes no use of the priority tag
1035  if (m_devQueueIface->GetNTxQueues () == 1)
1036  {
1037  SocketPriorityTag priorityTag;
1038  item->GetPacket ()->RemovePacketTag (priorityTag);
1039  }
1040  m_device->Send (item->GetPacket (), item->GetAddress (), item->GetProtocol ());
1041 
1042  // the behavior here slightly diverges from Linux. In Linux, it is advised that
1043  // the function called when a packet needs to be transmitted (ndo_start_xmit)
1044  // should always return NETDEV_TX_OK, which means that the packet is consumed by
1045  // the device driver and thus is not requeued. However, the ndo_start_xmit function
1046  // of the device driver is allowed to return NETDEV_TX_BUSY (and hence the packet
1047  // is requeued) when there is no room for the received packet in the device queue,
1048  // despite the queue is not stopped. This case is considered as a corner case or
1049  // an hard error, and should be avoided.
1050  // Here, we do not handle such corner case and always assume that the packet is
1051  // consumed by the netdevice. Thus, we ignore the value returned by Send and a
1052  // packet sent to a netdevice is never requeued. The reason is that the semantics
1053  // of the value returned by NetDevice::Send does not match that of the value
1054  // returned by ndo_start_xmit.
1055 
1056  // if the queue disc is empty or the device queue is now stopped, return false so
1057  // that the Run method does not attempt to dequeue other packets and exits
1058  if (GetNPackets () == 0 || m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
1059  {
1060  return false;
1061  }
1062 
1063  return true;
1064 }
1065 
1066 } // namespace ns3
uint32_t nTotalDequeuedPackets
Total dequeued packets.
Definition: queue-disc.h:200
Structure that keeps the queue disc statistics.
Definition: queue-disc.h:185
Ptr< const QueueDiscItem > Peek(void)
Get a copy of the next packet the queue discipline will extract, without actually extracting the pack...
Definition: queue-disc.cc:873
TracedValue< Time > m_sojourn
Sojourn time of the latest dequeued packet.
Definition: queue-disc.h:674
Stats()
constructor
Definition: queue-disc.cc:90
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
uint32_t nTotalMarkedPackets
Total marked packets.
Definition: queue-disc.h:228
uint32_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
Definition: queue-disc.cc:652
#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:682
std::map< std::string, uint32_t > nDroppedPacketsAfterDequeue
Packets dropped after dequeue, for each reason.
Definition: queue-disc.h:212
Class for representing queue sizes.
Definition: queue-size.h:94
uint32_t nTotalDroppedPackets
Total dropped packets.
Definition: queue-disc.h:204
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
Definition: queue-disc.cc:620
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
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:825
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
virtual ~QueueDiscClass()
Definition: queue-disc.cc:62
virtual ~QueueDisc()
Definition: queue-disc.cc:375
QueueSizeUnit
Enumeration of the operating modes of queues.
Definition: queue-size.h:42
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
Definition: queue-disc.cc:447
uint32_t nTotalRequeuedPackets
Total requeued packets.
Definition: queue-disc.h:224
bool Mark(Ptr< QueueDiscItem > item, const char *reason)
Marks the given packet and, if successful, updates the counters associated with the given reason...
Definition: queue-disc.cc:782
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< QueueDisc > m_queueDisc
Queue disc attached to this class.
Definition: queue-disc.h:79
bool m_prohibitChangeMode
True if changing mode is prohibited.
Definition: queue-disc.h:685
virtual void DoDispose(void)
Dispose of the object.
Definition: queue-disc.cc:68
void SetQueueDisc(Ptr< QueueDisc > qd)
Set the queue disc attached to this class.
Definition: queue-disc.cc:83
Used by queue discs with unlimited size.
Definition: queue-disc.h:108
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-vector.h:81
ChildQueueDiscDropFunctor m_childQueueDiscDbeFunctor
Function object called when a child queue disc dropped a packet before enqueue.
Definition: queue-disc.h:712
#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 nTotalSentPackets
Total sent packets – this value is not kept up to date, call GetStats first.
Definition: queue-disc.h:192
virtual Ptr< QueueDiscItem > DoDequeue(void)=0
This function actually extracts a packet from the queue disc.
TracedCallback< Ptr< const QueueDiscItem >, const char * > m_traceMark
Traced callback: fired when a packet is marked.
Definition: queue-disc.h:700
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
QueueSizeUnit GetUnit() const
Get the underlying unit.
Definition: queue-size.cc:169
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
QueueSize m_maxSize
max queue size
Definition: queue-disc.h:675
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:181
WakeMode
Used to determine whether the queue disc itself or its children must be activated when a netdevice wa...
Definition: queue-disc.h:479
TracedCallback< Ptr< const QueueDiscItem >, const char * > m_traceDropAfterDequeue
Traced callback: fired when a packet is dropped after dequeue.
Definition: queue-disc.h:698
uint32_t GetValue() const
Get the underlying value.
Definition: queue-size.cc:175
Used by queue discs with single child queue disc.
Definition: queue-disc.h:106
Ptr< QueueDiscItem > DequeuePeeked(void)
Extract from the queue disc the packet that has been dequeued by calling PeekDequeued.
Definition: queue-disc.cc:892
uint32_t nTotalMarkedBytes
Total marked bytes.
Definition: queue-disc.h:232
uint32_t nTotalDroppedPacketsBeforeEnqueue
Total packets dropped before enqueue.
Definition: queue-disc.h:206
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
uint64_t GetNDroppedBytes(std::string reason) const
Get the amount of bytes dropped for the given reason.
Definition: queue-disc.cc:134
static constexpr const char * CHILD_QUEUE_DISC_DROP
Packet dropped by a child queue disc.
Definition: queue-disc.h:500
virtual Ptr< const QueueDiscItem > DoPeek(void)=0
This function returns a copy of the next packet the queue disc will extract.
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
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
uint64_t nTotalEnqueuedBytes
Total enqueued bytes.
Definition: queue-disc.h:198
void PacketEnqueued(Ptr< const QueueDiscItem > item)
Perform the actions required when the queue disc is notified of a packet enqueue. ...
Definition: queue-disc.cc:678
std::string m_childQueueDiscDropMsg
Reason why a packet was dropped by a child queue disc.
Definition: queue-disc.h:683
void DoInitialize(void)
Check whether the configuration is correct and initialize parameters.
Definition: queue-disc.cc:394
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:680
InternalQueueDropFunctor m_internalQueueDbeFunctor
Function object called when an internal queue dropped a packet before enqueue.
Definition: queue-disc.h:708
Hold an unsigned integer type.
Definition: uinteger.h:44
TracedCallback< Ptr< const QueueDiscItem > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
Definition: queue-disc.h:690
Use number of packets for queue size.
Definition: queue-size.h:44
indicates whether the socket has a priority set.
Definition: socket.h:1303
uint64_t nTotalSentBytes
Total sent bytes – this value is not kept up to date, call GetStats first.
Definition: queue-disc.h:194
QueueDisc(QueueDiscSizePolicy policy=QueueDiscSizePolicy::SINGLE_INTERNAL_QUEUE)
Constructor.
Definition: queue-disc.cc:325
void Run(void)
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets...
Definition: queue-disc.cc:911
Ptr< PacketFilter > GetPacketFilter(uint32_t i) const
Get the i-th packet filter.
Definition: queue-disc.cc:607
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.
const Stats & GetStats(void)
Retrieve all the collected statistics.
Definition: queue-disc.cc:421
std::map< std::string, uint64_t > nDroppedBytesAfterDequeue
Bytes dropped after dequeue, for each reason.
Definition: queue-disc.h:222
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:1020
Ptr< QueueDisc > GetQueueDisc(void) const
Get the queue disc attached to this class.
Definition: queue-disc.cc:76
uint64_t nTotalDroppedBytesBeforeEnqueue
Total bytes dropped before enqueue.
Definition: queue-disc.h:216
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:658
Network device transmission queue interface.
virtual void DoDispose(void)
Dispose of the object.
Definition: queue-disc.cc:381
uint32_t GetNPacketFilters(void) const
Get the number of packet filters.
Definition: queue-disc.cc:614
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Definition: queue-disc.cc:113
std::map< std::string, uint32_t > nMarkedPackets
Marked packets, for each reason.
Definition: queue-disc.h:230
virtual WakeMode GetWakeMode(void) const
When setting up the wake callbacks on the netdevice queues, it is necessary to determine which queue ...
Definition: queue-disc.cc:672
InternalQueueDropFunctor m_internalQueueDadFunctor
Function object called when an internal queue dropped a packet after dequeue.
Definition: queue-disc.h:710
QueueDiscClass is the base class for classes that are included in a queue disc.
Definition: queue-disc.h:49
static const uint32_t DEFAULT_QUOTA
Default quota (as in /proc/sys/net/core/dev_weight)
Definition: queue-disc.h:666
Ptr< QueueDiscItem > Dequeue(void)
Request the queue discipline to extract a packet.
Definition: queue-disc.cc:860
uint64_t nTotalRequeuedBytes
Total requeued bytes.
Definition: queue-disc.h:226
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
double f(double x, void *params)
Definition: 80211b.c:72
uint32_t nTotalDroppedPacketsAfterDequeue
Total packets dropped after dequeue.
Definition: queue-disc.h:210
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
Definition: pointer.h:36
uint32_t nTotalReceivedPackets
Total received packets.
Definition: queue-disc.h:188
TracedCallback< Ptr< const QueueDiscItem >, const char * > m_traceDropBeforeEnqueue
Traced callback: fired when a packet is dropped before enqueue.
Definition: queue-disc.h:696
uint32_t m_quota
Maximum number of packets dequeued in a qdisc run.
Definition: queue-disc.h:678
uint64_t GetNMarkedBytes(std::string reason) const
Get the amount of bytes marked for the given reason.
Definition: queue-disc.cc:168
void Print(std::ostream &os) const
Print the statistics.
Definition: queue-disc.cc:181
std::vector< Ptr< InternalQueue > > m_queues
Internal queues.
Definition: queue-disc.h:668
bool RunBegin(void)
Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h).
Definition: queue-disc.cc:932
TracedCallback< Ptr< const QueueDiscItem > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
Definition: queue-disc.h:688
bool m_running
The queue disc is performing multiple dequeue operations.
Definition: queue-disc.h:681
uint64_t nTotalReceivedBytes
Total received bytes.
Definition: queue-disc.h:190
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
virtual uint32_t GetQuota(void) const
Get the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:560
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
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:673
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:1006
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
Definition: queue-disc.h:103
TracedValue< uint32_t > m_nPackets
Number of packets in the queue.
Definition: queue-disc.h:672
Ptr< const QueueDiscItem > PeekDequeued(void)
Dequeue a packet and retain it in the queue disc as a requeued packet.
Definition: queue-disc.cc:880
void PacketDequeued(Ptr< const QueueDiscItem > item)
Perform the actions required when the queue disc is notified of a packet dequeue. ...
Definition: queue-disc.cc:690
std::vector< Ptr< PacketFilter > > m_filters
Packet filters.
Definition: queue-disc.h:669
Used by queue discs with single internal queue.
Definition: queue-disc.h:105
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
uint64_t nTotalDequeuedBytes
Total dequeued bytes.
Definition: queue-disc.h:202
std::map< std::string, uint64_t > nDroppedBytesBeforeEnqueue
Bytes dropped before enqueue, for each reason.
Definition: queue-disc.h:218
Used by queue discs with multiple internal queues/child queue discs.
Definition: queue-disc.h:107
uint64_t nTotalDroppedBytesAfterDequeue
Total bytes dropped after dequeue.
Definition: queue-disc.h:220
QueueDiscSizePolicy m_sizePolicy
The queue disc size policy.
Definition: queue-disc.h:684
Ptr< NetDevice > m_device
The NetDevice on which this queue discipline is installed.
Definition: queue-disc.h:679
virtual void SetQuota(const uint32_t quota)
Set the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:553
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
ChildQueueDiscDropFunctor m_childQueueDiscDadFunctor
Function object called when a child queue disc dropped a packet after dequeue.
Definition: queue-disc.h:714
uint32_t nTotalEnqueuedPackets
Total enqueued packets.
Definition: queue-disc.h:196
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:600
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
Stats m_stats
The collected statistics.
Definition: queue-disc.h:677
uint64_t nTotalDroppedBytes
Total dropped bytes.
Definition: queue-disc.h:214
std::map< std::string, uint64_t > nMarkedBytes
Marked bytes, for each reason.
Definition: queue-disc.h:234
TracedCallback< Ptr< const QueueDiscItem > > m_traceDrop
Traced callback: fired when a packet is dropped.
Definition: queue-disc.h:694
virtual void InitializeParams(void)=0
Initialize parameters (if any) before the first packet is enqueued.
#define NS_OBJECT_TEMPLATE_CLASS_DEFINE(type, param)
Explicitly instantiate a template class and register the resulting instance with the TypeId system...
Definition: object-base.h:67
static TypeId GetTypeId(void)
Get the type ID.
Definition: queue-disc.cc:266
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
Definition: queue-disc.cc:155
A base class which provides memory management and object aggregation.
Definition: object.h:87
Container for a set of ns3::Object pointers.
bool Restart(void)
Modelled after the Linux function qdisc_restart (net/sched/sch_generic.c) Dequeue a packet (by callin...
Definition: queue-disc.cc:952
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
Ptr< QueueDiscItem > DequeuePacket(void)
Modelled after the Linux function dequeue_skb (net/sched/sch_generic.c)
Definition: queue-disc.cc:966
Ptr< NetDevice > GetNetDevice(void) const
Get the NetDevice on which this queue discipline is installed.
Definition: queue-disc.cc:546
static TypeId GetTypeId(void)
Get the type ID.
Definition: queue-disc.cc:43
TracedCallback< Ptr< const QueueDiscItem > > m_traceRequeue
Traced callback: fired when a packet is requeued.
Definition: queue-disc.h:692
void SetNetDevice(Ptr< NetDevice > device)
Set the NetDevice on which this queue discipline is installed.
Definition: queue-disc.cc:539
Ptr< QueueDiscClass > GetQueueDiscClass(uint32_t i) const
Get the i-th queue disc class.
Definition: queue-disc.cc:645
static constexpr const char * INTERNAL_QUEUE_DROP
Packet dropped by an internal queue.
Definition: queue-disc.h:499
void RunEnd(void)
Modelled after the Linux function qdisc_run_end (include/net/sch_generic.h).
Definition: queue-disc.cc:945
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
Definition: queue-disc.cc:454
std::vector< Ptr< QueueDiscClass > > m_classes
Classes.
Definition: queue-disc.h:670
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Definition: queue-disc.cc:440
std::map< std::string, uint32_t > nDroppedPacketsBeforeEnqueue
Packets dropped before enqueue, for each reason.
Definition: queue-disc.h:208