A Discrete-Event Network Simulator
API
ns3::PrioQueueDisc Class Reference

The Prio qdisc is a simple classful queueing discipline that contains an arbitrary number of classes of differing priority. More...

#include "prio-queue-disc.h"

+ Inheritance diagram for ns3::PrioQueueDisc:
+ Collaboration diagram for ns3::PrioQueueDisc:

Public Member Functions

 PrioQueueDisc ()
 PrioQueueDisc constructor. More...
 
 ~PrioQueueDisc () override
 
uint16_t GetBandForPriority (uint8_t prio) const
 Get the band (class) assigned to packets with specified priority. More...
 
void SetBandForPriority (uint8_t prio, uint16_t band)
 Set the band (class) assigned to packets with specified priority. More...
 
- Public Member Functions inherited from ns3::QueueDisc
 QueueDisc (const QueueDisc &)=delete
 
 QueueDisc (QueueDiscSizePolicy policy, QueueSizeUnit unit)
 Constructor. More...
 
 QueueDisc (QueueDiscSizePolicy policy=QueueDiscSizePolicy::SINGLE_INTERNAL_QUEUE)
 Constructor. More...
 
 ~QueueDisc () override
 
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 ()
 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 () const
 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 () const
 Get the maximum size of the queue disc. More...
 
uint32_t GetNBytes () const
 Get the amount of bytes stored by the queue disc. More...
 
Ptr< NetDeviceQueueInterfaceGetNetDeviceQueueInterface () const
 
std::size_t GetNInternalQueues () const
 Get the number of internal queues. More...
 
std::size_t GetNPacketFilters () const
 Get the number of packet filters. More...
 
uint32_t GetNPackets () const
 Get the number of packets stored by the queue disc. More...
 
std::size_t GetNQueueDiscClasses () 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 () const
 Get the maximum number of dequeue operations following a packet enqueue. More...
 
SendCallback GetSendCallback () const
 
const StatsGetStats ()
 Retrieve all the collected statistics. More...
 
virtual WakeMode GetWakeMode () 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...
 
QueueDiscoperator= (const QueueDisc &)=delete
 
Ptr< const QueueDiscItemPeek ()
 Get a copy of the next packet the queue discipline will extract. More...
 
void Run ()
 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 SetNetDeviceQueueInterface (Ptr< NetDeviceQueueInterface > ndqi)
 
virtual void SetQuota (const uint32_t quota)
 Set the maximum number of dequeue operations following a packet enqueue. More...
 
void SetSendCallback (SendCallback func)
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
 ~Object () override
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose ()
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one. More...
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object. More...
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized () 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[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount () const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o[[maybe_unused]])
 Assignment operator. More...
 
void Ref () const
 Increment the reference count. More...
 
void Unref () 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 errors. 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 ()
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::QueueDisc
static TypeId GetTypeId ()
 Get the type ID. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID. More...
 

Private Member Functions

bool CheckConfig () override
 Check whether the current configuration is correct. More...
 
Ptr< QueueDiscItemDoDequeue () override
 This function actually extracts a packet from the queue disc. More...
 
bool DoEnqueue (Ptr< QueueDiscItem > item) override
 This function actually enqueues a packet into the queue disc. More...
 
Ptr< const QueueDiscItemDoPeek () override
 Return a copy of the next packet the queue disc will extract. More...
 
void InitializeParams () override
 Initialize parameters (if any) before the first packet is enqueued. More...
 

Private Attributes

Priomap m_prio2band
 Priority to band mapping. More...
 

Additional Inherited Members

- Public Types inherited from ns3::QueueDisc
typedef Queue< QueueDiscItemInternalQueue
 Internal queues store QueueDiscItem objects. More...
 
typedef std::function< void(Ptr< QueueDiscItem >)> SendCallback
 Callback invoked to send a packet to the receiving object when Run is called. 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...
 
- Static Public Attributes inherited from ns3::QueueDisc
static constexpr const char * CHILD_QUEUE_DISC_DROP
 Packet dropped by a child queue disc. More...
 
static constexpr const char * CHILD_QUEUE_DISC_MARK
 Packet marked by a child queue disc. More...
 
static constexpr const char * INTERNAL_QUEUE_DROP
 Packet dropped by an internal queue. More...
 
- Protected Member Functions inherited from ns3::QueueDisc
void DoDispose () override
 Dispose of the object. More...
 
void DoInitialize () override
 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 ()
 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 ()
 Notifier called once the ObjectBase is fully constructed. More...
 

Detailed Description

The Prio qdisc is a simple classful queueing discipline that contains an arbitrary number of classes of differing priority.

The classes are dequeued in numerical descending order of priority. By default, three Fifo queue discs are created, unless the user provides (at least two) child queue discs.

If no packet filter is installed or able to classify a packet, then the packet is assigned a priority band based on its priority (modulo 16), which is used as an index into an array called priomap. If a packet is classified by a packet filter and the returned value is non-negative and less than the number of priority bands, then the packet is assigned the priority band corresponding to the value returned by the packet filter. Otherwise, the packet is assigned the priority band specified by the first element of the priomap array.

