A Discrete-Event Network Simulator
API
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ns3::QueueDisc Class Referenceabstract

QueueDisc is an abstract base class providing the interface and implementing the operations common to all the queueing disciplines. More...

#include "queue-disc.h"

+ Inheritance diagram for ns3::QueueDisc:

Classes

struct  Stats
 Structure that keeps the queue disc statistics. More...
 

Public Types

typedef Queue< QueueDiscItemInternalQueue
 Internal queues store QueueDiscItem objects. More...
 
enum  WakeMode { WAKE_ROOT = 0x00, WAKE_CHILD = 0x01 }
 Used to determine whether the queue disc itself or its children must be activated when a netdevice wakes a transmission queue. More...
 

Public Member Functions

 QueueDisc (QueueDiscSizePolicy policy=QueueDiscSizePolicy::SINGLE_INTERNAL_QUEUE)
 Constructor. More...
 
 QueueDisc (QueueDiscSizePolicy policy, QueueSizeUnit unit)
 Constructor. More...
 
virtual ~QueueDisc ()
 
void AddInternalQueue (Ptr< InternalQueue > queue)
 Add an internal queue to the tail of the list of queues. More...
 
void AddPacketFilter (Ptr< PacketFilter > filter)
 Add a packet filter to the tail of the list of filters used to classify packets. More...
 
void AddQueueDiscClass (Ptr< QueueDiscClass > qdClass)
 Add a queue disc class to the tail of the list of classes. More...
 
int32_t Classify (Ptr< QueueDiscItem > item)
 Classify a packet by calling the packet filters, one at a time, until either a filter able to classify the packet is found or all the filters have been processed. More...
 
Ptr< QueueDiscItemDequeue (void)
 Extract from the queue disc the packet that has been dequeued by calling Peek, if any, or call the private DoDequeue method (which must be implemented by derived classes) to dequeue a packet, otherwise. More...
 
bool Enqueue (Ptr< QueueDiscItem > item)
 Pass a packet to store to the queue discipline. More...
 
QueueSize GetCurrentSize (void)
 Get the current size of the queue disc in bytes, if operating in bytes mode, or packets, otherwise. More...
 
Ptr< InternalQueueGetInternalQueue (std::size_t i) const
 Get the i-th internal queue. More...
 
QueueSize GetMaxSize (void) const
 Get the maximum size of the queue disc. More...
 
uint32_t GetNBytes (void) const
 Get the amount of bytes stored by the queue disc. More...
 
Ptr< NetDeviceGetNetDevice (void) const
 Get the NetDevice on which this queue discipline is installed. More...
 
std::size_t GetNInternalQueues (void) const
 Get the number of internal queues. More...
 
std::size_t GetNPacketFilters (void) const
 Get the number of packet filters. More...
 
uint32_t GetNPackets (void) const
 Get the number of packets stored by the queue disc. More...
 
std::size_t GetNQueueDiscClasses (void) const
 Get the number of queue disc classes. More...
 
Ptr< PacketFilterGetPacketFilter (std::size_t i) const
 Get the i-th packet filter. More...
 
Ptr< QueueDiscClassGetQueueDiscClass (std::size_t i) const
 Get the i-th queue disc class. More...
 
virtual uint32_t GetQuota (void) const
 Get the maximum number of dequeue operations following a packet enqueue. More...
 
const StatsGetStats (void)
 Retrieve all the collected statistics. More...
 
virtual WakeMode GetWakeMode (void) const
 When setting up the wake callbacks on the netdevice queues, it is necessary to determine which queue disc (the root queue disc or one of its children) should be activated when the netdevice wakes one of its transmission queues. More...
 
Ptr< const QueueDiscItemPeek (void)
 Get a copy of the next packet the queue discipline will extract. More...
 
void Run (void)
 Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets, until a quota is exceeded or sending a packet to the device failed. More...
 
bool SetMaxSize (QueueSize size)
 Set the maximum size of the queue disc. More...
 
void SetNetDevice (Ptr< NetDevice > device)
 Set the NetDevice on which this queue discipline is installed. More...
 
virtual void SetQuota (const uint32_t quota)
 Set the maximum number of dequeue operations following a packet enqueue. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose (void)
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator (void) const
 Get an iterator to the Objects aggregated to this one. More...
 
virtual TypeId GetInstanceTypeId (void) const
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject (void) const
 Get a pointer to the requested aggregated Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
void Initialize (void)
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized (void) const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor. More...
 
uint32_t GetReferenceCount (void) const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator. More...
 
void Ref (void) const
 Increment the reference count. More...
 
void Unref (void) const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising erros. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 Get the type ID. More...
 

Static Public Attributes

static constexpr const char * CHILD_QUEUE_DISC_DROP = "(Dropped by child queue disc) "
 Packet dropped by a child queue disc. More...
 
static constexpr const char * INTERNAL_QUEUE_DROP = "Dropped by internal queue"
 Packet dropped by an internal queue. More...
 

Protected Member Functions

virtual void DoDispose (void)
 Dispose of the object. More...
 
void DoInitialize (void)
 Check whether the configuration is correct and initialize parameters. More...
 
void DropAfterDequeue (Ptr< const QueueDiscItem > item, const char *reason)
 Perform the actions required when the queue disc is notified of a packet dropped after dequeue. More...
 
void DropBeforeEnqueue (Ptr< const QueueDiscItem > item, const char *reason)
 Perform the actions required when the queue disc is notified of a packet dropped before enqueue. More...
 
bool Mark (Ptr< QueueDiscItem > item, const char *reason)
 Marks the given packet and, if successful, updates the counters associated with the given reason. More...
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void NotifyNewAggregate (void)
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted (void)
 Notifier called once the ObjectBase is fully constructed. More...
 

