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  m_childQueueDiscMarkFunctor = [this] (Ptr<const QueueDiscItem> item, const char* r)
364  {
365  return Mark (const_cast<QueueDiscItem *> (PeekPointer (item)),
366  m_childQueueDiscMarkMsg.assign (CHILD_QUEUE_DISC_MARK).append (r).data ());
367  };
368 }
369 
371  : QueueDisc (policy)
372 {
373  m_maxSize = QueueSize (unit, 0);
374  m_prohibitChangeMode = true;
375 }
376 
378 {
379  NS_LOG_FUNCTION (this);
380 }
381 
382 void
384 {
385  NS_LOG_FUNCTION (this);
386  m_queues.clear ();
387  m_filters.clear ();
388  m_classes.clear ();
389  m_devQueueIface = 0;
390  m_send = nullptr;
391  m_requeued = 0;
392  m_internalQueueDbeFunctor = nullptr;
393  m_internalQueueDadFunctor = nullptr;
394  m_childQueueDiscDbeFunctor = nullptr;
395  m_childQueueDiscDadFunctor = nullptr;
397 }
398 
399 void
401 {
402  NS_LOG_FUNCTION (this);
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 << ndqi);
542  m_devQueueIface = ndqi;
543 }
544 
547 {
548  NS_LOG_FUNCTION (this);
549  return m_devQueueIface;
550 }
551 
552 void
554 {
555  NS_LOG_FUNCTION (this);
556  m_send = func;
557 }
558 
561 {
562  NS_LOG_FUNCTION (this);
563  return m_send;
564 }
565 
566 void
567 QueueDisc::SetQuota (const uint32_t quota)
568 {
569  NS_LOG_FUNCTION (this << quota);
570  m_quota = quota;
571 }
572 
573 uint32_t
575 {
576  NS_LOG_FUNCTION (this);
577  return m_quota;
578 }
579 
580 void
582 {
583  NS_LOG_FUNCTION (this);
584 
585  // set various callbacks on the internal queue, so that the queue disc is
586  // notified of packets enqueued, dequeued or dropped by the internal queue
587  queue->TraceConnectWithoutContext ("Enqueue",
589  queue->TraceConnectWithoutContext ("Dequeue",
591  queue->TraceConnectWithoutContext ("DropBeforeEnqueue",
592  MakeCallback (&InternalQueueDropFunctor::operator(),
594  queue->TraceConnectWithoutContext ("DropAfterDequeue",
595  MakeCallback (&InternalQueueDropFunctor::operator(),
597  m_queues.push_back (queue);
598 }
599 
601 QueueDisc::GetInternalQueue (std::size_t i) const
602 {
603  NS_ASSERT (i < m_queues.size ());
604  return m_queues[i];
605 }
606 
607 std::size_t
609 {
610  return m_queues.size ();
611 }
612 
613 void
615 {
616  NS_LOG_FUNCTION (this);
617  m_filters.push_back (filter);
618 }
619 
621 QueueDisc::GetPacketFilter (std::size_t i) const
622 {
623  NS_ASSERT (i < m_filters.size ());
624  return m_filters[i];
625 }
626 
627 std::size_t
629 {
630  return m_filters.size ();
631 }
632 
633 void
635 {
636  NS_LOG_FUNCTION (this);
637  NS_ABORT_MSG_IF (qdClass->GetQueueDisc () == 0, "Cannot add a class with no attached queue disc");
638  // the child queue disc cannot be one with wake mode equal to WAKE_CHILD because
639  // such queue discs do not implement the enqueue/dequeue methods
640  NS_ABORT_MSG_IF (qdClass->GetQueueDisc ()->GetWakeMode () == WAKE_CHILD,
641  "A queue disc with WAKE_CHILD as wake mode can only be a root queue disc");
642 
643  // set the parent callbacks on the child queue disc, so that it can notify
644  // the parent queue disc of packets enqueued, dequeued, dropped, or marked
645  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("Enqueue",
647  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("Dequeue",
649  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("DropBeforeEnqueue",
650  MakeCallback (&ChildQueueDiscDropFunctor::operator(),
652  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("DropAfterDequeue",
653  MakeCallback (&ChildQueueDiscDropFunctor::operator(),
655  qdClass->GetQueueDisc ()->TraceConnectWithoutContext ("Mark",
656  MakeCallback (&ChildQueueDiscMarkFunctor::operator(),
658  m_classes.push_back (qdClass);
659 }
660 
662 QueueDisc::GetQueueDiscClass (std::size_t i) const
663 {
664  NS_ASSERT (i < m_classes.size ());
665  return m_classes[i];
666 }
667 
668 std::size_t
670 {
671  return m_classes.size ();
672 }
673 
674 int32_t
676 {
677  NS_LOG_FUNCTION (this << item);
678 
679  int32_t ret = PacketFilter::PF_NO_MATCH;
680  for (std::vector<Ptr<PacketFilter> >::iterator f = m_filters.begin ();
681  f != m_filters.end () && ret == PacketFilter::PF_NO_MATCH; f++)
682  {
683  ret = (*f)->Classify (item);
684  }
685  return ret;
686 }
687 
690 {
691  return WAKE_ROOT;
692 }
693 
694 void
696 {
697  m_nPackets++;
698  m_nBytes += item->GetSize ();
700  m_stats.nTotalEnqueuedBytes += item->GetSize ();
701 
702  NS_LOG_LOGIC ("m_traceEnqueue (p)");
703  m_traceEnqueue (item);
704 }
705 
706 void
708 {
709  // If the queue disc asked the internal queue or the child queue disc to
710  // dequeue a packet because a peek operation was requested, the packet is
711  // still held by the queue disc, hence we do not need to update statistics
712  // and fire the dequeue trace. This function will be explicitly called when
713  // the packet will be actually dequeued.
714  if (!m_peeked)
715  {
716  m_nPackets--;
717  m_nBytes -= item->GetSize ();
719  m_stats.nTotalDequeuedBytes += item->GetSize ();
720 
721  m_sojourn (Simulator::Now () - item->GetTimeStamp ());
722 
723  NS_LOG_LOGIC ("m_traceDequeue (p)");
724  m_traceDequeue (item);
725  }
726 }
727 
728 void
730 {
731  NS_LOG_FUNCTION (this << item << reason);
732 
734  m_stats.nTotalDroppedBytes += item->GetSize ();
736  m_stats.nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
737 
738  // update the number of packets dropped for the given reason
739  std::map<std::string, uint32_t>::iterator itp = m_stats.nDroppedPacketsBeforeEnqueue.find (reason);
740  if (itp != m_stats.nDroppedPacketsBeforeEnqueue.end ())
741  {
742  itp->second++;
743  }
744  else
745  {
747  }
748  // update the amount of bytes dropped for the given reason
749  std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesBeforeEnqueue.find (reason);
750  if (itb != m_stats.nDroppedBytesBeforeEnqueue.end ())
751  {
752  itb->second += item->GetSize ();
753  }
754  else
755  {
756  m_stats.nDroppedBytesBeforeEnqueue[reason] = item->GetSize ();
757  }
758 
759  NS_LOG_DEBUG ("Total packets/bytes dropped before enqueue: "
762  NS_LOG_LOGIC ("m_traceDropBeforeEnqueue (p)");
763  m_traceDrop (item);
764  m_traceDropBeforeEnqueue (item, reason);
765 }
766 
767 void
769 {
770  NS_LOG_FUNCTION (this << item << reason);
771 
773  m_stats.nTotalDroppedBytes += item->GetSize ();
775  m_stats.nTotalDroppedBytesAfterDequeue += item->GetSize ();
776 
777  // update the number of packets dropped for the given reason
778  std::map<std::string, uint32_t>::iterator itp = m_stats.nDroppedPacketsAfterDequeue.find (reason);
779  if (itp != m_stats.nDroppedPacketsAfterDequeue.end ())
780  {
781  itp->second++;
782  }
783  else
784  {
786  }
787  // update the amount of bytes dropped for the given reason
788  std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesAfterDequeue.find (reason);
789  if (itb != m_stats.nDroppedBytesAfterDequeue.end ())
790  {
791  itb->second += item->GetSize ();
792  }
793  else
794  {
795  m_stats.nDroppedBytesAfterDequeue[reason] = item->GetSize ();
796  }
797 
798  // if in the context of a peek request a dequeued packet is dropped, we need
799  // to update the statistics and fire the dequeue trace before firing the drop
800  // after dequeue trace
801  if (m_peeked)
802  {
803  // temporarily set m_peeked to false, otherwise PacketDequeued does nothing
804  m_peeked = false;
805  PacketDequeued (item);
806  m_peeked = true;
807  }
808 
809  NS_LOG_DEBUG ("Total packets/bytes dropped after dequeue: "
812  NS_LOG_LOGIC ("m_traceDropAfterDequeue (p)");
813  m_traceDrop (item);
814  m_traceDropAfterDequeue (item, reason);
815 }
816 
817 bool
818 QueueDisc::Mark (Ptr<QueueDiscItem> item, const char* reason)
819 {
820  NS_LOG_FUNCTION (this << item << reason);
821 
822  bool retval = item->Mark ();
823 
824  if (!retval)
825  {
826  return false;
827  }
828 
830  m_stats.nTotalMarkedBytes += item->GetSize ();
831 
832  // update the number of packets marked for the given reason
833  std::map<std::string, uint32_t>::iterator itp = m_stats.nMarkedPackets.find (reason);
834  if (itp != m_stats.nMarkedPackets.end ())
835  {
836  itp->second++;
837  }
838  else
839  {
840  m_stats.nMarkedPackets[reason] = 1;
841  }
842  // update the amount of bytes marked for the given reason
843  std::map<std::string, uint64_t>::iterator itb = m_stats.nMarkedBytes.find (reason);
844  if (itb != m_stats.nMarkedBytes.end ())
845  {
846  itb->second += item->GetSize ();
847  }
848  else
849  {
850  m_stats.nMarkedBytes[reason] = item->GetSize ();
851  }
852 
853  NS_LOG_DEBUG ("Total packets/bytes marked: "
854  << m_stats.nTotalMarkedPackets << " / "
856  m_traceMark (item, reason);
857  return true;
858 }
859 
860 bool
862 {
863  NS_LOG_FUNCTION (this << item);
864 
866  m_stats.nTotalReceivedBytes += item->GetSize ();
867 
868  bool retval = DoEnqueue (item);
869 
870  if (retval)
871  {
872  item->SetTimeStamp (Simulator::Now ());
873  }
874 
875  // DoEnqueue may return false because:
876  // 1) the internal queue is full
877  // -> the DropBeforeEnqueue method of this queue disc is automatically called
878  // because QueueDisc::AddInternalQueue sets the trace callback
879  // 2) the child queue disc dropped the packet
880  // -> the DropBeforeEnqueue method of this queue disc is automatically called
881  // because QueueDisc::AddQueueDiscClass sets the trace callback
882  // 3) it dropped the packet
883  // -> DoEnqueue has to explicitly call DropBeforeEnqueue
884  // Thus, we do not have to call DropBeforeEnqueue here.
885 
886  // check that the received packet was either enqueued or dropped
891 
892  return retval;
893 }
894 
897 {
898  NS_LOG_FUNCTION (this);
899 
900  // The QueueDisc::DoPeek method dequeues a packet and keeps it as a requeued
901  // packet. Thus, first check whether a peeked packet exists. Otherwise, call
902  // the private DoDequeue method.
904 
905  if (item)
906  {
907  m_requeued = 0;
908  if (m_peeked)
909  {
910  // If the packet was requeued because a peek operation was requested
911  // (which is the case here because DequeuePacket calls Dequeue only
912  // when m_requeued is null), we need to explicitly call PacketDequeued
913  // to update statistics about dequeued packets and fire the dequeue trace.
914  m_peeked = false;
915  PacketDequeued (item);
916  }
917  }
918  else
919  {
920  item = DoDequeue ();
921  }
922 
925 
926  return item;
927 }
928 
931 {
932  NS_LOG_FUNCTION (this);
933  return DoPeek ();
934 }
935 
938 {
939  NS_LOG_FUNCTION (this);
940 
941  if (!m_requeued)
942  {
943  m_peeked = true;
944  m_requeued = Dequeue ();
945  // if no packet is returned, reset the m_peeked flag
946  if (!m_requeued)
947  {
948  m_peeked = false;
949  }
950  }
951  return m_requeued;
952 }
953 
954 void
956 {
957  NS_LOG_FUNCTION (this);
958 
959  if (RunBegin ())
960  {
961  uint32_t quota = m_quota;
962  while (Restart ())
963  {
964  quota -= 1;
965  if (quota <= 0)
966  {
968  break;
969  }
970  }
971  RunEnd ();
972  }
973 }
974 
975 bool
977 {
978  NS_LOG_FUNCTION (this);
979  if (m_running)
980  {
981  return false;
982  }
983 
984  m_running = true;
985  return true;
986 }
987 
988 void
990 {
991  NS_LOG_FUNCTION (this);
992  m_running = false;
993 }
994 
995 bool
997 {
998  NS_LOG_FUNCTION (this);
1000  if (item == 0)
1001  {
1002  NS_LOG_LOGIC ("No packet to send");
1003  return false;
1004  }
1005 
1006  return Transmit (item);
1007 }
1008 
1011 {
1012  NS_LOG_FUNCTION (this);
1013 
1014  Ptr<QueueDiscItem> item;
1015 
1016  // First check if there is a requeued packet
1017  if (m_requeued != 0)
1018  {
1019  // If the queue where the requeued packet is destined to is not stopped, return
1020  // the requeued packet; otherwise, return an empty packet.
1021  // If the device does not support flow control, the device queue is never stopped
1022  if (!m_devQueueIface || !m_devQueueIface->GetTxQueue (m_requeued->GetTxQueueIndex ())->IsStopped ())
1023  {
1024  item = m_requeued;
1025  m_requeued = 0;
1026  if (m_peeked)
1027  {
1028  // If the packet was requeued because a peek operation was requested
1029  // we need to explicitly call PacketDequeued to update statistics
1030  // about dequeued packets and fire the dequeue trace.
1031  m_peeked = false;
1032  PacketDequeued (item);
1033  }
1034  }
1035  }
1036  else
1037  {
1038  // If the device is multi-queue (actually, Linux checks if the queue disc has
1039  // multiple queues), ask the queue disc to dequeue a packet (a multi-queue aware
1040  // queue disc should try not to dequeue a packet destined to a stopped queue).
1041  // Otherwise, ask the queue disc to dequeue a packet only if the (unique) queue
1042  // is not stopped.
1043  if (!m_devQueueIface ||
1044  m_devQueueIface->GetNTxQueues ()>1 || !m_devQueueIface->GetTxQueue (0)->IsStopped ())
1045  {
1046  item = Dequeue ();
1047  // If the item is not null, add the header to the packet.
1048  if (item != 0)
1049  {
1050  item->AddHeader ();
1051  }
1052  // Here, Linux tries bulk dequeues
1053  }
1054  }
1055  return item;
1056 }
1057 
1058 void
1060 {
1061  NS_LOG_FUNCTION (this << item);
1062  m_requeued = item;
1064 
1066  m_stats.nTotalRequeuedBytes += item->GetSize ();
1067 
1068  NS_LOG_LOGIC ("m_traceRequeue (p)");
1069  m_traceRequeue (item);
1070 }
1071 
1072 bool
1074 {
1075  NS_LOG_FUNCTION (this << item);
1076 
1077  // if the device queue is stopped, requeue the packet and return false.
1078  // Note that if the underlying device is tc-unaware, packets are never
1079  // requeued because the queues of tc-unaware devices are never stopped
1080  if (m_devQueueIface && m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
1081  {
1082  Requeue (item);
1083  return false;
1084  }
1085 
1086  // a single queue device makes no use of the priority tag
1087  // a device that does not install a device queue interface likely makes no use of it as well
1088  if (!m_devQueueIface || m_devQueueIface->GetNTxQueues () == 1)
1089  {
1090  SocketPriorityTag priorityTag;
1091  item->GetPacket ()->RemovePacketTag (priorityTag);
1092  }
1093  NS_ASSERT_MSG (m_send, "Send callback not set");
1094  m_send (item);
1095 
1096  // the behavior here slightly diverges from Linux. In Linux, it is advised that
1097  // the function called when a packet needs to be transmitted (ndo_start_xmit)
1098  // should always return NETDEV_TX_OK, which means that the packet is consumed by
1099  // the device driver and thus is not requeued. However, the ndo_start_xmit function
1100  // of the device driver is allowed to return NETDEV_TX_BUSY (and hence the packet
1101  // is requeued) when there is no room for the received packet in the device queue,
1102  // despite the queue is not stopped. This case is considered as a corner case or
1103  // an hard error, and should be avoided.
1104  // Here, we do not handle such corner case and always assume that the packet is
1105  // consumed by the netdevice. Thus, we ignore the value returned by Send and a
1106  // packet sent to a netdevice is never requeued. The reason is that the semantics
1107  // of the value returned by NetDevice::Send does not match that of the value
1108  // returned by ndo_start_xmit.
1109 
1110  // if the queue disc is empty or the device queue is now stopped, return false so
1111  // that the Run method does not attempt to dequeue other packets and exits
1112  if (GetNPackets () == 0 ||
1113  (m_devQueueIface && m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ()))
1114  {
1115  return false;
1116  }
1117 
1118  return true;
1119 }
1120 
1121 } // 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:930
Stats()
constructor
Definition: queue-disc.cc:87
TracedCallback< Time > m_sojourn
Sojourn time of the latest dequeued packet.
Definition: queue-disc.h:702
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: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:710
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:634
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:729
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:861
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
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:377
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:818
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:715
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:744
#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
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:411
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
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:730
#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:165
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
QueueSize m_maxSize
max queue size
Definition: queue-disc.h:703
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:728
Ptr< NetDeviceQueueInterface > GetNetDeviceQueueInterface(void) const
Definition: queue-disc.cc:546
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:574
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
bool m_peeked
A packet was dequeued because Peek was called.
Definition: queue-disc.h:711
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:937
static constexpr const char * CHILD_QUEUE_DISC_MARK
Packet marked by a child queue disc.
Definition: queue-disc.h:518
void AddInternalQueue(Ptr< InternalQueue > queue)
Add an internal queue to the tail of the list of queues.
Definition: queue-disc.cc:581
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:695
std::string m_childQueueDiscDropMsg
Reason why a packet was dropped by a child queue disc.
Definition: queue-disc.h:712
void DoInitialize(void)
Check whether the configuration is correct and initialize parameters.
Definition: queue-disc.cc:400
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:227
Ptr< NetDeviceQueueInterface > m_devQueueIface
NetDevice queue interface.
Definition: queue-disc.h:707
InternalQueueDropFunctor m_internalQueueDbeFunctor
Function object called when an internal queue dropped a packet before enqueue.
Definition: queue-disc.h:740
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Definition: queue-disc.cc:601
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:720
SendCallback m_send
Callback used to send a packet to the receiving object.
Definition: queue-disc.h:708
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:621
indicates whether the socket has a priority set.
Definition: socket.h:1308
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:955
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:1073
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:675
virtual void DoDispose(void)
Dispose of the object.
Definition: queue-disc.cc:383
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:662
std::map< std::string, uint32_t > nMarkedPackets
Marked packets, for each reason.
Definition: queue-disc.h:230
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:289
InternalQueueDropFunctor m_internalQueueDadFunctor
Function object called when an internal queue dropped a packet after dequeue.
Definition: queue-disc.h:742
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:694
Ptr< QueueDiscItem > Dequeue(void)
Extract from the queue disc the packet that has been dequeued by calling Peek, if any...
Definition: queue-disc.cc:896
uint64_t nTotalRequeuedBytes
Total requeued bytes.
Definition: queue-disc.h:226
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:669
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:726
uint32_t m_quota
Maximum number of packets dequeued in a qdisc run.
Definition: queue-disc.h:706
std::string m_childQueueDiscMarkMsg
Reason why a packet was marked by a child queue disc.
Definition: queue-disc.h:713
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:696
SendCallback GetSendCallback(void) const
Definition: queue-disc.cc:560
bool RunBegin(void)
Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h).
Definition: queue-disc.cc:976
TracedCallback< Ptr< const QueueDiscItem > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
Definition: queue-disc.h:718
bool m_running
The queue disc is performing multiple dequeue operations.
Definition: queue-disc.h:709
uint64_t nTotalReceivedBytes
Total received bytes.
Definition: queue-disc.h:190
ChildQueueDiscMarkFunctor m_childQueueDiscMarkFunctor
Function object called when a child queue disc marked a packet.
Definition: queue-disc.h:748
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
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:701
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:1059
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
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:700
void PacketDequeued(Ptr< const QueueDiscItem > item)
Perform the actions required when the queue disc is notified of a packet dequeue. ...
Definition: queue-disc.cc:707
std::vector< Ptr< PacketFilter > > m_filters
Packet filters.
Definition: queue-disc.h:697
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:714
std::size_t GetNPacketFilters(void) const
Get the number of packet filters.
Definition: queue-disc.cc:628
virtual void SetQuota(const uint32_t quota)
Set the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:567
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ChildQueueDiscDropFunctor m_childQueueDiscDadFunctor
Function object called when a child queue disc dropped a packet after dequeue.
Definition: queue-disc.h:746
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:614
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:768
Stats m_stats
The collected statistics.
Definition: queue-disc.h:705
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:724
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:689
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:996
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:553
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
Ptr< QueueDiscItem > DequeuePacket(void)
Modelled after the Linux function dequeue_skb (net/sched/sch_generic.c)
Definition: queue-disc.cc:1010
static TypeId GetTypeId(void)
Get the type ID.
Definition: queue-disc.cc:40
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
TracedCallback< Ptr< const QueueDiscItem > > m_traceRequeue
Traced callback: fired when a packet is requeued.
Definition: queue-disc.h:722
void SetNetDeviceQueueInterface(Ptr< NetDeviceQueueInterface > ndqi)
Definition: queue-disc.cc:539
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:989
std::vector< Ptr< QueueDiscClass > > m_classes
Classes.
Definition: queue-disc.h:698
std::size_t GetNInternalQueues(void) const
Get the number of internal queues.
Definition: queue-disc.cc:608
std::map< std::string, uint32_t > nDroppedPacketsBeforeEnqueue
Packets dropped before enqueue, for each reason.
Definition: queue-disc.h:208