TokenBucketMeter

Package: inet.queueing.meter

simple module TokenBucketMeter

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.

inet.queueing.meter.TokenBucketMeterTokenBucketMetersimple

Inheritance diagram

Known subclasses

Name

Type

Description

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 a green or red color depending on whether the token bucket contains the required number of tokens for the packet.

Extends

Name

Type

Description

PacketMeterBase

simple module

Base module for various packet meter modules. Derived modules must implement a single meterPacket() function which meters the flow of and attaches the required tags.

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, supports displaying pars, watches, and module-specific information

initialNumTokens

double

0

Initial number of tokens in the bucket

maxNumTokens

double

inf

Maximum number of tokens in the bucket

tokenProductionRate

double

The rate of internal token production per second

tokenConsumptionPerPacket

double

0

How many tokens are consumed per packet

tokenConsumptionPerBit

double

1

How many tokens are consumed per bit

label

string

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

defaultLabel

string

“”

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

labelPriority

object

[]

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

excessTokenModule

string

“”

Specifies the module (~ITokenStorage) that receives the excess tokens that are produced by this module when overflowed

Properties

Name

Value

Description

class

TokenBucketMeter

display

i=block/star

Gates

Name

Direction

Size

Description

in

input

out

output

Signals

Name

Type

Unit

Description

packetPulledIn

inet::Packet

packetPulledOut

inet::Packet

packetPushedIn

inet::Packet

packetPushedOut

inet::Packet

tokensChanged

double

Statistics

Name

Title

Source

Record

Unit

Interpolation Mode

Description

flowIncomingDataRate

flow specific incoming data rate

throughput(demuxFlow(merge(packetPushedIn, packetPulledIn)))

vector

bps

linear

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

flowIncomingPacketLengths

flow specific incoming packet lengths

packetLength(demuxFlow(merge(packetPushedIn, packetPulledIn)))

sum,histogram,vector

b

none

the statistical value is the flow specific length of the incoming packet

flowOutgoingDataRate

flow specific outgoing data rate

throughput(demuxFlow(merge(packetPushedOut, packetPulledOut)))

vector

bps

linear

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

flowOutgoingPacketLengths

flow specific outgoing packet lengths

packetLength(demuxFlow(merge(packetPushedOut, packetPulledOut)))

sum,histogram,vector

b

none

the statistical value is the flow specific length of the outgoing packet

incomingDataRate

incoming data rate

throughput(merge(packetPushedIn, packetPulledIn))

vector

bps

linear

the statistical value is the data rate of the incoming packets

incomingPacketLengths

incoming packet lengths

packetLength(merge(packetPushedIn, packetPulledIn))

sum,histogram,vector

b

none

the statistical value is the length of the incoming packet

incomingPackets

incoming packets

merge(packetPushedIn, packetPulledIn)

count

pk

the statistical value is the incoming packet

numTokens

number of tokens

tokensChanged

vector

tk

linear

outgoingDataRate

outgoing data rate

throughput(merge(packetPushedOut, packetPulledOut))

vector

bps

linear

the statistical value is the data rate of the outgoing packets

outgoingPacketLengths

outgoing packet lengths

packetLength(merge(packetPushedOut, packetPulledOut))

sum,histogram,vector

b

none

the statistical value is the length of the outgoing packet

outgoingPackets

outgoing packets

merge(packetPushedOut, packetPulledOut)

count

pk

the statistical value is the outgoing packet

Source code

//
// 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.
//
simple TokenBucketMeter extends PacketMeterBase like IPacketMeter
{
    parameters:
        double initialNumTokens = default(0); // Initial number of tokens in the bucket
        double maxNumTokens = default(inf); // Maximum number of tokens in the bucket
        double tokenProductionRate; // The rate of internal token production per second
        double tokenConsumptionPerPacket = default(0); // How many tokens are consumed per packet
        double tokenConsumptionPerBit = default(1); // How many tokens are consumed per bit
        string label; // The label that is attached to packets if there are enough tokens in the bucket
        string defaultLabel = default(""); // The label that is attached to packets if there are not enough tokens in the bucket, no label by default
        object labelPriority = default([]); // The list of labels in the order of priority, if specified packets can only be promoted in this order
        string excessTokenModule = default(""); // Specifies the module (~ITokenStorage) that receives the excess tokens that are produced by this module when overflowed
        displayStringTextFormat = default("contains %n tk\nmetered %p pk (%l)");
        @signal[tokensChanged](type=double);
        @statistic[numTokens](title="number of tokens"; source=tokensChanged; record=vector; unit=tk; interpolationmode=linear);
        @class(TokenBucketMeter);
}

File: src/inet/queueing/meter/TokenBucketMeter.ned