Private Types

typedef std::function< void(Ptr< const QueueDiscItem >, const char *)> ChildQueueDiscDropFunctor
 Type for the function objects notifying that a packet has been dropped by a child queue disc. More...
 
typedef std::function< void(Ptr< const QueueDiscItem >)> InternalQueueDropFunctor
 Type for the function objects notifying that a packet has been dropped by an internal queue. More...
 

Private Member Functions

 QueueDisc (const QueueDisc &o)
 Copy constructor. More...
 
virtual bool CheckConfig (void)=0
 Check whether the current configuration is correct. More...
 
Ptr< QueueDiscItemDequeuePacket (void)
 Modelled after the Linux function dequeue_skb (net/sched/sch_generic.c) More...
 
virtual Ptr< QueueDiscItemDoDequeue (void)=0
 This function actually extracts a packet from the queue disc. More...
 
virtual bool DoEnqueue (Ptr< QueueDiscItem > item)=0
 This function actually enqueues a packet into the queue disc. More...
 
virtual Ptr< const QueueDiscItemDoPeek (void)
 Return a copy of the next packet the queue disc will extract. More...
 
virtual void InitializeParams (void)=0
 Initialize parameters (if any) before the first packet is enqueued. More...
 
QueueDiscoperator= (const QueueDisc &o)
 Assignment operator. More...
 
void PacketDequeued (Ptr< const QueueDiscItem > item)
 Perform the actions required when the queue disc is notified of a packet dequeue. More...
 
void PacketEnqueued (Ptr< const QueueDiscItem > item)
 Perform the actions required when the queue disc is notified of a packet enqueue. More...
 
void Requeue (Ptr< QueueDiscItem > item)
 Modelled after the Linux function dev_requeue_skb (net/sched/sch_generic.c) Requeues a packet whose transmission failed. More...
 
bool Restart (void)
 Modelled after the Linux function qdisc_restart (net/sched/sch_generic.c) Dequeue a packet (by calling DequeuePacket) and send it to the device (by calling Transmit). More...
 
bool RunBegin (void)
 Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h). More...
 
void RunEnd (void)
 Modelled after the Linux function qdisc_run_end (include/net/sch_generic.h). More...
 
bool Transmit (Ptr< QueueDiscItem > item)
 Modelled after the Linux function sch_direct_xmit (net/sched/sch_generic.c) Sends a packet to the device if the device queue is not stopped, and requeues it otherwise. More...
 

Private Attributes

ChildQueueDiscDropFunctor m_childQueueDiscDadFunctor
 Function object called when a child queue disc dropped a packet after dequeue. More...
 
ChildQueueDiscDropFunctor m_childQueueDiscDbeFunctor
 Function object called when a child queue disc dropped a packet before enqueue. More...
 
std::string m_childQueueDiscDropMsg
 Reason why a packet was dropped by a child queue disc. More...
 
std::vector< Ptr< QueueDiscClass > > m_classes
 Classes. More...
 
Ptr< NetDevicem_device
 The NetDevice on which this queue discipline is installed. More...
 
Ptr< NetDeviceQueueInterfacem_devQueueIface
 NetDevice queue interface. More...
 
std::vector< Ptr< PacketFilter > > m_filters
 Packet filters. More...
 
InternalQueueDropFunctor m_internalQueueDadFunctor
 Function object called when an internal queue dropped a packet after dequeue. More...
 
InternalQueueDropFunctor m_internalQueueDbeFunctor
 Function object called when an internal queue dropped a packet before enqueue. More...
 
QueueSize m_maxSize
 max queue size More...
 
TracedValue< uint32_t > m_nBytes
 Number of bytes in the queue. More...
 
TracedValue< uint32_t > m_nPackets
 Number of packets in the queue. More...
 
bool m_peeked
 A packet was dequeued because Peek was called. More...
 
bool m_prohibitChangeMode
 True if changing mode is prohibited. More...
 
std::vector< Ptr< InternalQueue > > m_queues
 Internal queues. More...
 
uint32_t m_quota
 Maximum number of packets dequeued in a qdisc run. More...
 
Ptr< QueueDiscItemm_requeued
 The last packet that failed to be transmitted. More...
 
bool m_running
 The queue disc is performing multiple dequeue operations. More...
 
QueueDiscSizePolicy m_sizePolicy
 The queue disc size policy. More...
 
TracedCallback< Timem_sojourn
 Sojourn time of the latest dequeued packet. More...
 
Stats m_stats
 The collected statistics. More...
 
TracedCallback< Ptr< const QueueDiscItem > > m_traceDequeue
 Traced callback: fired when a packet is dequeued. More...
 
TracedCallback< Ptr< const QueueDiscItem > > m_traceDrop
 Traced callback: fired when a packet is dropped. More...
 
TracedCallback< Ptr< const QueueDiscItem >, const char *> m_traceDropAfterDequeue
 Traced callback: fired when a packet is dropped after dequeue. More...
 
TracedCallback< Ptr< const QueueDiscItem >, const char *> m_traceDropBeforeEnqueue
 Traced callback: fired when a packet is dropped before enqueue. More...
 
TracedCallback< Ptr< const QueueDiscItem > > m_traceEnqueue
 Traced callback: fired when a packet is enqueued. More...
 
TracedCallback< Ptr< const QueueDiscItem >, const char *> m_traceMark
 Traced callback: fired when a packet is marked. More...
 
TracedCallback< Ptr< const QueueDiscItem > > m_traceRequeue
 Traced callback: fired when a packet is requeued. More...
 

Static Private Attributes

static const uint32_t DEFAULT_QUOTA = 64
 Default quota (as in /proc/sys/net/core/dev_weight) More...
 

Additional Inherited Members

Detailed Description

