30#include "ns3/object.h" 
   31#include "ns3/packet.h" 
   32#include "ns3/traced-callback.h" 
   33#include "ns3/traced-value.h" 
  201  void EnableRunningAverage(
Time averageWindow);
 
  202  void DisableRunningAverage();
 
  204  double GetQueueSizeAverage();
 
  205  double GetReceivedBytesPerSecondAverage();
 
  206  double GetReceivedPacketsPerSecondAverage();
 
  207  double GetDroppedBytesPerSecondAverage();
 
  208  double GetDroppedPacketsPerSecondAverage();
 
  210  double GetQueueSizeVariance();
 
  211  double GetReceivedBytesPerSecondVariance();
 
  212  double GetReceivedPacketsPerSecondVariance();
 
  213  double GetDroppedBytesPerSecondVariance();
 
  214  double GetDroppedPacketsPerSecondVariance();
 
  266template <
typename Item, 
typename Container>
 
  399    template <
class, 
class = 
void>
 
  421        std::void_t<decltype(std::declval<T>().GetItem(std::declval<ConstIterator>()))>>
 
  430            return container.GetItem(it);
 
  453template <
typename Item, 
typename Container>
 
  457    std::string name = GetTemplateClassName<Queue<Item, Container>>();
 
  458    auto startPos = name.find(
'<') + 1;
 
  459    auto endPos = name.find_first_of(
",>", startPos);
 
  460    std::string tcbName = 
"ns3::" + name.substr(startPos, endPos - startPos) + 
"::TracedCallback";
 
  465            .SetGroupName(
"Network")
 
  466            .AddTraceSource(
"Enqueue",
 
  467                            "Enqueue a packet in the queue.",
 
  470            .AddTraceSource(
"Dequeue",
 
  471                            "Dequeue a packet from the queue.",
 
  474            .AddTraceSource(
"Drop",
 
  475                            "Drop a packet (for whatever reason).",
 
  480                "Drop a packet before enqueue.",
 
  485                "Drop a packet after dequeue.",
 
  491template <
typename Item, 
typename Container>
 
  497template <
typename Item, 
typename Container>
 
  502template <
typename Item, 
typename Container>
 
  509template <
typename Item, 
typename Container>
 
  514    return DoEnqueue(pos, item, ret);
 
  517template <
typename Item, 
typename Container>
 
  523    if (GetCurrentSize() + item > GetMaxSize())
 
  526        DropBeforeEnqueue(item);
 
  530    ret = m_packets.insert(pos, item);
 
  534    m_nTotalReceivedBytes += size;
 
  537    m_nTotalReceivedPackets++;
 
  540    m_traceEnqueue(item);
 
  545template <
typename Item, 
typename Container>
 
  551    if (m_nPackets.Get() == 0)
 
  561        m_packets.erase(pos);
 
  562        NS_ASSERT(m_nBytes.Get() >= item->GetSize());
 
  565        m_nBytes -= item->GetSize();
 
  569        m_traceDequeue(item);
 
  574template <
typename Item, 
typename Container>
 
  580    if (m_nPackets.Get() == 0)
 
  590        m_packets.erase(pos);
 
  591        NS_ASSERT(m_nBytes.Get() >= item->GetSize());
 
  594        m_nBytes -= item->GetSize();
 
  599        m_traceDequeue(item);
 
  601        DropAfterDequeue(item);
 
  606template <
typename Item, 
typename Container>
 
  617template <
typename Item, 
typename Container>
 
  626template <
typename Item, 
typename Container>
 
  632    if (m_nPackets.Get() == 0)
 
  641template <
typename Item, 
typename Container>
 
  647    m_nTotalDroppedPackets++;
 
  648    m_nTotalDroppedPacketsBeforeEnqueue++;
 
  649    m_nTotalDroppedBytes += item->GetSize();
 
  650    m_nTotalDroppedBytesBeforeEnqueue += item->GetSize();
 
  654    m_traceDropBeforeEnqueue(item);
 
  657template <
typename Item, 
typename Container>
 
  663    m_nTotalDroppedPackets++;
 
  664    m_nTotalDroppedPacketsAfterDequeue++;
 
  665    m_nTotalDroppedBytes += item->GetSize();
 
  666    m_nTotalDroppedBytesAfterDequeue += item->GetSize();
 
  670    m_traceDropAfterDequeue(item);
 
A base class which provides memory management and object aggregation.
 
virtual void DoDispose()
Destructor implementation.
 
Smart pointer class similar to boost::intrusive_ptr.
 
Abstract base class for packet Queues.
 
uint32_t m_nTotalDroppedBytesBeforeEnqueue
Total dropped bytes before enqueue.
 
uint32_t GetTotalDroppedPacketsAfterDequeue() const
 
TracedValue< uint32_t > m_nPackets
Number of packets in the queue.
 
uint32_t GetTotalDroppedPacketsBeforeEnqueue() const
 
uint32_t m_nTotalDroppedPacketsAfterDequeue
Total dropped packets after dequeue.
 
uint32_t m_nTotalReceivedPackets
Total received packets.
 
uint32_t GetTotalDroppedBytesAfterDequeue() const
 
QueueSize GetMaxSize() const
 
uint32_t GetTotalReceivedBytes() const
 
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...
 
void ResetStatistics()
Resets the counts for dropped packets, dropped bytes, received packets, and received bytes.
 
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 GetTotalDroppedBytes() const
 
static TypeId GetTypeId()
Get the type ID.
 
uint32_t GetTotalDroppedBytesBeforeEnqueue() const
 
uint32_t m_nTotalDroppedBytes
Total dropped bytes.
 
uint32_t GetNBytes() const
 
uint32_t m_nTotalDroppedPacketsBeforeEnqueue
Total dropped packets before enqueue.
 
QueueSize m_maxSize
max queue size
 
uint32_t m_nTotalDroppedPackets
Total dropped packets.
 
uint32_t GetNPackets() const
 
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
 
uint32_t GetTotalReceivedPackets() const
 
TracedValue< uint32_t > m_nBytes
Number of bytes in the queue.
 
uint32_t m_nTotalDroppedBytesAfterDequeue
Total dropped bytes after dequeue.
 
uint32_t GetTotalDroppedPackets() const
 
uint32_t m_nTotalReceivedBytes
Total received bytes.
 
QueueSize GetCurrentSize() const
 
Template class for packet Queues.
 
virtual Ptr< const Item > Peek() const =0
Get a copy of an item in the queue (each subclass defines the position) without removing it.
 
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
 
bool DoEnqueue(ConstIterator pos, Ptr< Item > item, Iterator &ret)
Push an item in the queue.
 
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.
 
void Flush()
Flush the queue by calling Remove() on each item enqueued.
 
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.
 
void DoDispose() override
Destructor implementation.
 
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)
 
const Container & GetContainer() const
Get a const reference to the container of queue items.
 
TracedCallback< Ptr< const Item > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
 
virtual Ptr< Item > Remove()=0
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as bot...
 
void DropBeforeEnqueue(Ptr< Item > item)
Drop a packet before enqueue.
 
static TypeId GetTypeId()
Get the type ID.
 
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 > Dequeue()=0
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as deq...
 
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.
 
Trace classes with value semantics.
 
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.
 
Forward declaration of template class Queue.
 
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)