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"
216 void EnableRunningAverage (
Time averageWindow);
217 void DisableRunningAverage (
void);
219 double GetQueueSizeAverage (
void);
220 double GetReceivedBytesPerSecondAverage (
void);
221 double GetReceivedPacketsPerSecondAverage (
void);
222 double GetDroppedBytesPerSecondAverage (
void);
223 double GetDroppedPacketsPerSecondAverage (
void);
225 double GetQueueSizeVariance (
void);
226 double GetReceivedBytesPerSecondVariance (
void);
227 double GetReceivedPacketsPerSecondVariance (
void);
228 double GetDroppedBytesPerSecondVariance (
void);
229 double GetDroppedPacketsPerSecondVariance (
void);
249 template <
typename Item>
277 template <
typename Item>
342 ConstIterator
Head (
void)
const;
358 ConstIterator
Tail (
void)
const;
430 template <
typename Item>
434 std::string name = GetTypeParamName<Queue<Item> > ();
435 static TypeId tid =
TypeId ((
"ns3::Queue<" + name +
">").c_str ())
437 .SetGroupName (
"Network")
438 .AddTraceSource (
"Enqueue",
"Enqueue a packet in the queue.",
440 "ns3::" + name +
"::TracedCallback")
441 .AddTraceSource (
"Dequeue",
"Dequeue a packet from the queue.",
443 "ns3::" + name +
"::TracedCallback")
444 .AddTraceSource (
"Drop",
"Drop a packet (for whatever reason).",
446 "ns3::" + name +
"::TracedCallback")
447 .AddTraceSource (
"DropBeforeEnqueue",
"Drop a packet before enqueue.",
449 "ns3::" + name +
"::TracedCallback")
450 .AddTraceSource (
"DropAfterDequeue",
"Drop a packet after dequeue.",
452 "ns3::" + name +
"::TracedCallback")
457 template <
typename Item>
463 template <
typename Item>
468 template <
typename Item>
474 if (m_mode == QUEUE_MODE_PACKETS && (m_nPackets.Get () >= m_maxPackets))
476 NS_LOG_LOGIC (
"Queue full (at max packets) -- dropping pkt");
477 DropBeforeEnqueue (item);
481 if (m_mode == QUEUE_MODE_BYTES && (m_nBytes.Get () + item->GetSize () > m_maxBytes))
483 NS_LOG_LOGIC (
"Queue full (packet would exceed max bytes) -- dropping pkt");
484 DropBeforeEnqueue (item);
488 m_packets.insert (pos, item);
490 uint32_t size = item->GetSize ();
492 m_nTotalReceivedBytes += size;
495 m_nTotalReceivedPackets++;
498 m_traceEnqueue (item);
503 template <
typename Item>
509 if (m_nPackets.Get () == 0)
516 m_packets.erase (pos);
520 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
523 m_nBytes -= item->GetSize ();
527 m_traceDequeue (item);
532 template <
typename Item>
538 if (m_nPackets.Get () == 0)
545 m_packets.erase (pos);
549 NS_ASSERT (m_nBytes.Get () >= item->GetSize ());
552 m_nBytes -= item->GetSize ();
557 m_traceDequeue (item);
559 DropAfterDequeue (item);
564 template <
typename Item>
575 template <
typename Item>
581 if (m_nPackets.Get () == 0)
590 template <
typename Item>
593 return m_packets.cbegin ();
596 template <
typename Item>
599 return m_packets.cend ();
602 template <
typename Item>
608 m_nTotalDroppedPackets++;
609 m_nTotalDroppedPacketsBeforeEnqueue++;
610 m_nTotalDroppedBytes += item->GetSize ();
611 m_nTotalDroppedBytesBeforeEnqueue += item->GetSize ();
615 m_traceDropBeforeEnqueue (item);
618 template <
typename Item>
624 m_nTotalDroppedPackets++;
625 m_nTotalDroppedPacketsAfterDequeue++;
626 m_nTotalDroppedBytes += item->GetSize ();
627 m_nTotalDroppedBytesAfterDequeue += item->GetSize ();
631 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 "...
ConstIterator Head(void) const
Get a const iterator which refers to the first item in the queue.
TracedCallback< Ptr< const Item > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
uint32_t m_maxBytes
max bytes in the queue
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 m_nTotalDroppedBytesAfterDequeue
Total dropped bytes after dequeue.
Ptr< Item > DoRemove(ConstIterator pos)
Pull the item to drop from the queue.
uint32_t GetTotalDroppedPacketsBeforeEnqueue(void) const
TracedCallback< Ptr< const Item > > m_traceDrop
Traced callback: fired when a packet is dropped.
QueueBase::QueueMode GetMode(void) const
Get the operating mode of this device.
QueueMode m_mode
queue mode (packets or bytes)
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 '>'. ...
Use number of packets for maximum queue size.
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_maxPackets
max packets in the queue
void SetMode(QueueBase::QueueMode mode)
Set the operating mode of this device.
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 SetMaxPackets(uint32_t maxPackets)
Set the maximum amount of packets that can be stored in this queue.
void DropAfterDequeue(Ptr< Item > item)
Drop a packet after dequeue.
uint32_t GetMaxPackets(void) const
ConstIterator Tail(void) const
Get a const iterator which indicates past-the-last item in the queue.
uint32_t GetTotalDroppedBytes(void) const
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.
virtual Ptr< Item > Remove(void)=0
Remove an item from the Queue (each subclass defines the position), counting it as dropped...
uint32_t GetTotalDroppedBytesAfterDequeue(void) const
void SetMaxBytes(uint32_t maxBytes)
Set the maximum amount of bytes that can be stored in this queue.
Use number of bytes for maximum queue size.
TracedCallback< Ptr< const Item > > m_traceDropBeforeEnqueue
Traced callback: fired when a packet is dropped before enqueue.
uint32_t GetTotalReceivedPackets(void) const
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
uint32_t GetMaxBytes(void) const
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...
Ptr< const Item > DoPeek(ConstIterator pos) const
Peek the front item in the queue.
void DropBeforeEnqueue(Ptr< Item > item)
Drop a packet before enqueue.
uint32_t GetNPackets(void) const
uint32_t GetTotalDroppedPacketsAfterDequeue(void) const
uint32_t GetTotalDroppedPackets(void) const
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.
QueueMode
Enumeration of the modes supported in the class.
Ptr< Item > DoDequeue(ConstIterator pos)
Pull the item to dequeue from the queue.
a unique identifier for an interface.
uint32_t GetTotalReceivedBytes(void) const
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.
uint32_t GetTotalDroppedBytesBeforeEnqueue(void) const
TracedValue< uint32_t > m_nBytes
Number of bytes in the queue.