Hi, What exactly are the "tokens"? I thought each token allowed the sending of one byte, that tokens are stored in a bucket that can hold a max of "burst" tokens, and that this bucket is filled with tokens at "rate". But theory does not seem to explain the "tc -s .." output in the examples below. And I can''t figure out why or how... #tc qdisc del dev eth0 root #tc qdisc add dev eth0 root handle 1: htb default 1 #tc class add dev eth0 parent 1:0 classid 1:1 htb rate 2mbit #tc -s -d class show dev eth0 class htb 1:1 root prio 0 quantum 25000 rate 2000Kbit ceil 2000Kbit burst 2599b/8 mpu 0b overhead 0b cburst 2599b/8 mpu 0b overhead 0b level 0 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) rate 0bit 0pps backlog 0b 0p requeues 0 lended: 0 borrowed: 0 giants: 0 tokens: 10649 ctokens: 10649 #tc qdisc del dev eth0 root #tc qdisc add dev eth0 root handle 1: htb default 1 #tc class add dev eth0 parent 1:0 classid 1:1 htb rate 1mbit #tc -s -d class show dev eth0 class htb 1:1 root prio 0 quantum 12500 rate 1000Kbit ceil 1000Kbit burst 2099b/8 mpu 0b overhead 0b cburst 2099b/8 mpu 0b overhead 0b level 0 Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) rate 0bit 0pps backlog 0b 0p requeues 0 lended: 0 borrowed: 0 giants: 0 tokens: 17203 ctokens: 17203 Why do the amount of tokens go UP if the configured rate (and burst) is lower? (The commands where run from a script so these amounts of tokens available right after the creation of the class.) If I set the rate to 9mbit the amount of tokens is always lower then the burst size. Wouldn''t that mean that there are always too few tokens available to actually burst the "burst" amount of data? Regards, Mark.
Hi Mark,>Hi, > >What exactly are the "tokens"? > >I thought each token allowed the sending of one byte, that tokens are >stored in a bucket that can hold a max of "burst" tokens, and that this >bucket is filled with tokens at "rate". > >But theory does not seem to explain the "tc -s .." output in the >examples below. And I can''t figure out why or how...Tokens normally represent the number of bytes the token bucket algorithm has accumulated. However, the numbers you see with tokens/ctokens are not expressed in bytes: they are expressed in units of time whose size is an approximation of 1 microsecond (how close a unit of time is to 1 microsecond depends on the kernel config). For example, the value of "tokens" that you see soon after configuring the HTB qdisc (and supposing no traffic has gone through the qdisc yet) is the number of pseudo microseconds that are necessary to transmit "burst" bytes at the rate "rate" configured on the class. It may look more complex that what it actually is. Just think of it as the number of (pseudo) microseconds the class can transmit at rate "rate" without terminating its tokens. The last sentence above should answer your questions in the second part of the email too. Regards /Christian [ http://benve.info ]>#tc qdisc del dev eth0 root >#tc qdisc add dev eth0 root handle 1: htb default 1 >#tc class add dev eth0 parent 1:0 classid 1:1 htb rate 2mbit >#tc -s -d class show dev eth0 >class htb 1:1 root prio 0 quantum 25000 rate 2000Kbit ceil 2000Kbit burst 2599b/8 mpu 0b overhead 0b cburst 2599b/8 mpu 0b overhead 0b level 0 > Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) > rate 0bit 0pps backlog 0b 0p requeues 0 > lended: 0 borrowed: 0 giants: 0 > tokens: 10649 ctokens: 10649 > >#tc qdisc del dev eth0 root >#tc qdisc add dev eth0 root handle 1: htb default 1 >#tc class add dev eth0 parent 1:0 classid 1:1 htb rate 1mbit >#tc -s -d class show dev eth0 >class htb 1:1 root prio 0 quantum 12500 rate 1000Kbit ceil 1000Kbit burst 2099b/8 mpu 0b overhead 0b cburst 2099b/8 mpu 0b overhead 0b level 0 > Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) > rate 0bit 0pps backlog 0b 0p requeues 0 > lended: 0 borrowed: 0 giants: 0 > tokens: 17203 ctokens: 17203 > >Why do the amount of tokens go UP if the configured rate (and burst) is >lower? >(The commands where run from a script so these amounts of tokens >available right after the creation of the class.) > >If I set the rate to 9mbit the amount of tokens is always lower then the >burst size. Wouldn''t that mean that there are always too few tokens >available to actually burst the "burst" amount of data? > >Regards, >Mark.
On Thu, 2007-06-21 at 23:22 +0200, Christian Benvenuti wrote:> Hi Mark, > > >Hi, > > > >What exactly are the "tokens"? > > > >I thought each token allowed the sending of one byte, that tokens are > >stored in a bucket that can hold a max of "burst" tokens, and that this > >bucket is filled with tokens at "rate". > > > >But theory does not seem to explain the "tc -s .." output in the > >examples below. And I can''t figure out why or how... > > Tokens normally represent the number of bytes the token bucket algorithm has > accumulated. However, the numbers you see with tokens/ctokens are not expressed > in bytes: they are expressed in units of time whose size is an approximation of > 1 microsecond (how close a unit of time is to 1 microsecond depends on the kernel > config). > For example, the value of "tokens" that you see soon after configuring the > HTB qdisc (and supposing no traffic has gone through the qdisc yet) is the > number of pseudo microseconds that are necessary to transmit "burst" bytes > at the rate "rate" configured on the class.Thanks for the explanation. I understand, the tokens as displayed are based on implementation details rather then pure concept/theory. Guess it also explains why the number of tokens can be negative. If a (c)bursts causes a class to exceed it''s configured rate it will take some time (that many pseudo microseconds) for the rate to drop back to the configured rate. Right?> It may look more complex that what it actually is. Just think of it as > the number of (pseudo) microseconds the class can transmit at rate "rate" > without terminating its tokens. > The last sentence above should answer your questions in the second part of > the email too.Indeed. Thanks, Mark.> Regards > /Christian > [ http://benve.info ] > > > >#tc qdisc del dev eth0 root > >#tc qdisc add dev eth0 root handle 1: htb default 1 > >#tc class add dev eth0 parent 1:0 classid 1:1 htb rate 2mbit > >#tc -s -d class show dev eth0 > >class htb 1:1 root prio 0 quantum 25000 rate 2000Kbit ceil 2000Kbit burst 2599b/8 mpu 0b overhead 0b cburst 2599b/8 mpu 0b overhead 0b level 0 > > Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) > > rate 0bit 0pps backlog 0b 0p requeues 0 > > lended: 0 borrowed: 0 giants: 0 > > tokens: 10649 ctokens: 10649 > > > >#tc qdisc del dev eth0 root > >#tc qdisc add dev eth0 root handle 1: htb default 1 > >#tc class add dev eth0 parent 1:0 classid 1:1 htb rate 1mbit > >#tc -s -d class show dev eth0 > >class htb 1:1 root prio 0 quantum 12500 rate 1000Kbit ceil 1000Kbit burst 2099b/8 mpu 0b overhead 0b cburst 2099b/8 mpu 0b overhead 0b level 0 > > Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) > > rate 0bit 0pps backlog 0b 0p requeues 0 > > lended: 0 borrowed: 0 giants: 0 > > tokens: 17203 ctokens: 17203 > > > >Why do the amount of tokens go UP if the configured rate (and burst) is > >lower? > >(The commands where run from a script so these amounts of tokens > >available right after the creation of the class.) > > > >If I set the rate to 9mbit the amount of tokens is always lower then the > >burst size. Wouldn''t that mean that there are always too few tokens > >available to actually burst the "burst" amount of data? > > > >Regards, > >Mark. > >