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