Table Of Contents
Table Of Contents

Generating Tokens Periodically

The TimeBasedTokenGenerator generates tokens periodically into a token-based server, with a configurable generation interval.

In this step, packets are generated by a passive packet source (PassivePacketSource). A TokenBasedServer pops packets from the connected packet source when it has enough tokens, and pushes them onto a passive packet sink (PassivePacketSink). Tokens are generated at random intervals by a TimeBasedTokenGenerator.

network TimeBasedTokenGeneratorTutorialStep
        provider: PassivePacketSource {
        server: TokenBasedServer {
        consumer: PassivePacketSink {
        tokenGenerator: TimeBasedTokenGenerator {
            storageModule = "^.server";
    connections allowunconnected:
        provider.out -->;
        server.out -->;
[Config TimeBasedTokenGenerator]
network = TimeBasedTokenGeneratorTutorialStep
sim-time-limit = 10s

*.provider.packetLength = 1B
*.tokenGenerator.generationInterval = intuniform(1s,2s)
*.tokenGenerator.numTokens = intuniform(1,2)
*.server.tokenConsumptionPerPacket = intuniform(1,2)