A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
32namespace ns3
33{
34
35NS_LOG_COMPONENT_DEFINE("QueueDisc");
36
37NS_OBJECT_ENSURE_REGISTERED(QueueDiscClass);
38
39TypeId
41{
42 static TypeId tid = TypeId("ns3::QueueDiscClass")
44 .SetGroupName("TrafficControl")
45 .AddConstructor<QueueDiscClass>()
46 .AddAttribute("QueueDisc",
47 "The queue disc attached to the class",
50 MakePointerChecker<QueueDisc>());
51 return tid;
52}
53
55{
56 NS_LOG_FUNCTION(this);
57}
58
60{
61 NS_LOG_FUNCTION(this);
62}
63
64void
66{
67 NS_LOG_FUNCTION(this);
68 m_queueDisc = nullptr;
70}
71
74{
75 NS_LOG_FUNCTION(this);
76 return m_queueDisc;
77}
78
79void
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
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
131uint64_t
132QueueDisc::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
153QueueDisc::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
165uint64_t
166QueueDisc::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
178void
179QueueDisc::Stats::Print(std::ostream& os) const
180{
181 std::map<std::string, uint32_t>::const_iterator itp;
182 std::map<std::string, uint64_t>::const_iterator itb;
183
184 os << std::endl
185 << "Packets/Bytes received: " << nTotalReceivedPackets << " / " << nTotalReceivedBytes
186 << std::endl
187 << "Packets/Bytes enqueued: " << nTotalEnqueuedPackets << " / " << nTotalEnqueuedBytes
188 << std::endl
189 << "Packets/Bytes dequeued: " << nTotalDequeuedPackets << " / " << nTotalDequeuedBytes
190 << std::endl
191 << "Packets/Bytes requeued: " << nTotalRequeuedPackets << " / " << nTotalRequeuedBytes
192 << std::endl
193 << "Packets/Bytes dropped: " << nTotalDroppedPackets << " / " << nTotalDroppedBytes
194 << std::endl
195 << "Packets/Bytes dropped before enqueue: " << nTotalDroppedPacketsBeforeEnqueue << " / "
196 << nTotalDroppedBytesBeforeEnqueue;
197
198 itp = nDroppedPacketsBeforeEnqueue.begin();
199 itb = nDroppedBytesBeforeEnqueue.begin();
200
201 while (itp != nDroppedPacketsBeforeEnqueue.end() && itb != nDroppedBytesBeforeEnqueue.end())
202 {
203 NS_ASSERT(itp->first == itb->first);
204 os << std::endl << " " << itp->first << ": " << itp->second << " / " << itb->second;
205 itp++;
206 itb++;
207 }
208
209 os << std::endl
210 << "Packets/Bytes dropped after dequeue: " << nTotalDroppedPacketsAfterDequeue << " / "
211 << nTotalDroppedBytesAfterDequeue;
212
213 itp = nDroppedPacketsAfterDequeue.begin();
214 itb = nDroppedBytesAfterDequeue.begin();
215
216 while (itp != nDroppedPacketsAfterDequeue.end() && itb != nDroppedBytesAfterDequeue.end())
217 {
218 NS_ASSERT(itp->first == itb->first);
219 os << std::endl << " " << itp->first << ": " << itp->second << " / " << itb->second;
220 itp++;
221 itb++;
222 }
223
224 os << std::endl
225 << "Packets/Bytes sent: " << nTotalSentPackets << " / " << nTotalSentBytes << std::endl
226 << "Packets/Bytes marked: " << nTotalMarkedPackets << " / " << nTotalMarkedBytes;
227
228 itp = nMarkedPackets.begin();
229 itb = nMarkedBytes.begin();
230
231 while (itp != nMarkedPackets.end() && itb != nMarkedBytes.end())
232 {
233 NS_ASSERT(itp->first == itb->first);
234 os << std::endl << " " << itp->first << ": " << itp->second << " / " << itb->second;
235 itp++;
236 itb++;
237 }
238
239 os << std::endl;
240}
241
242std::ostream&
243operator<<(std::ostream& os, const QueueDisc::Stats& stats)
244{
245 stats.Print(os);
246 return os;
247}
248
250
251TypeId
253{
254 static TypeId tid =
255 TypeId("ns3::QueueDisc")
256 .SetParent<Object>()
257 .SetGroupName("TrafficControl")
258 .AddAttribute("Quota",
259 "The maximum number of packets dequeued in a qdisc run",
262 MakeUintegerChecker<uint32_t>())
263 .AddAttribute("InternalQueueList",
264 "The list of internal queues.",
267 MakeObjectVectorChecker<InternalQueue>())
268 .AddAttribute("PacketFilterList",
269 "The list of packet filters.",
272 MakeObjectVectorChecker<PacketFilter>())
273 .AddAttribute("QueueDiscClassList",
274 "The list of queue disc classes.",
277 MakeObjectVectorChecker<QueueDiscClass>())
278 .AddTraceSource("Enqueue",
279 "Enqueue a packet in the queue disc",
281 "ns3::QueueDiscItem::TracedCallback")
282 .AddTraceSource("Dequeue",
283 "Dequeue a packet from the queue disc",
285 "ns3::QueueDiscItem::TracedCallback")
286 .AddTraceSource("Requeue",
287 "Requeue a packet in the queue disc",
289 "ns3::QueueDiscItem::TracedCallback")
290 .AddTraceSource("Drop",
291 "Drop a packet stored in the queue disc",
293 "ns3::QueueDiscItem::TracedCallback")
294 .AddTraceSource("DropBeforeEnqueue",
295 "Drop a packet before enqueue",
297 "ns3::QueueDiscItem::TracedCallback")
298 .AddTraceSource("DropAfterDequeue",
299 "Drop a packet after dequeue",
301 "ns3::QueueDiscItem::TracedCallback")
302 .AddTraceSource("Mark",
303 "Mark a packet stored in the queue disc",
305 "ns3::QueueDiscItem::TracedCallback")
306 .AddTraceSource("PacketsInQueue",
307 "Number of packets currently stored in the queue disc",
309 "ns3::TracedValueCallback::Uint32")
310 .AddTraceSource("BytesInQueue",
311 "Number of bytes currently stored in the queue disc",
313 "ns3::TracedValueCallback::Uint32")
314 .AddTraceSource("SojournTime",
315 "Sojourn time of the last packet dequeued from the queue disc",
317 "ns3::Time::TracedCallback");
318 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.
339 };
342 };
343
344 // These lambdas call the DropBeforeEnqueue or DropAfterDequeue methods of this
345 // QueueDisc object. Given that a callback to the operator() of these lambdas
346 // is connected to the DropBeforeEnqueue and DropAfterDequeue traces of the
347 // child queue discs, the concatenation of the CHILD_QUEUE_DISC_DROP constant
348 // and the second argument provided by such traces is passed as the reason why
349 // the packet is dropped.
350 m_childQueueDiscDbeFunctor = [this](Ptr<const QueueDiscItem> item, const char* r) {
351 return DropBeforeEnqueue(
352 item,
353 m_childQueueDiscDropMsg.assign(CHILD_QUEUE_DISC_DROP).append(r).data());
354 };
355 m_childQueueDiscDadFunctor = [this](Ptr<const QueueDiscItem> item, const char* r) {
356 return DropAfterDequeue(
357 item,
358 m_childQueueDiscDropMsg.assign(CHILD_QUEUE_DISC_DROP).append(r).data());
359 };
360 m_childQueueDiscMarkFunctor = [this](Ptr<const QueueDiscItem> item, const char* r) {
361 return Mark(const_cast<QueueDiscItem*>(PeekPointer(item)),
362 m_childQueueDiscMarkMsg.assign(CHILD_QUEUE_DISC_MARK).append(r).data());
363 };
364}
365
367 : QueueDisc(policy)
368{
369 m_maxSize = QueueSize(unit, 0);
371}
372
374{
375 NS_LOG_FUNCTION(this);
376}
377
378void
380{
381 NS_LOG_FUNCTION(this);
382 m_queues.clear();
383 m_filters.clear();
384 m_classes.clear();
385 m_devQueueIface = nullptr;
386 m_send = nullptr;
387 m_requeued = nullptr;
393}
394
395void
397{
398 NS_LOG_FUNCTION(this);
399
400 // Check the configuration and initialize the parameters of this queue disc
401 bool ok [[maybe_unused]] = CheckConfig();
402 NS_ASSERT_MSG(ok, "The queue disc configuration is not correct");
404
405 // Check the configuration and initialize the parameters of the child queue discs
406 for (std::vector<Ptr<QueueDiscClass>>::iterator cl = m_classes.begin(); cl != m_classes.end();
407 cl++)
408 {
409 (*cl)->GetQueueDisc()->Initialize();
410 }
411
413}
414
415const QueueDisc::Stats&
417{
422
423 // the total number of sent packets is only updated here to avoid to increase it
424 // after a dequeue and then having to decrease it if the packet is dropped after
425 // dequeue or requeued
429 (m_requeued ? m_requeued->GetSize() : 0) -
431
432 return m_stats;
433}
434
437{
438 NS_LOG_FUNCTION(this);
439 return m_nPackets;
440}
441
444{
445 NS_LOG_FUNCTION(this);
446 return m_nBytes;
447}
448
451{
452 NS_LOG_FUNCTION(this);
453
454 switch (m_sizePolicy)
455 {
457 NS_FATAL_ERROR("The size of this queue disc is not limited");
458
460 if (GetNInternalQueues())
461 {
462 return GetInternalQueue(0)->GetMaxSize();
463 }
464
467 {
468 return GetQueueDiscClass(0)->GetQueueDisc()->GetMaxSize();
469 }
470
472 default:
473 return m_maxSize;
474 }
475}
476
477bool
479{
480 NS_LOG_FUNCTION(this << size);
481
482 // do nothing if the limit is null
483 if (!size.GetValue())
484 {
485 return false;
486 }
487
489 {
490 NS_LOG_DEBUG("Changing the mode of this queue disc is prohibited");
491 return false;
492 }
493
494 switch (m_sizePolicy)
495 {
497 NS_FATAL_ERROR("The size of this queue disc is not limited");
498
500 if (GetNInternalQueues())
501 {
502 GetInternalQueue(0)->SetMaxSize(size);
503 }
504
507 {
508 GetQueueDiscClass(0)->GetQueueDisc()->SetMaxSize(size);
509 }
510
512 default:
513 m_maxSize = size;
514 }
515 return true;
516}
517
520{
521 NS_LOG_FUNCTION(this);
522
523 if (GetMaxSize().GetUnit() == QueueSizeUnit::PACKETS)
524 {
526 }
527 if (GetMaxSize().GetUnit() == QueueSizeUnit::BYTES)
528 {
530 }
531 NS_ABORT_MSG("Unknown queue size unit");
532}
533
534void
536{
537 NS_LOG_FUNCTION(this << ndqi);
538 m_devQueueIface = ndqi;
539}
540
543{
544 NS_LOG_FUNCTION(this);
545 return m_devQueueIface;
546}
547
548void
550{
551 NS_LOG_FUNCTION(this);
552 m_send = func;
553}
554
557{
558 NS_LOG_FUNCTION(this);
559 return m_send;
560}
561
562void
564{
565 NS_LOG_FUNCTION(this << quota);
566 m_quota = quota;
567}
568
571{
572 NS_LOG_FUNCTION(this);
573 return m_quota;
574}
575
576void
578{
579 NS_LOG_FUNCTION(this);
580
581 // set various callbacks on the internal queue, so that the queue disc is
582 // notified of packets enqueued, dequeued or dropped by the internal queue
583 queue->TraceConnectWithoutContext("Enqueue", MakeCallback(&QueueDisc::PacketEnqueued, this));
584 queue->TraceConnectWithoutContext("Dequeue", MakeCallback(&QueueDisc::PacketDequeued, this));
585 queue->TraceConnectWithoutContext(
586 "DropBeforeEnqueue",
587 MakeCallback(&InternalQueueDropFunctor::operator(), &m_internalQueueDbeFunctor));
588 queue->TraceConnectWithoutContext(
589 "DropAfterDequeue",
590 MakeCallback(&InternalQueueDropFunctor::operator(), &m_internalQueueDadFunctor));
591 m_queues.push_back(queue);
592}
593
595QueueDisc::GetInternalQueue(std::size_t i) const
596{
597 NS_ASSERT(i < m_queues.size());
598 return m_queues[i];
599}
600
601std::size_t
603{
604 return m_queues.size();
605}
606
607void
609{
610 NS_LOG_FUNCTION(this);
611 m_filters.push_back(filter);
612}
613
615QueueDisc::GetPacketFilter(std::size_t i) const
616{
617 NS_ASSERT(i < m_filters.size());
618 return m_filters[i];
619}
620
621std::size_t
623{
624 return m_filters.size();
625}
626
627void
629{
630 NS_LOG_FUNCTION(this);
631 NS_ABORT_MSG_IF(!qdClass->GetQueueDisc(), "Cannot add a class with no attached queue disc");
632 // the child queue disc cannot be one with wake mode equal to WAKE_CHILD because
633 // such queue discs do not implement the enqueue/dequeue methods
634 NS_ABORT_MSG_IF(qdClass->GetQueueDisc()->GetWakeMode() == WAKE_CHILD,
635 "A queue disc with WAKE_CHILD as wake mode can only be a root queue disc");
636
637 // set the parent callbacks on the child queue disc, so that it can notify
638 // the parent queue disc of packets enqueued, dequeued, dropped, or marked
639 qdClass->GetQueueDisc()->TraceConnectWithoutContext(
640 "Enqueue",
642 qdClass->GetQueueDisc()->TraceConnectWithoutContext(
643 "Dequeue",
645 qdClass->GetQueueDisc()->TraceConnectWithoutContext(
646 "DropBeforeEnqueue",
647 MakeCallback(&ChildQueueDiscDropFunctor::operator(), &m_childQueueDiscDbeFunctor));
648 qdClass->GetQueueDisc()->TraceConnectWithoutContext(
649 "DropAfterDequeue",
650 MakeCallback(&ChildQueueDiscDropFunctor::operator(), &m_childQueueDiscDadFunctor));
651 qdClass->GetQueueDisc()->TraceConnectWithoutContext(
652 "Mark",
653 MakeCallback(&ChildQueueDiscMarkFunctor::operator(), &m_childQueueDiscMarkFunctor));
654 m_classes.push_back(qdClass);
655}
656
659{
660 NS_ASSERT(i < m_classes.size());
661 return m_classes[i];
662}
663
664std::size_t
666{
667 return m_classes.size();
668}
669
672{
673 NS_LOG_FUNCTION(this << item);
674
676 for (std::vector<Ptr<PacketFilter>>::iterator f = m_filters.begin();
677 f != m_filters.end() && ret == PacketFilter::PF_NO_MATCH;
678 f++)
679 {
680 ret = (*f)->Classify(item);
681 }
682 return ret;
683}
684
687{
688 return WAKE_ROOT;
689}
690
691void
693{
694 m_nPackets++;
695 m_nBytes += item->GetSize();
697 m_stats.nTotalEnqueuedBytes += item->GetSize();
698
699 NS_LOG_LOGIC("m_traceEnqueue (p)");
700 m_traceEnqueue(item);
701}
702
703void
705{
706 // If the queue disc asked the internal queue or the child queue disc to
707 // dequeue a packet because a peek operation was requested, the packet is
708 // still held by the queue disc, hence we do not need to update statistics
709 // and fire the dequeue trace. This function will be explicitly called when
710 // the packet will be actually dequeued.
711 if (!m_peeked)
712 {
713 m_nPackets--;
714 m_nBytes -= item->GetSize();
716 m_stats.nTotalDequeuedBytes += item->GetSize();
717
718 m_sojourn(Simulator::Now() - item->GetTimeStamp());
719
720 NS_LOG_LOGIC("m_traceDequeue (p)");
721 m_traceDequeue(item);
722 }
723}
724
725void
727{
728 NS_LOG_FUNCTION(this << item << reason);
729
731 m_stats.nTotalDroppedBytes += item->GetSize();
733 m_stats.nTotalDroppedBytesBeforeEnqueue += item->GetSize();
734
735 // update the number of packets dropped for the given reason
736 std::map<std::string, uint32_t>::iterator itp =
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 =
778 if (itp != m_stats.nDroppedPacketsAfterDequeue.end())
779 {
780 itp->second++;
781 }
782 else
783 {
785 }
786 // update the amount of bytes dropped for the given reason
787 std::map<std::string, uint64_t>::iterator itb = m_stats.nDroppedBytesAfterDequeue.find(reason);
788 if (itb != m_stats.nDroppedBytesAfterDequeue.end())
789 {
790 itb->second += item->GetSize();
791 }
792 else
793 {
794 m_stats.nDroppedBytesAfterDequeue[reason] = item->GetSize();
795 }
796
797 // if in the context of a peek request a dequeued packet is dropped, we need
798 // to update the statistics and fire the dequeue trace before firing the drop
799 // after dequeue trace
800 if (m_peeked)
801 {
802 // temporarily set m_peeked to false, otherwise PacketDequeued does nothing
803 m_peeked = false;
804 PacketDequeued(item);
805 m_peeked = true;
806 }
807
808 NS_LOG_DEBUG("Total packets/bytes dropped after dequeue: "
811 NS_LOG_LOGIC("m_traceDropAfterDequeue (p)");
812 m_traceDrop(item);
813 m_traceDropAfterDequeue(item, reason);
814}
815
816bool
817QueueDisc::Mark(Ptr<QueueDiscItem> item, const char* reason)
818{
819 NS_LOG_FUNCTION(this << item << reason);
820
821 bool retval = item->Mark();
822
823 if (!retval)
824 {
825 return false;
826 }
827
829 m_stats.nTotalMarkedBytes += item->GetSize();
830
831 // update the number of packets marked for the given reason
832 std::map<std::string, uint32_t>::iterator itp = m_stats.nMarkedPackets.find(reason);
833 if (itp != m_stats.nMarkedPackets.end())
834 {
835 itp->second++;
836 }
837 else
838 {
839 m_stats.nMarkedPackets[reason] = 1;
840 }
841 // update the amount of bytes marked for the given reason
842 std::map<std::string, uint64_t>::iterator itb = m_stats.nMarkedBytes.find(reason);
843 if (itb != m_stats.nMarkedBytes.end())
844 {
845 itb->second += item->GetSize();
846 }
847 else
848 {
849 m_stats.nMarkedBytes[reason] = item->GetSize();
850 }
851
852 NS_LOG_DEBUG("Total packets/bytes marked: " << 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 = nullptr;
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;
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)
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)
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 ||
1021 !m_devQueueIface->GetTxQueue(m_requeued->GetTxQueueIndex())->IsStopped())
1022 {
1023 item = m_requeued;
1024 m_requeued = nullptr;
1025 if (m_peeked)
1026 {
1027 // If the packet was requeued because a peek operation was requested
1028 // we need to explicitly call PacketDequeued to update statistics
1029 // about dequeued packets and fire the dequeue trace.
1030 m_peeked = false;
1031 PacketDequeued(item);
1032 }
1033 }
1034 }
1035 else
1036 {
1037 // If the device is multi-queue (actually, Linux checks if the queue disc has
1038 // multiple queues), ask the queue disc to dequeue a packet (a multi-queue aware
1039 // queue disc should try not to dequeue a packet destined to a stopped queue).
1040 // Otherwise, ask the queue disc to dequeue a packet only if the (unique) queue
1041 // is not stopped.
1042 if (!m_devQueueIface || m_devQueueIface->GetNTxQueues() > 1 ||
1043 !m_devQueueIface->GetTxQueue(0)->IsStopped())
1044 {
1045 item = Dequeue();
1046 // If the item is not null, add the header to the packet.
1047 if (item)
1048 {
1049 item->AddHeader();
1050 }
1051 // Here, Linux tries bulk dequeues
1052 }
1053 }
1054 return item;
1055}
1056
1057void
1059{
1060 NS_LOG_FUNCTION(this << item);
1061 m_requeued = item;
1063
1065 m_stats.nTotalRequeuedBytes += item->GetSize();
1066
1067 NS_LOG_LOGIC("m_traceRequeue (p)");
1068 m_traceRequeue(item);
1069}
1070
1071bool
1073{
1074 NS_LOG_FUNCTION(this << item);
1075
1076 // if the device queue is stopped, requeue the packet and return false.
1077 // Note that if the underlying device is tc-unaware, packets are never
1078 // requeued because the queues of tc-unaware devices are never stopped
1079 if (m_devQueueIface && m_devQueueIface->GetTxQueue(item->GetTxQueueIndex())->IsStopped())
1080 {
1081 Requeue(item);
1082 return false;
1083 }
1084
1085 // a single queue device makes no use of the priority tag
1086 // a device that does not install a device queue interface likely makes no use of it as well
1087 if (!m_devQueueIface || m_devQueueIface->GetNTxQueues() == 1)
1088 {
1089 SocketPriorityTag priorityTag;
1090 item->GetPacket()->RemovePacketTag(priorityTag);
1091 }
1092 NS_ASSERT_MSG(m_send, "Send callback not set");
1093 m_send(item);
1094
1095 // the behavior here slightly diverges from Linux. In Linux, it is advised that
1096 // the function called when a packet needs to be transmitted (ndo_start_xmit)
1097 // should always return NETDEV_TX_OK, which means that the packet is consumed by
1098 // the device driver and thus is not requeued. However, the ndo_start_xmit function
1099 // of the device driver is allowed to return NETDEV_TX_BUSY (and hence the packet
1100 // is requeued) when there is no room for the received packet in the device queue,
1101 // despite the queue is not stopped. This case is considered as a corner case or
1102 // an hard error, and should be avoided.
1103 // Here, we do not handle such corner case and always assume that the packet is
1104 // consumed by the netdevice. Thus, we ignore the value returned by Send and a
1105 // packet sent to a netdevice is never requeued. The reason is that the semantics
1106 // of the value returned by NetDevice::Send does not match that of the value
1107 // returned by ndo_start_xmit.
1108
1109 // if the queue disc is empty or the device queue is now stopped, return false so
1110 // that the Run method does not attempt to dequeue other packets and exits
1111 return !(
1112 GetNPackets() == 0 ||
1113 (m_devQueueIface && m_devQueueIface->GetTxQueue(item->GetTxQueueIndex())->IsStopped()));
1114}
1115
1116} // 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:360
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
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
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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:577
virtual uint32_t GetQuota() const
Get the maximum number of dequeue operations following a packet enqueue.
Definition: queue-disc.cc:570
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:535
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
Definition: queue-disc.cc:628
QueueSize m_maxSize
max queue size
Definition: queue-disc.h:697
QueueSize GetCurrentSize()
Get the current size of the queue disc in bytes, if operating in bytes mode, or packets,...
Definition: queue-disc.cc:519
SendCallback GetSendCallback() const
Definition: queue-disc.cc:556
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:436
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:1072
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:443
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:321
Ptr< InternalQueue > GetInternalQueue(std::size_t i) const
Get the i-th internal queue.
Definition: queue-disc.cc:595
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:1058
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:608
TracedCallback< Ptr< const QueueDiscItem > > m_traceDrop
Traced callback: fired when a packet is dropped.
Definition: queue-disc.h:718
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:935
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:671
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:692
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:396
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:542
void Run()
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets,...
Definition: queue-disc.cc:953
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:766
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:987
std::size_t GetNQueueDiscClasses() const
Get the number of queue disc classes.
Definition: queue-disc.cc:665
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:416
bool Restart()
Modelled after the Linux function qdisc_restart (net/sched/sch_generic.c) Dequeue a packet (by callin...
Definition: queue-disc.cc:994
QueueSize GetMaxSize() const
Get the maximum size of the queue disc.
Definition: queue-disc.cc:450
Ptr< QueueDiscClass > GetQueueDiscClass(std::size_t i) const
Get the i-th queue disc class.
Definition: queue-disc.cc:658
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:622
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:563
bool RunBegin()
Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h).
Definition: queue-disc.cc:974
bool SetMaxSize(QueueSize size)
Set the maximum size of the queue disc.
Definition: queue-disc.cc:478
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:602
static TypeId GetTypeId()
Get the type ID.
Definition: queue-disc.cc:252
void DoDispose() override
Dispose of the object.
Definition: queue-disc.cc:379
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:686
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:1008
Ptr< QueueDiscItem > Dequeue()
Extract from the queue disc the packet that has been dequeued by calling Peek, if any,...
Definition: queue-disc.cc:894
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:928
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
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:817
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:726
Ptr< PacketFilter > GetPacketFilter(std::size_t i) const
Get the i-th packet filter.
Definition: queue-disc.cc:615
void PacketDequeued(Ptr< const QueueDiscItem > item)
Perform the actions required when the queue disc is notified of a packet dequeue.
Definition: queue-disc.cc:704
virtual Ptr< QueueDiscItem > DoDequeue()=0
This function actually extracts a packet from the queue disc.
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:549
~QueueDisc() override
Definition: queue-disc.cc:373
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:199
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:936
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
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 > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#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.
U * PeekPointer(const Ptr< U > &p)
Definition: ptr.h:488
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:702
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
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