PacketQueue

Package: inet.queueing.queue

simple module PacketQueue

Implements a configurable packet queue, which is suitable for use in MAC protocols, traffic conditioning, and quality of services, among others. This is a passive component: packets are pushed into it on its input, and pulled from it on its output. This module can be used on its own, but it’s also often supplemented by additional queueing components such as servers, classifiers, schedulers, multiplexers, etc. This kind of composition allows to form a larger module which can act as a packet queue with more complex behavior.

By default, this module acts as a standard FIFO queue with an infinite internal buffer. Nevertheless, it can also be configured to limit the number of packets and the total data length of packets in the internal buffer. If the queue becomes overloaded by surpassing the limits of the internal buffer, an error is raised unless a packet drop algorithm is configured.

When a packet drop algorithm is used, then one or more packets are dropped until the storage limits are met according to the dropping strategy. Packets are only dropped after the new packet has been inserted into the queue. This method allows higher priority packets to take precedence over already stored lower priority packets even if the queue is already full. If a packet dropper function is not used and any queue capacity parameter is specified then the queue provides back pressure towards its source.

The queue can also keep the packets sorted according to a comparator function. If a comparator is not configured, then packets are pushed at the back of the queue and they are kept in this order. Packets are always pulled at the front of the queue.

It’s also possible to use an external buffer, which can be shared among multiple queues. In this case, the storage limits are configured on the packet buffer, which also takes care of dropping packets from either this queue or some other queues as necessary.

Some often used packet queue variants such as DropTailQueue are implemented as derived modules.

Some notable packet dropper functions are: ~PacketAtCollectionBeginDropper, ~PacketAtCollectionEndDropper, ~PacketWithHighestOwnerModuleIdDropper, ~PacketWithLowestOwnerModuleIdDropper.

Some notable packet comparator functions are: ~PacketUserPriorityComparator, ~PacketCreationTimeComparator, ~PacketEligibilityTimeComparator.

See also: IPacketBuffer

inet.queueing.queue.PacketQueuePacketQueuesimple

Usage diagram

Inheritance diagram

Used in compound modules

Name

Type

Description

EthernetFragmentingMacLayer

compound module

(no description)

EthernetMacLayer

compound module

(no description)

EthernetStreamingMacLayer

compound module

(no description)

CompoundPendingQueue

compound module

Implements a prioritized queue system for IEEE 802.11 MAC frames. Uses a classifier to separate incoming packets into three queues: management frames (highest priority), multicast frames (medium priority), and unicast frames (lowest priority). A priority scheduler then selects packets from these queues in order of priority.

Ieee8021qTimeAwareShaper

compound module

Implements the IEEE 802.1Q time aware shaper.

AFxyQueue

compound module

This is an example queue that implements one class of the Assured Forwarding PHB group (RFC 2597).

QueueingPacketDelayer

compound module

Compound module that delays packets for a specified amount of time while preserving their order. Implements the IPacketDelayer interface using a queue and server architecture. The queue stores packets while they wait, and the server processes each packet with a processing time equal to the configured delay. Note that the actual packet delay will be the sum of the queueing time and the configured delay. Unlike the simple PacketDelayer module, this implementation always maintains packet order regardless of delay distribution.

GatingPriorityQueue

compound module

Implements a priority queue with multiple inner queues each having its own periodic gate for packet selection and an optional shared memory buffer.

GatingQueue

compound module

Implements a queue having its own periodic gate.

PriorityQueue

compound module

Implements a priority queue with multiple inner queues and an optional shared memory buffer.

RedDropperQueue

compound module

Combines a packet queue with random early detection (RED) dropper.

PacketShaper

compound module

Combines a packet queue and a packet gate into a packet shaper module. The queue stores the packets sorted according to its ordering and the gate decides when the first packet can be pulled from the queue.

RequestConsumer

compound module

Processes incoming packets one by one in the order they arrive. First, it classifies a packet according to the configured classifier function, then it generates tokens for the selected category in the configured response producer.

