21 #include "ns3/abort.h"
22 #include "ns3/uinteger.h"
23 #include "ns3/pointer.h"
24 #include "ns3/object-vector.h"
25 #include "ns3/packet.h"
26 #include "ns3/unused.h"
36 m_protocol (protocol),
76 <<
"txq " << (uint8_t)
m_txq
87 .SetGroupName (
"TrafficControl")
89 .AddAttribute (
"QueueDisc",
"The queue disc attached to the class",
92 MakePointerChecker<QueueDisc> ())
131 .SetGroupName (
"TrafficControl")
132 .AddAttribute (
"Quota",
"The maximum number of packets dequeued in a qdisc run",
136 MakeUintegerChecker<uint32_t> ())
137 .AddAttribute (
"InternalQueueList",
"The list of internal queues.",
140 MakeObjectVectorChecker<Queue> ())
141 .AddAttribute (
"PacketFilterList",
"The list of packet filters.",
144 MakeObjectVectorChecker<PacketFilter> ())
145 .AddAttribute (
"QueueDiscClassList",
"The list of queue disc classes.",
148 MakeObjectVectorChecker<QueueDiscClass> ())
149 .AddTraceSource (
"Enqueue",
"Enqueue a packet in the queue disc",
151 "ns3::QueueItem::TracedCallback")
152 .AddTraceSource (
"Dequeue",
"Dequeue a packet from the queue disc",
154 "ns3::QueueItem::TracedCallback")
155 .AddTraceSource (
"Requeue",
"Requeue a packet in the queue disc",
157 "ns3::QueueItem::TracedCallback")
158 .AddTraceSource (
"Drop",
"Drop a packet stored in the queue disc",
160 "ns3::QueueItem::TracedCallback")
161 .AddTraceSource (
"PacketsInQueue",
162 "Number of packets currently stored in the queue disc",
164 "ns3::TracedValueCallback::Uint32")
165 .AddTraceSource (
"BytesInQueue",
166 "Number of bytes currently stored in the queue disc",
168 "ns3::TracedValueCallback::Uint32")
176 m_nTotalReceivedPackets (0),
177 m_nTotalReceivedBytes (0),
178 m_nTotalDroppedPackets (0),
179 m_nTotalDroppedBytes (0),
180 m_nTotalRequeuedPackets (0),
181 m_nTotalRequeuedBytes (0),
213 NS_ASSERT_MSG (ok,
"The queue disc configuration is not correct");
221 (*cl)->GetQueueDisc ()->Initialize ();
355 NS_ABORT_MSG_IF (qdClass->GetQueueDisc () == 0,
"Cannot add a class with no attached queue disc");
381 ret = (*f)->Classify (item);
398 <<
" is reported to be dropped is greater than the amount of bytes"
399 <<
"stored in the queue disc");
577 if (!
m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
582 ret =
m_device->Send (copy, item->GetAddress (), item->GetProtocol ());
592 if (ret &&
m_devQueueIface->GetTxQueue (item->GetTxQueueIndex ())->IsStopped ())
uint8_t GetTxQueueIndex(void) const
Get the transmission queue index included in this item.
TracedCallback< Ptr< const QueueItem > > m_traceRequeue
Traced callback: fired when a packet is requeued.
virtual void DoInitialize(void)
Initialize() implementation.
uint32_t GetNQueueDiscClasses(void) const
Get the number of queue disc classes.
Base class to represent items of packet Queues.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Ptr< QueueDiscItem > m_requeued
The last packet that failed to be transmitted.
uint32_t GetTotalReceivedPackets(void) const
Get the total number of received packets.
void AddQueueDiscClass(Ptr< QueueDiscClass > qdClass)
Add a queue disc class to the tail of the list of classes.
static const int PF_NO_MATCH
bool Enqueue(Ptr< QueueDiscItem > item)
Pass a packet to store to the queue discipline.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< Queue > GetInternalQueue(uint32_t i) const
Get the i-th internal queue.
uint32_t GetNBytes(void) const
Get the amount of bytes stored by the queue disc.
uint32_t GetTotalRequeuedPackets(void) const
Get the total number of requeued packets.
uint8_t m_txq
Transmission queue index.
Ptr< QueueDisc > m_queueDisc
Queue disc attached to this class.
virtual void DoDispose(void)
Dispose of the object.
void SetQueueDisc(Ptr< QueueDisc > qd)
Set the queue disc attached to this class.
void SetTxQueueIndex(uint8_t txq)
Set the transmission queue index to store in this item.
TracedCallback< Ptr< const QueueItem > > m_traceEnqueue
Traced callback: fired when a packet is enqueued.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
#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 m_nTotalReceivedPackets
Total received packets.
virtual Ptr< QueueDiscItem > DoDequeue(void)=0
This function actually extracts a packet from the queue disc.
#define NS_UNUSED(x)
Mark a local variable as unused.
virtual void DoDispose(void)
Destructor implementation.
QueueDisc is an abstract base class providing the interface and implementing the operations common to...
Address GetAddress(void) const
Get the MAC address included in this item.
bool Transmit(Ptr< QueueDiscItem > p)
Modelled after the Linux function sch_direct_xmit (net/sched/sch_generic.c) Sends a packet to the dev...
a polymophic address class
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
uint32_t GetTotalReceivedBytes(void) const
Get the total amount of received bytes.
std::vector< Ptr< Queue > > m_queues
Internal queues.
uint32_t GetNInternalQueues(void) const
Get the number of internal queues.
virtual void DoInitialize(void)
Check whether the configuration is correct and initialize parameters.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Ptr< NetDeviceQueueInterface > m_devQueueIface
NetDevice queue interface.
Hold an unsigned integer type.
uint16_t m_protocol
L3 Protocol number.
QueueDiscItem()
Default constructor.
void AddInternalQueue(Ptr< Queue > queue)
Add an internal queue to the tail of the list of queues.
uint32_t m_nTotalReceivedBytes
Total received bytes.
void Run(void)
Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets...
Ptr< PacketFilter > GetPacketFilter(uint32_t i) const
Get the i-th packet filter.
uint32_t m_nTotalDroppedBytes
Total dropped bytes.
virtual bool DoEnqueue(Ptr< QueueDiscItem > item)=0
This function actually enqueues a packet into the queue disc.
TracedCallback< Ptr< const QueueItem > > m_traceDequeue
Traced callback: fired when a packet is dequeued.
Ptr< QueueDisc > GetQueueDisc(void) const
Get the queue disc attached to this class.
int32_t Classify(Ptr< QueueDiscItem > item)
Classify a packet by calling the packet filters, one at a time, until either a filter able to classif...
Network device transmission queue interface.
virtual void DoDispose(void)
Dispose of the object.
uint32_t GetNPacketFilters(void) const
Get the number of packet filters.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
TracedCallback< Ptr< const QueueItem > > m_traceDrop
Traced callback: fired when a packet is dropped.
QueueDiscClass is the base class for classes that are included in a queue disc.
static const uint32_t DEFAULT_QUOTA
Default quota (as in /proc/sys/net/core/dev_weight)
Ptr< QueueDiscItem > Dequeue(void)
Request the queue discipline to extract a packet.
uint32_t m_nTotalRequeuedBytes
Total requeued bytes.
double f(double x, void *params)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
uint32_t GetTotalDroppedPackets(void) const
Get the total number of dropped packets.
WakeMode GetWakeMode(void)
When setting up the wake callbacks on the netdevice queues, it is necessary to determine which queue ...
uint32_t m_quota
Maximum number of packets dequeued in a qdisc run.
uint32_t GetTotalDroppedBytes(void) const
Get the total amount of dropped bytes.
bool RunBegin(void)
Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h).
bool m_running
The queue disc is performing multiple dequeue operations.
virtual void Print(std::ostream &os) const
Print the item contents.
virtual uint32_t GetQuota(void) const
Get the maximum number of dequeue operations following a packet enqueue.
virtual bool CheckConfig(void)=0
Check whether the current configuration is correct.
TracedValue< uint32_t > m_nBytes
Number of bytes in the queue.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void Drop(Ptr< QueueDiscItem > item)
Drop a packet.
TracedValue< uint32_t > m_nPackets
Number of packets in the queue.
void Requeue(Ptr< QueueDiscItem > p)
Modelled after the Linux function dev_requeue_skb (net/sched/sch_generic.c) Requeues a packet whose t...
std::vector< Ptr< PacketFilter > > m_filters
Packet filters.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Ptr< NetDevice > m_device
The NetDevice on which this queue discipline is installed.
virtual void SetQuota(const uint32_t quota)
Set the maximum number of dequeue operations following a packet enqueue.
uint32_t GetTotalRequeuedBytes(void) const
Get the total amount of requeued bytes.
void AddPacketFilter(Ptr< PacketFilter > filter)
Add a packet filter to the tail of the list of filters used to classify packets.
WakeMode
Used to determine whether the queue disc itself or its children must be activated when a netdevice wa...
virtual void InitializeParams(void)=0
Initialize parameters (if any) before the first packet is enqueued.
static TypeId GetTypeId(void)
Get the type ID.
uint16_t GetProtocol(void) const
Get the L3 protocol included in this item.
A base class which provides memory management and object aggregation.
Container for a set of ns3::Object pointers.
virtual Ptr< const QueueDiscItem > DoPeek(void) const =0
This function returns a copy of the next packet the queue disc will extract.
bool Restart(void)
Modelled after the Linux function qdisc_restart (net/sched/sch_generic.c) Dequeue a packet (by callin...
Address m_address
MAC destination address.
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.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< QueueDiscItem > DequeuePacket(void)
Modelled after the Linux function dequeue_skb (net/sched/sch_generic.c)
Ptr< NetDevice > GetNetDevice(void) const
Get the NetDevice on which this queue discipline is installed.
static TypeId GetTypeId(void)
Get the type ID.
uint32_t m_nTotalRequeuedPackets
Total requeued packets.
Ptr< const QueueDiscItem > Peek(void) const
Get a copy of the next packet the queue discipline will extract, without actually extracting the pack...
uint32_t m_nTotalDroppedPackets
Total dropped packets.
void SetNetDevice(Ptr< NetDevice > device)
Set the NetDevice on which this queue discipline is installed.
Ptr< QueueDiscClass > GetQueueDiscClass(uint32_t i) const
Get the i-th queue disc class.
void RunEnd(void)
Modelled after the Linux function qdisc_run_end (include/net/sch_generic.h).
std::vector< Ptr< QueueDiscClass > > m_classes
Classes.
uint32_t GetNPackets(void) const
Get the number of packets stored by the queue disc.
Ptr< Packet > GetPacket(void) const