Blame man/man8/tc-tbf.8

Packit Service 3880ab
.TH TC 8 "13 December 2001" "iproute2" "Linux"
Packit Service 3880ab
.SH NAME
Packit Service 3880ab
tbf \- Token Bucket Filter
Packit Service 3880ab
.SH SYNOPSIS
Packit Service 3880ab
.B tc qdisc ... tbf rate
Packit Service 3880ab
rate
Packit Service 3880ab
.B burst
Packit Service 3880ab
bytes/cell
Packit Service 3880ab
.B ( latency
Packit Service 3880ab
ms
Packit Service 3880ab
.B | limit
Packit Service 3880ab
bytes
Packit Service 3880ab
.B ) [ mpu
Packit Service 3880ab
bytes
Packit Service 3880ab
.B [ peakrate
Packit Service 3880ab
rate
Packit Service 3880ab
.B mtu
Packit Service 3880ab
bytes/cell
Packit Service 3880ab
.B ] ]
Packit Service 3880ab
.P
Packit Service 3880ab
burst is also known as buffer and maxburst. mtu is also known as minburst.
Packit Service 3880ab
.SH DESCRIPTION
Packit Service 3880ab
Packit Service 3880ab
The Token Bucket Filter is a classful queueing discipline available for
Packit Service 3880ab
traffic control with the
Packit Service 3880ab
.BR tc (8)
Packit Service 3880ab
command.
Packit Service 3880ab
Packit Service 3880ab
TBF is a pure shaper and never schedules traffic. It is non-work-conserving and may throttle
Packit Service 3880ab
itself, although packets are available, to ensure that the configured rate is not exceeded.
Packit Service 3880ab
It is able to shape up to 1mbit/s of normal traffic with ideal minimal burstiness,
Packit Service 3880ab
sending out data exactly at the configured rates.
Packit Service 3880ab
Packit Service 3880ab
Much higher rates are possible but at the cost of losing the minimal burstiness. In that
Packit Service 3880ab
case, data is on average dequeued at the configured rate but may be sent much faster at millisecond
Packit Service 3880ab
timescales. Because of further queues living in network adaptors, this is often not a problem.
Packit Service 3880ab
Packit Service 3880ab
.SH ALGORITHM
Packit Service 3880ab
As the name implies, traffic is filtered based on the expenditure of
Packit Service 3880ab
.B tokens.
Packit Service 3880ab
Tokens roughly correspond to bytes, with the additional constraint
Packit Service 3880ab
that each packet consumes some tokens, no matter how small it is. This
Packit Service 3880ab
reflects the fact that even a zero-sized packet occupies the link for
Packit Service 3880ab
some time.
Packit Service 3880ab
Packit Service 3880ab
On creation, the TBF is stocked with tokens which correspond to the amount of traffic that can be burst
Packit Service 3880ab
in one go. Tokens arrive at a steady rate, until the bucket is full.
Packit Service 3880ab
Packit Service 3880ab
If no tokens are available, packets are queued, up to a configured limit. The TBF now
Packit Service 3880ab
calculates the token deficit, and throttles until the first packet in the queue can be sent.
Packit Service 3880ab
Packit Service 3880ab
If it is not acceptable to burst out packets at maximum speed, a peakrate can be configured
Packit Service 3880ab
to limit the speed at which the bucket empties. This peakrate is implemented as a second TBF
Packit Service 3880ab
with a very small bucket, so that it doesn't burst.
Packit Service 3880ab
Packit Service 3880ab
To achieve perfection, the second bucket may contain only a single packet, which leads to
Packit Service 3880ab
the earlier mentioned 1mbit/s limit.
Packit Service 3880ab
Packit Service 3880ab
This limit is caused by the fact that the kernel can only throttle for at minimum 1 'jiffy', which depends
Packit Service 3880ab
on HZ as 1/HZ. For perfect shaping, only a single packet can get sent per jiffy - for HZ=100, this means 100
Packit Service 3880ab
packets of on average 1000 bytes each, which roughly corresponds to 1mbit/s.
Packit Service 3880ab
Packit Service 3880ab
.SH PARAMETERS
Packit Service 3880ab
See
Packit Service 3880ab
.BR tc (8)
Packit Service 3880ab
for how to specify the units of these values.
Packit Service 3880ab
.TP
Packit Service 3880ab
limit or latency
Packit Service 3880ab
Limit is the number of bytes that can be queued waiting for tokens to become
Packit Service 3880ab
available. You can also specify this the other way around by setting the
Packit Service 3880ab
latency parameter, which specifies the maximum amount of time a packet can
Packit Service 3880ab
sit in the TBF. The latter calculation takes into account the size of the
Packit Service 3880ab
bucket, the rate and possibly the peakrate (if set). These two parameters
Packit Service 3880ab
are mutually exclusive.
Packit Service 3880ab
.TP
Packit Service 3880ab
burst
Packit Service 3880ab
Also known as buffer or maxburst.
Packit Service 3880ab
Size of the bucket, in bytes. This is the maximum amount of bytes that tokens can be available for instantaneously.
Packit Service 3880ab
In general, larger shaping rates require a larger buffer. For 10mbit/s on Intel, you need at least 10kbyte buffer
Packit Service 3880ab
if you want to reach your configured rate!
Packit Service 3880ab
Packit Service 3880ab
If your buffer is too small, packets may be dropped because more tokens arrive per timer tick than fit in your bucket.
Packit Service 3880ab
The minimum buffer size can be calculated by dividing the rate by HZ.
Packit Service 3880ab
Packit Service 3880ab
Token usage calculations are performed using a table which by default has a resolution of 8 packets.
Packit Service 3880ab
This resolution can be changed by specifying the
Packit Service 3880ab
.B cell
Packit Service 3880ab
size with the burst. For example, to specify a 6000 byte buffer with a 16
Packit Service 3880ab
byte cell size, set a burst of 6000/16. You will probably never have to set
Packit Service 3880ab
this. Must be an integral power of 2.
Packit Service 3880ab
.TP
Packit Service 3880ab
mpu
Packit Service 3880ab
A zero-sized packet does not use zero bandwidth. For ethernet, no packet uses less than 64 bytes. The Minimum Packet Unit
Packit Service 3880ab
determines the minimal token usage (specified in bytes) for a packet. Defaults to zero.
Packit Service 3880ab
.TP
Packit Service 3880ab
rate
Packit Service 3880ab
The speed knob. See remarks above about limits! See
Packit Service 3880ab
.BR tc (8)
Packit Service 3880ab
for units.
Packit Service 3880ab
.PP
Packit Service 3880ab
Furthermore, if a peakrate is desired, the following parameters are available:
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
peakrate
Packit Service 3880ab
Maximum depletion rate of the bucket. The peakrate does not
Packit Service 3880ab
need to be set, it is only necessary if perfect millisecond timescale
Packit Service 3880ab
shaping is required.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
mtu/minburst
Packit Service 3880ab
Specifies the size of the peakrate bucket. For perfect accuracy, should be set to the MTU of the interface.
Packit Service 3880ab
If a peakrate is needed, but some burstiness is acceptable, this size can be raised. A 3000 byte minburst
Packit Service 3880ab
allows around 3mbit/s of peakrate, given 1000 byte packets.
Packit Service 3880ab
Packit Service 3880ab
Like the regular burstsize you can also specify a
Packit Service 3880ab
.B cell
Packit Service 3880ab
size.
Packit Service 3880ab
.SH EXAMPLE & USAGE
Packit Service 3880ab
Packit Service 3880ab
To attach a TBF with a sustained maximum rate of 0.5mbit/s, a peakrate of 1.0mbit/s,
Packit Service 3880ab
a 5kilobyte buffer, with a pre-bucket queue size limit calculated so the TBF causes
Packit Service 3880ab
at most 70ms of latency, with perfect peakrate behaviour, issue:
Packit Service 3880ab
.P
Packit Service 3880ab
# tc qdisc add dev eth0 handle 10: root tbf rate 0.5mbit \\
Packit Service 3880ab
  burst 5kb latency 70ms peakrate 1mbit       \\
Packit Service 3880ab
  minburst 1540
Packit Service 3880ab
.P
Packit Service 3880ab
To attach an inner qdisc, for example sfq, issue:
Packit Service 3880ab
.P
Packit Service 3880ab
# tc qdisc add dev eth0 parent 10:1 handle 100: sfq
Packit Service 3880ab
.P
Packit Service 3880ab
Without inner qdisc TBF queue acts as bfifo. If the inner qdisc is changed
Packit Service 3880ab
the limit/latency is not effective anymore.
Packit Service 3880ab
.P
Packit Service 3880ab
Packit Service 3880ab
.SH SEE ALSO
Packit Service 3880ab
.BR tc (8)
Packit Service 3880ab
Packit Service 3880ab
.SH AUTHOR
Packit Service 3880ab
Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru>. This manpage maintained by
Packit Service 3880ab
bert hubert <ahu@ds9a.nl>