TokenBucketClassifier

Package: inet.queueing.classifier

TokenBucketClassifier

simple module

This module classifies packets to the first output gate if the bucket contains enough number of tokens for the packet passing through, otherwise the second output gate is used. 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
SingleRateTwoColorClassifier simple module

This packet classifier module classifies packets using one token bucket. Each packet is classified depending on whether the token bucket contains the required number of tokens for the packet.

Extends

Name Type Description
PacketClassifierBase simple module

This is a base module for various packet classifier modules. Derived modules must implement a single packet classifier function which determines the index of the output gate for the next pushed packet.

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

reverseOrder bool false
initialNumTokens double 0

initial number of tokens

maxNumTokens double inf

maximum number of tokens

tokenProductionRate double
tokenConsumptionPerPacket double 0

how many tokens are consumed per packet

tokenConsumptionPerBit double 1

how many tokens are consumed per bit

excessTokenModule string ""

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

Properties

Name Value Description
display i=block/classifier
class TokenBucketClassifier

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 classifies packets to the first output gate if the bucket contains
// enough number of tokens for the packet passing through, otherwise the second
// output gate is used. 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 TokenBucketClassifier extends PacketClassifierBase like IPacketClassifier
{
    parameters:
        double initialNumTokens = default(0); // initial number of tokens
        double maxNumTokens = default(inf); // maximum number of tokens
        double tokenProductionRate;
        double tokenConsumptionPerPacket = default(0); // how many tokens are consumed per packet
        double tokenConsumptionPerBit = default(1); // how many tokens are consumed per bit
        string excessTokenModule = default(""); // specifies the module (~ITokenConsumer) that receives the excess tokens that are produced by this module
        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(TokenBucketClassifier);
}
File: src/inet/queueing/classifier/TokenBucketClassifier.ned