QueueDisc is an abstract base class providing the interface and implementing the operations common to all the queueing disciplines.


Introspection did not find any typical Config paths.

Child classes need to implement the methods used to enqueue a packet (DoEnqueue), dequeue a single packet (DoDequeue), get a copy of the next packet to extract (DoPeek), check whether the current configuration is correct (CheckConfig).

As in Linux, a queue disc may contain distinct elements:

Notice that a child queue disc must be attached to every class and a packet filter is only able to classify packets of a single protocol. Also, while in Linux some queue discs (e.g., fq-codel) use an internal classifier and do not make use of packet filters, in ns-3 every queue disc including multiple queues or multiple classes needs an external filter to classify packets (this is to avoid having the traffic-control module depend on other modules such as internet).

Queue disc configuration vary from queue disc to queue disc. A typical taxonomy divides queue discs in classful (i.e., support classes) and classless (i.e., do not support classes). More recently, after the appearance of multi-queue devices (such as Wifi), some multi-queue aware queue discs have been introduced. Multi-queue aware queue discs handle as many queues (or queue discs – without using classes) as the number of transmission queues used by the device on which the queue disc is installed. An attempt is made, also, to enqueue each packet in the "same" queue both within the queue disc and within the device.

The traffic control layer interacts with a queue disc in a simple manner: after requesting to enqueue a packet, the traffic control layer requests the qdisc to "run", i.e., to dequeue a set of packets, until a predefined number ("quota") of packets is dequeued or the netdevice stops the queue disc. A netdevice shall stop the queue disc when its transmission queue does not have room for another packet. Also, a netdevice shall wake the queue disc when it detects that there is room for another packet in its transmission queue, but the transmission queue is stopped. Waking a queue disc is equivalent to make it run.

Every queue disc collects statistics about the total number of packets/bytes received from the upper layers (in case of root queue disc) or from the parent queue disc (in case of child queue disc), enqueued, dequeued, requeued, dropped, dropped before enqueue, dropped after dequeue, queued in the queue disc and sent to the netdevice or to the parent queue disc. Note that packets that are dequeued may be requeued, i.e., retained by the traffic control infrastructure, if the netdevice is not ready to receive them. Requeued packets are not part of the queue disc. The following identities hold:

Separate counters are also kept for each possible reason to drop a packet. When a packet is dropped by an internal queue, e.g., because the queue is full, the reason is "Dropped by internal queue". When a packet is dropped by a child queue disc, the reason is "(Dropped by child queue disc) " followed by the reason why the child queue disc dropped the packet.

The QueueDisc base class provides the SojournTime trace source, which provides the sojourn time of every packet dequeued from a queue disc, including packets that are dropped or requeued after being dequeued. The sojourn time is taken when the packet is dequeued from the queue disc, hence it does not account for the additional time the packet is retained within the traffic control infrastructure in case it is requeued.

The design and implementation of this class is heavily inspired by Linux. For more details, see the traffic-control model page.


Attributes

TraceSources

Size of this type is 928 bytes (on a 64-bit architecture).

Definition at line 182 of file queue-disc.h.

Member Typedef Documentation

◆ ChildQueueDiscDropFunctor

typedef std::function<void (Ptr<const QueueDiscItem>, const char*)> ns3::QueueDisc::ChildQueueDiscDropFunctor
private

Type for the function objects notifying that a packet has been dropped by a child queue disc.

Definition at line 701 of file queue-disc.h.

◆ InternalQueue

Internal queues store QueueDiscItem objects.

Definition at line 400 of file queue-disc.h.

◆ InternalQueueDropFunctor

typedef std::function<void (Ptr<const QueueDiscItem>)> ns3::QueueDisc::InternalQueueDropFunctor
private

Type for the function objects notifying that a packet has been dropped by an internal queue.

Definition at line 699 of file queue-disc.h.

Member Enumeration Documentation

◆ WakeMode

Used to determine whether the queue disc itself or its children must be activated when a netdevice wakes a transmission queue.

Enumerator
WAKE_ROOT 
WAKE_CHILD 

Definition at line 474 of file queue-disc.h.

Constructor & Destructor Documentation

◆ QueueDisc() [1/3]

ns3::QueueDisc::QueueDisc ( QueueDiscSizePolicy  policy = QueueDiscSizePolicy::SINGLE_INTERNAL_QUEUE)

◆ QueueDisc() [2/3]

ns3::QueueDisc::QueueDisc ( QueueDiscSizePolicy  policy,
QueueSizeUnit  unit 
)

Constructor.

Parameters
policythe policy to handle the queue disc size
unitThe fixed operating mode of this queue disc

Definition at line 368 of file queue-disc.cc.

References m_maxSize, and m_prohibitChangeMode.

◆ ~QueueDisc()

ns3::QueueDisc::~QueueDisc ( )
virtual

Definition at line 375 of file queue-disc.cc.

References NS_LOG_FUNCTION.

◆ QueueDisc() [3/3]

ns3::QueueDisc::QueueDisc ( const QueueDisc o)
private

Copy constructor.

Parameters
oobject to copy

Defined and unimplemented to avoid misuse

Member Function Documentation

◆ AddInternalQueue()

void ns3::QueueDisc::AddInternalQueue ( Ptr< InternalQueue queue)

◆ AddPacketFilter()

void ns3::QueueDisc::AddPacketFilter ( Ptr< PacketFilter filter)

Add a packet filter to the tail of the list of filters used to classify packets.

Parameters
filterthe packet filter to be added

Definition at line 600 of file queue-disc.cc.

References m_filters, and NS_LOG_FUNCTION.

Referenced by ns3::QueueDiscFactory::CreateQueueDisc(), FqCoDelQueueDiscNoSuitableFilter::DoRun(), and PrioQueueDiscTestCase::DoRun().

