Table Of Contents
Table Of Contents

Token-Based Server

The TokenBasedServer module pops packets from a passive source and processes them when it has enough tokens. A configured amount of tokens is lost when a packet is processed. The module processes packets in zero simulation time, and pushes them onto the packet consumer connected to its output. The module acquires tokens from token generator modules.

In this step, packets are generated by a passive packet source (PassivePacketSource). The packets are popped by the TokenBasedServer module. There are no token generators in this network, but the server has 10 initial tokens to process packets; the tokens eventually run out. Packets are consumed by a passive packet sink (PassivePacketSink).

network TokenBasedServerTutorialStep
        provider: PassivePacketSource {
        server: TokenBasedServer {
        consumer: PassivePacketSink {
    connections allowunconnected:
        provider.out -->;
        server.out -->;
[Config TokenBasedServer]
network = TokenBasedServerTutorialStep
sim-time-limit = 10s

*.provider.packetLength = 1B
*.server.initialNumTokens = 10