]> git.proxmox.com Git - mirror_iproute2.git/blame - man/man8/tc-tbf.8
docs: make spacing consistent
[mirror_iproute2.git] / man / man8 / tc-tbf.8
CommitLineData
985794ad
SH
1.TH TC 8 "13 December 2001" "iproute2" "Linux"
2.SH NAME
3tbf \- Token Bucket Filter
4.SH SYNOPSIS
5.B tc qdisc ... tbf rate
6rate
7.B burst
8bytes/cell
9.B ( latency
10ms
11.B | limit
12bytes
13.B ) [ mpu
14bytes
15.B [ peakrate
16rate
17.B mtu
18bytes/cell
19.B ] ]
20.P
21burst is also known as buffer and maxburst. mtu is also known as minburst.
22.SH DESCRIPTION
23
7bc7fcaa 24The Token Bucket Filter is a classful queueing discipline available for
985794ad
SH
25traffic control with the
26.BR tc (8)
27command.
28
29TBF is a pure shaper and never schedules traffic. It is non-work-conserving and may throttle
30itself, although packets are available, to ensure that the configured rate is not exceeded.
1b95cb8d
SH
31It is able to shape up to 1mbit/s of normal traffic with ideal minimal burstiness,
32sending out data exactly at the configured rates.
985794ad
SH
33
34Much higher rates are possible but at the cost of losing the minimal burstiness. In that
35case, data is on average dequeued at the configured rate but may be sent much faster at millisecond
36timescales. Because of further queues living in network adaptors, this is often not a problem.
37
985794ad
SH
38.SH ALGORITHM
39As the name implies, traffic is filtered based on the expenditure of
40.B tokens.
1b95cb8d
SH
41Tokens roughly correspond to bytes, with the additional constraint
42that each packet consumes some tokens, no matter how small it is. This
43reflects the fact that even a zero-sized packet occupies the link for
44some time.
985794ad
SH
45
46On creation, the TBF is stocked with tokens which correspond to the amount of traffic that can be burst
47in one go. Tokens arrive at a steady rate, until the bucket is full.
48
49If no tokens are available, packets are queued, up to a configured limit. The TBF now
50calculates the token deficit, and throttles until the first packet in the queue can be sent.
51
52If it is not acceptable to burst out packets at maximum speed, a peakrate can be configured
53to limit the speed at which the bucket empties. This peakrate is implemented as a second TBF
54with a very small bucket, so that it doesn't burst.
55
56To achieve perfection, the second bucket may contain only a single packet, which leads to
57the earlier mentioned 1mbit/s limit.
58
59This limit is caused by the fact that the kernel can only throttle for at minimum 1 'jiffy', which depends
60on HZ as 1/HZ. For perfect shaping, only a single packet can get sent per jiffy - for HZ=100, this means 100
61packets of on average 1000 bytes each, which roughly corresponds to 1mbit/s.
62
63.SH PARAMETERS
64See
65.BR tc (8)
66for how to specify the units of these values.
67.TP
68limit or latency
69Limit is the number of bytes that can be queued waiting for tokens to become
70available. You can also specify this the other way around by setting the
71latency parameter, which specifies the maximum amount of time a packet can
72sit in the TBF. The latter calculation takes into account the size of the
73bucket, the rate and possibly the peakrate (if set). These two parameters
74are mutually exclusive.
75.TP
76burst
77Also known as buffer or maxburst.
78Size of the bucket, in bytes. This is the maximum amount of bytes that tokens can be available for instantaneously.
79In general, larger shaping rates require a larger buffer. For 10mbit/s on Intel, you need at least 10kbyte buffer
80if you want to reach your configured rate!
81
82If your buffer is too small, packets may be dropped because more tokens arrive per timer tick than fit in your bucket.
83The minimum buffer size can be calculated by dividing the rate by HZ.
84
85Token usage calculations are performed using a table which by default has a resolution of 8 packets.
86This resolution can be changed by specifying the
87.B cell
88size with the burst. For example, to specify a 6000 byte buffer with a 16
89byte cell size, set a burst of 6000/16. You will probably never have to set
90this. Must be an integral power of 2.
91.TP
92mpu
93A zero-sized packet does not use zero bandwidth. For ethernet, no packet uses less than 64 bytes. The Minimum Packet Unit
94determines the minimal token usage (specified in bytes) for a packet. Defaults to zero.
95.TP
96rate
97The speed knob. See remarks above about limits! See
98.BR tc (8)
99for units.
100.PP
101Furthermore, if a peakrate is desired, the following parameters are available:
102
103.TP
104peakrate
a89d5329 105Maximum depletion rate of the bucket. The peakrate does not
1b95cb8d
SH
106need to be set, it is only necessary if perfect millisecond timescale
107shaping is required.
985794ad
SH
108
109.TP
110mtu/minburst
111Specifies the size of the peakrate bucket. For perfect accuracy, should be set to the MTU of the interface.
112If a peakrate is needed, but some burstiness is acceptable, this size can be raised. A 3000 byte minburst
113allows around 3mbit/s of peakrate, given 1000 byte packets.
114
115Like the regular burstsize you can also specify a
116.B cell
117size.
118.SH EXAMPLE & USAGE
119
120To attach a TBF with a sustained maximum rate of 0.5mbit/s, a peakrate of 1.0mbit/s,
121a 5kilobyte buffer, with a pre-bucket queue size limit calculated so the TBF causes
122at most 70ms of latency, with perfect peakrate behaviour, issue:
123.P
7bc7fcaa 124# tc qdisc add dev eth0 handle 10: root tbf rate 0.5mbit \\
985794ad
SH
125 burst 5kb latency 70ms peakrate 1mbit \\
126 minburst 1540
7bc7fcaa
SL
127.P
128To attach an inner qdisc, for example sfq, issue:
129.P
130# tc qdisc add dev eth0 parent 10:1 handle 100: sfq
131.P
132Without inner qdisc TBF queue acts as bfifo. If the inner qdisc is changed
133the limit/latency is not effective anymore.
134.P
985794ad
SH
135
136.SH SEE ALSO
137.BR tc (8)
138
139.SH AUTHOR
140Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru>. This manpage maintained by
141bert hubert <ahu@ds9a.nl>
142
143