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