Table Of Contents
Table Of Contents

Token Bucket

The TokenBucket compound module implements the token bucket algorithm. By default, the module contains a DropTailQueue and a TokenBasedServer. The queue capacity and the token consumption of the token-based server can be used to parameterize the token bucket algorithm. The module uses an external token generator for the token-based server.

In this example network, packets are produced periodically by an active packet source (ActivePacketSource). The packets are pushed into a token bucket (TokenBucket), which pushes them into a passive packet sink (PassivePacketSink). A token generator (TimeBasedTokenGenerator) generates tokens periodically into the token bucket module.

network TokenBucketTutorialStep
        producer: ActivePacketSource {
        bucket: TokenBucket {
        consumer: PassivePacketSink {
        tokenGenerator: TimeBasedTokenGenerator {
            serverModule = "^.bucket.server";
    connections allowunconnected:
        producer.out -->;
        bucket.out -->;
[Config TokenBucket]
network = TokenBucketTutorialStep
sim-time-limit = 10s

*.producer.packetLength = 1B
*.producer.productionInterval = uniform(0s, 2s)
*.bucket.server.maxNumTokens = 10
*.tokenGenerator.generationInterval = uniform(0s, 2s)