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