TokenBasedServer

Package: inet.queueing.server

TokenBasedServer

simple module

C++ definition

This module repeatedly pulls packets from the connected packet provider and it pushes them into the connected packet consumer. The packets are processed in zero simulation time, and the process continues until the available number of tokens is not sufficient anymore.

TokenBasedServer

Inheritance diagram

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.

Used in compound modules

Name Type Description
ResponseProducer compound module

This module is capable of generating several different streams of packets, one after the other. For each traffic category, the packets are produced by a separate token based server. The traffic stream can be started by adding tokens the corresponding server module. The packet data, packet length, and timing distributions can be configured in the corresponding packet provider.

Used in

Name Type Description
PacketBasedTokenGeneratorTutorialStep network (no description)
QueueBasedTokenGeneratorTutorialStep network (no description)
SignalBasedTokenGeneratorTutorialStep network (no description)
TimeBasedTokenGeneratorTutorialStep network (no description)
TokenBasedServerTutorialStep network (no description)

Extends

Name Type Description
PacketServerBase simple module

This is a base module for various packet server modules.

Parameters

Name Type Default value Description
displayStringTextFormat string "contains %n tk\nserved %p pk (%l)"

determines the text that is written on top of the submodule

initialNumTokens double 0

initial number of tokens

maxNumTokens double nan

maximum number of tokens

tokenConsumptionPerPacket double 1

how many tokens are consumed per processed packet

tokenConsumptionPerBit double 0

how many tokens are consumed per processed bit

Properties

Name Value Description
display i=block/server
class TokenBasedServer

Gates

Name Direction Size Description
in input
out output

Signals

Name Type Unit
tokensAdded double
tokensRemoved double
tokensDepleted double

Statistics

Name Title Source Record Unit Interpolation Mode
addedTokens added tokens tokensAdded sum tk none
removedTokens removed tokens tokensRemoved sum tk none
numTokensDepleted number of times tokens are depleted tokensDepleted count tk none
numTokens number of tokens sum(tokensAdded) - sum(tokensRemoved) vector tk sample-hold

Source code

//
// This module repeatedly pulls packets from the connected packet provider and
// it pushes them into the connected packet consumer. The packets are processed
// in zero simulation time, and the process continues until the available number
// of tokens is not sufficient anymore.
//
simple TokenBasedServer extends PacketServerBase like IPacketServer
{
    parameters:
        double initialNumTokens = default(0); // initial number of tokens
        double maxNumTokens = default(nan); // maximum number of tokens
        volatile double tokenConsumptionPerPacket = default(1); // how many tokens are consumed per processed packet
        volatile double tokenConsumptionPerBit = default(0); // how many tokens are consumed per processed bit
        displayStringTextFormat = default("contains %n tk\nserved %p pk (%l)"); // determines display string text above the submodule
        @signal[tokensAdded](type=double);
        @signal[tokensRemoved](type=double);
        @signal[tokensDepleted](type=double);
        @statistic[addedTokens](title="added tokens"; source=tokensAdded; record=sum; unit=tk; interpolationmode=none);
        @statistic[removedTokens](title="removed tokens"; source=tokensRemoved; record=sum; unit=tk; interpolationmode=none);
        @statistic[numTokensDepleted](title="number of times tokens are depleted"; source=tokensDepleted; record=count; unit=tk; interpolationmode=none);
        @statistic[numTokens](title="number of tokens"; source=sum(tokensAdded) - sum(tokensRemoved); record=vector; unit=tk; interpolationmode=sample-hold);
        @class(TokenBasedServer);
}
File: src/inet/queueing/server/TokenBasedServer.ned