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::Time::TracedCallback")
321  ;
322  return tid;
323 }
324 
326  : m_nPackets (0),
327  m_nBytes (0),
328  m_maxSize (QueueSize ("1p")), // to avoid that setting the mode at construction time is ignored
329  m_running (false),
330  m_peeked (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 (std::size_t i) const
588 {
589  NS_ASSERT (i < m_queues.size ());
590  return m_queues[i];
591 }
592 
593 std::size_t
595 {
596  return m_queues.size ();
597 }
598 
599 void
601 {
602  NS_LOG_FUNCTION (this);
603  m_filters.push_back (filter);
604 }
605 
607 QueueDisc::GetPacketFilter (std::size_t i) const
608 {
609  NS_ASSERT (i < m_filters.size ());
610  return m_filters[i];
611 }
612 
613 std::size_t
615 {
616  return 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 
645 QueueDisc::GetQueueDiscClass (std::size_t i) const
646 {
647  NS_ASSERT (i < m_classes.size ());
648  return m_classes[i];
649 }
650 
651 std::size_t
653 {
654  return 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  // If the queue disc asked the internal queue or the child queue disc to
693  // dequeue a packet because a peek operation was requested, the packet is
694  // still held by the queue disc, hence we do not need to update statistics
695  // and fire the dequeue trace. This function will be explicitly called when
696  // the packet will be actually dequeued.
697  if (!m_peeked)
698  {
699  m_nPackets--;
700  m_nBytes -= item->GetSize ();
702  m_stats.nTotalDequeuedBytes += item->GetSize ();
703 
704  m_sojourn (Simulator::Now () - item->GetTimeStamp ());
705 
706  NS_LOG_LOGIC ("m_traceDequeue (p)");
707  m_traceDequeue (item);
708  }
709 }
710 
711 void
713 {
714  NS_LOG_FUNCTION (this << item << reason);
715 
717  m_stats.nTotalDroppedBytes += item->GetSize ();
719  m_stats.nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
720 
721  // update the number of packets dropped for the given reason
722  std::map<std::string, uint32_t>::iterator itp = m_stats.nDroppedPacketsBeforeEnqueue.find (reason);
723  if (itp != m_stats.nDroppedPacketsBeforeEnqueue.end ())
724  {
725  itp->second++;
726  }
727  else
728  {
730  }
731  // update the amount of bytes dropped for the given reason
732  std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesBeforeEnqueue.find (reason);
733  if (itb != m_stats.nDroppedBytesBeforeEnqueue.end ())
734  {
735  itb->second += item->GetSize ();
736  }
737  else
738  {
739  m_stats.nDroppedBytesBeforeEnqueue[reason] = item->GetSize ();
740  }
741 
742  NS_LOG_DEBUG ("Total packets/bytes dropped before enqueue: "
745  NS_LOG_LOGIC ("m_traceDropBeforeEnqueue (p)");
746  m_traceDrop (item);
747  m_traceDropBeforeEnqueue (item, reason);
748 }
749 
750 void
752 {
753  NS_LOG_FUNCTION (this << item << reason);
754 
756  m_stats.nTotalDroppedBytes += item->GetSize ();
758  m_stats.nTotalDroppedBytesAfterDequeue += item->GetSize ();
759 
760  // update the number of packets dropped for the given reason
761  std::map<std::string, uint32_t>::iterator itp = m_stats.nDroppedPacketsAfterDequeue.find (reason);
762  if (itp != m_stats.nDroppedPacketsAfterDequeue.end ())
763  {
764  itp->second++;
765  }
766  else
767  {
769  }
770  // update the amount of bytes dropped for the given reason
771  std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesAfterDequeue.find (reason);
772  if (itb != m_stats.nDroppedBytesAfterDequeue.end ())
773  {
774  itb->second += item->GetSize ();
775  }
776  else
777  {
778  m_stats.nDroppedBytesAfterDequeue[reason] = item->GetSize ();
779  }
780 
781  // if in the context of a peek request a dequeued packet is dropped, we need
782  // to update the statistics and fire the dequeue trace before firing the drop
783  // after dequeue trace
784  if (m_peeked)
785  {
786  // temporarily set m_peeked to false, otherwise PacketDequeued does nothing
787  m_peeked = false;
788  PacketDequeued (item);
789  m_peeked = true;
790  }
791 
792  NS_LOG_DEBUG ("Total packets/bytes dropped after dequeue: "
795  NS_LOG_LOGIC ("m_traceDropAfterDequeue (p)");
796  m_traceDrop (item);
797  m_traceDropAfterDequeue (item, reason);
798 }
799 
800 bool
801 QueueDisc::Mark (Ptr<QueueDiscItem> item, const char* reason)
802 {
803  NS_LOG_FUNCTION (this << item << reason);
804 
805  bool retval = item->Mark ();
806 
807  if (!retval)
808  {
809  return false;
810  }
811 
813  m_stats.nTotalMarkedBytes += item->GetSize ();
814 
815  // update the number of packets marked for the given reason
816  std::map<std::string, uint32_t>::iterator itp = m_stats.nMarkedPackets.find (reason);
817  if (itp != m_stats.nMarkedPackets.end ())
818  {
819  itp->second++;
820  }
821  else
822  {
823  m_stats.nMarkedPackets[reason] = 1;
824  }
825  // update the amount of bytes marked for the given reason
826  std::map<std::string, uint64_t>::iterator itb = m_stats.nMarkedBytes.find (reason);
827  if (itb != m_stats.nMarkedBytes.end ())
828  {
829  itb->second += item->GetSize ();
830  }
831  else
832  {
833  m_stats.nMarkedBytes[reason] = item->GetSize ();
834  }
835 
836  NS_LOG_DEBUG ("Total packets/bytes marked: "
837  << m_stats.nTotalMarkedPackets << " / "
839  m_traceMark (item, reason);
840  return true;
841 }
842 
843 bool
845 {
846  NS_LOG_FUNCTION (this << item);
847 
849  m_stats.nTotalReceivedBytes += item->GetSize ();
850 
851  bool retval = DoEnqueue (item);
852 
853  if (retval)
854  {
855  item->SetTimeStamp (Simulator::Now ());
856  }
857 
858  // DoEnqueue may return false because:
859  // 1) the internal queue is full
860  // -> the DropBeforeEnqueue method of this queue disc is automatically called
861  // because QueueDisc::AddInternalQueue sets the trace callback
862  // 2) the child queue disc dropped the packet
863  // -> the DropBeforeEnqueue method of this queue disc is automatically called
864  // because QueueDisc::AddQueueDiscClass sets the trace callback
865  // 3) it dropped the packet
866  // -> DoEnqueue has to explicitly call DropBeforeEnqueue
867  // Thus, we do not have to call DropBeforeEnqueue here.
868 
869  // check that the received packet was either enqueued or dropped
874 
875  return retval;
876 }
877 
880 {
881  NS_LOG_FUNCTION (this);
882 
883  // The QueueDisc::DoPeek method dequeues a packet and keeps it as a requeued
884  // packet. Thus, first check whether a peeked packet exists. Otherwise, call
885  // the private DoDequeue method.
887 
888  if (item)
889  {
890  m_requeued = 0;
891  if (m_peeked)
892  {
893  // If the packet was requeued because a peek operation was requested
894  // (which is the case here because DequeuePacket calls Dequeue only
895  // when m_requeued is null), we need to explicitly call PacketDequeued
896  // to update statistics about dequeued packets and fire the dequeue trace.
897  m_peeked = false;
898  PacketDequeued (item);
899  }
900  }
901  else
902  {
903  item = DoDequeue ();
904  }
905 
908 
909  return item;
910 }
911 
914 {
915  NS_LOG_FUNCTION (this);
916  return DoPeek ();
917 }
918 
921 {
922  NS_LOG_FUNCTION (this);
923 
924  if (!m_requeued)
925  {
926  m_peeked = true;
927  m_requeued = Dequeue ();
928  // if no packet is returned, reset the m_peeked flag
929  if (!m_requeued)
930  {
931  m_peeked = false;
932  }
933  }
934  return m_requeued;
935 }
936 
937 void
939 {
940  NS_LOG_FUNCTION (this);
941 
942  if (RunBegin ())
943  {
944  uint32_t quota = m_quota;
945  while (Restart ())
946  {
947  quota -= 1;
948  if (quota <= 0)
949  {
951  break;
952  }
953  }
954  RunEnd ();
955  }
956 }
957 
958 bool
960 {
961  NS_LOG_FUNCTION (this);
962  if (m_running)
963  {
964  return false;
965  }
966 
967  m_running = true;
968  return true;
969 }
970 
971 void
973 {
974  NS_LOG_FUNCTION (this);
975  m_running = false;
976 }
977 
978 bool
980 {
981  NS_LOG_FUNCTION (this);
983  if (item == 0)
984  {
985  NS_LOG_LOGIC ("No packet to send");
986  return false;
987  }
988 
989  return Transmit (item);
990 }
991 
994 {
995  NS_LOG_FUNCTION (this);
997  Ptr<QueueDiscItem> item;
998 
999  // First check if there is a requeued packet
1000  if (m_requeued != 0)
1001  {
1002  // If the queue where the requeued packet is destined to is not stopped, return
1003  // the requeued packet; otherwise, return an empty packet.
1004  // If the device does not support flow control, the device queue is never stopped
1005  if (!m_devQueueIface->GetTxQueue (m_requeued->GetTxQueueIndex ())->IsStopped ())
1006  {
1007  item = m_requeued;
1008  m_requeued = 0;
1009  if (m_peeked)
1010  {
1011  // If the packet was requeued because a peek operation was requested
1012  // we need to explicitly call PacketDequeued to update statistics
1013  // about dequeued packets and fire the dequeue trace.
1014  m_peeked = false;
1015  PacketDequeued (item);
1016  }
1017  }
1018  }
1019  else
1020  {
1021  // If the device is multi-queue (actually, Linux checks if the queue disc has
1022  // multiple queues), ask the queue disc to dequeue a packet (a multi-queue aware
1023  // queue disc should try not to dequeue a packet destined to a stopped queue).
1024  // Otherwise, ask the queue disc to dequeue a packet only if the (unique) queue
1025  // is not stopped.
1026  if (m_devQueueIface->GetNTxQueues ()>1 || !m_devQueueIface->GetTxQueue (0)->IsStopped ())
1027  {
1028  item = Dequeue ();
1029  // If the item is not null, add the header to the packet.
1030  if (item != 0)
1031  {
1032  item->AddHeader ();
1033  }
1034  // Here, Linux tries bulk dequeues
1035  }
1036  }
1037  return item;
1038 }
1039 
1040 void
1042 {
1043  NS_LOG_FUNCTION (this << item);
1044  m_requeued = item;
1046 
1048  m_stats.nTotalRequeuedBytes += item->GetSize ();
1049 
1050  NS_LOG_LOGIC ("m_traceRequeue (p)");
1051  m_traceRequeue (item);
1052 }
1053 
1054 bool
1056 {
1057  NS_LOG_FUNCTION (this << item);
1059 
1060  // if the device queue is stopped, requeue the packet and return false.
1061  // Note that if the underlying device is tc-unaware, packets are never
1062  // requeued because the queues of tc-unaware devices are never stopped
1063  if (m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
1064  {
1065  Requeue (item);
1066  return false;
1067  }
1068 
1069  // a single queue device makes no use of the priority tag
1070  if (m_devQueueIface->GetNTxQueues () == 1)
1071  {
1072  SocketPriorityTag priorityTag;
1073  item->GetPacket ()->RemovePacketTag (priorityTag);
1074  }
1075  m_device->Send (item->GetPacket (), item->GetAddress (), item->GetProtocol ());
1076 
1077  // the behavior here slightly diverges from Linux. In Linux, it is advised that
1078  // the function called when a packet needs to be transmitted (ndo_start_xmit)
1079  // should always return NETDEV_TX_OK, which means that the packet is consumed by
1080  // the device driver and thus is not requeued. However, the ndo_start_xmit function
1081  // of the device driver is allowed to return NETDEV_TX_BUSY (and hence the packet
1082  // is requeued) when there is no room for the received packet in the device queue,
1083  // despite the queue is not stopped. This case is considered as a corner case or
1084  // an hard error, and should be avoided.
1085  // Here, we do not handle such corner case and always assume that the packet is
1086  // consumed by the netdevice. Thus, we ignore the value returned by Send and a
1087  // packet sent to a netdevice is never requeued. The reason is that the semantics
1088  // of the value returned by NetDevice::Send does not match that of the value
1089  // returned by ndo_start_xmit.
1090 
1091  // if the queue disc is empty or the device queue is now stopped, return false so
1092  // that the Run method does not attempt to dequeue other packets and exits
1093  if (GetNPackets () == 0 || m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
1094  {
1095  return false;
1096  }
1097 
1098  return true;
1099 }
1100 
1101 } // namespace ns3
uint32_t nTotalDequeuedPackets
Total dequeued packets.
Definition: queue-disc.h:201
Structure that keeps the queue disc statistics.
Definition: queue-disc.h:186
Ptr< const QueueDiscItem > Peek(void)
Get a copy of the next packet the queue discipline will extract.
Definition: queue-disc.cc:913
Stats()
constructor
Definition: queue-disc.cc:90
Ptr< NetDevice > GetNetDevice(void) const
Get the NetDevice on which this queue discipline is installed.
Definition: queue-disc.cc:546
TracedCallback< Time > m_sojourn
Sojourn time of the latest dequeued packet.
Definition: queue-disc.h:669
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Definition: queue-disc.cc:440
uint32_t nTotalMarkedPackets
Total marked packets.
Definition: queue-disc.h:229
#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:677
std::map< std::string, uint32_t > nDroppedPacketsAfterDequeue
Packets dropped after dequeue, for each reason.
Definition: queue-disc.h:213
Class for representing queue sizes.
Definition: queue-size.h:94
uint32_t nTotalDroppedPackets
Total dropped packets.
Definition: queue-disc.h:205
#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:712
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:844
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
uint32_t GetValue() const
Get the underlying value.
Definition: queue-size.cc:175
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 nTotalRequeuedPackets
Total requeued packets.
Definition: queue-disc.h:225
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:801
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:80
bool m_prohibitChangeMode
True if changing mode is prohibited.
Definition: queue-disc.h:681
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:109
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:708
#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:202
uint32_t nTotalSentPackets
Total sent packets – this value is not kept up to date, call GetStats first.
Definition: queue-disc.h:193
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:696
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
Definition: queue-disc.cc:447
#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:670
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:182
TracedCallback< Ptr< const QueueDiscItem >, const char *> m_traceDropAfterDequeue
Traced callback: fired when a packet is dropped after dequeue.
Definition: queue-disc.h:694
Used by queue discs with single child queue disc.
Definition: queue-disc.h:107
uint64_t GetNMarkedBytes(std::string reason) const
Get the amount of bytes marked for the given reason.
Definition: queue-disc.cc:168
uint32_t nTotalMarkedBytes
Total marked bytes.
Definition: queue-disc.h:233
uint32_t nTotalDroppedPacketsBeforeEnqueue
Total packets dropped before enqueue.
Definition: queue-disc.h:207
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual uint32_t GetQuota(void) const
Get the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:560
bool m_peeked
A packet was dequeued because Peek was called.
Definition: queue-disc.h:678
static constexpr const char * CHILD_QUEUE_DISC_DROP
Packet dropped by a child queue disc.
Definition: queue-disc.h:495
virtual Ptr< const QueueDiscItem > DoPeek(void)
Return a copy of the next packet the queue disc will extract.
Definition: queue-disc.cc:920
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:199
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:679
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:675
InternalQueueDropFunctor m_internalQueueDbeFunctor
Function object called when an internal queue dropped a packet before enqueue.
Definition: queue-disc.h:704
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Definition: queue-disc.cc:587
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:686
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Definition: queue-disc.cc:113
Use number of packets for queue size.
Definition: queue-size.h:44
Ptr< PacketFilter > GetPacketFilter(std::size_t i) const
Get the i-th packet filter.
Definition: queue-disc.cc:607
indicates whether the socket has a priority set.
Definition: socket.h:1307
uint64_t nTotalSentBytes
Total sent bytes – this value is not kept up to date, call GetStats first.
Definition: queue-disc.h:195
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:938
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:223
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:1055
uint64_t nTotalDroppedBytesBeforeEnqueue
Total bytes dropped before enqueue.
Definition: queue-disc.h:217
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
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
Definition: queue-disc.cc:645
std::map< std::string, uint32_t > nMarkedPackets
Marked packets, for each reason.
Definition: queue-disc.h:231
InternalQueueDropFunctor m_internalQueueDadFunctor
Function object called when an internal queue dropped a packet after dequeue.
Definition: queue-disc.h:706
QueueDiscClass is the base class for classes that are included in a queue disc.
Definition: queue-disc.h:50
static const uint32_t DEFAULT_QUOTA
Default quota (as in /proc/sys/net/core/dev_weight)
Definition: queue-disc.h:661
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
Definition: queue-disc.cc:879
uint64_t nTotalRequeuedBytes
Total requeued bytes.
Definition: queue-disc.h:227
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:70
uint32_t nTotalDroppedPacketsAfterDequeue
Total packets dropped after dequeue.
Definition: queue-disc.h:211
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
Definition: queue-disc.cc:652
uint32_t nTotalReceivedPackets
Total received packets.
Definition: queue-disc.h:189
TracedCallback< Ptr< const QueueDiscItem >, const char *> m_traceDropBeforeEnqueue
Traced callback: fired when a packet is dropped before enqueue.
Definition: queue-disc.h:692
uint32_t m_quota
Maximum number of packets dequeued in a qdisc run.
Definition: queue-disc.h:673
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
Definition: queue-disc.cc:155
std::vector< Ptr< InternalQueue > > m_queues
Internal queues.
Definition: queue-disc.h:663
bool RunBegin(void)
Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h).
Definition: queue-disc.cc:959
TracedCallback< Ptr< const QueueDiscItem > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
Definition: queue-disc.h:684
bool m_running
The queue disc is performing multiple dequeue operations.
Definition: queue-disc.h:676
uint64_t nTotalReceivedBytes
Total received bytes.
Definition: queue-disc.h:191
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint64_t GetNDroppedBytes(std::string reason) const
Get the amount of bytes dropped for the given reason.
Definition: queue-disc.cc:134
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:668
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
Definition: queue-disc.cc:454
QueueSizeUnit GetUnit() const
Get the underlying unit.
Definition: queue-size.cc:169
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:1041
QueueDiscSizePolicy
Enumeration of the available policies to handle the queue disc size.
Definition: queue-disc.h:104
TracedValue< uint32_t > m_nPackets
Number of packets in the queue.
Definition: queue-disc.h:667
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:664
Used by queue discs with single internal queue.
Definition: queue-disc.h:106
void Print(std::ostream &os) const
Print the statistics.
Definition: queue-disc.cc:181
#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:203
std::map< std::string, uint64_t > nDroppedBytesBeforeEnqueue
Bytes dropped before enqueue, for each reason.
Definition: queue-disc.h:219
Used by queue discs with multiple internal queues/child queue discs.
Definition: queue-disc.h:108
uint64_t nTotalDroppedBytesAfterDequeue
Total bytes dropped after dequeue.
Definition: queue-disc.h:221
QueueDiscSizePolicy m_sizePolicy
The queue disc size policy.
Definition: queue-disc.h:680
Ptr< NetDevice > m_device
The NetDevice on which this queue discipline is installed.
Definition: queue-disc.h:674
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
Definition: queue-disc.cc:614
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:270
ChildQueueDiscDropFunctor m_childQueueDiscDadFunctor
Function object called when a child queue disc dropped a packet after dequeue.
Definition: queue-disc.h:710
uint32_t nTotalEnqueuedPackets
Total enqueued packets.
Definition: queue-disc.h:197
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:751
Stats m_stats
The collected statistics.
Definition: queue-disc.h:672
uint64_t nTotalDroppedBytes
Total dropped bytes.
Definition: queue-disc.h:215
std::map< std::string, uint64_t > nMarkedBytes
Marked bytes, for each reason.
Definition: queue-disc.h:235
TracedCallback< Ptr< const QueueDiscItem > > m_traceDrop
Traced callback: fired when a packet is dropped.
Definition: queue-disc.h:690
WakeMode
Used to determine whether the queue disc itself or its children must be activated when a netdevice wa...
Definition: queue-disc.h:474
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
Ptr< QueueDisc > GetQueueDisc(void) const
Get the queue disc attached to this class.
Definition: queue-disc.cc:76
A base class which provides memory management and object aggregation.
Definition: object.h:87
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
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:979
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:915
Ptr< QueueDiscItem > DequeuePacket(void)
Modelled after the Linux function dequeue_skb (net/sched/sch_generic.c)
Definition: queue-disc.cc:993
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:688
void SetNetDevice(Ptr< NetDevice > device)
Set the NetDevice on which this queue discipline is installed.
Definition: queue-disc.cc:539
static constexpr const char * INTERNAL_QUEUE_DROP
Packet dropped by an internal queue.
Definition: queue-disc.h:494
void RunEnd(void)
Modelled after the Linux function qdisc_run_end (include/net/sch_generic.h).
Definition: queue-disc.cc:972
std::vector< Ptr< QueueDiscClass > > m_classes
Classes.
Definition: queue-disc.h:665
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
Definition: queue-disc.cc:594
std::map< std::string, uint32_t > nDroppedPacketsBeforeEnqueue
Packets dropped before enqueue, for each reason.
Definition: queue-disc.h:209