TokenBucket

Package: inet.queueing.shaper

compound module TokenBucket

Implements a parameterizable token bucket algorithm.

Usage diagram

Inheritance diagram

Properties

Name

Value

Description

display

i=block/buffer

Gates

Name

Direction

Size

Description

in

input

out

output

Unassigned submodule parameters

Name

Type

Default value

Description

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

queue.packetCapacity

int

100

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

queue.dataCapacity

int

-1b

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

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

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

queue.bufferModule

string

“”

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

server.displayStringTextFormat

string

“contains {numTokens} tk\nserved {numProcessedPackets} pk ({processedTotalLength})”

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

server.initialNumTokens

double

0

Initial number of tokens

server.maxNumTokens

double

nan

Maximum number of tokens

server.tokenConsumptionPerPacket

double

1

How many tokens are consumed per processed packet

server.tokenConsumptionPerBit

double

0

How many tokens are consumed per processed bit

Source code

//
// Implements a parameterizable token bucket algorithm.
//
module TokenBucket like ITrafficConditioner
{
    parameters:
        @display("i=block/buffer");
    gates:
        input in @labels(push);
        output out @labels(pull);
    submodules:
        queue: <default("DropTailQueue")> like IPacketQueue {
            parameters:
                @display("p=150,120");
        }
        server: <default("TokenBasedServer")> like IPacketServer {
            parameters:
                @display("p=350,120");
        }
    connections:
        in --> { @display("m=w"); } --> queue.in;
        queue.out --> server.in;
        server.out --> { @display("m=e"); } --> out;
}

File: src/inet/queueing/shaper/TokenBucket.ned