Definition at line 51 of file prio-queue-disc.h.

Constructor & Destructor Documentation

◆ PrioQueueDisc()

ns3::PrioQueueDisc::PrioQueueDisc ( )

PrioQueueDisc constructor.

Definition at line 77 of file prio-queue-disc.cc.

References NS_LOG_FUNCTION.

◆ ~PrioQueueDisc()

ns3::PrioQueueDisc::~PrioQueueDisc ( )
override

Definition at line 83 of file prio-queue-disc.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

◆ CheckConfig()

bool ns3::PrioQueueDisc::CheckConfig ( )
overrideprivatevirtual

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. This method is automatically called at simulation initialization time, and it is called before the InitializeParams () method. It is appropriate to promote parameter initialization to this method if it aids in checking for correct configuration.

See also
QueueDisc::InitializeParams
Returns
true if the configuration is correct, false otherwise

Implements ns3::QueueDisc.

Definition at line 194 of file prio-queue-disc.cc.

References ns3::QueueDisc::AddQueueDiscClass(), ns3::ObjectFactory::Create(), ns3::QueueDisc::GetNInternalQueues(), ns3::QueueDisc::GetNQueueDiscClasses(), ns3::Object::Initialize(), NS_LOG_ERROR, NS_LOG_FUNCTION, and ns3::ObjectFactory::SetTypeId().

+ Here is the call graph for this function:

◆ DoDequeue()

Ptr< QueueDiscItem > ns3::PrioQueueDisc::DoDequeue ( )
overrideprivatevirtual

This function actually extracts a packet from the queue disc.

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

Implements ns3::QueueDisc.

Definition at line 150 of file prio-queue-disc.cc.

References ns3::QueueDisc::Dequeue(), ns3::QueueDisc::GetNPackets(), ns3::QueueDisc::GetNQueueDiscClasses(), ns3::QueueDisc::GetQueueDiscClass(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.

+ Here is the call graph for this function:

◆ DoEnqueue()

bool ns3::PrioQueueDisc::DoEnqueue ( Ptr< QueueDiscItem item)
overrideprivatevirtual

This function actually enqueues a packet into the queue disc.

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

Implements ns3::QueueDisc.

Definition at line 109 of file prio-queue-disc.cc.

References ns3::QueueDisc::Classify(), ns3::QueueDisc::GetNPackets(), ns3::QueueDisc::GetNQueueDiscClasses(), ns3::SocketPriorityTag::GetPriority(), ns3::QueueDisc::GetQueueDiscClass(), m_prio2band, NS_ASSERT_MSG, NS_LOG_DEBUG, NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::PacketFilter::PF_NO_MATCH.

+ Here is the call graph for this function:

◆ DoPeek()

Ptr< const QueueDiscItem > ns3::PrioQueueDisc::DoPeek ( )
overrideprivatevirtual

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 from ns3::QueueDisc.

Definition at line 172 of file prio-queue-disc.cc.

References ns3::QueueDisc::GetNPackets(), ns3::QueueDisc::GetNQueueDiscClasses(), ns3::QueueDisc::GetQueueDiscClass(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::QueueDisc::Peek().

+ Here is the call graph for this function:

◆ GetBandForPriority()

uint16_t ns3::PrioQueueDisc::GetBandForPriority ( uint8_t  prio) const

Get the band (class) assigned to packets with specified priority.

Parameters
priothe priority of packets (a value between 0 and 15).
Returns
the band assigned to packets.

Definition at line 99 of file prio-queue-disc.cc.

References m_prio2band, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

◆ GetTypeId()

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

Get the type ID.

Returns
the object TypeId

Definition at line 62 of file prio-queue-disc.cc.

References m_prio2band, and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ InitializeParams()

void ns3::PrioQueueDisc::InitializeParams ( )
overrideprivatevirtual

Initialize parameters (if any) before the first packet is enqueued.

This method is automatically called at simulation initialization time, after the CheckConfig() method has been called.

See also
QueueDisc::CheckConfig

Implements ns3::QueueDisc.

Definition at line 228 of file prio-queue-disc.cc.

References NS_LOG_FUNCTION.

◆ SetBandForPriority()

void ns3::PrioQueueDisc::SetBandForPriority ( uint8_t  prio,
uint16_t  band 
)

Set the band (class) assigned to packets with specified priority.

Parameters
priothe priority of packets (a value between 0 and 15).
bandthe band assigned to packets.

Definition at line 89 of file prio-queue-disc.cc.

References m_prio2band, NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Member Data Documentation

◆ m_prio2band

Priomap ns3::PrioQueueDisc::m_prio2band
private

Priority to band mapping.

Definition at line 89 of file prio-queue-disc.h.

Referenced by DoEnqueue(), GetBandForPriority(), GetTypeId(), and SetBandForPriority().


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