Known subclasses

Name

Type

Description

EligibilityTimeQueue

simple module

A packet queue that keeps the packets in ascending order based on the eligibility time in the attached EligibilityTimeTag of the packets.

DropHeadQueue

simple module

This is a limited packet queue that drops packets at the head of the queue.

DropTailQueue

simple module

A limited packet queue that drops packets at the tail of the queue.

InProgressQueue

simple module

Specialized packet queue that only accepts packets with higher priority than those already in the queue. Unlike standard packet queues, it always returns false for canPushSomePacket() and only allows insertion of packets that compare favorably against the first packet in the queue according to the configured comparator function (see comparatorClass parameter). Useful for implementing priority-based packet processing where only higher priority packets can preempt currently queued packets.

Extends

Name

Type

Description

PacketQueueBase

simple module

Base module for various packet queue modules which maintains a few statistics.

Parameters

Name

Type

Default value

Description

displayStringTextFormat

string

“contains %p pk (%l) pushed %u\npulled %o removed %r dropped %d”

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

packetCapacity

int

-1

Maximum number of packets in the queue, no limit by default

dataCapacity

int

-1b

Maximum total length of packets in the queue, no limit by default

dropperClass

string

“”

Determines which packets are dropped when the queue is overloaded, packets are not dropped by default; the parameter must be the name of a C++ class which implements the IPacketDropperFunction C++ interface and is registered via Register_Class

comparatorClass

string

“”

Determines the order of packets in the queue, insertion order by default; the parameter must be the name of a C++ class which implements the IPacketComparatorFunction C++ interface and is registered via Register_Class

bufferModule

string

“”

Relative module path to the IPacketBuffer module used by this queue, implicit buffer by default

Properties

Name

Value

Description

class

PacketQueue

defaultStatistic

queueLength:vector

display

i=block/queue

Gates

Name

Direction

Size

Description

in

input

out

output

Signals

Name

Type

Unit

Description

packetDropped

inet::Packet

packetPulled

inet::Packet

packetPushEnded

inet::Packet?

packetPushStarted

inet::Packet

packetRemoved

inet::Packet

Statistics

Name

Title

Source

Record

Unit

Interpolation Mode

Description

droppedPacketLengthsQueueOverflow

dropped packet lengths: queue overflow

packetLength(packetDropReasonIsQueueOverflow(packetDropped))

sum,vector

b

none

the statistical value is the length of the packet that is dropped due to queue overflow

droppedPacketsQueueOverflow

dropped packets: queue overflow

packetDropReasonIsQueueOverflow(packetDropped)

count

pk

none

the statistical value is the packet that is dropped due to queue overflow

flowIncomingDataRate

flow specific incoming data rate

throughput(flowPacketLength(demuxFlow(packetPushStarted)))

vector

bps

linear

the statistical value is the flow specific data rate of the incoming packets

flowOutgoingDataRate

flow specific outgoing data rate

throughput(flowPacketLength(demuxFlow(packetPulled)))

vector

bps

linear

the statistical value is the flow specific data rate of the outgoing packets

flowQueueingTime

flow queueing times

queueingTime(demuxFlow(packetPulled))

histogram,vector

s

none

the statistical value is the flow specific queueing time of packets

incomingDataRate

incoming datarate

throughput(packetPushStarted)

vector

bps

linear

the statistical value is the data rate of the incoming packets

incomingPacketLengths

incoming packet lengths

packetLength(packetPushStarted)

sum,histogram,vector

b

none

the statistical value is the length of the incoming packet

incomingPackets

incoming packets

packetPushStarted

count

pk

the statistical value is the incoming packet

outgoingDataRate

outgoing datarate

throughput(packetPulled)

vector

bps

linear

the statistical value is the data rate of the outgoing packets

outgoingPacketLengths

outgoing packet lengths

packetLength(packetPulled)

sum,histogram,vector

b

none

