26 #include "ns3/packet.h"
27 #include "ns3/object.h"
28 #include "ns3/traced-callback.h"
29 #include "ns3/traced-value.h"
31 #include "ns3/queue-size.h"
32 #include "ns3/queue-item.h"
188 bool WouldOverflow (uint32_t nPackets, uint32_t nBytes)
const;
198 void EnableRunningAverage (
Time averageWindow);
199 void DisableRunningAverage (
void);
201 double GetQueueSizeAverage (
void);
202 double GetReceivedBytesPerSecondAverage (
void);
203 double GetReceivedPacketsPerSecondAverage (
void);
204 double GetDroppedBytesPerSecondAverage (
void);
205 double GetDroppedPacketsPerSecondAverage (
void);
207 double GetQueueSizeVariance (
void);
208 double GetReceivedBytesPerSecondVariance (
void);
209 double GetReceivedPacketsPerSecondVariance (
void);
210 double GetDroppedBytesPerSecondVariance (
void);
211 double GetDroppedPacketsPerSecondVariance (
void);
229 template <
typename Item>
260 template <
typename Item>
316 typedef typename std::list<Ptr<Item> >::iterator
Iterator;
463 template <
typename Item>
467 std::string name = GetTypeParamName<Queue<Item> > ();
470 .SetGroupName (
"Network")
471 .AddTraceSource (
"Enqueue",
"Enqueue a packet in the queue.",
473 "ns3::" + name +
"::TracedCallback")
474 .AddTraceSource (
"Dequeue",
"Dequeue a packet from the queue.",
476 "ns3::" + name +
"::TracedCallback")
477 .AddTraceSource (
"Drop",
"Drop a packet (for whatever reason).",
479 "ns3::" + name +
"::TracedCallback")
480 .AddTraceSource (
"DropBeforeEnqueue",
"Drop a packet before enqueue.",
482 "ns3::" + name +
"::TracedCallback")
483 .AddTraceSource (
"DropAfterDequeue",
"Drop a packet after dequeue.",
485 "ns3::" + name +
"::TracedCallback")
490 template <
typename Item>
496 template <
typename Item>
501 template <
typename Item>
506 return DoEnqueue (pos, item, ret);
509 template <
typename Item>
515 if (GetCurrentSize () + item > GetMaxSize ())
518 DropBeforeEnqueue (item);
522 ret = m_packets.insert (pos, item);
524 uint32_t size = item->GetSize ();
526 m_nTotalReceivedBytes += size;
529 m_nTotalReceivedPackets++;
532 m_traceEnqueue (item);
537 template <
typename Item>
543 if (m_nPackets.Get () == 0)
550 m_packets.erase (pos);
554 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
557 m_nBytes -= item->GetSize ();
561 m_traceDequeue (item);
566 template <
typename Item>
572 if (m_nPackets.Get () == 0)
579 m_packets.erase (pos);
583 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
586 m_nBytes -= item->GetSize ();
591 m_traceDequeue (item);
593 DropAfterDequeue (item);
598 template <
typename Item>
609 template <
typename Item>
618 template <
typename Item>
624 if (m_nPackets.Get () == 0)
633 template <
typename Item>
636 return m_packets.cbegin ();
639 template <
typename Item>
642 return m_packets.begin ();
645 template <
typename Item>
648 return m_packets.cend ();
651 template <
typename Item>
654 return m_packets.end ();
657 template <
typename Item>
663 m_nTotalDroppedPackets++;
664 m_nTotalDroppedPacketsBeforeEnqueue++;
665 m_nTotalDroppedBytes += item->GetSize ();
666 m_nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
670 m_traceDropBeforeEnqueue (item);
673 template <
typename Item>
679 m_nTotalDroppedPackets++;
680 m_nTotalDroppedPacketsAfterDequeue++;
681 m_nTotalDroppedBytes += item->GetSize ();
682 m_nTotalDroppedBytesAfterDequeue += item->GetSize ();
686 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.
bool WouldOverflow(uint32_t nPackets, uint32_t nBytes) const
Check if the queue would overflow with additional bytes or packets Note: the check is performed accor...
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.