◆ AddQueueDiscClass()

void ns3::QueueDisc::AddQueueDiscClass ( Ptr< QueueDiscClass qdClass)

◆ CheckConfig()

virtual bool ns3::QueueDisc::CheckConfig ( void  )
privatepure virtual

Check whether the current configuration is correct.

Default objects (such as internal queues) might be created by this method to ensure the configuration is correct.

Returns
true if the configuration is correct, false otherwise

Implemented in ns3::RedQueueDisc, TestParentQueueDisc, ns3::TbfQueueDisc, ns3::FqCoDelQueueDisc, ns3::CoDelQueueDisc, ns3::PieQueueDisc, TestChildQueueDisc, ns3::PrioQueueDisc, ns3::PfifoFastQueueDisc, ns3::MqQueueDisc, and ns3::FifoQueueDisc.

Referenced by DoInitialize().

◆ Classify()

int32_t ns3::QueueDisc::Classify ( Ptr< QueueDiscItem item)

Classify a packet by calling the packet filters, one at a time, until either a filter able to classify the packet is found or all the filters have been processed.

Parameters
itemitem to classify
Returns
-1 if no filter able to classify the packet has been found, the value returned by first filter found to be able to classify the packet otherwise.

Definition at line 658 of file queue-disc.cc.

References f(), m_filters, NS_LOG_FUNCTION, and ns3::PacketFilter::PF_NO_MATCH.

Referenced by ns3::PrioQueueDisc::DoEnqueue(), and ns3::FqCoDelQueueDisc::DoEnqueue().

◆ Dequeue()

Ptr< QueueDiscItem > ns3::QueueDisc::Dequeue ( void  )

◆ DequeuePacket()

Ptr< QueueDiscItem > ns3::QueueDisc::DequeuePacket ( void  )
private

Modelled after the Linux function dequeue_skb (net/sched/sch_generic.c)

Returns
the requeued packet, if any, or the packet dequeued by the queue disc, otherwise.

Definition at line 993 of file queue-disc.cc.

References Dequeue(), m_devQueueIface, m_peeked, m_requeued, NS_ASSERT, NS_LOG_FUNCTION, and PacketDequeued().

Referenced by Restart().

◆ DoDequeue()

virtual Ptr<QueueDiscItem> ns3::QueueDisc::DoDequeue ( void  )
privatepure virtual

This function actually extracts a packet from the queue disc.

Returns
0 if the operation was not successful; the item otherwise.

Implemented in ns3::RedQueueDisc, TestParentQueueDisc, ns3::TbfQueueDisc, ns3::FqCoDelQueueDisc, ns3::CoDelQueueDisc, ns3::PieQueueDisc, TestChildQueueDisc, ns3::PrioQueueDisc, ns3::PfifoFastQueueDisc, ns3::MqQueueDisc, and ns3::FifoQueueDisc.

Referenced by Dequeue().

◆ DoDispose()

void ns3::QueueDisc::DoDispose ( void  )
protectedvirtual

◆ DoEnqueue()

virtual bool ns3::QueueDisc::DoEnqueue ( Ptr< QueueDiscItem item)
privatepure virtual

This function actually enqueues a packet into the queue disc.

Parameters
itemitem to enqueue
Returns
True if the operation was successful; false otherwise

Implemented in ns3::RedQueueDisc, TestParentQueueDisc, ns3::TbfQueueDisc, ns3::FqCoDelQueueDisc, ns3::CoDelQueueDisc, ns3::PieQueueDisc, TestChildQueueDisc, ns3::PrioQueueDisc, ns3::PfifoFastQueueDisc, ns3::MqQueueDisc, and ns3::FifoQueueDisc.

Referenced by Enqueue().

◆ DoInitialize()

void ns3::QueueDisc::DoInitialize ( void  )
protectedvirtual

Check whether the configuration is correct and initialize parameters.

This method is not virtual to prevent subclasses from redefining it. Subclasses must instead provide the implementation of the CheckConfig and InitializeParams methods (which are called by this method).

Reimplemented from ns3::Object.

Definition at line 394 of file queue-disc.cc.

References CheckConfig(), ns3::Object::DoInitialize(), InitializeParams(), m_classes, m_device, m_devQueueIface, NS_ASSERT_MSG(), NS_LOG_FUNCTION, and NS_UNUSED.

◆ DoPeek()

Ptr< const QueueDiscItem > ns3::QueueDisc::DoPeek ( void  )
privatevirtual

Return a copy of the next packet the queue disc will extract.

The implementation of this method is based on the qdisc_peek_dequeued function of the Linux kernel, which dequeues a packet and retains it in the queue disc as a requeued packet. The packet is not traced as requeued, nor is the total count of requeued packets increased. The packet is still considered to be part of the queue disc and the dequeue trace is fired when Dequeue is called and the packet is actually extracted from the queue disc.

This approach is especially recommended for queue discs for which it is not obvious what is the next packet that will be dequeued (e.g., queue discs having multiple internal queues or child queue discs or queue discs that drop packets after dequeue). Subclasses can however provide their own implementation of this method that overrides the default one.

Returns
0 if the operation was not successful; the packet otherwise.

Reimplemented in ns3::RedQueueDisc, ns3::PrioQueueDisc, ns3::PfifoFastQueueDisc, ns3::MqQueueDisc, and ns3::FifoQueueDisc.

Definition at line 920 of file queue-disc.cc.

References Dequeue(), m_peeked, m_requeued, and NS_LOG_FUNCTION.

Referenced by Peek().

◆ DropAfterDequeue()

void ns3::QueueDisc::DropAfterDequeue ( Ptr< const QueueDiscItem item,
const char *  reason 
)
protected

