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