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