Table Of Contents
Table Of Contents

Generating Tokens When a Queue Becomes Empty

The QueueBasedTokenGenerator module generates tokens into a token-based server when an observed queue becomes empty. The module can be used by applications to create traffic that completely utilizes a network interface, for example.

In this example network, packets are generated by a passive packet source (PassivePacketSource). A token-based server (TokenBasedServer) pops packets from the source when it has enough tokens. Then it pushes packets into the connected queue (PacketQueue). Packets are collected from the queue by an active packet sink (ActivePacketSink). Tokens are generated by a QueueBasedTokenGenerator, which observes the queue, and generates a token whenever the queue is empty.

network QueueBasedTokenGeneratorTutorialStep
        provider: PassivePacketSource {
        server: TokenBasedServer {
        queue: PacketQueue {
        collector: ActivePacketSink {
        tokenGenerator: QueueBasedTokenGenerator {
            serverModule = "^.server";
            queueModule = "^.queue";
    connections allowunconnected:
        provider.out -->;
        server.out -->;
        queue.out -->;
[Config QueueBasedTokenGenerator]
network = QueueBasedTokenGeneratorTutorialStep
sim-time-limit = 10s

*.provider.packetLength = 1B
*.collector.collectionInterval = 1s