Perform the actions required when the queue disc is notified of a packet dropped after dequeue.

Parameters
itemitem that was dropped
reasonthe reason why the item was dropped This method must be called by subclasses to record that a packet was dropped after dequeue for the specified reason

Definition at line 751 of file queue-disc.cc.

References m_peeked, m_stats, m_traceDrop, m_traceDropAfterDequeue, ns3::QueueDisc::Stats::nDroppedBytesAfterDequeue, ns3::QueueDisc::Stats::nDroppedPacketsAfterDequeue, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_LOGIC(), ns3::QueueDisc::Stats::nTotalDroppedBytes, ns3::QueueDisc::Stats::nTotalDroppedBytesAfterDequeue, ns3::QueueDisc::Stats::nTotalDroppedPackets, ns3::QueueDisc::Stats::nTotalDroppedPacketsAfterDequeue, and PacketDequeued().

Referenced by TestChildQueueDisc::DoDequeue(), ns3::CoDelQueueDisc::DoDequeue(), ns3::FqCoDelQueueDisc::FqCoDelDrop(), and QueueDisc().

◆ DropBeforeEnqueue()

void ns3::QueueDisc::DropBeforeEnqueue ( Ptr< const QueueDiscItem item,
const char *  reason 
)
protected

◆ Enqueue()

bool ns3::QueueDisc::Enqueue ( Ptr< QueueDiscItem item)

Pass a packet to store to the queue discipline.

This function only updates the statistics and calls the (private) DoEnqueue function, which must be implemented by derived classes.

Parameters
itemitem to enqueue
Returns
True if the operation was successful; false otherwise

Definition at line 844 of file queue-disc.cc.

References DoEnqueue(), m_stats, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION, ns3::QueueDisc::Stats::nTotalDroppedBytesBeforeEnqueue, ns3::QueueDisc::Stats::nTotalDroppedPacketsBeforeEnqueue, ns3::QueueDisc::Stats::nTotalEnqueuedBytes, ns3::QueueDisc::Stats::nTotalEnqueuedPackets, ns3::QueueDisc::Stats::nTotalReceivedBytes, and ns3::QueueDisc::Stats::nTotalReceivedPackets.

Referenced by FqCoDelQueueDiscIPFlowsSeparationAndPacketLimit::AddPacket(), PfifoFastQueueDiscOverflow::AddPacket(), FqCoDelQueueDiscDeficit::AddPacket(), FqCoDelQueueDiscTCPFlowsSeparation::AddPacket(), FqCoDelQueueDiscUDPFlowsSeparation::AddPacket(), FqCoDelQueueDiscNoSuitableFilter::DoRun(), CoDelQueueDiscBasicEnqueueDequeue::DoRun(), PrioQueueDiscTestCase::DoRun(), CoDelQueueDiscBasicOverflow::DoRun(), PfifoFastQueueDiscNoPriority::DoRun(), QueueDiscTracesTestCase::DoRun(), FifoQueueDiscTestCase::DoRunFifoTest(), PieQueueDiscTestCase::Enqueue(), AredQueueDiscTestCase::Enqueue(), TbfQueueDiscTestCase::Enqueue(), RedQueueDiscTestCase::Enqueue(), CoDelQueueDiscBasicOverflow::Enqueue(), CoDelQueueDiscBasicDrop::Enqueue(), PieQueueDiscTestCase::RunPieTest(), RedQueueDiscTestCase::RunRedTest(), TbfQueueDiscTestCase::RunTbfTest(), ns3::TrafficControlLayer::Send(), PfifoFastQueueDiscDscpPrioritization::TestDscpValue(), and PfifoFastQueueDiscTosPrioritization::TestTosValue().

◆ GetCurrentSize()

QueueSize ns3::QueueDisc::GetCurrentSize ( void  )

◆ GetInternalQueue()

Ptr< QueueDisc::InternalQueue > ns3::QueueDisc::GetInternalQueue ( std::size_t  i) const

◆ GetMaxSize()

QueueSize ns3::QueueDisc::GetMaxSize ( void  ) const

◆ GetNBytes()

uint32_t ns3::QueueDisc::GetNBytes ( void  ) const

◆ GetNetDevice()

Ptr< NetDevice > ns3::QueueDisc::GetNetDevice ( void  ) const

Get the NetDevice on which this queue discipline is installed.

Returns
the NetDevice on which this queue discipline is installed.

Definition at line 546 of file queue-disc.cc.

References m_device, and NS_LOG_FUNCTION.

Referenced by ns3::TbfQueueDisc::CheckConfig(), and ns3::FqCoDelQueueDisc::InitializeParams().

◆ GetNInternalQueues()

std::size_t ns3::QueueDisc::GetNInternalQueues ( void  ) const

◆ GetNPacketFilters()

std::size_t ns3::QueueDisc::GetNPacketFilters ( void  ) const

◆ GetNPackets()

uint32_t ns3::QueueDisc::GetNPackets ( void  ) const

◆ GetNQueueDiscClasses()

std::size_t ns3::QueueDisc::GetNQueueDiscClasses ( void  ) const

◆ GetPacketFilter()

Ptr< PacketFilter > ns3::QueueDisc::GetPacketFilter ( std::size_t  i) const

Get the i-th packet filter.

Parameters
ithe index of the packet filter
Returns
the i-th packet filter.

Definition at line 607 of file queue-disc.cc.

References m_filters, and NS_ASSERT.

◆ GetQueueDiscClass()

Ptr< QueueDiscClass > ns3::QueueDisc::GetQueueDiscClass ( std::size_t  i) const

◆ GetQuota()

uint32_t ns3::QueueDisc::GetQuota ( void  ) const
virtual

Get the maximum number of dequeue operations following a packet enqueue.

