TokenBasedServer¶
Package: inet.queueing.server
simple module TokenBasedServer
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.
Usage diagram¶
Inheritance diagram¶
Used in compound modules¶
Name |
Type |
Description |
|---|---|---|
compound module |
Contains a configurable pre-composed telnet traffic source and traffic sink as part of a telnet server application. |
|
compound module |
Implements a parameterizable token bucket algorithm. |
|
compound module |
Processes incoming packets one by one in the order they arrive. First, it classifies a packet according to the configured classifier function, then it generates tokens for the selected category in the configured response producer. |
|
compound module |
Produces packets in order to prevent a queue from becoming empty. |
|
compound module |
Generates 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 to the corresponding server module. The packet data, packet length, and timing distributions can be configured in the corresponding packet provider. |
Extends¶
Name |
Type |
Description |
|---|---|---|
simple module |
Base module for various packet server modules. |
Parameters¶
Name |
Type |
Default value |
Description |
|---|---|---|---|
displayStringTextFormat |
string |
“contains {numTokens} tk\nserved {numProcessedPackets} pk ({processedTotalLength})” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
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 |
|---|---|---|
class |
TokenBasedServer |
|
display |
i=block/server |
Gates¶
Name |
Direction |
Size |
Description |
|---|---|---|---|
in |
input |
||
out |
output |
Signals¶
Name |
Type |
Unit |
Description |
|---|---|---|---|
packetPulled |
|||
packetPushed |
|||
tokensAdded |
double |
||
tokensDepleted |
double |
||
tokensRemoved |
double |
Statistics¶
Name |
Title |
Source |
Record |
Unit |
Interpolation Mode |
Description |
|---|---|---|---|---|---|---|
addedTokens |
added tokens |
tokensAdded |
sum |
tk |
none |
|
incomingDataRate |
incoming datarate |
throughput(packetPulled) |
vector |
bps |
linear |
the statistical value is the data rate of the incoming packets |
incomingPacketLengths |
incoming packet lengths |
packetLength(packetPulled) |
sum,histogram,vector |
b |
none |
the statistical value is the length of the incoming packet |
incomingPackets |
incoming packets |
packetPulled |
count |
pk |
the statistical value is the incoming packet |
|
numTokens |
number of tokens |
sum(tokensAdded) - sum(tokensRemoved) |
vector |
tk |
sample-hold |
|
numTokensDepleted |
number of times tokens are depleted |
tokensDepleted |
count |
tk |
none |
|
outgoingDataRate |
outgoing datarate |
throughput(packetPushed) |
vector |
bps |
linear |
the statistical value is the data rate of the outgoing packets |
outgoingPacketLengths |
outgoing packet lengths |
packetLength(packetPushed) |
sum,histogram,vector |
b |
none |
the statistical value is the length of the outgoing packet |
outgoingPackets |
outgoing packets |
packetPushed |
count |
pk |
the statistical value is the outgoing packet |
|
removedTokens |
removed tokens |
tokensRemoved |
sum |
tk |
none |
Source code¶
//
// 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 {numTokens} tk\nserved {numProcessedPackets} pk ({processedTotalLength})"); // 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);
}