TokenBucketClassifier¶
Package: inet.queueing.classifier
simple module TokenBucketClassifier
Classifies packets to the first output gate if the bucket contains enough number of tokens for the packet passing through, otherwise the second output gate is used. The amount of required tokens is equal to the packet length in bits and is subtracted from the number of stored tokens. New tokens are generated with the provided constant rate and they may also be added by other modules.
Inheritance diagram¶
Known subclasses¶
Name |
Type |
Description |
|---|---|---|
simple module |
This packet classifier module classifies packets using one token bucket. Each packet is classified depending on whether the token bucket contains the required number of tokens for the packet. |
Extends¶
Name |
Type |
Description |
|---|---|---|
simple module |
Base module for various packet classifier modules. Derived modules must implement a single packet classifier function which determines the index of the output gate for the next pushed packet. |
Parameters¶
Name |
Type |
Default value |
Description |
|---|---|---|---|
displayStringTextFormat |
string |
“contains %n tk\nmetered %p pk (%l)” |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
reverseOrder |
bool |
false |
|
initialNumTokens |
double |
0 |
Initial number of tokens |
maxNumTokens |
double |
inf |
Maximum number of tokens |
tokenProductionRate |
double |
||
tokenConsumptionPerPacket |
double |
0 |
How many tokens are consumed per packet |
tokenConsumptionPerBit |
double |
1 |
How many tokens are consumed per bit |
excessTokenModule |
string |
“” |
Specifies the module (~ITokenStorage) that receives the excess tokens that are produced by this module |
Properties¶
Name |
Value |
Description |
|---|---|---|
class |
TokenBucketClassifier |
|
display |
i=block/classifier |
Gates¶
Name |
Direction |
Size |
Description |
|---|---|---|---|
in |
input |
||
out [ ] |
output |
Signals¶
Name |
Type |
Unit |
Description |
|---|---|---|---|
packetPushed |
|||
tokensChanged |
double |
Statistics¶
Name |
Title |
Source |
Record |
Unit |
Interpolation Mode |
Description |
|---|---|---|---|---|---|---|
dataRate |
data rate |
throughput(packetPushed) |
vector |
bps |
linear |
the statistical value is the data rate of the classified packets |
numTokens |
number of tokens |
tokensChanged |
vector |
tk |
linear |
|
packetLengths |
packet lengths |
packetLength(packetPushed) |
sum,histogram,vector |
b |
none |
the statistical value is the length of the classified packet |
packets |
packets |
packetPushed |
count |
pk |
the statistical value is the classified packet |
Source code¶
//
// Classifies packets to the first output gate if the bucket contains
// enough number of tokens for the packet passing through, otherwise the second
// output gate is used. The amount of required tokens is equal to the packet
// length in bits and is subtracted from the number of stored tokens. New tokens
// are generated with the provided constant rate and they may also be added by
// other modules.
//
simple TokenBucketClassifier extends PacketClassifierBase like IPacketClassifier
{
parameters:
double initialNumTokens = default(0); // Initial number of tokens
double maxNumTokens = default(inf); // Maximum number of tokens
double tokenProductionRate;
double tokenConsumptionPerPacket = default(0); // How many tokens are consumed per packet
double tokenConsumptionPerBit = default(1); // How many tokens are consumed per bit
string excessTokenModule = default(""); // Specifies the module (~ITokenStorage) that receives the excess tokens that are produced by this module
displayStringTextFormat = default("contains %n tk\nmetered %p pk (%l)");
@signal[tokensChanged](type=double);
@statistic[numTokens](title="number of tokens"; source=tokensChanged; record=vector; unit=tk; interpolationmode=linear);
@class(TokenBucketClassifier);
}
File: src/inet/queueing/classifier/TokenBucketClassifier.ned