Returns
the maximum number of dequeue operations following a packet enqueue.

Definition at line 560 of file queue-disc.cc.

References m_quota, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

◆ GetStats()

const QueueDisc::Stats & ns3::QueueDisc::GetStats ( void  )

◆ GetTypeId()

TypeId ns3::QueueDisc::GetTypeId ( void  )
static

◆ GetWakeMode()

QueueDisc::WakeMode ns3::QueueDisc::GetWakeMode ( void  ) const
virtual

When setting up the wake callbacks on the netdevice queues, it is necessary to determine which queue disc (the root queue disc or one of its children) should be activated when the netdevice wakes one of its transmission queues.

The implementation of this method for the base class returns WAKE_ROOT, i.e., the root queue disc is activated. Subclasses implementing queue discs adopting a different strategy (e.g., multi-queue aware queue discs such as mq) have to redefine this method.

Returns
the wake mode adopted by this queue disc.

Reimplemented in ns3::MqQueueDisc.

Definition at line 672 of file queue-disc.cc.

References WAKE_ROOT.

◆ InitializeParams()

virtual void ns3::QueueDisc::InitializeParams ( void  )
privatepure virtual

◆ Mark()

bool ns3::QueueDisc::Mark ( Ptr< QueueDiscItem item,
const char *  reason 
)
protected

Marks the given packet and, if successful, updates the counters associated with the given reason.

Parameters
itemitem that has to be marked
reasonthe reason why the item has to be marked
Returns
true if the item was successfully marked, false otherwise

Definition at line 801 of file queue-disc.cc.

References m_stats, m_traceMark, ns3::QueueDisc::Stats::nMarkedBytes, ns3::QueueDisc::Stats::nMarkedPackets, NS_LOG_DEBUG, NS_LOG_FUNCTION, ns3::QueueDisc::Stats::nTotalMarkedBytes, and ns3::QueueDisc::Stats::nTotalMarkedPackets.

Referenced by ns3::RedQueueDisc::DoEnqueue().

◆ operator=()

QueueDisc& ns3::QueueDisc::operator= ( const QueueDisc o)
private

Assignment operator.

Parameters
oobject to copy
Returns
the copied object

Defined and unimplemented to avoid misuse

◆ PacketDequeued()

void ns3::QueueDisc::PacketDequeued ( Ptr< const QueueDiscItem item)
private

Perform the actions required when the queue disc is notified of a packet dequeue.

Parameters
itemitem that was dequeued

Definition at line 690 of file queue-disc.cc.

References m_nBytes, m_nPackets, m_peeked, m_sojourn, m_stats, m_traceDequeue, ns3::Simulator::Now(), NS_LOG_LOGIC(), ns3::QueueDisc::Stats::nTotalDequeuedBytes, and ns3::QueueDisc::Stats::nTotalDequeuedPackets.

Referenced by AddInternalQueue(), AddQueueDiscClass(), Dequeue(), DequeuePacket(), and DropAfterDequeue().

◆ PacketEnqueued()

void ns3::QueueDisc::PacketEnqueued ( Ptr< const QueueDiscItem item)
private

Perform the actions required when the queue disc is notified of a packet enqueue.

Parameters
itemitem that was enqueued

Definition at line 678 of file queue-disc.cc.

References m_nBytes, m_nPackets, m_stats, m_traceEnqueue, NS_LOG_LOGIC(), ns3::QueueDisc::Stats::nTotalEnqueuedBytes, and ns3::QueueDisc::Stats::nTotalEnqueuedPackets.

Referenced by AddInternalQueue(), and AddQueueDiscClass().

◆ Peek()

Ptr< const QueueDiscItem > ns3::QueueDisc::Peek ( void  )

Get a copy of the next packet the queue discipline will extract.

This function only calls the (private) DoPeek function. This base class provides a default implementation of DoPeek, which dequeues the next packet but retains it into the queue disc.

Returns
0 if the operation was not successful; the item otherwise.

Definition at line 913 of file queue-disc.cc.

References DoPeek(), and NS_LOG_FUNCTION.

Referenced by ns3::PfifoFastQueueDisc::DoPeek(), ns3::PrioQueueDisc::DoPeek(), and QueueDiscTracesTestCase::DoRun().

◆ Requeue()

void ns3::QueueDisc::Requeue ( Ptr< QueueDiscItem item)
private

Modelled after the Linux function dev_requeue_skb (net/sched/sch_generic.c) Requeues a packet whose transmission failed.

Parameters
itemthe packet to requeue
Todo:
netif_schedule (q);

Definition at line 1041 of file queue-disc.cc.

References m_requeued, m_stats, m_traceRequeue, NS_LOG_FUNCTION, NS_LOG_LOGIC(), ns3::QueueDisc::Stats::nTotalRequeuedBytes, and ns3::QueueDisc::Stats::nTotalRequeuedPackets.

Referenced by Transmit().

◆ Restart()

bool ns3::QueueDisc::Restart ( void  )
private

Modelled after the Linux function qdisc_restart (net/sched/sch_generic.c) Dequeue a packet (by calling DequeuePacket) and send it to the device (by calling Transmit).

Returns
true if a packet is successfully sent to the device.

Definition at line 979 of file queue-disc.cc.

References DequeuePacket(), NS_LOG_FUNCTION, NS_LOG_LOGIC(), and Transmit().

Referenced by Run().

◆ Run()

void ns3::QueueDisc::Run ( void  )

Modelled after the Linux function __qdisc_run (net/sched/sch_generic.c) Dequeues multiple packets, until a quota is exceeded or sending a packet to the device failed.

Todo:
netif_schedule (q);

Definition at line 938 of file queue-disc.cc.

References m_quota, NS_LOG_FUNCTION, Restart(), RunBegin(), and RunEnd().

