20 #include "ns3/abort.h"
22 #include "ns3/uinteger.h"
23 #include "ns3/trace-source-accessor.h"
37 .SetGroupName (
"Network")
38 .AddAttribute (
"Mode",
39 "Whether to use bytes (see MaxBytes) or packets (see MaxPackets) as the maximum queue size metric.",
45 .AddAttribute (
"MaxPackets",
46 "The maximum number of packets accepted by this queue.",
50 MakeUintegerChecker<uint32_t> ())
51 .AddAttribute (
"MaxBytes",
52 "The maximum number of bytes accepted by this queue.",
56 MakeUintegerChecker<uint32_t> ())
57 .AddTraceSource (
"Enqueue",
"Enqueue a packet in the queue.",
59 "ns3::Packet::TracedCallback")
60 .AddTraceSource (
"Dequeue",
"Dequeue a packet from the queue.",
62 "ns3::Packet::TracedCallback")
63 .AddTraceSource (
"Drop",
"Drop a packet (for whatever reason).",
65 "ns3::Packet::TracedCallback")
66 .AddTraceSource (
"PacketsInQueue",
67 "Number of packets currently stored in the queue",
69 "ns3::TracedValueCallback::Uint32")
70 .AddTraceSource (
"BytesInQueue",
71 "Number of bytes currently stored in the queue",
73 "ns3::TracedValueCallback::Uint32")
80 m_nTotalReceivedBytes (0),
82 m_nTotalReceivedPackets (0),
83 m_nTotalDroppedBytes (0),
84 m_nTotalDroppedPackets (0),
85 m_mode (QUEUE_MODE_PACKETS)
104 NS_LOG_LOGIC (
"Queue full (at max packets) -- dropping pkt");
111 NS_LOG_LOGIC (
"Queue full (packet would exceed max bytes) -- dropping pkt");
125 uint32_t size = item->GetPacketSize ();
261 "Cannot change queue mode in a queue with packets.");
266 "Cannot change queue mode in a queue with packets.");
287 "The new queue size cannot be less than the number of currently stored packets.");
308 "The new queue size cannot be less than the amount of bytes of currently stored packets.");
virtual bool DoEnqueue(Ptr< QueueItem > item)=0
Push an item in the queue.
QueueMode m_mode
queue mode (packets or bytes limited)
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint32_t m_nTotalDroppedBytes
Total dropped bytes.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
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.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint32_t GetTotalDroppedPackets(void) const
TracedValue< uint32_t > m_nPackets
Number of packets in the queue.
uint32_t m_nTotalReceivedBytes
Total received bytes.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void ResetStatistics(void)
Resets the counts for dropped packets, dropped bytes, received packets, and received bytes...
T Get(void) const
Get the underlying value.
uint32_t m_maxPackets
max packets in the queue
virtual Ptr< const QueueItem > DoPeek(void) const =0
Peek the front item in the queue.
TracedValue< uint32_t > m_nBytes
Number of bytes in the queue.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint32_t GetTotalReceivedBytes(void) const
QueueMode
Enumeration of the modes supported in the class.
Hold variables of type enum.
static TypeId GetTypeId(void)
Get the type ID.
Hold an unsigned integer type.
uint32_t GetMaxPackets(void) const
uint32_t GetNPackets(void) const
uint32_t GetMaxBytes(void) const
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
TracedCallback< Ptr< const Packet > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
Queue::QueueMode GetMode(void) const
Get the encapsulation mode of this device.
TracedCallback< Ptr< const Packet > > m_traceDrop
Traced callback: fired when a packet is dropped.
uint32_t m_maxBytes
max bytes in the queue
uint32_t GetNBytes(void) const
void Drop(Ptr< Packet > p)
Drop a packet.
void SetMode(Queue::QueueMode mode)
Set the operating mode of this device.
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
uint32_t GetTotalReceivedPackets(void) const
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
virtual Ptr< QueueItem > DoDequeue(void)=0
Pull an item from the queue.
uint32_t m_nTotalReceivedPackets
Total received packets.
void SetMaxPackets(uint32_t maxPackets)
Set the maximum amount of packets that can be stored in this queue.
uint32_t m_nTotalDroppedPackets
Total dropped packets.
void DequeueAll(void)
Flush the queue.
TracedCallback< Ptr< const Packet > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
Ptr< const QueueItem > Peek(void) const
Get a copy of the item at the front of the queue without removing it.
Use number of packets for maximum queue size.
uint32_t GetTotalDroppedBytes(void) const
A base class which provides memory management and object aggregation.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
bool Enqueue(Ptr< QueueItem > item)
Place a queue item into the rear of the Queue.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< QueueItem > Dequeue(void)
Remove an item from the front of the Queue.