|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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);
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
a unique identifier for an interface.
uint32_t GetTotalDroppedBytesBeforeEnqueue(void) const
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
uint32_t GetNBytes(void) const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Iterator end(void)
Get an iterator which indicates past-the-last item in the queue.
uint32_t GetNPackets(void) const
uint32_t GetTotalDroppedBytes(void) const
void DoDispose(void) override
TracedCallback< Ptr< const Item > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
uint32_t m_nTotalDroppedBytesAfterDequeue
Total dropped bytes after dequeue.
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedCallback< Ptr< const Item > > m_traceDrop
Traced callback: fired when a packet is dropped.
TracedValue< uint32_t > m_nPackets
Number of packets in the queue.
uint32_t GetTotalReceivedBytes(void) const
std::list< Ptr< Item > >::const_iterator ConstIterator
Const iterator.
static TypeId GetTypeId(void)
Get the type ID.
TracedValue< uint32_t > m_nBytes
Number of bytes in the queue.
NS_LOG_TEMPLATE_DECLARE
the log component
uint32_t m_nTotalDroppedPacketsAfterDequeue
Total dropped packets after dequeue.
Item ItemType
Define ItemType as the type of the stored elements.
uint32_t m_nTotalDroppedBytesBeforeEnqueue
Total dropped bytes before enqueue.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Iterator begin(void)
Get an iterator which refers to the first item in the queue.
void DropAfterDequeue(Ptr< Item > item)
Drop a packet after dequeue.
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 GetTotalReceivedPackets(void) const
QueueSize GetCurrentSize(void) const
TracedCallback< Ptr< const Item > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
uint32_t m_nTotalDroppedPackets
Total dropped packets.
uint32_t m_nTotalDroppedPacketsBeforeEnqueue
Total dropped packets before enqueue.
void ResetStatistics(void)
Resets the counts for dropped packets, dropped bytes, received packets, and received bytes.
A base class which provides memory management and object aggregation.
bool DoEnqueue(ConstIterator pos, Ptr< Item > item)
Push an item in the queue.
uint32_t m_nTotalDroppedBytes
Total dropped bytes.
Introspection did not find any typical Config paths.
void Flush(void)
Flush the queue by calling Remove() on each item enqueued.
ConstIterator end(void) const
Get a const iterator which indicates past-the-last item in the queue.
Simulation virtual time values and global simulation resolution.
TracedCallback< Ptr< const Item > > m_traceDropAfterDequeue
Traced callback: fired when a packet is dropped after dequeue.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Abstract base class for packet Queues.
uint32_t GetTotalDroppedPacketsAfterDequeue(void) const
uint32_t m_nTotalReceivedPackets
Total received packets.
uint32_t m_nTotalReceivedBytes
Total received bytes.
virtual Ptr< Item > Dequeue(void)=0
Remove an item from the Queue (each subclass defines the position), counting it and tracing it as deq...
std::list< Ptr< Item > >::iterator Iterator
Iterator.
virtual bool Enqueue(Ptr< Item > item)=0
Place an item into the Queue (each subclass defines the position)
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
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_traceDropBeforeEnqueue
Traced callback: fired when a packet is dropped before enqueue.
void DropBeforeEnqueue(Ptr< Item > item)
Drop a packet before enqueue.
static TypeId GetTypeId(void)
Get the type ID.
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.
ConstIterator begin(void) const
Get a const iterator which refers to the first item in the queue.
std::list< Ptr< Item > > m_packets
the items in the queue
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
uint32_t GetTotalDroppedPacketsBeforeEnqueue(void) const
uint32_t GetTotalDroppedPackets(void) const
Forward calls to a chain of Callback.
uint32_t GetTotalDroppedBytesAfterDequeue(void) const
QueueSize GetMaxSize(void) const
QueueSize m_maxSize
max queue size
Class for representing queue sizes.
Template class for packet Queues.
virtual void DoDispose(void)
Destructor implementation.
Ptr< const Item > DoPeek(ConstIterator pos) const
Peek the front item in the queue.