DiffservQueue

Package: inet.networklayer.diffserv

compound module DiffservQueue

This is an example queue that can be used in interfaces of DS core and edge nodes to support the AFxy (RFC 2597) and EF (RFC 3246) PHBs.

The incoming packets are first classified according to their DSCP field. DSCPs other than AFxy and EF are handled as BE (best effort).

EF packets are stored in a dedicated queue and served first when a packet is requested. Because they can preempt the other queues, the rate of the EF packets should be limited to a fraction of the bandwidth of the link. This is achieved by metering the EF traffic with a token bucket meter and dropping packets that do not conform to the traffic profile.

There are other queues for AFx classes and BE. The AFx queues use RED to implement 3 different drop priorities within the class. BE packets are stored in a drop-tail queue. Packets from AFxy and BE queues are scheduled by a WRR scheduler, which ensures that the remaining bandwidth is allocated among the classes according to the specified weights.

See also: AFxyQueue

DiffservQueuein --> classifier.inclassifier.out++ --> efMeter.inclassifier.out++ --> af1xQueue.afx1Inclassifier.out++ --> af1xQueue.afx2Inclassifier.out++ --> af1xQueue.afx3Inclassifier.out++ --> af2xQueue.afx1Inclassifier.out++ --> af2xQueue.afx2Inclassifier.out++ --> af2xQueue.afx3Inclassifier.out++ --> af3xQueue.afx1Inclassifier.out++ --> af3xQueue.afx2Inclassifier.out++ --> af3xQueue.afx3Inclassifier.out++ --> af4xQueue.afx1Inclassifier.out++ --> af4xQueue.afx2Inclassifier.out++ --> af4xQueue.afx3Inclassifier.defaultOut --> beQueue.inefMeter.greenOut --> efQueue.inefMeter.redOut --> sink.inaf1xQueue.out --> wrr.in++af2xQueue.out --> wrr.in++af3xQueue.out --> wrr.in++af4xQueue.out --> wrr.in++beQueue.out --> wrr.in++efQueue.out --> priority.in++wrr.out --> priority.in++priority.out --> outclassifier: inet.networklayer.diffserv.BehaviorAggregateClassifier Reads the DSCP (lower six bits of ToS/TrafficClass) from the received datagram, and forwards the... Source: classifier: BehaviorAggregateClassifier { dscps = "EF AF11 AF12 AF13 AF21 AF22 AF23 AF31 AF32 AF33 AF41 AF42 AF43"; @display("p=100,330"); }classifierefMeter: inet.networklayer.diffserv.TokenBucketMeter Simple token bucket meter. Source: efMeter: TokenBucketMeter { cir = default("10%"); // Reserved EF bandwidth as a percentage of the datarate of the interface cbs = default(5000B); // 5 1000B packets @display("p=250,130"); }efMetersink: inet.queueing.sink.PassivePacketSink A passive packet sink which is pushed with packets by the connected packet producer. Source: sink: PassivePacketSink { @display("p=400,80"); }sinkefQueue: inet.queueing.queue.DropTailQueue A limited packet queue that drops packets at the tail of the queue. Source: efQueue: DropTailQueue { packetCapacity = default(5); // Keep low for low delay and jitter @display("p=400,180"); }efQueueaf1xQueue: inet.networklayer.diffserv.AFxyQueue This is an example queue that implements one class of the Assured Forwarding PHB group (RFC 2597). Source: af1xQueue: AFxyQueue { @display("p=250,230"); }#af1xQueueaf2xQueue: inet.networklayer.diffserv.AFxyQueue This is an example queue that implements one class of the Assured Forwarding PHB group (RFC 2597). Source: af2xQueue: AFxyQueue { @display("p=250,330"); }#af2xQueueaf3xQueue: inet.networklayer.diffserv.AFxyQueue This is an example queue that implements one class of the Assured Forwarding PHB group (RFC 2597). Source: af3xQueue: AFxyQueue { @display("p=250,430"); }#af3xQueueaf4xQueue: inet.networklayer.diffserv.AFxyQueue This is an example queue that implements one class of the Assured Forwarding PHB group (RFC 2597). Source: af4xQueue: AFxyQueue { @display("p=250,530"); }#af4xQueuebeQueue: inet.queueing.queue.DropTailQueue A limited packet queue that drops packets at the tail of the queue. Source: beQueue: DropTailQueue { @display("p=250,630"); }beQueuewrr: inet.queueing.scheduler.WrrScheduler Implements weighted round-robin scheduling. Source: wrr: WrrScheduler { weights = default("1 1 1 1 1"); @display("p=400,330"); }wrrpriority: inet.queueing.scheduler.PriorityScheduler This scheduler pulls packets from the first non-empty among its connected packet providers. Source: priority: PriorityScheduler { @display("p=550,330"); }priority

Usage diagram

Inheritance diagram

Extends

Name

Type

Description

CompoundPacketQueueBase

compound module

This compound module serves as a base module for complex packet queues formed by combining several queueing components.

Parameters

Name

Type

Default value

Description

displayStringTextFormat

string

“contains %p pk (%l) pushed %u created %c\n pulled %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

interfaceTableModule

string

Properties

Name

Value

Description

class

CompoundPacketQueueBase

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(warmup(localSignal(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(warmup(localSignal(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(warmup(localSignal(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(warmup(localSignal(packetPulled)))))

vector

bps

linear

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

flowQueueingTime

flow queueing times

queueingTime(demuxFlow(warmup(localSignal(packetPulled))))

histogram,vector

s

none

the statistical value is the flow specific queueing time of packets

incomingDataRate

incoming datarate

throughput(warmup(localSignal(packetPushStarted)))

vector

bps

linear

the statistical value is the data rate of the incoming packets

incomingPacketLengths

incoming packet lengths

packetLength(warmup(localSignal(packetPushStarted)))

sum,histogram,vector

b

none

the statistical value is the length of the incoming packet

incomingPackets

incoming packets

warmup(localSignal(packetPushStarted))

count

pk

the statistical value is the incoming packet

outgoingDataRate

outgoing datarate

throughput(warmup(localSignal(packetPulled)))

vector

bps

linear

the statistical value is the data rate of the outgoing packets

outgoingPacketLengths

outgoing packet lengths

packetLength(warmup(localSignal(packetPulled)))

sum,histogram,vector

b

none

the statistical value is the length of the outgoing packet

outgoingPackets

outgoing packets

warmup(localSignal(packetPulled))

count

pk

the statistical value is the outgoing packet

queueBitLength

queue bit length

warmup(atomic(constant0(localSignal(packetPushEnded)) + sum(packetLength(localSignal(packetPushStarted))) - sum(packetLength(localSignal(packetPulled))) - sum(packetLength(localSignal(packetRemoved))) - sum(packetLength(localSignal(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(warmup(localSignal(packetPulled)))

histogram,vector

s

none

the statistical value is the queueing time of packets

queueLength

queue length

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

last,max,timeavg,vector

pk

sample-hold

the statistical value is the number of packets in the queue

Unassigned submodule parameters

Name

Type

Default value

Description

classifier.displayStringTextFormat

string

“{classifierStatus}”

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

classifier.reverseOrder

bool

false

efMeter.displayStringTextFormat

string

“{meterStatus}”

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

efMeter.interfaceTableModule

string

The path to the InterfaceTable module

efMeter.cir

string

“10%”

Committed information rate, either absolute bitrate (e.g. “100kbps”) or relative to the link’s datarate (e.g. “20%”)

efMeter.cbs

int

5000B

Committed burst size

efMeter.colorAwareMode

bool

false

Enables color-aware mode

sink.displayStringTextFormat

string

“received %p pk (%l)”

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

sink.clockModule

string

“”

Relative path of a module that implements IClock(1,:ref:2 <neddoc-msg-inet-iclock>); optional

sink.initialConsumptionOffset

double

0s

Initial duration before which packets are not consumed

sink.consumptionInterval

double

0s

Elapsed time between subsequent packets allowed to be pushed by the connected packet producer, 0 means any number of packets can be pushed at the same simulation time

sink.scheduleForAbsoluteTime

bool

true

When a clock is used, “relative” means that setting the clock will not affect the simulation time of the event

efQueue.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

efQueue.packetCapacity

int

5

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

efQueue.dataCapacity

int

-1b

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

efQueue.dropperClass

string

“inet::queueing::PacketAtCollectionEndDropper”

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

efQueue.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

efQueue.bufferModule

string

“”

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

af1xQueue.red1.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af1xQueue.red1.backpressure

bool

false

af1xQueue.red1.pkrate

double

150

Average packet rate for calculations when queue is empty

af1xQueue.red1.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af1xQueue.red1.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af1xQueue.red2.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af1xQueue.red2.backpressure

bool

false

af1xQueue.red2.pkrate

double

150

Average packet rate for calculations when queue is empty

af1xQueue.red2.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af1xQueue.red2.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af1xQueue.red3.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af1xQueue.red3.backpressure

bool

false

af1xQueue.red3.pkrate

double

150

Average packet rate for calculations when queue is empty

af1xQueue.red3.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af1xQueue.red3.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af1xQueue.mux.displayStringTextFormat

string

“passed %p pk (%l)”

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

af1xQueue.mux.forwardServiceRegistration

bool

true

af1xQueue.mux.forwardProtocolRegistration

bool

true

af1xQueue.queue.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

af1xQueue.queue.packetCapacity

int

-1

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

af1xQueue.queue.dataCapacity

int

-1b

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

af1xQueue.queue.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

af1xQueue.queue.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

af1xQueue.queue.bufferModule

string

“”

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

af2xQueue.red1.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af2xQueue.red1.backpressure

bool

false

af2xQueue.red1.pkrate

double

150

Average packet rate for calculations when queue is empty

af2xQueue.red1.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af2xQueue.red1.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af2xQueue.red2.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af2xQueue.red2.backpressure

bool

false

af2xQueue.red2.pkrate

double

150

Average packet rate for calculations when queue is empty

af2xQueue.red2.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af2xQueue.red2.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af2xQueue.red3.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af2xQueue.red3.backpressure

bool

false

af2xQueue.red3.pkrate

double

150

Average packet rate for calculations when queue is empty

af2xQueue.red3.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af2xQueue.red3.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af2xQueue.mux.displayStringTextFormat

string

“passed %p pk (%l)”

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

af2xQueue.mux.forwardServiceRegistration

bool

true

af2xQueue.mux.forwardProtocolRegistration

bool

true

af2xQueue.queue.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

af2xQueue.queue.packetCapacity

int

-1

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

af2xQueue.queue.dataCapacity

int

-1b

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

af2xQueue.queue.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

af2xQueue.queue.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

af2xQueue.queue.bufferModule

string

“”

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

af3xQueue.red1.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af3xQueue.red1.backpressure

bool

false

af3xQueue.red1.pkrate

double

150

Average packet rate for calculations when queue is empty

af3xQueue.red1.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af3xQueue.red1.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af3xQueue.red2.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af3xQueue.red2.backpressure

bool

false

af3xQueue.red2.pkrate

double

150

Average packet rate for calculations when queue is empty

af3xQueue.red2.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af3xQueue.red2.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af3xQueue.red3.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af3xQueue.red3.backpressure

bool

false

af3xQueue.red3.pkrate

double

150

Average packet rate for calculations when queue is empty

af3xQueue.red3.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af3xQueue.red3.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af3xQueue.mux.displayStringTextFormat

string

“passed %p pk (%l)”

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

af3xQueue.mux.forwardServiceRegistration

bool

true

af3xQueue.mux.forwardProtocolRegistration

bool

true

af3xQueue.queue.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

af3xQueue.queue.packetCapacity

int

-1

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

af3xQueue.queue.dataCapacity

int

-1b

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

af3xQueue.queue.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

af3xQueue.queue.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

af3xQueue.queue.bufferModule

string

“”

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

af4xQueue.red1.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af4xQueue.red1.backpressure

bool

false

af4xQueue.red1.pkrate

double

150

Average packet rate for calculations when queue is empty

af4xQueue.red1.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af4xQueue.red1.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af4xQueue.red2.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af4xQueue.red2.backpressure

bool

false

af4xQueue.red2.pkrate

double

150

Average packet rate for calculations when queue is empty

af4xQueue.red2.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af4xQueue.red2.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af4xQueue.red3.displayStringTextFormat

string

“dropped {numDroppedPackets}/{numProcessedPackets} pk ({droppedTotalLength}/{processedTotalLength})”

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

af4xQueue.red3.backpressure

bool

false

af4xQueue.red3.pkrate

double

150

Average packet rate for calculations when queue is empty

af4xQueue.red3.useEcn

bool

false

If enabled, packets are marked with ECN if applicable

af4xQueue.red3.packetCapacity

int

int(maxth)

Packets are dropped if queue length is greater

af4xQueue.mux.displayStringTextFormat

string

“passed %p pk (%l)”

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

af4xQueue.mux.forwardServiceRegistration

bool

true

af4xQueue.mux.forwardProtocolRegistration

bool

true

af4xQueue.queue.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

af4xQueue.queue.packetCapacity

int

-1

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

af4xQueue.queue.dataCapacity

int

-1b

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

af4xQueue.queue.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

af4xQueue.queue.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

af4xQueue.queue.bufferModule

string

“”

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

beQueue.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

beQueue.packetCapacity

int

100

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

beQueue.dataCapacity

int

-1b

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

beQueue.dropperClass

string

“inet::queueing::PacketAtCollectionEndDropper”

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

beQueue.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

beQueue.bufferModule

string

“”

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

wrr.displayStringTextFormat

string

“scheduled %p pk (%l)”

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

wrr.reverseOrder

bool

false

wrr.weights

string

“1 1 1 1 1”

priority.displayStringTextFormat

string

“scheduled %p pk (%l)”

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

priority.reverseOrder

bool

false

Source code

//
// This is an example queue that can be used in
// interfaces of DS core and edge nodes to support
// the AFxy (RFC 2597) and EF (RFC 3246) PHBs.
//
// The incoming packets are first classified according to
// their DSCP field. DSCPs other than AFxy and EF are handled
// as BE (best effort).
//
// EF packets are stored in a dedicated queue and served first
// when a packet is requested. Because they can preempt the other
// queues, the rate of the EF packets should be limited to a fraction
// of the bandwidth of the link. This is achieved by metering the EF
// traffic with a token bucket meter and dropping packets that
// do not conform to the traffic profile.
//
// There are other queues for AFx classes and BE. The AFx queues
// use RED to implement 3 different drop priorities within the class.
// BE packets are stored in a drop-tail queue.
// Packets from AFxy and BE queues are scheduled by a WRR scheduler,
// which ensures that the remaining bandwidth is allocated among the classes
// according to the specified weights.
//
// @see ~AFxyQueue
//
module DiffservQueue extends CompoundPacketQueueBase
{
    parameters:
        string interfaceTableModule;
        *.interfaceTableModule = default(absPath(this.interfaceTableModule));
    submodules:
        classifier: BehaviorAggregateClassifier {
            dscps = "EF AF11 AF12 AF13 AF21 AF22 AF23 AF31 AF32 AF33 AF41 AF42 AF43";
            @display("p=100,330");
        }
        efMeter: TokenBucketMeter {
            cir = default("10%"); // Reserved EF bandwidth as a percentage of the datarate of the interface
            cbs = default(5000B); // 5 1000B packets
            @display("p=250,130");
        }
        sink: PassivePacketSink {
            @display("p=400,80");
        }
        efQueue: DropTailQueue {
            packetCapacity = default(5); // Keep low for low delay and jitter
            @display("p=400,180");
        }
        af1xQueue: AFxyQueue {
            @display("p=250,230");
        }
        af2xQueue: AFxyQueue {
            @display("p=250,330");
        }
        af3xQueue: AFxyQueue {
            @display("p=250,430");
        }
        af4xQueue: AFxyQueue {
            @display("p=250,530");
        }
        beQueue: DropTailQueue {
            @display("p=250,630");
        }
        wrr: WrrScheduler {
            weights = default("1 1 1 1 1");
            @display("p=400,330");
        }
        priority: PriorityScheduler {
            @display("p=550,330");
        }

    connections:
        in --> classifier.in;
        classifier.out++ --> efMeter.in;
        classifier.out++ --> af1xQueue.afx1In;
        classifier.out++ --> af1xQueue.afx2In;
        classifier.out++ --> af1xQueue.afx3In;
        classifier.out++ --> af2xQueue.afx1In;
        classifier.out++ --> af2xQueue.afx2In;
        classifier.out++ --> af2xQueue.afx3In;
        classifier.out++ --> af3xQueue.afx1In;
        classifier.out++ --> af3xQueue.afx2In;
        classifier.out++ --> af3xQueue.afx3In;
        classifier.out++ --> af4xQueue.afx1In;
        classifier.out++ --> af4xQueue.afx2In;
        classifier.out++ --> af4xQueue.afx3In;
        classifier.defaultOut --> beQueue.in;

        efMeter.greenOut --> { @display("ls=green"); } --> efQueue.in;
        efMeter.redOut --> { @display("ls=red"); } --> sink.in;

        af1xQueue.out --> wrr.in++;
        af2xQueue.out --> wrr.in++;
        af3xQueue.out --> wrr.in++;
        af4xQueue.out --> wrr.in++;
        beQueue.out --> wrr.in++;
        efQueue.out --> priority.in++;
        wrr.out --> priority.in++;
        priority.out --> out;
}

File: src/inet/networklayer/diffserv/DiffservQueue.ned