SingleRateTwoColorMeter

Package: inet.queueing.meter

SingleRateTwoColorMeter

simple module

This packet meter module measures the packet flow that is passing through using one token bucket. The meter attaches a LabelsTag to each packet with either green or red color depending on whether the token bucket contains the required number of tokens for the packet.

By default, packets consume 1 token per byte.

See also: SingleRateThreeColorMeter(1,2), DualRateThreeColorMeter

See also: SingleRateTwoColorClassifier, SingleRateThreeColorClassifier, DualRateThreeColorClassifier

Inheritance diagram

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

Extends

Name Type Description
TokenBucketMeter simple module

This module labels each packet if the token bucket contains enough tokens for the packet that is passing through. The amount of required tokens is equal to the packet length in bits and is subtracted from the number of stored tokens. New tokens are generated with the provided constant rate and they may also be added by other modules.

Parameters

Name Type Default value Description
displayStringTextFormat string "contains %n tk\nmetered %p pk (%l)"

determines the text that is written on top of the submodule

initialNumTokens double maxNumTokens

initial number of tokens in the bucket

maxNumTokens double dropUnit(committedBurstSize) / bitsPerToken

maximum number of tokens in the bucket

tokenProductionRate double dropUnit(committedInformationRate) / bitsPerToken

the rate of internal token production per second

tokenConsumptionPerPacket double 0

how many tokens are consumed per packet

tokenConsumptionPerBit double 1 / bitsPerToken

how many tokens are consumed per bit

label string "green"

the label that is attached to packets if there are enough tokens in the bucket

defaultLabel string "red"

the label that is attached to packets if there are not enouth tokens in the bucket, no label by default

labelPriority object colorAware ? ["green", "red"] : []

the list of labels in the order of priority, if specified packets can only be promoted in this order

excessTokenModule string ""

specifies the module (ITokenConsumer) that receives the excess tokens that are produced by this module when overflown

committedInformationRate double

committed information rate

committedBurstSize int

committed burst size

bitsPerToken int 8

how many bits are represented by 1 token

colorAware bool false

enables color-aware mode where packets can only be demoted

Properties

Name Value Description
display i=block/star
class TokenBucketMeter

Gates

Name Direction Size Description
in input
out output

Signals

Name Type Unit
tokensChanged double

Statistics

Name Title Source Record Unit Interpolation Mode
numTokens number of tokens tokensChanged vector tk linear

Direct method calls (observed)

call tofunctioninfo
LabelFilterinet::queueing::LabelFilter::pushPacketpushPacket
InteractiveGateinet::queueing::InteractiveGate::handleCanPushPacketChangedhandleCanPushPacketChanged

Called methods (observed)

functioninfocall from
inet::queueing::TokenBucketMeter::handleCanPushPacketChangedhandleCanPushPacketChangedLabelFilter
inet::queueing::TokenBucketMeter::pushPacketpushPacketInteractiveGate

Pushed in messages (observed)

gatemsgkindctrlsrcModuletags
inPacket0InteractiveGateDirectionTag, PacketProtocolTag, DispatchProtocolReq?, DropEligibleInd?, EncapsulationProtocolInd?, InterfaceInd?, MacAddressInd?, PcpInd?, StreamInd?, StreamReq?, UserPriorityInd?, VlanInd?

Push out messages (observed)

gatemsgkindctrldestModuletags
outPacket0LabelFilterDirectionTag, LabelsTag, PacketProtocolTag, DispatchProtocolReq?, DropEligibleInd?, EncapsulationProtocolInd?, InterfaceInd?, MacAddressInd?, PcpInd?, StreamInd?, StreamReq?, UserPriorityInd?, VlanInd?

Shared Tagging operations (observed)

tagTypetagAction
LabelsTagaddTagIfAbsent

Region Tagging operations (observed)

tagTypetagAction
FlowTagmapAllTags

Source code

//
// This packet meter module measures the packet flow that is passing through
// using one token bucket. The meter attaches a ~LabelsTag to each packet with
// either green or red color depending on whether the token bucket contains the
// required number of tokens for the packet.
//
// By default, packets consume 1 token per byte.
//
// @see ~SingleRateThreeColorMeter, ~DualRateThreeColorMeter
// @see ~SingleRateTwoColorClassifier, ~SingleRateThreeColorClassifier, ~DualRateThreeColorClassifier
//
simple SingleRateTwoColorMeter extends TokenBucketMeter
{
    parameters:
        double committedInformationRate @unit(bps); // committed information rate
        int committedBurstSize @unit(b); // committed burst size
        int bitsPerToken = default(8); // how many bits are represented by 1 token
        bool colorAware = default(false); // enables color-aware mode where packets can only be demoted
        initialNumTokens = default(maxNumTokens);
        maxNumTokens = dropUnit(committedBurstSize) / bitsPerToken;
        tokenProductionRate = dropUnit(committedInformationRate) / bitsPerToken;
        tokenConsumptionPerBit = 1 / bitsPerToken;
        label = default("green");
        defaultLabel = default("red");
        labelPriority = default(colorAware ? ["green", "red"] : []);
}
File: src/inet/queueing/meter/SingleRateTwoColorMeter.ned