Referenced by ns3::TbfQueueDisc::DoDequeue(), ns3::TrafficControlLayer::DoInitialize(), and ns3::TrafficControlLayer::Send().

◆ RunBegin()

bool ns3::QueueDisc::RunBegin ( void  )
private

Modelled after the Linux function qdisc_run_begin (include/net/sch_generic.h).

Returns
false if the qdisc is already running; otherwise, set the qdisc as running and return true.

Definition at line 959 of file queue-disc.cc.

References m_running, and NS_LOG_FUNCTION.

Referenced by Run().

◆ RunEnd()

void ns3::QueueDisc::RunEnd ( void  )
private

Modelled after the Linux function qdisc_run_end (include/net/sch_generic.h).

Set the qdisc as not running.

Definition at line 972 of file queue-disc.cc.

References m_running, and NS_LOG_FUNCTION.

Referenced by Run().

◆ SetMaxSize()

bool ns3::QueueDisc::SetMaxSize ( QueueSize  size)

◆ SetNetDevice()

void ns3::QueueDisc::SetNetDevice ( Ptr< NetDevice device)

Set the NetDevice on which this queue discipline is installed.

Parameters
devicethe NetDevice on which this queue discipline is installed.

Definition at line 539 of file queue-disc.cc.

References m_device, and NS_LOG_FUNCTION.

Referenced by ns3::TrafficControlHelper::Install(), and TbfQueueDiscTestCase::RunTbfTest().

◆ SetQuota()

void ns3::QueueDisc::SetQuota ( const uint32_t  quota)
virtual

Set the maximum number of dequeue operations following a packet enqueue.

Parameters
quotathe maximum number of dequeue operations following a packet enqueue.

Definition at line 553 of file queue-disc.cc.

References m_quota, and NS_LOG_FUNCTION.

Referenced by GetTypeId().

◆ Transmit()

bool ns3::QueueDisc::Transmit ( Ptr< QueueDiscItem item)
private

Modelled after the Linux function sch_direct_xmit (net/sched/sch_generic.c) Sends a packet to the device if the device queue is not stopped, and requeues it otherwise.

Parameters
itemthe packet to transmit
Returns
true if the device queue is not stopped and the queue disc is not empty

Definition at line 1055 of file queue-disc.cc.

References GetNPackets(), m_device, m_devQueueIface, NS_ASSERT, NS_LOG_FUNCTION, and Requeue().

Referenced by Restart().

Member Data Documentation

◆ CHILD_QUEUE_DISC_DROP

constexpr const char* ns3::QueueDisc::CHILD_QUEUE_DISC_DROP = "(Dropped by child queue disc) "
static

Packet dropped by a child queue disc.

Definition at line 495 of file queue-disc.h.

Referenced by QueueDisc().

◆ DEFAULT_QUOTA

const uint32_t ns3::QueueDisc::DEFAULT_QUOTA = 64
staticprivate

Default quota (as in /proc/sys/net/core/dev_weight)

Definition at line 661 of file queue-disc.h.

Referenced by GetTypeId().

◆ INTERNAL_QUEUE_DROP

constexpr const char* ns3::QueueDisc::INTERNAL_QUEUE_DROP = "Dropped by internal queue"
static

Packet dropped by an internal queue.

Definition at line 494 of file queue-disc.h.

Referenced by QueueDisc().

◆ m_childQueueDiscDadFunctor

ChildQueueDiscDropFunctor ns3::QueueDisc::m_childQueueDiscDadFunctor
private

Function object called when a child queue disc dropped a packet after dequeue.

Definition at line 710 of file queue-disc.h.

Referenced by AddQueueDiscClass(), and QueueDisc().

◆ m_childQueueDiscDbeFunctor

ChildQueueDiscDropFunctor ns3::QueueDisc::m_childQueueDiscDbeFunctor
private

Function object called when a child queue disc dropped a packet before enqueue.

Definition at line 708 of file queue-disc.h.

Referenced by AddQueueDiscClass(), and QueueDisc().

◆ m_childQueueDiscDropMsg

std::string ns3::QueueDisc::m_childQueueDiscDropMsg
private

Reason why a packet was dropped by a child queue disc.

Definition at line 679 of file queue-disc.h.

Referenced by QueueDisc().

◆ m_classes

std::vector<Ptr<QueueDiscClass> > ns3::QueueDisc::m_classes
private

◆ m_device

Ptr<NetDevice> ns3::QueueDisc::m_device
private

The NetDevice on which this queue discipline is installed.

Definition at line 674 of file queue-disc.h.

Referenced by DoDispose(), DoInitialize(), GetNetDevice(), SetNetDevice(), and Transmit().

◆ m_devQueueIface

Ptr<NetDeviceQueueInterface> ns3::QueueDisc::m_devQueueIface
private

NetDevice queue interface.

Definition at line 675 of file queue-disc.h.

Referenced by DequeuePacket(), DoDispose(), DoInitialize(), and Transmit().

◆ m_filters

std::vector<Ptr<PacketFilter> > ns3::QueueDisc::m_filters
private

Packet filters.

Definition at line 664 of file queue-disc.h.

Referenced by AddPacketFilter(), Classify(), DoDispose(), GetNPacketFilters(), GetPacketFilter(), and GetTypeId().

◆ m_internalQueueDadFunctor

InternalQueueDropFunctor ns3::QueueDisc::m_internalQueueDadFunctor
private

Function object called when an internal queue dropped a packet after dequeue.

Definition at line 706 of file queue-disc.h.

Referenced by AddInternalQueue(), and QueueDisc().

◆ m_internalQueueDbeFunctor

InternalQueueDropFunctor ns3::QueueDisc::m_internalQueueDbeFunctor
private

