Traffic-Control-tcng-HTB-HOWTO.pdf
(
48 KB
)
Pobierz
Traffic Control using tcng and HTB HOWTO
Traffic Control using tcng and HTB HOWTO
Version 1.0
Martin A. Brown
SecurePipe, Inc.
Network Administration
<
mabrown@securepipe.com
>
April 2003
Revision History
Revision 1.0
2003−04−16
Revised by: tab
Initial Release, reviewed by LDP
Revision 0.5
2002−04−01
Revised by: MAB
submit to tldp, rename/retitle with HOWTO
Revision 0.4
2002−03−31
Revised by: MAB
new example, bucket crash course
Revision 0.3
2002−03−16
Revised by: MAB
corrections and notes from Jacob Teplitsky, raptor and Joshua Heling
Revision 0.2
2002−03−15
Revised by: MAB
links, cleanup, publish
Revision 0.1
2002−03−14
Revised by: MAB
initial revision
© 2003, Martin A. Brown
Permission is granted to copy, distribute and/or modify this document under the terms of the
GNU Free Documentation License, Version 1.1 or any later version published by the Free
Software Foundation; with no invariant sections, with no Front−Cover Texts, with no
Back−Cover Text. A copy of the license is located at
www.gnu.org/copyleft/fdl.html
.
Traffic Control using tcng and HTB HOWTO
Table of Contents
1. Introduction.
....................................................................................................................................................1
1.1. What is traffic control and how does it work?.
.................................................................................1
1.2. What is htb?.
.....................................................................................................................................2
1.3. What is tcng?..
...................................................................................................................................2
2. Requirements.
..................................................................................................................................................4
2.1. kernel requirements.
..........................................................................................................................4
2.2. tc requirements.
.................................................................................................................................4
2.3. tcng requirements.
.............................................................................................................................4
3. Configuration examples..
................................................................................................................................5
3.1. Using tcng to shape download only.
.................................................................................................5
3.2. Using a two−rate three−color meter.
................................................................................................7
4. Miscellaneous Notes.
.......................................................................................................................................9
5. Links and Further documentation.
.............................................................................................................10
i
1. Introduction
This is a brief tutorial on using
tcng
(
Traffic Control Next Generation
)
with HTB (
Hierarchical Token
Bucket
) to perform traffic shaping on a Linux machine.
This tutorial is intended for systems administrators who have
·
EITHER the capability to compile iproute2 and tcng from source
AT LEAST, a basic understanding of traffic control
·
OR the capability of building RPMS from provided SRPMs
·
EITHER a modular kernel with support for htb and dsmark
OR capability to compile a kernel with support for htb and dsmark
This article is neither comprehensive nor authoritative. The author solicits positive and negative
feedback at
<
mabrown@securepipe.com
>
. Corrections, additions, and further examples are always
welcome.
1.1. What is traffic control and how does it work?
Traffic control is the term given to the entire packet queuing subsystem in a network or network device.
Traffic control consists of several distinct operations. Classifying is a mechanism by which to identify packets
and place them in individual flows or classes. Policing is a mechanism by which one limits the number of
packets or bytes in a stream matching a particular classification. Scheduling is the decision−making process
by which packets are ordered and re−ordered for transmission. Shaping is the process by which packets are
delayed and transmitted to produce an even and predictable flow rate.
These many characteristics of a traffic control system can be combined in complex ways to reserve bandwidth
for a particular flow (or application) or to limit the amount of bandwidth available to a particular flow or
application.
One of the key concepts of traffic control is the concept of tokens. A policing or shaping implementation
needs to calculate the number of bytes or packets which have passed at what rate. Each packet or byte
(depending on the implementation), corresponds to a token, and the policing or shaping implementation will
only transmit or pass the packet if it has a token available. A common metaphorical container in which an
implementation keeps its token is the bucket. In short, a bucket represents the both the number of tokens
which can be used instantaneously (the size of the bucket), and the rate at which the tokens are replenished
(how fast the bucket gets refilled).
See
Section 1.2
for an example of buckets in a linux traffic control system.
Under linux, traffic control has historically been a complex endeavor. The
tc
command line tool provides an
interface to the kernel structures which perform the shaping, scheduling, policing and classifying. The syntax
of this command is, however, arcane. The
tcng
project provides a much friendlier interface to the human by
layering a language on top of the powerful
tc
command line tool. By writing traffic control configurations in
tcng
they become easily maintainable, less arcane, and importantly also more portable.
1. Introduction
1
Traffic Control using tcng and HTB HOWTO
1.2. What is htb?
Hierarchichal Token Bucket
is a classful qdisc written by Martin Devera with a simpler set of configuration
parameters than CBQ. There is a great deal of documentation on the author's site and also on
Stef Coene's
website
about HTB and its uses. Below is a very brief sketch of the HTB system.
Conceptually, HTB is an arbitrary number of token buckets arranged in a hierarchy (yes, you probably could
have figured that out without my sentence). Let's consider the simplest scenario. The primary egress queuing
discipline on any device is known as the
root
qdisc.
The
root
qdisc will contain one class (complex scenarios could have multiple classes attached to the
root
qdisc). This single HTB class will be set with two parameters, a
rate
and a
ceil
. These values should be
the same for the top−level class, and will represent the total available bandwidth on the link.
In HTB,
rate
means the guaranteed bandwidth available for a given class and
ceil
is short for ceiling,
which indicates the maximum bandwidth that class is allowed to consume. Any bandwidth used between
rate
and
ceil
is borrowed from a parent class, hence the suggestion that
rate
and
ceil
be the same in
the top−level class.
A number of children classes can be made under this class, each of which can be allocated some amount of
the available bandwidth from the parent class. In these children classes, the
rate
and
ceil
parameter values
need not be the same as suggested for the parent class. This allows you to reserve a specified amount of
bandwidth to a particular class. It also allows HTB to calculate the ratio of distribution of available bandwidth
to the ratios of the classes themselves. This should be more apparent in the examples below.
Hierarchical Token Bucket implements a classful queuing mechanism for the linux traffic control system, and
provides
rate
and
ceil
to allow the user to control the absolute bandwidth to particular classes of traffic as
well as indicate the ratio of distribution of bandwidth when extra bandwidth becomes available (up to
ceil
).
Keep in mind when choosing the bandwidth for your top−level class that traffic shaping only helps if you are
the bottleneck between your LAN and the Internet. Typically, this is the case in home and office network
environments, where an entire LAN is serviced by a DSL or T1 connection.
In practice, this means that you should probably set the bandwidth for your top−level class to your available
bandwidth minus a fraction of that bandwidth.
1.3. What is tcng?
Traffic Control Next Generation (tcng)
is a project by Werner Almesberger to provide a powerful, abstract,
and uniform language in which to describe traffic control structures. The
tcc
parser in the
tcng
distribution
transforms tcng the language into a number of output formats. By default,
tcc
will read a file (specified as an
argument or as STDIN) and print to STDOUT the series of
tc
commands (see
iproute2
below) required to
create the desired traffic control structure in the kernel.
Consult the
parameter reference for
tcng
to see the supported queuing disciplines. Jacob Teplitsky, active on
the
LARTC mailing list
and a contributor to the tcng project, wrote the htb support for
tcng
.
The
tcc
tool can produce a number of different types of output, but this document will only consider the
conventional and default output. Consult the
TCNG manual
for more detailed information about the use of
1. Introduction
2
Traffic Control using tcng and HTB HOWTO
tcng
.
The
tcsim
tool is a traffic control simulator which accepts tcng configuration files and reads a control
language to simulate the behaviour of a kernel sending and receiving packets with the specified control
structures. Although
tcsim
is a significant portion of the
tcng
project,
tcsim
will not be covered here at all.
1. Introduction
3
Plik z chomika:
megaskrypty
Inne pliki z tego folderu:
3-Button-Mouse(1).pdf
(58 KB)
XWindow-Overview-HOWTO(1).pdf
(30 KB)
Xterm-Title(1).pdf
(39 KB)
Xterminals(1).pdf
(30 KB)
Xinerama-HOWTO(1).pdf
(33 KB)
Inne foldery tego chomika:
Programowanie
Zgłoś jeśli
naruszono regulamin