the statistical value is the length of the outgoing packet

outgoingPackets

outgoing packets

packetPulled

count

pk

the statistical value is the outgoing packet

queueBitLength

queue bit length

warmup(atomic(constant0(packetPushEnded) + sum(packetLength(packetPushStarted)) - sum(packetLength(packetPulled)) - sum(packetLength(packetRemoved)) - sum(packetLength(packetDropped))))

last,max,timeavg,vector

b

sample-hold

the statistical value is the total bit length of all packets in the queue

queueingTime

queueing times

queueingTime(packetPulled)

histogram,vector

s

none

the statistical value is the queueing time of packets

queueLength

queue length

warmup(atomic(constant0(packetPushEnded) + count(packetPushStarted) - count(packetPulled) - count(packetRemoved) - count(packetDropped)))

last,max,timeavg,vector

pk

sample-hold

the statistical value is the number of packets in the queue

Source code

//
// Implements a configurable packet queue, which is suitable for use
// in MAC protocols, traffic conditioning, and quality of services, among others.
// This is a passive component: packets are pushed into it on its input, and pulled
// from it on its output. This module can be used on its own, but it's also often supplemented
// by additional queueing components such as servers, classifiers, schedulers,
// multiplexers, etc. This kind of composition allows to form a larger module
// which can act as a packet queue with more complex behavior.
//
// By default, this module acts as a standard FIFO queue with an infinite
// internal buffer. Nevertheless, it can also be configured to limit the number
// of packets and the total data length of packets in the internal buffer.
// If the queue becomes overloaded by surpassing the limits of the internal
// buffer, an error is raised unless a packet drop algorithm is configured.
//
// When a packet drop algorithm is used, then one or more packets are dropped
// until the storage limits are met according to the dropping strategy. Packets
// are only dropped after the new packet has been inserted into the queue. This
// method allows higher priority packets to take precedence over already stored
// lower priority packets even if the queue is already full. If a packet dropper
// function is not used and any queue capacity parameter is specified then the
// queue provides back pressure towards its source.
//
// The queue can also keep the packets sorted according to a comparator function.
// If a comparator is not configured, then packets are pushed at the back of the
// queue and they are kept in this order. Packets are always pulled at the front
// of the queue.
//
// It's also possible to use an external buffer, which can be shared among multiple
// queues. In this case, the storage limits are configured on the packet buffer,
// which also takes care of dropping packets from either this queue or some
// other queues as necessary.
//
// Some often used packet queue variants such as ~DropTailQueue are implemented
// as derived modules.
//
// Some notable packet dropper functions are: ~PacketAtCollectionBeginDropper,
// ~PacketAtCollectionEndDropper, ~PacketWithHighestOwnerModuleIdDropper,
// ~PacketWithLowestOwnerModuleIdDropper.
//
// Some notable packet comparator functions are: ~PacketUserPriorityComparator,
// ~PacketCreationTimeComparator, ~PacketEligibilityTimeComparator.
//
// @see ~IPacketBuffer
//
simple PacketQueue extends PacketQueueBase like IPacketQueue
{
    parameters:
        int packetCapacity = default(-1); // Maximum number of packets in the queue, no limit by default
        int dataCapacity @unit(b) = default(-1b); // Maximum total length of packets in the queue, no limit by default
        string dropperClass = default(""); // Determines which packets are dropped when the queue is overloaded, packets are not dropped by default; the parameter must be the name of a C++ class which implements the IPacketDropperFunction C++ interface and is registered via Register_Class
        string comparatorClass = default(""); // Determines the order of packets in the queue, insertion order by default; the parameter must be the name of a C++ class which implements the IPacketComparatorFunction C++ interface and is registered via Register_Class
        string bufferModule = default(""); // Relative module path to the IPacketBuffer module used by this queue, implicit buffer by default
        displayStringTextFormat = default("contains %p pk (%l) pushed %u\npulled %o removed %r dropped %d"); // See ~PacketQueueBase for available format specifiers
        @class(PacketQueue);
        @signal[packetPushStarted](type=inet::Packet);
        @signal[packetPushEnded](type=inet::Packet?);
        @signal[packetPulled](type=inet::Packet);
        @signal[packetRemoved](type=inet::Packet);
        @signal[packetDropped](type=inet::Packet);
        // the statistical value is the number of packets in the queue
        @statistic[queueLength](title="queue length"; source=warmup(atomic(constant0(packetPushEnded) + count(packetPushStarted) - count(packetPulled) - count(packetRemoved) - count(packetDropped))); record=last,max,timeavg,vector; unit=pk; interpolationmode=sample-hold; autoWarmupFilter=false);
        // the statistical value is the total bit length of all packets in the queue
        @statistic[queueBitLength](title="queue bit length"; source=warmup(atomic(constant0(packetPushEnded) + sum(packetLength(packetPushStarted)) - sum(packetLength(packetPulled)) - sum(packetLength(packetRemoved)) - sum(packetLength(packetDropped)))); record=last,max,timeavg,vector; unit=b; interpolationmode=sample-hold; autoWarmupFilter=false);
        // the statistical value is the queueing time of packets
        @statistic[queueingTime](title="queueing times"; source=queueingTime(packetPulled); record=histogram,vector; unit=s; interpolationmode=none);
        // the statistical value is the incoming packet
        @statistic[incomingPackets](title="incoming packets"; source=packetPushStarted; record=count; unit=pk);
        // the statistical value is the length of the incoming packet
        @statistic[incomingPacketLengths](title="incoming packet lengths"; source=packetLength(packetPushStarted); record=sum,histogram,vector; unit=b; interpolationmode=none);
        // the statistical value is the data rate of the incoming packets
        @statistic[incomingDataRate](title="incoming datarate"; source=throughput(packetPushStarted); record=vector; unit=bps; interpolationmode=linear);
        // the statistical value is the outgoing packet
        @statistic[outgoingPackets](title="outgoing packets"; source=packetPulled; record=count; unit=pk);
        // the statistical value is the length of the outgoing packet
        @statistic[outgoingPacketLengths](title="outgoing packet lengths"; source=packetLength(packetPulled); record=sum,histogram,vector; unit=b; interpolationmode=none);
        // the statistical value is the data rate of the outgoing packets
        @statistic[outgoingDataRate](title="outgoing datarate"; source=throughput(packetPulled); record=vector; unit=bps; interpolationmode=linear);
        // the statistical value is the packet that is dropped due to queue overflow
        @statistic[droppedPacketsQueueOverflow](title="dropped packets: queue overflow"; source=packetDropReasonIsQueueOverflow(packetDropped); record=count; unit=pk; interpolationmode=none);
        // the statistical value is the length of the packet that is dropped due to queue overflow
        @statistic[droppedPacketLengthsQueueOverflow](title="dropped packet lengths: queue overflow"; source=packetLength(packetDropReasonIsQueueOverflow(packetDropped)); record=sum,vector; unit=b; interpolationmode=none);
        // the statistical value is the flow specific queueing time of packets
        @statistic[flowQueueingTime](title="flow queueing times"; source=queueingTime(demuxFlow(packetPulled)); record=histogram,vector; unit=s; interpolationmode=none);
        // the statistical value is the flow specific data rate of the incoming packets
        @statistic[flowIncomingDataRate](title="flow specific incoming data rate"; source=throughput(flowPacketLength(demuxFlow(packetPushStarted))); record=vector; unit=bps; interpolationmode=linear);
        // the statistical value is the flow specific data rate of the outgoing packets
        @statistic[flowOutgoingDataRate](title="flow specific outgoing data rate"; source=throughput(flowPacketLength(demuxFlow(packetPulled))); record=vector; unit=bps; interpolationmode=linear);
        @defaultStatistic(queueLength:vector);
}

File: src/inet/queueing/queue/PacketQueue.ned