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>
251 template <
typename Item>
404 template <
typename Item>
408 std::string name = GetTypeParamName<Queue<Item> > ();
409 static TypeId tid =
TypeId ((
"ns3::Queue<" + name +
">").c_str ())
411 .SetGroupName (
"Network")
412 .AddTraceSource (
"Enqueue",
"Enqueue a packet in the queue.",
414 "ns3::" + name +
"::TracedCallback")
415 .AddTraceSource (
"Dequeue",
"Dequeue a packet from the queue.",
417 "ns3::" + name +
"::TracedCallback")
418 .AddTraceSource (
"Drop",
"Drop a packet (for whatever reason).",
420 "ns3::" + name +
"::TracedCallback")
421 .AddTraceSource (
"DropBeforeEnqueue",
"Drop a packet before enqueue.",
423 "ns3::" + name +
"::TracedCallback")
424 .AddTraceSource (
"DropAfterDequeue",
"Drop a packet after dequeue.",
426 "ns3::" + name +
"::TracedCallback")
431 template <
typename Item>
437 template <
typename Item>
442 template <
typename Item>
448 if (GetCurrentSize () + item > GetMaxSize ())
451 DropBeforeEnqueue (item);
455 m_packets.insert (pos, item);
457 uint32_t size = item->GetSize ();
459 m_nTotalReceivedBytes += size;
462 m_nTotalReceivedPackets++;
465 m_traceEnqueue (item);
470 template <
typename Item>
476 if (m_nPackets.Get () == 0)
483 m_packets.erase (pos);
487 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
490 m_nBytes -= item->GetSize ();
494 m_traceDequeue (item);
499 template <
typename Item>
505 if (m_nPackets.Get () == 0)
512 m_packets.erase (pos);
516 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
519 m_nBytes -= item->GetSize ();
524 m_traceDequeue (item);
526 DropAfterDequeue (item);
531 template <
typename Item>
542 template <
typename Item>
548 if (m_nPackets.Get () == 0)
557 template <
typename Item>
560 return m_packets.cbegin ();
563 template <
typename Item>
566 return m_packets.cend ();
569 template <
typename Item>
575 m_nTotalDroppedPackets++;
576 m_nTotalDroppedPacketsBeforeEnqueue++;
577 m_nTotalDroppedBytes += item->GetSize ();
578 m_nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
582 m_traceDropBeforeEnqueue (item);
585 template <
typename Item>
591 m_nTotalDroppedPackets++;
592 m_nTotalDroppedPacketsAfterDequeue++;
593 m_nTotalDroppedBytes += item->GetSize ();
594 m_nTotalDroppedBytesAfterDequeue += item->GetSize ();
598 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.