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"
33#include "ns3/queue-fwd.h"
199 void EnableRunningAverage (
Time averageWindow);
200 void DisableRunningAverage (
void);
202 double GetQueueSizeAverage (
void);
203 double GetReceivedBytesPerSecondAverage (
void);
204 double GetReceivedPacketsPerSecondAverage (
void);
205 double GetDroppedBytesPerSecondAverage (
void);
206 double GetDroppedPacketsPerSecondAverage (
void);
208 double GetQueueSizeVariance (
void);
209 double GetReceivedBytesPerSecondVariance (
void);
210 double GetReceivedPacketsPerSecondVariance (
void);
211 double GetDroppedBytesPerSecondVariance (
void);
212 double GetDroppedPacketsPerSecondVariance (
void);
265template <
typename Item,
typename Container>
398 template <
class,
class =
void>
418 struct MakeGetItem<T,
std::void_t<decltype (std::declval<T> ().GetItem (std::declval<ConstIterator> ()))> >
427 return container.GetItem (it);
451template <
typename Item,
typename Container>
455 std::string name = GetTemplateClassName<Queue<Item, Container>> ();
456 auto startPos = name.find (
'<') + 1;
457 auto endPos = name.find_first_of (
",>", startPos);
458 std::string tcbName =
"ns3::" + name.substr (startPos, endPos - startPos) +
"::TracedCallback";
462 .SetGroupName (
"Network")
463 .AddTraceSource (
"Enqueue",
"Enqueue a packet in the queue.",
466 .AddTraceSource (
"Dequeue",
"Dequeue a packet from the queue.",
469 .AddTraceSource (
"Drop",
"Drop a packet (for whatever reason).",
472 .AddTraceSource (
"DropBeforeEnqueue",
"Drop a packet before enqueue.",
475 .AddTraceSource (
"DropAfterDequeue",
"Drop a packet after dequeue.",
482template <
typename Item,
typename Container>
488template <
typename Item,
typename Container>
493template <
typename Item,
typename Container>
500template <
typename Item,
typename Container>
505 return DoEnqueue (pos, item, ret);
508template <
typename Item,
typename Container>
514 if (GetCurrentSize () + item > GetMaxSize ())
517 DropBeforeEnqueue (item);
521 ret = m_packets.insert (pos, item);
525 m_nTotalReceivedBytes += size;
528 m_nTotalReceivedPackets++;
531 m_traceEnqueue (item);
536template <
typename Item,
typename Container>
542 if (m_nPackets.Get () == 0)
552 m_packets.erase (pos);
553 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
556 m_nBytes -= item->GetSize ();
560 m_traceDequeue (item);
565template <
typename Item,
typename Container>
571 if (m_nPackets.Get () == 0)
581 m_packets.erase (pos);
582 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
585 m_nBytes -= item->GetSize ();
590 m_traceDequeue (item);
592 DropAfterDequeue (item);
597template <
typename Item,
typename Container>
608template <
typename Item,
typename Container>
617template <
typename Item,
typename Container>
623 if (m_nPackets.Get () == 0)
632template <
typename Item,
typename Container>
638 m_nTotalDroppedPackets++;
639 m_nTotalDroppedPacketsBeforeEnqueue++;
640 m_nTotalDroppedBytes += item->GetSize ();
641 m_nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
645 m_traceDropBeforeEnqueue (item);
648template <
typename Item,
typename Container>
654 m_nTotalDroppedPackets++;
655 m_nTotalDroppedPacketsAfterDequeue++;
656 m_nTotalDroppedBytes += item->GetSize ();
657 m_nTotalDroppedBytesAfterDequeue += item->GetSize ();
661 m_traceDropAfterDequeue (item);
A base class which provides memory management and object aggregation.
virtual void DoDispose(void)
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
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.
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
static TypeId GetTypeId(void)
Get the type ID.
bool DoEnqueue(ConstIterator pos, Ptr< Item > item, Iterator &ret)
Push an item in the queue.
virtual Ptr< Item > Dequeue(void)=0
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as deq...
TracedCallback< Ptr< const Item > > m_traceDrop
Traced callback: fired when a packet is dropped.
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
Container m_packets
the items in the queue
TracedCallback< Ptr< const Item > > m_traceDropAfterDequeue
Traced callback: fired when a packet is dropped after dequeue.
bool DoEnqueue(ConstIterator pos, Ptr< Item > item)
Push an item in the queue.
Ptr< const Item > DoPeek(ConstIterator pos) const
Peek the front item in the queue.
void DropAfterDequeue(Ptr< Item > item)
Drop a packet after dequeue.
TracedCallback< Ptr< const Item > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
virtual bool Enqueue(Ptr< Item > item)=0
Place an item into the Queue (each subclass defines the position)
TracedCallback< Ptr< const Item > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
const Container & GetContainer(void) const
Get a const reference to the container of queue items.
void DropBeforeEnqueue(Ptr< Item > item)
Drop a packet before enqueue.
void Flush(void)
Flush the queue by calling Remove() on each item enqueued.
void DoDispose(void) override
Destructor implementation.
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.
Container::iterator Iterator
Iterator.
TracedCallback< Ptr< const Item > > m_traceDropBeforeEnqueue
Traced callback: fired when a packet is dropped before enqueue.
Container::const_iterator ConstIterator
Const 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...
Item ItemType
Define ItemType as the type of the stored elements.
NS_LOG_TEMPLATE_DECLARE
the log component
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.
static Ptr< Item > GetItem(const Container &container, const ConstIterator it)
Struct providing a static method returning the object stored within the queue that is included in the...
static Ptr< Item > GetItem(const Container &, const ConstIterator it)