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