PacketQueue

Package: inet.queueing.queue

PacketQueue

simple module

This module implements a widely configurable packet queue, which is suitable among others, to be used in MAC protocols, traffic conditioning, and quality of services. 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 dervide modules.

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

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

See also: IPacketBuffer

Inheritance diagram

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.

Used in compound modules

Name Type Description
AFxyQueue compound module

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

CompoundPendingQueue compound module (no description)

Known subclasses

Name Type Description
DropHeadQueue simple module

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

DropTailQueue simple module

This module is a limited packet queue which drops packets at the tail of the queue.

EligibilityTimeQueue simple module

This module is a packet queue that keeps the packets in ascending order based on the eligibility time in the attached EligibilityTimeTag of the packets.

InProgressQueue simple module (no description)

Extends

Name Type Description
PacketQueueBase simple module

This is a 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

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
display i=block/queue
class PacketQueue
defaultStatistic queueLength:vector

Gates

Name Direction Size Description
in input
out output

Signals

Name Type Unit
packetRemoved inet::Packet
packetPushStarted inet::Packet
packetDropped inet::Packet
packetPushEnded inet::Packet?
packetPulled inet::Packet

Statistics

Name Title Source Record Unit Interpolation Mode
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
queueLength queue length warmup(atomic(constant0(packetPushEnded) + count(packetPushStarted) - count(packetPulled) - count(packetRemoved) - count(packetDropped))) last, max, timeavg, vector pk sample-hold
droppedPacketsQueueOverflow dropped packets: queue overflow packetDropReasonIsQueueOverflow(packetDropped) count pk none
queueingTime queueing times queueingTime(packetPulled) histogram, vector s none
incomingDataRate incoming datarate throughput(packetPushStarted) vector bps linear
flowQueueingTime flow queueing times queueingTime(demuxFlow(packetPulled)) histogram, vector s none
incomingPacketLengths incoming packet lengths packetLength(packetPushStarted) sum, histogram, vector b none
flowIncomingDataRate flow specific incoming data rate throughput(flowPacketLength(demuxFlow(packetPushStarted))) vector bps linear
outgoingDataRate outgoing datarate throughput(packetPulled) vector bps linear
outgoingPacketLengths outgoing packet lengths packetLength(packetPulled) sum, histogram, vector b none
droppedPacketLengthsQueueOverflow dropped packet lengths: queue overflow packetLength(packetDropReasonIsQueueOverflow(packetDropped)) sum, vector b none
flowOutgoingDataRate flow specific outgoing data rate throughput(flowPacketLength(demuxFlow(packetPulled))) vector bps linear
incomingPackets incoming packets packetPushStarted count pk
outgoingPackets outgoing packets packetPulled count pk

Direct method calls (observed)

call tofunctioninfo
EthernetMacinet::EthernetMac::handleCanPullPacketChangedhandleCanPullPacketChanged
Ieee8021qCreditBasedShaperinet::queueing::CreditBasedGate::handleCanPullPacketChangedhandleCanPullPacketChanged
PcpTrafficClassClassifierinet::PcpTrafficClassClassifier::handleCanPushPacketChangedhandleCanPushPacketChanged
Pppinet::Ppp::handleCanPullPacketChangedhandleCanPullPacketChanged
PacketBufferinet::queueing::PacketBuffer::addPacketaddPacket
PacketBufferinet::queueing::PacketBuffer::removePacketremovePacket
PriorityBufferinet::queueing::PacketBuffer::addPacketaddPacket
PriorityBufferinet::queueing::PacketBuffer::removePacketremovePacket
PriorityClassifierinet::queueing::PriorityClassifier::handleCanPushPacketChangedhandleCanPushPacketChanged
WrrClassifierinet::queueing::WrrClassifier::handleCanPushPacketChangedhandleCanPushPacketChanged
PacketMultiplexerinet::queueing::PacketMultiplexer::handleCanPushPacketChangedhandleCanPushPacketChanged
RedDropperinet::queueing::RedDropper::handleCanPushPacketChangedhandleCanPushPacketChanged
RedDropperinet::queueing::RedDropper::receiveSignalpacketPulled
FlowMeasurementStarterinet::queueing::FlowMeasurementStarter::handleCanPushPacketChangedhandleCanPushPacketChanged
PeriodicGateinet::queueing::PeriodicGate::handleCanPullPacketChangedhandleCanPullPacketChanged
PacketQueueinet::queueing::PacketQueue::pushPacketpushPacket
PrioritySchedulerinet::queueing::PriorityScheduler::handleCanPullPacketChangedhandleCanPullPacketChanged
WrrSchedulerinet::queueing::WrrScheduler::handleCanPullPacketChangedhandleCanPullPacketChanged
InstantServerinet::queueing::InstantServer::handleCanPullPacketChangedhandleCanPullPacketChanged
PacketServerinet::queueing::PacketServer::handleCanPullPacketChangedhandleCanPullPacketChanged
TokenBasedServerinet::queueing::TokenBasedServer::handleCanPullPacketChangedhandleCanPullPacketChanged
TokenBasedServerinet::queueing::TokenBasedServer::handleCanPushPacketChangedhandleCanPushPacketChanged
ActivePacketSinkinet::queueing::ActivePacketSink::handleCanPullPacketChangedhandleCanPullPacketChanged
ActivePacketSourceinet::queueing::ActivePacketSource::handleCanPushPacketChangedhandleCanPushPacketChanged
QueueBasedTokenGeneratorinet::queueing::QueueBasedTokenGenerator::receiveSignalpacketPulled

