26 #include "ns3/packet.h"
27 #include "ns3/object.h"
28 #include "ns3/traced-callback.h"
29 #include "ns3/traced-value.h"
30 #include "ns3/unused.h"
32 #include "ns3/queue-size.h"
33 #include "ns3/queue-item.h"
190 void EnableRunningAverage (
Time averageWindow);
191 void DisableRunningAverage (
void);
193 double GetQueueSizeAverage (
void);
194 double GetReceivedBytesPerSecondAverage (
void);
195 double GetReceivedPacketsPerSecondAverage (
void);
196 double GetDroppedBytesPerSecondAverage (
void);
197 double GetDroppedPacketsPerSecondAverage (
void);
199 double GetQueueSizeVariance (
void);
200 double GetReceivedBytesPerSecondVariance (
void);
201 double GetReceivedPacketsPerSecondVariance (
void);
202 double GetDroppedBytesPerSecondVariance (
void);
203 double GetDroppedPacketsPerSecondVariance (
void);
221 template <
typename Item>
252 template <
typename Item>
308 typedef typename std::list<Ptr<Item> >::iterator
Iterator;
455 template <
typename Item>
459 std::string name = GetTypeParamName<Queue<Item> > ();
460 static TypeId tid =
TypeId ((
"ns3::Queue<" + name +
">").c_str ())
462 .SetGroupName (
"Network")
463 .AddTraceSource (
"Enqueue",
"Enqueue a packet in the queue.",
465 "ns3::" + name +
"::TracedCallback")
466 .AddTraceSource (
"Dequeue",
"Dequeue a packet from the queue.",
468 "ns3::" + name +
"::TracedCallback")
469 .AddTraceSource (
"Drop",
"Drop a packet (for whatever reason).",
471 "ns3::" + name +
"::TracedCallback")
472 .AddTraceSource (
"DropBeforeEnqueue",
"Drop a packet before enqueue.",
474 "ns3::" + name +
"::TracedCallback")
475 .AddTraceSource (
"DropAfterDequeue",
"Drop a packet after dequeue.",
477 "ns3::" + name +
"::TracedCallback")
482 template <
typename Item>
488 template <
typename Item>
493 template <
typename Item>
498 return DoEnqueue (pos, item, ret);
501 template <
typename Item>
507 if (GetCurrentSize () + item > GetMaxSize ())
510 DropBeforeEnqueue (item);
514 ret = m_packets.insert (pos, item);
516 uint32_t size = item->GetSize ();
518 m_nTotalReceivedBytes += size;
521 m_nTotalReceivedPackets++;
524 m_traceEnqueue (item);
529 template <
typename Item>
535 if (m_nPackets.Get () == 0)
542 m_packets.erase (pos);
546 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
549 m_nBytes -= item->GetSize ();
553 m_traceDequeue (item);
558 template <
typename Item>
564 if (m_nPackets.Get () == 0)
571 m_packets.erase (pos);
575 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
578 m_nBytes -= item->GetSize ();
583 m_traceDequeue (item);
585 DropAfterDequeue (item);
590 template <
typename Item>
601 template <
typename Item>
610 template <
typename Item>
616 if (m_nPackets.Get () == 0)
625 template <
typename Item>
628 return m_packets.cbegin ();
631 template <
typename Item>
634 return m_packets.begin ();
637 template <
typename Item>
640 return m_packets.cend ();
643 template <
typename Item>
646 return m_packets.end ();
649 template <
typename Item>
655 m_nTotalDroppedPackets++;
656 m_nTotalDroppedPacketsBeforeEnqueue++;
657 m_nTotalDroppedBytes += item->GetSize ();
658 m_nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
662 m_traceDropBeforeEnqueue (item);
665 template <
typename Item>
671 m_nTotalDroppedPackets++;
672 m_nTotalDroppedPacketsAfterDequeue++;
673 m_nTotalDroppedBytes += item->GetSize ();
674 m_nTotalDroppedBytesAfterDequeue += item->GetSize ();
678 m_traceDropAfterDequeue (item);
A base class which provides memory management and object aggregation.
virtual void DoDispose(void)
Destructor implementation.
Introspection did not find any typical Config paths.
Abstract base class for packet Queues.
uint32_t GetTotalDroppedPacketsBeforeEnqueue(void) const
uint32_t GetTotalDroppedBytes(void) const
uint32_t m_nTotalDroppedBytesBeforeEnqueue
Total dropped bytes before enqueue.
uint32_t GetTotalDroppedPackets(void) const
void ResetStatistics(void)
Resets the counts for dropped packets, dropped bytes, received packets, and received bytes.
TracedValue< uint32_t > m_nPackets
Number of packets in the queue.
uint32_t m_nTotalDroppedPacketsAfterDequeue
Total dropped packets after dequeue.
uint32_t m_nTotalReceivedPackets
Total received packets.
uint32_t GetNPackets(void) const
uint32_t GetTotalDroppedBytesAfterDequeue(void) const
static void AppendItemTypeIfNotPresent(std::string &typeId, const std::string &itemType)
Append the item type to the provided type ID if the latter does not end with '>'.
uint32_t m_nTotalDroppedBytes
Total dropped bytes.
uint32_t m_nTotalDroppedPacketsBeforeEnqueue
Total dropped packets before enqueue.
uint32_t GetTotalDroppedBytesBeforeEnqueue(void) const
QueueSize m_maxSize
max queue size
uint32_t m_nTotalDroppedPackets
Total dropped packets.
uint32_t GetTotalReceivedPackets(void) const
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
uint32_t GetTotalReceivedBytes(void) const
TracedValue< uint32_t > m_nBytes
Number of bytes in the queue.
QueueSize GetCurrentSize(void) const
uint32_t m_nTotalDroppedBytesAfterDequeue
Total dropped bytes after dequeue.
uint32_t m_nTotalReceivedBytes
Total received bytes.
uint32_t GetTotalDroppedPacketsAfterDequeue(void) const
static TypeId GetTypeId(void)
Get the type ID.
uint32_t GetNBytes(void) const
QueueSize GetMaxSize(void) const
Template class for packet Queues.
void DropAfterDequeue(Ptr< Item > item)
Drop a packet after dequeue.
void Flush(void)
Flush the queue by calling Remove() on each item enqueued.
Item ItemType
Define ItemType as the type of the stored elements.
void DropBeforeEnqueue(Ptr< Item > item)
Drop a packet before enqueue.
std::list< Ptr< Item > >::iterator Iterator
Iterator.
virtual Ptr< Item > Remove(void)=0
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as bot...
TracedCallback< Ptr< const Item > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
std::list< Ptr< Item > > m_packets
the items in the queue
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
Iterator end(void)
Get an iterator which indicates past-the-last item in the queue.
virtual Ptr< const Item > Peek(void) const =0
Get a copy of an item in the queue (each subclass defines the position) without removing it.
TracedCallback< Ptr< const Item > > m_traceDropAfterDequeue
Traced callback: fired when a packet is dropped after dequeue.
TracedCallback< Ptr< const Item > > m_traceDropBeforeEnqueue
Traced callback: fired when a packet is dropped before enqueue.
NS_LOG_TEMPLATE_DECLARE
the log component
virtual Ptr< Item > Dequeue(void)=0
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as deq...
Iterator begin(void)
Get an iterator which refers to the first item in the queue.
void DoDispose(void) override
Destructor implementation.
bool DoEnqueue(ConstIterator pos, Ptr< Item > item)
Push an item in the queue.
TracedCallback< Ptr< const Item > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
bool DoEnqueue(ConstIterator pos, Ptr< Item > item, Iterator &ret)
Push an item in the queue.
virtual bool Enqueue(Ptr< Item > item)=0
Place an item into the Queue (each subclass defines the position)
TracedCallback< Ptr< const Item > > m_traceDrop
Traced callback: fired when a packet is dropped.
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
Ptr< const Item > DoPeek(ConstIterator pos) const
Peek the front item in the queue.
std::list< Ptr< Item > >::const_iterator ConstIterator
Const iterator.
ConstIterator begin(void) const
Get a const iterator which refers to the first item in the queue.
ConstIterator end(void) const
Get a const iterator which indicates past-the-last item in the queue.
static TypeId GetTypeId(void)
Get the type ID.
Class for representing queue sizes.
Simulation virtual time values and global simulation resolution.
Forward calls to a chain of Callback.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.