Function object called when an internal queue dropped a packet before enqueue.

Definition at line 704 of file queue-disc.h.

Referenced by AddInternalQueue(), and QueueDisc().

◆ m_maxSize

QueueSize ns3::QueueDisc::m_maxSize
private

max queue size

Definition at line 670 of file queue-disc.h.

Referenced by GetMaxSize(), QueueDisc(), and SetMaxSize().

◆ m_nBytes

TracedValue<uint32_t> ns3::QueueDisc::m_nBytes
private

Number of bytes in the queue.

Definition at line 668 of file queue-disc.h.

Referenced by Dequeue(), GetCurrentSize(), GetNBytes(), GetTypeId(), PacketDequeued(), and PacketEnqueued().

◆ m_nPackets

TracedValue<uint32_t> ns3::QueueDisc::m_nPackets
private

Number of packets in the queue.

Definition at line 667 of file queue-disc.h.

Referenced by Dequeue(), GetCurrentSize(), GetNPackets(), GetTypeId(), PacketDequeued(), and PacketEnqueued().

◆ m_peeked

bool ns3::QueueDisc::m_peeked
private

A packet was dequeued because Peek was called.

Definition at line 678 of file queue-disc.h.

Referenced by Dequeue(), DequeuePacket(), DoPeek(), DropAfterDequeue(), and PacketDequeued().

◆ m_prohibitChangeMode

bool ns3::QueueDisc::m_prohibitChangeMode
private

True if changing mode is prohibited.

Definition at line 681 of file queue-disc.h.

Referenced by QueueDisc(), and SetMaxSize().

◆ m_queues

std::vector<Ptr<InternalQueue> > ns3::QueueDisc::m_queues
private

Internal queues.

Definition at line 663 of file queue-disc.h.

Referenced by AddInternalQueue(), DoDispose(), GetInternalQueue(), GetNInternalQueues(), and GetTypeId().

◆ m_quota

uint32_t ns3::QueueDisc::m_quota
private

Maximum number of packets dequeued in a qdisc run.

Definition at line 673 of file queue-disc.h.

Referenced by GetQuota(), Run(), and SetQuota().

◆ m_requeued

Ptr<QueueDiscItem> ns3::QueueDisc::m_requeued
private

The last packet that failed to be transmitted.

Definition at line 677 of file queue-disc.h.

Referenced by Dequeue(), DequeuePacket(), DoDispose(), DoPeek(), GetStats(), and Requeue().

◆ m_running

bool ns3::QueueDisc::m_running
private

The queue disc is performing multiple dequeue operations.

Definition at line 676 of file queue-disc.h.

Referenced by RunBegin(), and RunEnd().

◆ m_sizePolicy

QueueDiscSizePolicy ns3::QueueDisc::m_sizePolicy
private

The queue disc size policy.

Definition at line 680 of file queue-disc.h.

Referenced by GetMaxSize(), and SetMaxSize().

◆ m_sojourn

TracedCallback<Time> ns3::QueueDisc::m_sojourn
private

Sojourn time of the latest dequeued packet.

Definition at line 669 of file queue-disc.h.

Referenced by GetTypeId(), and PacketDequeued().

◆ m_stats

Stats ns3::QueueDisc::m_stats
private

The collected statistics.

Definition at line 672 of file queue-disc.h.

Referenced by Dequeue(), DropAfterDequeue(), DropBeforeEnqueue(), Enqueue(), GetStats(), Mark(), PacketDequeued(), PacketEnqueued(), and Requeue().

◆ m_traceDequeue

TracedCallback<Ptr<const QueueDiscItem> > ns3::QueueDisc::m_traceDequeue
private

Traced callback: fired when a packet is dequeued.

Definition at line 686 of file queue-disc.h.

Referenced by GetTypeId(), and PacketDequeued().

◆ m_traceDrop

TracedCallback<Ptr<const QueueDiscItem> > ns3::QueueDisc::m_traceDrop
private

Traced callback: fired when a packet is dropped.

Definition at line 690 of file queue-disc.h.

Referenced by DropAfterDequeue(), DropBeforeEnqueue(), and GetTypeId().

◆ m_traceDropAfterDequeue

TracedCallback<Ptr<const QueueDiscItem>, const char* > ns3::QueueDisc::m_traceDropAfterDequeue
private

Traced callback: fired when a packet is dropped after dequeue.

Definition at line 694 of file queue-disc.h.

Referenced by DropAfterDequeue(), and GetTypeId().

◆ m_traceDropBeforeEnqueue

TracedCallback<Ptr<const QueueDiscItem>, const char* > ns3::QueueDisc::m_traceDropBeforeEnqueue
private

Traced callback: fired when a packet is dropped before enqueue.

Definition at line 692 of file queue-disc.h.

Referenced by DropBeforeEnqueue(), and GetTypeId().

◆ m_traceEnqueue

TracedCallback<Ptr<const QueueDiscItem> > ns3::QueueDisc::m_traceEnqueue
private

Traced callback: fired when a packet is enqueued.

Definition at line 684 of file queue-disc.h.

Referenced by GetTypeId(), and PacketEnqueued().

◆ m_traceMark

TracedCallback<Ptr<const QueueDiscItem>, const char* > ns3::QueueDisc::m_traceMark
private

Traced callback: fired when a packet is marked.

Definition at line 696 of file queue-disc.h.

Referenced by GetTypeId(), and Mark().

◆ m_traceRequeue

TracedCallback<Ptr<const QueueDiscItem> > ns3::QueueDisc::m_traceRequeue
private

Traced callback: fired when a packet is requeued.

Definition at line 688 of file queue-disc.h.

Referenced by GetTypeId(), and Requeue().


The documentation for this class was generated from the following files: