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" 189 void EnableRunningAverage (
Time averageWindow);
190 void DisableRunningAverage (
void);
192 double GetQueueSizeAverage (
void);
193 double GetReceivedBytesPerSecondAverage (
void);
194 double GetReceivedPacketsPerSecondAverage (
void);
195 double GetDroppedBytesPerSecondAverage (
void);
196 double GetDroppedPacketsPerSecondAverage (
void);
198 double GetQueueSizeVariance (
void);
199 double GetReceivedBytesPerSecondVariance (
void);
200 double GetReceivedPacketsPerSecondVariance (
void);
201 double GetDroppedBytesPerSecondVariance (
void);
202 double GetDroppedPacketsPerSecondVariance (
void);
220 template <
typename Item>
248 template <
typename Item>
401 template <
typename Item>
405 std::string name = GetTypeParamName<Queue<Item> > ();
406 static TypeId tid =
TypeId ((
"ns3::Queue<" + name +
">").c_str ())
408 .SetGroupName (
"Network")
409 .AddTraceSource (
"Enqueue",
"Enqueue a packet in the queue.",
411 "ns3::" + name +
"::TracedCallback")
412 .AddTraceSource (
"Dequeue",
"Dequeue a packet from the queue.",
414 "ns3::" + name +
"::TracedCallback")
415 .AddTraceSource (
"Drop",
"Drop a packet (for whatever reason).",
417 "ns3::" + name +
"::TracedCallback")
418 .AddTraceSource (
"DropBeforeEnqueue",
"Drop a packet before enqueue.",
420 "ns3::" + name +
"::TracedCallback")
421 .AddTraceSource (
"DropAfterDequeue",
"Drop a packet after dequeue.",
423 "ns3::" + name +
"::TracedCallback")
428 template <
typename Item>
434 template <
typename Item>
439 template <
typename Item>
445 if (GetCurrentSize () + item > GetMaxSize ())
448 DropBeforeEnqueue (item);
452 m_packets.insert (pos, item);
454 uint32_t size = item->GetSize ();
456 m_nTotalReceivedBytes += size;
459 m_nTotalReceivedPackets++;
462 m_traceEnqueue (item);
467 template <
typename Item>
473 if (m_nPackets.Get () == 0)
480 m_packets.erase (pos);
484 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
487 m_nBytes -= item->GetSize ();
491 m_traceDequeue (item);
496 template <
typename Item>
502 if (m_nPackets.Get () == 0)
509 m_packets.erase (pos);
513 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
516 m_nBytes -= item->GetSize ();
521 m_traceDequeue (item);
523 DropAfterDequeue (item);
528 template <
typename Item>
539 template <
typename Item>
545 if (m_nPackets.Get () == 0)
554 template <
typename Item>
557 return m_packets.cbegin ();
560 template <
typename Item>
563 return m_packets.cend ();
566 template <
typename Item>
572 m_nTotalDroppedPackets++;
573 m_nTotalDroppedPacketsBeforeEnqueue++;
574 m_nTotalDroppedBytes += item->GetSize ();
575 m_nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
579 m_traceDropBeforeEnqueue (item);
582 template <
typename Item>
588 m_nTotalDroppedPackets++;
589 m_nTotalDroppedPacketsAfterDequeue++;
590 m_nTotalDroppedBytes += item->GetSize ();
591 m_nTotalDroppedBytesAfterDequeue += item->GetSize ();
595 m_traceDropAfterDequeue (item);
uint32_t m_nTotalDroppedPacketsBeforeEnqueue
Total dropped packets before enqueue.
uint32_t m_nTotalReceivedPackets
Total received packets.
Simulation virtual time values and global simulation resolution.
uint32_t m_nTotalDroppedPackets
Total dropped packets.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
TracedCallback< Ptr< const Item > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
Class for representing queue sizes.
QueueSize GetMaxSize(void) const
uint32_t GetTotalDroppedPacketsBeforeEnqueue(void) const
uint32_t GetTotalDroppedBytes(void) const
uint32_t GetTotalReceivedPackets(void) const
NS_LOG_TEMPLATE_DECLARE
the log component
Forward calls to a chain of Callback.
void Flush(void)
Flush the queue.
uint32_t m_nTotalDroppedBytes
Total dropped bytes.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
uint32_t m_nTotalDroppedPacketsAfterDequeue
Total dropped packets after dequeue.
uint32_t GetTotalDroppedBytesBeforeEnqueue(void) const
uint32_t m_nTotalDroppedBytesAfterDequeue
Total dropped bytes after dequeue.
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
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.
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 '>'. ...
QueueSize m_maxSize
max queue size
uint32_t GetTotalDroppedBytesAfterDequeue(void) const
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Template class for packet Queues.
static TypeId GetTypeId(void)
Get the type ID.
TracedCallback< Ptr< const Item > > m_traceDropAfterDequeue
Traced callback: fired when a packet is dropped after dequeue.
uint32_t GetNBytes(void) const
uint32_t m_nTotalDroppedBytesBeforeEnqueue
Total dropped bytes before enqueue.
#define NS_LOG_TEMPLATE_DEFINE(name)
Initialize a reference to a Log component.
TracedCallback< Ptr< const Item > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
void DropAfterDequeue(Ptr< Item > item)
Drop a packet after dequeue.
ConstIterator Tail(void) const
Get a const iterator which indicates past-the-last item in the queue.
uint32_t m_nTotalReceivedBytes
Total received bytes.
void ResetStatistics(void)
Resets the counts for dropped packets, dropped bytes, received packets, and received bytes...
virtual bool Enqueue(Ptr< Item > item)=0
Place an item into the Queue (each subclass defines the position)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ConstIterator Head(void) const
Get a const iterator which refers to the first item in the queue.
virtual Ptr< Item > Remove(void)=0
Remove an item from the Queue (each subclass defines the position), counting it as dropped...
uint32_t GetTotalDroppedPacketsAfterDequeue(void) const
TracedCallback< Ptr< const Item > > m_traceDropBeforeEnqueue
Traced callback: fired when a packet is dropped before enqueue.
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
Ptr< const Item > DoPeek(ConstIterator pos) const
Peek the front item in the queue.
Abstract base class for packet Queues.
virtual Ptr< Item > Dequeue(void)=0
Remove an item from the Queue (each subclass defines the position), counting it as dequeued...
uint32_t GetTotalDroppedPackets(void) const
void DropBeforeEnqueue(Ptr< Item > item)
Drop a packet before enqueue.
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...
A base class which provides memory management and object aggregation.
uint32_t GetTotalReceivedBytes(void) const
void SetMaxSize(QueueSize size)
Set the maximum size of this queue.
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
QueueSize GetCurrentSize(void) const
uint32_t GetNPackets(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
bool DoEnqueue(ConstIterator pos, Ptr< Item > item)
Push an item in the queue.
std::list< Ptr< Item > >::const_iterator ConstIterator
Const iterator.
std::list< Ptr< Item > > m_packets
the items in the queue
static TypeId GetTypeId(void)
Get the type ID.
TracedValue< uint32_t > m_nBytes
Number of bytes in the queue.