Table Of Contents
Table Of Contents

Generating Tokens Based on Received Signals

The SignalBasedTokenGenerator module generates tokens into a token-based server when receiving signals.

In this example network, packets are generated by a passive packet source (PassivePacketSource). A token-based server (TokenBasedServer) pops packet from a passive packet source (PassivePacketSource) when it has tokens, and pushes them into a passive packet sink (PassivePacketSink). The token generator is subscribed to the packetDropped signal of the consumer, and generates a token whenever the signal is emitted. The provider has a configured providing interval of 1s. Setting a providing interval is necessary because otherwise (if the provider could generate packets any time), an infinite amount of packets would be generated and dropped in zero simulation time, resulting in an error.

network SignalBasedTokenGeneratorTutorialStep
        provider: PassivePacketSource {
        server: TokenBasedServer {
        consumer: PassivePacketSink {
        tokenGenerator: SignalBasedTokenGenerator {
            signals = "packetDropped";
            subscriptionModule = "^.consumer";
            serverModule = "^.server";
    connections allowunconnected:
        provider.out -->;
        server.out -->;
[Config SignalBasedTokenGenerator]
network = SignalBasedTokenGeneratorTutorialStep
sim-time-limit = 10s

*.provider.packetLength = 1B
*.provider.providingInterval = 1s
*.server.initialNumTokens = 1