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/net-device-queue-interface.h"
31 #include "ns3/queue.h"
32 
33 namespace ns3 {
34 
35 NS_LOG_COMPONENT_DEFINE ("QueueDisc");
36 
37 
38 NS_OBJECT_ENSURE_REGISTERED (QueueDiscClass);
39 
41 {
42  static TypeId tid = TypeId ("ns3::QueueDiscClass")
43  .SetParent<Object> ()
44  .SetGroupName ("TrafficControl")
45  .AddConstructor<QueueDiscClass> ()
46  .AddAttribute ("QueueDisc", "The queue disc attached to the class",
47  PointerValue (),
49  MakePointerChecker<QueueDisc> ())
50  ;
51  return tid;
52 }
53 
55 {
56  NS_LOG_FUNCTION (this);
57 }
58 
60 {
61  NS_LOG_FUNCTION (this);
62 }
63 
64 void
66 {
67  NS_LOG_FUNCTION (this);
68  m_queueDisc = 0;
70 }
71 
74 {
75  NS_LOG_FUNCTION (this);
76  return m_queueDisc;
77 }
78 
79 void
81 {
82  NS_LOG_FUNCTION (this);
83  NS_ABORT_MSG_IF (m_queueDisc, "Cannot set the queue disc on a class already having an attached queue disc");
84  m_queueDisc = qd;
85 }
86 
88  : nTotalReceivedPackets (0),
89  nTotalReceivedBytes (0),
90  nTotalSentPackets (0),
91  nTotalSentBytes (0),
92  nTotalEnqueuedPackets (0),
93  nTotalEnqueuedBytes (0),
94  nTotalDequeuedPackets (0),
95  nTotalDequeuedBytes (0),
96  nTotalDroppedPackets (0),
97  nTotalDroppedPacketsBeforeEnqueue (0),
98  nTotalDroppedPacketsAfterDequeue (0),
99  nTotalDroppedBytes (0),
100  nTotalDroppedBytesBeforeEnqueue (0),
101  nTotalDroppedBytesAfterDequeue (0),
102  nTotalRequeuedPackets (0),
103  nTotalRequeuedBytes (0),
104  nTotalMarkedPackets (0),
105  nTotalMarkedBytes (0)
106 {
107 }
108 
109 uint32_t
110 QueueDisc::Stats::GetNDroppedPackets (std::string reason) const
111 {
112  uint32_t count = 0;
113  auto it = nDroppedPacketsBeforeEnqueue.find (reason);
114 
115  if (it != nDroppedPacketsBeforeEnqueue.end ())
116  {
117  count += it->second;
118  }
119 
120  it = nDroppedPacketsAfterDequeue.find (reason);
121 
122  if (it != nDroppedPacketsAfterDequeue.end ())
123  {
124  count += it->second;
125  }
126 
127  return count;
128 }
129 
130 uint64_t
131 QueueDisc::Stats::GetNDroppedBytes (std::string reason) const
132 {
133  uint64_t count = 0;
134  auto it = nDroppedBytesBeforeEnqueue.find (reason);
135 
136  if (it != nDroppedBytesBeforeEnqueue.end ())
137  {
138  count += it->second;
139  }
140 
141  it = nDroppedBytesAfterDequeue.find (reason);
142 
143  if (it != nDroppedBytesAfterDequeue.end ())
144  {
145  count += it->second;
146  }
147 
148  return count;
149 }
150 
151 uint32_t
152 QueueDisc::Stats::GetNMarkedPackets (std::string reason) const
153 {
154  auto it = nMarkedPackets.find (reason);
155 
156  if (it != nMarkedPackets.end ())
157  {
158  return it->second;
159  }
160 
161  return 0;
162 }
163 
164 uint64_t
165 QueueDisc::Stats::GetNMarkedBytes (std::string reason) const
166 {
167  auto it = nMarkedBytes.find (reason);
168 
169  if (it != nMarkedBytes.end ())
170  {
171  return it->second;
172  }
173 
174  return 0;
175 }
176 
177 void
178 QueueDisc::Stats::Print (std::ostream &os) const
179 {
180  std::map<std::string, uint32_t>::const_iterator itp;
181  std::map<std::string, uint64_t>::const_iterator itb;
182 
183  os << std::endl << "Packets/Bytes received: "
184  << nTotalReceivedPackets << " / "
185  << nTotalReceivedBytes
186  << std::endl << "Packets/Bytes enqueued: "
187  << nTotalEnqueuedPackets << " / "
188  << nTotalEnqueuedBytes
189  << std::endl << "Packets/Bytes dequeued: "
190  << nTotalDequeuedPackets << " / "
191  << nTotalDequeuedBytes
192  << std::endl << "Packets/Bytes requeued: "
193  << nTotalRequeuedPackets << " / "
194  << nTotalRequeuedBytes
195  << std::endl << "Packets/Bytes dropped: "
196  << nTotalDroppedPackets << " / "
197  << nTotalDroppedBytes
198  << std::endl << "Packets/Bytes dropped before enqueue: "
199  << nTotalDroppedPacketsBeforeEnqueue << " / "
200  << nTotalDroppedBytesBeforeEnqueue;
201 
202  itp = nDroppedPacketsBeforeEnqueue.begin ();
203  itb = nDroppedBytesBeforeEnqueue.begin ();
204 
205  while (itp != nDroppedPacketsBeforeEnqueue.end () &&
206  itb != nDroppedBytesBeforeEnqueue.end ())
207  {
208  NS_ASSERT (itp->first.compare (itb->first) == 0);
209  os << std::endl << " " << itp->first << ": "
210  << itp->second << " / " << itb->second;
211  itp++;
212  itb++;
213  }
214 
215  os << std::endl << "Packets/Bytes dropped after dequeue: "
216  << nTotalDroppedPacketsAfterDequeue << " / "
217  << nTotalDroppedBytesAfterDequeue;
218 
219  itp = nDroppedPacketsAfterDequeue.begin ();
220  itb = nDroppedBytesAfterDequeue.begin ();
221 
222  while (itp != nDroppedPacketsAfterDequeue.end () &&
223  itb != nDroppedBytesAfterDequeue.end ())
224  {
225  NS_ASSERT (itp->first.compare (itb->first) == 0);
226  os << std::endl << " " << itp->first << ": "
227  << itp->second << " / " << itb->second;
228  itp++;
229  itb++;
230  }
231 
232  os << std::endl << "Packets/Bytes sent: "
233  << nTotalSentPackets << " / "
234  << nTotalSentBytes
235  << std::endl << "Packets/Bytes marked: "
236  << nTotalMarkedPackets << " / "
237  << nTotalMarkedBytes;
238 
239  itp = nMarkedPackets.begin ();
240  itb = nMarkedBytes.begin ();
241 
242  while (itp != nMarkedPackets.end () &&
243  itb != nMarkedBytes.end ())
244  {
245  NS_ASSERT (itp->first.compare (itb->first) == 0);
246  os << std::endl << " " << itp->first << ": "
247  << itp->second << " / " << itb->second;
248  itp++;
249  itb++;
250  }
251 
252  os << std::endl;
253 }
254 
255 std::ostream & operator << (std::ostream &os, const QueueDisc::Stats &stats)
256 {
257  stats.Print (os);
258  return os;
259 }
260 
262 
264 {
265  static TypeId tid = TypeId ("ns3::QueueDisc")
266  .SetParent<Object> ()
267  .SetGroupName ("TrafficControl")
268  .AddAttribute ("Quota", "The maximum number of packets dequeued in a qdisc run",
272  MakeUintegerChecker<uint32_t> ())
273  .AddAttribute ("InternalQueueList", "The list of internal queues.",
276  MakeObjectVectorChecker<InternalQueue> ())
277  .AddAttribute ("PacketFilterList", "The list of packet filters.",
280  MakeObjectVectorChecker<PacketFilter> ())
281  .AddAttribute ("QueueDiscClassList", "The list of queue disc classes.",
284  MakeObjectVectorChecker<QueueDiscClass> ())
285  .AddTraceSource ("Enqueue", "Enqueue a packet in the queue disc",
287  "ns3::QueueDiscItem::TracedCallback")
288  .AddTraceSource ("Dequeue", "Dequeue a packet from the queue disc",
290  "ns3::QueueDiscItem::TracedCallback")
291  .AddTraceSource ("Requeue", "Requeue a packet in the queue disc",
293  "ns3::QueueDiscItem::TracedCallback")
294  .AddTraceSource ("Drop", "Drop a packet stored in the queue disc",
296  "ns3::QueueDiscItem::TracedCallback")
297  .AddTraceSource ("DropBeforeEnqueue", "Drop a packet before enqueue",
299  "ns3::QueueDiscItem::TracedCallback")
300  .AddTraceSource ("DropAfterDequeue", "Drop a packet after dequeue",
302  "ns3::QueueDiscItem::TracedCallback")
303  .AddTraceSource ("Mark", "Mark a packet stored in the queue disc",
305  "ns3::QueueDiscItem::TracedCallback")
306  .AddTraceSource ("PacketsInQueue",
307  "Number of packets currently stored in the queue disc",
309  "ns3::TracedValueCallback::Uint32")
310  .AddTraceSource ("BytesInQueue",
311  "Number of bytes currently stored in the queue disc",
313  "ns3::TracedValueCallback::Uint32")
314  .AddTraceSource ("SojournTime",
315  "Sojourn time of the last packet dequeued from the queue disc",
317  "ns3::Time::TracedCallback")
318  ;
319  return tid;
320 }
321 
323  : m_nPackets (0),
324  m_nBytes (0),
325  m_maxSize (QueueSize ("1p")), // to avoid that setting the mode at construction time is ignored
326  m_running (false),
327  m_peeked (false),
328  m_sizePolicy (policy),
329  m_prohibitChangeMode (false)
330 {
331  NS_LOG_FUNCTION (this << (uint16_t)policy);
332 
333  // These lambdas call the DropBeforeEnqueue or DropAfterDequeue methods of this
334  // QueueDisc object. Given that a callback to the operator() of these lambdas
335  // is connected to the DropBeforeEnqueue and DropAfterDequeue traces of the
336  // internal queues, the INTERNAL_QUEUE_DROP constant is passed as the reason
337  // why the packet is dropped.
339  {
340  return DropBeforeEnqueue (item, INTERNAL_QUEUE_DROP);
341  };
343  {
344  return DropAfterDequeue (item, INTERNAL_QUEUE_DROP);
345  };
346 
347  // These lambdas call the DropBeforeEnqueue or DropAfterDequeue methods of this
348  // QueueDisc object. Given that a callback to the operator() of these lambdas
349  // is connected to the DropBeforeEnqueue and DropAfterDequeue traces of the
350  // child queue discs, the concatenation of the CHILD_QUEUE_DISC_DROP constant
351  // and the second argument provided by such traces is passed as the reason why
352  // the packet is dropped.
353  m_childQueueDiscDbeFunctor = [this] (Ptr<const QueueDiscItem> item, const char* r)
354  {
355  return DropBeforeEnqueue (item,
356  m_childQueueDiscDropMsg.assign (CHILD_QUEUE_DISC_DROP).append (r).data ());
357  };
358  m_childQueueDiscDadFunctor = [this] (Ptr<const QueueDiscItem> item, const char* r)
359  {
360  return DropAfterDequeue (item,
361  m_childQueueDiscDropMsg.assign (CHILD_QUEUE_DISC_DROP).append (r).data ());
362  };
363 }
364 
366  : QueueDisc (policy)
367 {
368  m_maxSize = QueueSize (unit, 0);
369  m_prohibitChangeMode = true;
370 }
371 
373 {
374  NS_LOG_FUNCTION (this);
375 }
376 
377 void
379 {
380  NS_LOG_FUNCTION (this);
381  m_queues.clear ();
382  m_filters.clear ();
383  m_classes.clear ();
384  m_devQueueIface = 0;
385  m_send = nullptr;
386  m_requeued = 0;
387  m_internalQueueDbeFunctor = nullptr;
388  m_internalQueueDadFunctor = nullptr;
389  m_childQueueDiscDbeFunctor = nullptr;
390  m_childQueueDiscDadFunctor = nullptr;
392 }
393 
394 void
396 {
397  NS_LOG_FUNCTION (this);
398 
399  // Check the configuration and initialize the parameters of this queue disc
400  bool ok = CheckConfig ();
401  NS_ASSERT_MSG (ok, "The queue disc configuration is not correct");
402  NS_UNUSED (ok); // suppress compiler warning
403  InitializeParams ();
404 
405  // Check the configuration and initialize the parameters of the child queue discs
406  for (std::vector<Ptr<QueueDiscClass> >::iterator cl = m_classes.begin ();
407  cl != m_classes.end (); cl++)
408  {
409  (*cl)->GetQueueDisc ()->Initialize ();
410  }
411 
413 }
414 
415 const QueueDisc::Stats&
417 {
422 
423  // the total number of sent packets is only updated here to avoid to increase it
424  // after a dequeue and then having to decrease it if the packet is dropped after
425  // dequeue or requeued
430 
431  return m_stats;
432 }
433 
434 uint32_t
436 {
437  NS_LOG_FUNCTION (this);
438  return m_nPackets;
439 }
440 
441 uint32_t
443 {
444  NS_LOG_FUNCTION (this);
445  return m_nBytes;
446 }
447 
448 QueueSize
450 {
451  NS_LOG_FUNCTION (this);
452 
453  switch (m_sizePolicy)
454  {
456  NS_FATAL_ERROR ("The size of this queue disc is not limited");
457 
459  if (GetNInternalQueues ())
460  {
461  return GetInternalQueue (0)->GetMaxSize ();
462  }
463 
465  if (GetNQueueDiscClasses ())
466  {
467  return GetQueueDiscClass (0)->GetQueueDisc ()->GetMaxSize ();
468  }
469 
471  default:
472  return m_maxSize;
473  }
474 }
475 
476 bool
478 {
479  NS_LOG_FUNCTION (this << size);
480 
481  // do nothing if the limit is null
482  if (!size.GetValue ())
483  {
484  return false;
485  }
486 
487  if (m_prohibitChangeMode && size.GetUnit () != m_maxSize.GetUnit ())
488  {
489  NS_LOG_DEBUG ("Changing the mode of this queue disc is prohibited");
490  return false;
491  }
492 
493  switch (m_sizePolicy)
494  {
496  NS_FATAL_ERROR ("The size of this queue disc is not limited");
497 
499  if (GetNInternalQueues ())
500  {
501  GetInternalQueue (0)->SetMaxSize (size);
502  }
503 
505  if (GetNQueueDiscClasses ())
506  {
507  GetQueueDiscClass (0)->GetQueueDisc ()->SetMaxSize (size);
508  }
509 
511  default:
512  m_maxSize = size;
513  }
514  return true;
515 }
516 
517 QueueSize
519 {
520  NS_LOG_FUNCTION (this);
521 
522  if (GetMaxSize ().GetUnit () == QueueSizeUnit::PACKETS)
523  {
525  }
526  if (GetMaxSize ().GetUnit () == QueueSizeUnit::BYTES)
527  {
529  }
530  NS_ABORT_MSG ("Unknown queue size unit");
531 }
532 
533 void
535 {
536  NS_LOG_FUNCTION (this << ndqi);
537  m_devQueueIface = ndqi;
538 }
539 
542 {
543  NS_LOG_FUNCTION (this);
544  return m_devQueueIface;
545 }
546 
547 void
549 {
550  NS_LOG_FUNCTION (this);
551  m_send = func;
552 }
553 
556 {
557  NS_LOG_FUNCTION (this);
558  return m_send;
559 }
560 
561 void
562 QueueDisc::SetQuota (const uint32_t quota)
563 {
564  NS_LOG_FUNCTION (this << quota);
565  m_quota = quota;
566 }
567 
568 uint32_t
570 {
571  NS_LOG_FUNCTION (this);
572  return m_quota;
573 }
574 
575 void
577 {
578  NS_LOG_FUNCTION (this);
579 
580  // set various callbacks on the internal queue, so that the queue disc is
581  // notified of packets enqueued, dequeued or dropped by the internal queue
582  queue->TraceConnectWithoutContext ("Enqueue",
584  queue->TraceConnectWithoutContext ("Dequeue",
586  queue->TraceConnectWithoutContext ("DropBeforeEnqueue",
587  MakeCallback (&InternalQueueDropFunctor::operator(),
589  queue->TraceConnectWithoutContext ("DropAfterDequeue",
590  MakeCallback (&InternalQueueDropFunctor::operator(),
592  m_queues.push_back (queue);
593 }
594 
596 QueueDisc::GetInternalQueue (std::size_t i) const
597 {
598  NS_ASSERT (i < m_queues.size ());
599  return m_queues[i];
600 }
601 
602 std::size_t
604 {
605  return m_queues.size ();
606 }
607 
608 void
610 {
611  NS_LOG_FUNCTION (this);
612  m_filters.push_back (filter);
613 }
614 
616 QueueDisc::GetPacketFilter (std::size_t i) const
617 {
618  NS_ASSERT (i < m_filters.size ());
619  return m_filters[i];
620 }
621 
622 std::size_t
624 {
625  return m_filters.size ();
626 }
627 
628 void
630 {
631  NS_LOG_FUNCTION (this);
632  NS_ABORT_MSG_IF (qdClass->GetQueueDisc () == 0, "Cannot add a class with no attached queue disc");
633  // the child queue disc cannot be one with wake mode equal to WAKE_CHILD because
634  // such queue discs do not implement the enqueue/dequeue methods
635  NS_ABORT_MSG_IF (qdClass->GetQueueDisc ()->GetWakeMode () == WAKE_CHILD,
636  "A queue disc with WAKE_CHILD as wake mode can only be a root queue disc");
637 
638  // set the parent callbacks on the child queue disc, so that it can notify
639  // the parent queue disc of packets enqueued, dequeued or dropped
640  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("Enqueue",
642  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("Dequeue",
644  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("DropBeforeEnqueue",
645  MakeCallback (&ChildQueueDiscDropFunctor::operator(),
647  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("DropAfterDequeue",
648  MakeCallback (&ChildQueueDiscDropFunctor::operator(),
650  m_classes.push_back (qdClass);
651 }
652 
654 QueueDisc::GetQueueDiscClass (std::size_t i) const
655 {
656  NS_ASSERT (i < m_classes.size ());
657  return m_classes[i];
658 }
659 
660 std::size_t
662 {
663  return m_classes.size ();
664 }
665 
666 int32_t
668 {
669  NS_LOG_FUNCTION (this << item);
670 
671  int32_t ret = PacketFilter::PF_NO_MATCH;
672  for (std::vector<Ptr<PacketFilter> >::iterator f = m_filters.begin ();
673  f != m_filters.end () && ret == PacketFilter::PF_NO_MATCH; f++)
674  {
675  ret = (*f)->Classify (item);
676  }
677  return ret;
678 }
679 
682 {
683  return WAKE_ROOT;
684 }
685 
686 void
688 {
689  m_nPackets++;
690  m_nBytes += item->GetSize ();
692  m_stats.nTotalEnqueuedBytes += item->GetSize ();
693 
694  NS_LOG_LOGIC ("m_traceEnqueue (p)");
695  m_traceEnqueue (item);
696 }
697 
698 void
700 {
701  // If the queue disc asked the internal queue or the child queue disc to
702  // dequeue a packet because a peek operation was requested, the packet is
703  // still held by the queue disc, hence we do not need to update statistics
704  // and fire the dequeue trace. This function will be explicitly called when
705  // the packet will be actually dequeued.
706  if (!m_peeked)
707  {
708  m_nPackets--;
709  m_nBytes -= item->GetSize ();
711  m_stats.nTotalDequeuedBytes += item->GetSize ();
712 
713  m_sojourn (Simulator::Now () - item->GetTimeStamp ());
714 
715  NS_LOG_LOGIC ("m_traceDequeue (p)");
716  m_traceDequeue (item);
717  }
718 }
719 
720 void
722 {
723  NS_LOG_FUNCTION (this << item << reason);
724 
726  m_stats.nTotalDroppedBytes += item->GetSize ();
728  m_stats.nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
729 
730  // update the number of packets dropped for the given reason
731  std::map<std::string, uint32_t>::iterator itp = m_stats.nDroppedPacketsBeforeEnqueue.find (reason);
732  if (itp != m_stats.nDroppedPacketsBeforeEnqueue.end ())
733  {
734  itp->second++;
735  }
736  else
737  {
739  }
740  // update the amount of bytes dropped for the given reason
741  std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesBeforeEnqueue.find (reason);
742  if (itb != m_stats.nDroppedBytesBeforeEnqueue.end ())
743  {
744  itb->second += item->GetSize ();
745  }
746  else
747  {
748  m_stats.nDroppedBytesBeforeEnqueue[reason] = item->GetSize ();
749  }
750 
751  NS_LOG_DEBUG ("Total packets/bytes dropped before enqueue: "
754  NS_LOG_LOGIC ("m_traceDropBeforeEnqueue (p)");
755  m_traceDrop (item);
756  m_traceDropBeforeEnqueue (item, reason);
757 }
758 
759 void
761 {
762  NS_LOG_FUNCTION (this << item << reason);
763 
765  m_stats.nTotalDroppedBytes += item->GetSize ();
767  m_stats.nTotalDroppedBytesAfterDequeue += item->GetSize ();
768 
769  // update the number of packets dropped for the given reason
770  std::map<std::string, uint32_t>::iterator itp = m_stats.nDroppedPacketsAfterDequeue.find (reason);
771  if (itp != m_stats.nDroppedPacketsAfterDequeue.end ())
772  {
773  itp->second++;
774  }
775  else
776  {
778  }
779  // update the amount of bytes dropped for the given reason
780  std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesAfterDequeue.find (reason);
781  if (itb != m_stats.nDroppedBytesAfterDequeue.end ())
782  {
783  itb->second += item->GetSize ();
784  }
785  else
786  {
787  m_stats.nDroppedBytesAfterDequeue[reason] = item->GetSize ();
788  }
789 
790  // if in the context of a peek request a dequeued packet is dropped, we need
791  // to update the statistics and fire the dequeue trace before firing the drop
792  // after dequeue trace
793  if (m_peeked)
794  {
795  // temporarily set m_peeked to false, otherwise PacketDequeued does nothing
796  m_peeked = false;
797  PacketDequeued (item);
798  m_peeked = true;
799  }
800 
801  NS_LOG_DEBUG ("Total packets/bytes dropped after dequeue: "
804  NS_LOG_LOGIC ("m_traceDropAfterDequeue (p)");
805  m_traceDrop (item);
806  m_traceDropAfterDequeue (item, reason);
807 }
808 
809 bool
810 QueueDisc::Mark (Ptr<QueueDiscItem> item, const char* reason)
811 {
812  NS_LOG_FUNCTION (this << item << reason);
813 
814  bool retval = item->Mark ();
815 
816  if (!retval)
817  {
818  return false;
819  }
820 
822  m_stats.nTotalMarkedBytes += item->GetSize ();
823 
824  // update the number of packets marked for the given reason
825  std::map<std::string, uint32_t>::iterator itp = m_stats.nMarkedPackets.find (reason);
826  if (itp != m_stats.nMarkedPackets.end ())
827  {
828  itp->second++;
829  }
830  else
831  {
832  m_stats.nMarkedPackets[reason] = 1;
833  }
834  // update the amount of bytes marked for the given reason
835  std::map<std::string, uint64_t>::iterator itb = m_stats.nMarkedBytes.find (reason);
836  if (itb != m_stats.nMarkedBytes.end ())
837  {
838  itb->second += item->GetSize ();
839  }
840  else
841  {
842  m_stats.nMarkedBytes[reason] = item->GetSize ();
843  }
844 
845  NS_LOG_DEBUG ("Total packets/bytes marked: "
846  << m_stats.nTotalMarkedPackets << " / "
848  m_traceMark (item, reason);
849  return true;
850 }
851 
852 bool
854 {
855  NS_LOG_FUNCTION (this << item);
856 
858  m_stats.nTotalReceivedBytes += item->GetSize ();
859 
860  bool retval = DoEnqueue (item);
861 
862  if (retval)
863  {
864  item->SetTimeStamp (Simulator::Now ());
865  }
866 
867  // DoEnqueue may return false because:
868  // 1) the internal queue is full
869  // -> the DropBeforeEnqueue method of this queue disc is automatically called
870  // because QueueDisc::AddInternalQueue sets the trace callback
871  // 2) the child queue disc dropped the packet
872  // -> the DropBeforeEnqueue method of this queue disc is automatically called
873  // because QueueDisc::AddQueueDiscClass sets the trace callback
874  // 3) it dropped the packet
875  // -> DoEnqueue has to explicitly call DropBeforeEnqueue
876  // Thus, we do not have to call DropBeforeEnqueue here.
877 
878  // check that the received packet was either enqueued or dropped
883 
884  return retval;
885 }
886 
889 {
890  NS_LOG_FUNCTION (this);
891 
892  // The QueueDisc::DoPeek method dequeues a packet and keeps it as a requeued
893  // packet. Thus, first check whether a peeked packet exists. Otherwise, call
894  // the private DoDequeue method.
896 
897  if (item)
898  {
899  m_requeued = 0;
900  if (m_peeked)
901  {
902  // If the packet was requeued because a peek operation was requested
903  // (which is the case here because DequeuePacket calls Dequeue only
904  // when m_requeued is null), we need to explicitly call PacketDequeued
905  // to update statistics about dequeued packets and fire the dequeue trace.
906  m_peeked = false;
907  PacketDequeued (item);
908  }
909  }
910  else
911  {
912  item = DoDequeue ();
913  }
914 
917 
918  return item;
919 }
920 
923 {
924  NS_LOG_FUNCTION (this);
925  return DoPeek ();
926 }
927 
930 {
931  NS_LOG_FUNCTION (this);
932 
933  if (!m_requeued)
934  {
935  m_peeked = true;
936  m_requeued = Dequeue ();
937  // if no packet is returned, reset the m_peeked flag
938  if (!m_requeued)
939  {
940  m_peeked = false;
941  }
942  }
943  return m_requeued;
944 }
945 
946 void
948 {
949  NS_LOG_FUNCTION (this);
950 
951  if (RunBegin ())
952  {
953  uint32_t quota = m_quota;
954  while (Restart ())
955  {
956  quota -= 1;
957  if (quota <= 0)
958  {
960  break;
961  }
962  }
963  RunEnd ();
964  }
965 }
966 
967 bool
969 {
970  NS_LOG_FUNCTION (this);
971  if (m_running)
972  {
973  return false;
974  }
975 
976  m_running = true;
977  return true;
978 }
979 
980 void
982 {
983  NS_LOG_FUNCTION (this);
984  m_running = false;
985 }
986 
987 bool
989 {
990  NS_LOG_FUNCTION (this);
992  if (item == 0)
993  {
994  NS_LOG_LOGIC ("No packet to send");
995  return false;
996  }
997 
998  return Transmit (item);
999 }
1000 
1003 {
1004  NS_LOG_FUNCTION (this);
1005 
1006  Ptr<QueueDiscItem> item;
1007 
1008  // First check if there is a requeued packet
1009  if (m_requeued != 0)
1010  {
1011  // If the queue where the requeued packet is destined to is not stopped, return
1012  // the requeued packet; otherwise, return an empty packet.
1013  // If the device does not support flow control, the device queue is never stopped
1014  if (!m_devQueueIface || !m_devQueueIface->GetTxQueue (m_requeued->GetTxQueueIndex ())->IsStopped ())
1015  {
1016  item = m_requeued;
1017  m_requeued = 0;
1018  if (m_peeked)
1019  {
1020  // If the packet was requeued because a peek operation was requested
1021  // we need to explicitly call PacketDequeued to update statistics
1022  // about dequeued packets and fire the dequeue trace.
1023  m_peeked = false;
1024  PacketDequeued (item);
1025  }
1026  }
1027  }
1028  else
1029  {
1030  // If the device is multi-queue (actually, Linux checks if the queue disc has
1031  // multiple queues), ask the queue disc to dequeue a packet (a multi-queue aware
1032  // queue disc should try not to dequeue a packet destined to a stopped queue).
1033  // Otherwise, ask the queue disc to dequeue a packet only if the (unique) queue
1034  // is not stopped.
1035  if (!m_devQueueIface ||
1036  m_devQueueIface->GetNTxQueues ()>1 || !m_devQueueIface->GetTxQueue (0)->IsStopped ())
1037  {
1038  item = Dequeue ();
1039  // If the item is not null, add the header to the packet.
1040  if (item != 0)
1041  {
1042  item->AddHeader ();
1043  }
1044  // Here, Linux tries bulk dequeues
1045  }
1046  }
1047  return item;
1048 }
1049 
1050 void
1052 {
1053  NS_LOG_FUNCTION (this << item);
1054  m_requeued = item;
1056 
1058  m_stats.nTotalRequeuedBytes += item->GetSize ();
1059 
1060  NS_LOG_LOGIC ("m_traceRequeue (p)");
1061  m_traceRequeue (item);
1062 }
1063 
1064 bool
1066 {
1067  NS_LOG_FUNCTION (this << item);
1068 
1069  // if the device queue is stopped, requeue the packet and return false.
1070  // Note that if the underlying device is tc-unaware, packets are never
1071  // requeued because the queues of tc-unaware devices are never stopped
1072  if (m_devQueueIface && m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
1073  {
1074  Requeue (item);
1075  return false;
1076  }
1077 
1078  // a single queue device makes no use of the priority tag
1079  // a device that does not install a device queue interface likely makes no use of it as well
1080  if (!m_devQueueIface || m_devQueueIface->GetNTxQueues () == 1)
1081  {
1082  SocketPriorityTag priorityTag;
1083  item->GetPacket ()->RemovePacketTag (priorityTag);
1084  }
1085  NS_ASSERT_MSG (m_send, "Send callback not set");
1086  m_send (item);
1087 
1088  // the behavior here slightly diverges from Linux. In Linux, it is advised that
1089  // the function called when a packet needs to be transmitted (ndo_start_xmit)
1090  // should always return NETDEV_TX_OK, which means that the packet is consumed by
1091  // the device driver and thus is not requeued. However, the ndo_start_xmit function
1092  // of the device driver is allowed to return NETDEV_TX_BUSY (and hence the packet
1093  // is requeued) when there is no room for the received packet in the device queue,
1094  // despite the queue is not stopped. This case is considered as a corner case or
1095  // an hard error, and should be avoided.
1096  // Here, we do not handle such corner case and always assume that the packet is
1097  // consumed by the netdevice. Thus, we ignore the value returned by Send and a
1098  // packet sent to a netdevice is never requeued. The reason is that the semantics
1099  // of the value returned by NetDevice::Send does not match that of the value
1100  // returned by ndo_start_xmit.
1101 
1102  // if the queue disc is empty or the device queue is now stopped, return false so
1103  // that the Run method does not attempt to dequeue other packets and exits
1104  if (GetNPackets () == 0 ||
1105  (m_devQueueIface && m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ()))
1106  {
1107  return false;
1108  }
1109 
1110  return true;
1111 }
1112 
1113 } // 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.
Definition: queue-disc.cc:922
Stats()
constructor
Definition: queue-disc.cc:87
TracedCallback< Time > m_sojourn
Sojourn time of the latest dequeued packet.
Definition: queue-disc.h:701
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:435
uint32_t nTotalMarkedPackets
Total marked packets.
Definition: queue-disc.h:228
#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:709
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:629
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:721
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:853
#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:59
virtual ~QueueDisc()
Definition: queue-disc.cc:372
QueueSizeUnit
Enumeration of the operating modes of queues.
Definition: queue-size.h:42
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:810
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:518
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:713
virtual void DoDispose(void)
Dispose of the object.
Definition: queue-disc.cc:65
void SetQueueDisc(Ptr< QueueDisc > qd)
Set the queue disc attached to this class.
Definition: queue-disc.cc:80
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:740
#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:204
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:728
#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:442
#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:702
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Definition: queue-disc.h:181
TracedCallback< Ptr< const QueueDiscItem >, const char *> m_traceDropAfterDequeue
Traced callback: fired when a packet is dropped after dequeue.
Definition: queue-disc.h:726
Ptr< NetDeviceQueueInterface > GetNetDeviceQueueInterface(void) const
Definition: queue-disc.cc:541
Used by queue discs with single child queue disc.
Definition: queue-disc.h:106
uint64_t GetNMarkedBytes(std::string reason) const
Get the amount of bytes marked for the given reason.
Definition: queue-disc.cc:165
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.
virtual uint32_t GetQuota(void) const
Get the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:569
bool m_peeked
A packet was dequeued because Peek was called.
Definition: queue-disc.h:710
static constexpr const char * CHILD_QUEUE_DISC_DROP
Packet dropped by a child queue disc.
Definition: queue-disc.h:517
virtual Ptr< const QueueDiscItem > DoPeek(void)
Return a copy of the next packet the queue disc will extract.
Definition: queue-disc.cc:929
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
Definition: queue-disc.cc:576
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:687
std::string m_childQueueDiscDropMsg
Reason why a packet was dropped by a child queue disc.
Definition: queue-disc.h:711
void DoInitialize(void)
Check whether the configuration is correct and initialize parameters.
Definition: queue-disc.cc:395
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:706
InternalQueueDropFunctor m_internalQueueDbeFunctor
Function object called when an internal queue dropped a packet before enqueue.
Definition: queue-disc.h:736
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Definition: queue-disc.cc:596
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:718
SendCallback m_send
Callback used to send a packet to the receiving object.
Definition: queue-disc.h:707
uint32_t GetNDroppedPackets(std::string reason) const
Get the number of packets dropped for the given reason.
Definition: queue-disc.cc:110
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:616
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:194
QueueDisc(QueueDiscSizePolicy policy=QueueDiscSizePolicy::SINGLE_INTERNAL_QUEUE)
Constructor.
Definition: queue-disc.cc:322
void Run(void)
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets...
Definition: queue-disc.cc:947
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:416
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:1065
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:667
virtual void DoDispose(void)
Dispose of the object.
Definition: queue-disc.cc:378
std::function< void(Ptr< QueueDiscItem >)> SendCallback
Callback invoked to send a packet to the receiving object when Run is called.
Definition: queue-disc.h:357
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
Definition: queue-disc.cc:654
std::map< std::string, uint32_t > nMarkedPackets
Marked packets, for each reason.
Definition: queue-disc.h:230
InternalQueueDropFunctor m_internalQueueDadFunctor
Function object called when an internal queue dropped a packet after dequeue.
Definition: queue-disc.h:738
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:693
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
Definition: queue-disc.cc:888
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:70
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<T>.
Definition: pointer.h:36
std::size_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
Definition: queue-disc.cc:661
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:724
uint32_t m_quota
Maximum number of packets dequeued in a qdisc run.
Definition: queue-disc.h:705
uint32_t GetNMarkedPackets(std::string reason) const
Get the number of packets marked for the given reason.
Definition: queue-disc.cc:152
std::vector< Ptr< InternalQueue > > m_queues
Internal queues.
Definition: queue-disc.h:695
SendCallback GetSendCallback(void) const
Definition: queue-disc.cc:555
bool RunBegin(void)
Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h).
Definition: queue-disc.cc:968
TracedCallback< Ptr< const QueueDiscItem > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
Definition: queue-disc.h:716
bool m_running
The queue disc is performing multiple dequeue operations.
Definition: queue-disc.h:708
uint64_t nTotalReceivedBytes
Total received bytes.
Definition: queue-disc.h:190
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
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:131
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:700
QueueSize GetMaxSize(void) const
Get the maximum size of the queue disc.
Definition: queue-disc.cc:449
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:1051
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:699
void PacketDequeued(Ptr< const QueueDiscItem > item)
Perform the actions required when the queue disc is notified of a packet dequeue. ...
Definition: queue-disc.cc:699
std::vector< Ptr< PacketFilter > > m_filters
Packet filters.
Definition: queue-disc.h:696
Used by queue discs with single internal queue.
Definition: queue-disc.h:105
void Print(std::ostream &os) const
Print the statistics.
Definition: queue-disc.cc:178
#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:712
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
Definition: queue-disc.cc:623
virtual void SetQuota(const uint32_t quota)
Set the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:562
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:272
ChildQueueDiscDropFunctor m_childQueueDiscDadFunctor
Function object called when a child queue disc dropped a packet after dequeue.
Definition: queue-disc.h:742
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:609
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
Definition: queue-disc.cc:477
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:760
Stats m_stats
The collected statistics.
Definition: queue-disc.h:704
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:722
WakeMode
Used to determine whether the queue disc itself or its children must be activated when a netdevice wa...
Definition: queue-disc.h:496
virtual void InitializeParams(void)=0
Initialize parameters (if any) before the first packet is enqueued.
static TypeId GetTypeId(void)
Get the type ID.
Definition: queue-disc.cc:263
Ptr< QueueDisc > GetQueueDisc(void) const
Get the queue disc attached to this class.
Definition: queue-disc.cc:73
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:681
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:988
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
void SetSendCallback(SendCallback func)
Definition: queue-disc.cc:548
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:1002
static TypeId GetTypeId(void)
Get the type ID.
Definition: queue-disc.cc:40
TracedCallback< Ptr< const QueueDiscItem > > m_traceRequeue
Traced callback: fired when a packet is requeued.
Definition: queue-disc.h:720
void SetNetDeviceQueueInterface(Ptr< NetDeviceQueueInterface > ndqi)
Definition: queue-disc.cc:534
static constexpr const char * INTERNAL_QUEUE_DROP
Packet dropped by an internal queue.
Definition: queue-disc.h:516
void RunEnd(void)
Modelled after the Linux function qdisc_run_end (include/net/sch_generic.h).
Definition: queue-disc.cc:981
std::vector< Ptr< QueueDiscClass > > m_classes
Classes.
Definition: queue-disc.h:697
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
Definition: queue-disc.cc:603
std::map< std::string, uint32_t > nDroppedPacketsBeforeEnqueue
Packets dropped before enqueue, for each reason.
Definition: queue-disc.h:208