Called methods (observed)

functioninfocall from
inet::queueing::PacketQueue::handlePacketRemovedhandlePacketRemovedPacketBuffer, PriorityBuffer
inet::queueing::PacketQueue::pullPacketpullPacketinet.examples.inet.netperfmeter.REDQueue, Ieee8021qCreditBasedShaper, PeriodicGate, RedDropperQueue, PriorityScheduler, WrrScheduler, InstantServer, PacketServer, TokenBasedServer, ActivePacketSink
inet::queueing::PacketQueue::pushPacketpushPacketLayeredEthernetInterface, EthernetCutthroughInterface, PcpTrafficClassClassifier, PriorityClassifier, WrrClassifier, PacketMultiplexer, RedDropper, FlowMeasurementStarter, PacketQueue, TokenBasedServer, ActivePacketSource
inet::queueing::PacketQueue::removeAllPacketsremoveAllPacketsEthernetMacLayer

Incoming messages (observed)

gatemsgkindctrlsrcModuletags
inPacket0UdpSocketIoDscpInd, EcnInd, HopLimitInd, InterfaceInd, L3AddressInd, L4PortInd, NetworkProtocolInd, TosInd, TransportProtocolInd
inPacket1TcpServerSocketIo

Pulled out messages (observed)

gatemsgkindctrldestModuletags
outPacket0EthernetMacDispatchProtocolInd, EncapsulationProtocolReq, InterfaceInd, InterfaceReq, MacAddressInd, MacAddressReq, NetworkProtocolInd, PacketProtocolTag
outPacket0Ieee8021qCreditBasedShaperDirectionTag, EncapsulationProtocolReq, InterfaceInd, InterfaceReq, MacAddressReq, PacketProtocolTag, DropEligibleInd?, DropEligibleReq?, PcpInd?, PcpReq?, StreamReq?, UserPriorityInd?, UserPriorityReq?, VlanInd?, VlanReq?
outPacket0PppDispatchProtocolInd, InterfaceInd, InterfaceReq, NetworkProtocolInd, PacketProtocolTag
outPacket0PeriodicGateDirectionTag, EncapsulationProtocolReq, InterfaceInd, InterfaceReq, MacAddressReq, PacketProtocolTag, DropEligibleInd?, DropEligibleReq?, PcpInd?, PcpReq?, StreamReq?, UserPriorityInd?, UserPriorityReq?, VlanInd?, VlanReq?
outPacket0PrioritySchedulerDirectionTag, PacketProtocolTag
outPacket0WrrSchedulerDispatchProtocolInd, InterfaceInd, InterfaceReq, NetworkProtocolInd, PacketProtocolTag, MacAddressInd?
outPacket0InstantServerInterfaceReq, MacAddressReq, PacketProtocolTag, CutthroughTag?, DirectionTag?, DispatchProtocolInd?, DropEligibleInd?, DropEligibleReq?, EcnInd?, EncapsulationProtocolReq?, Ieee802SapReq?, InterfaceInd?, MulticastReq?, NetworkProtocolInd?, PcpInd?, PcpReq?, SequenceNumberInd?, SocketReq?, StreamReq?, TransportProtocolInd?, UserPriorityInd?, UserPriorityReq?, VlanInd?, VlanReq?
outPacket0PacketServerDirectionTag, PacketProtocolTag
outPacket0TokenBasedServerDirectionTag?, DscpInd?, EcnInd?, HopLimitInd?, InterfaceInd?, L3AddressInd?, L4PortInd?, NetworkProtocolInd?, PacketProtocolTag?, TosInd?, TransportProtocolInd?
outPacket0ActivePacketSinkDirectionTag, PacketProtocolTag
outPacket1TokenBasedServer

