Dear reader, I'm not updating these pages anymore. If you have tc or ip related questions, you can post them on the LARTC mailing list.



From help-file :
TBF queue
CONFIG_NET_SCH_TBF
  Say Y here if you want to use the Simple Token Bucket Filter (TBF)
  packet scheduling algorithm for some of your network devices or as a
  leaf discipline for the CBQ scheduling algorithm (see the top of
  net/sched/sch_tbf.c for a description of the TBF algorithm).
 
  This code is also available as a module called sch_tbf.o ( = code
  which can be inserted in and removed from the running kernel
  whenever you want). If you want to compile it as a module, say M
  here and read Documentation/modules.txt

From source-files :
Simple Token Bucket Filter.
=======================================

SOURCE.
-------

None.

Description.
------------

A data flow obeys TBF with rate R and depth B, if for any
time interval t_i...t_f the number of transmitted bits
does not exceed B + R*(t_f-t_i).

Packetized version of this definition:
The sequence of packets of sizes s_i served at moments t_i
obeys TBF, if for any i<=k:

s_i+....+s_k <= B + R*(t_k - t_i)

Algorithm.
----------

Let N(t_i) be B/R initially and N(t) grow continuously with time as:

N(t+delta) = min{B/R, N(t) + delta}

If the first packet in queue has length S, it may be
transmited only at the time t_* when S/R <= N(t_*),
and in this case N(t) jumps:

N(t_* + 0) = N(t_* - 0) - S/R.



Actually, QoS requires two TBF to be applied to a data stream.
One of them controls steady state burst size, another
one with rate P (peak rate) and depth M (equal to link MTU)
limits bursts at a smaller time scale.

It is easy to see that P>R, and B>M. If P is infinity, this double
TBF is equivalent to a single one.

When TBF works in reshaping mode, latency is estimated as:

lat = max ((L-B)/R, (L-M)/P)


NOTES.
------

If TBF throttles, it starts a watchdog timer, which will wake it up
when it is ready to transmit.
Note that the minimal timer resolution is 1/HZ.
If no new packets arrive during this period,
or if the device is not awaken by EOI for some previous packet,
TBF can stop its activity for 1/HZ.


This means, that with depth B, the maximal rate is

R_crit = B*HZ

F.e. for 10Mbit ethernet and HZ=100 the minimal allowed B is ~10Kbytes.

Note that the peak rate TBF is much more tough: with MTU 1500
P_crit = 150Kbytes/sec. So, if you need greater peak
rates, use alpha with HZ=1000 :-)