TokenBucketMeter

Package: inet.queueing.meter

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.

Inheritance diagram

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the 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 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

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

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 enouth 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 (ITokenConsumer) that receives the excess tokens that are produced by this module when overflown

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

Source code

//
// 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.
//
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 enouth 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 (~ITokenConsumer) that receives the excess tokens that are produced by this module when overflown
        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