Pushed in messages (observed)

gatemsgkindctrlsrcModuletags
inPacket0MessageDispatcherInterfaceReq, MacAddressReq, PacketProtocolTag, CutthroughTag?, DirectionTag?, DispatchProtocolInd?, DropEligibleInd?, DropEligibleReq?, EcnInd?, EncapsulationProtocolReq?, Ieee802SapReq?, InterfaceInd?, MulticastReq?, NetworkProtocolInd?, PcpInd?, PcpReq?, SequenceNumberInd?, SocketReq?, StreamReq?, TransportProtocolInd?, UserPriorityInd?, UserPriorityReq?, VlanInd?, VlanReq?
inPacket0LayeredEthernetInterfaceInterfaceReq, MacAddressReq, PacketProtocolTag, DirectionTag?, DispatchProtocolInd?, DropEligibleInd?, DropEligibleReq?, EcnInd?, EncapsulationProtocolReq?, Ieee802SapReq?, InterfaceInd?, MulticastReq?, NetworkProtocolInd?, PcpInd?, PcpReq?, SequenceNumberInd?, SocketReq?, StreamReq?, TransportProtocolInd?, UserPriorityInd?, UserPriorityReq?, VlanInd?, VlanReq?
inPacket0EthernetCutthroughInterfaceCutthroughTag, DirectionTag, EncapsulationProtocolReq, InterfaceInd, InterfaceReq, MacAddressReq, PacketProtocolTag
inPacket0PcpTrafficClassClassifierDirectionTag, EncapsulationProtocolReq, InterfaceInd, InterfaceReq, MacAddressReq, PacketProtocolTag, DropEligibleInd?, DropEligibleReq?, PcpInd?, PcpReq?, StreamReq?, UserPriorityInd?, UserPriorityReq?, VlanInd?, VlanReq?
inPacket0PriorityClassifierDirectionTag, PacketProtocolTag
inPacket0WrrClassifierDirectionTag, PacketProtocolTag
inPacket0PacketMultiplexerDispatchProtocolInd, InterfaceInd, InterfaceReq, NetworkProtocolInd, PacketProtocolTag, MacAddressInd?
inPacket0RedDropperPacketProtocolTag, DirectionTag?, DispatchProtocolInd?, EncapsulationProtocolReq?, InterfaceInd?, InterfaceReq?, MacAddressInd?, MacAddressReq?, NetworkProtocolInd?
inPacket0FlowMeasurementStarterDirectionTag, InterfaceReq, MacAddressReq, PacketProtocolTag
inPacket0TokenBasedServerDirectionTag, PacketProtocolTag
inPacket0ActivePacketSourceDirectionTag, PacketProtocolTag

Packet operations (observed)

chunkTypepacketAction
BytesChunkpeekDataAt

Region Tagging operations (observed)

tagTypetagAction
FlowTagmapAllTags
PacketEventTagmapAllTagsForUpdate
QueueingTimeTagmapAllTagsForUpdate

Source code

//
// This module implements a widely configurable packet queue, which is suitable
// among others, to be used in MAC protocols, traffic conditioning, and quality
// of services. 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 dervide modules.
//
// Some notable packet dropper functions are: ~PacketAtCollectionBeginDropper,
// ~PacketAtCollectionEndDropper, ~PacketWithHighestOwnerModuleIdDropper,
// ~PacketWithLowestModuleIdDropper.
//
// 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");
        @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