Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 6275

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Components of Linux Traffic Control</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Traffic Control HOWTO"
HREF="index.html"><LINK
REL="PREVIOUS"
TITLE="Traditional Elements of Traffic Control"
HREF="elements.html"><LINK
REL="NEXT"
TITLE="Software and Tools"
HREF="software.html"></HEAD
><BODY
CLASS="section"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Traffic Control HOWTO: </TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="elements.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="software.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="components"
></A
>4. Components of Linux Traffic Control</H1
><P
>&#13;  </P
><P
>&#13;  </P
><P
>&#13;  </P
><DIV
CLASS="table"
><A
NAME="tb-c-components-correlation"
></A
><P
><B
>Table 1. Correlation between traffic control elements and Linux
      components</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
WIDTH="25%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>traditional element</TH
><TH
WIDTH="75%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>Linux component</TH
></TR
></THEAD
><TBODY
><TR
><TD
WIDTH="25%"
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="elements.html#e-shaping"
>shaping</A
></TD
><TD
WIDTH="75%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>The <A
HREF="components.html#c-class"
><TT
CLASS="constant"
>class</TT
></A
> offers shaping capabilities.</TD
></TR
><TR
><TD
WIDTH="25%"
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="elements.html#e-scheduling"
>scheduling</A
></TD
><TD
WIDTH="75%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>A <A
HREF="components.html#c-qdisc"
><TT
CLASS="constant"
>qdisc</TT
></A
> is a scheduler.  Schedulers
                                can be simple such as the FIFO or
                                complex, containing classes and other
                                qdiscs, such as HTB.</TD
></TR
><TR
><TD
WIDTH="25%"
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="elements.html#e-classifying"
>classifying</A
></TD
><TD
WIDTH="75%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>The <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
> object performs the
                                classification through the agency of a
                                <A
HREF="components.html#c-classifier"
><TT
CLASS="constant"
>classifier</TT
></A
> object.  Strictly speaking,
                                Linux classifiers cannot exist outside
                                of a filter.</TD
></TR
><TR
><TD
WIDTH="25%"
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="elements.html#e-policing"
>policing</A
></TD
><TD
WIDTH="75%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>A <A
HREF="components.html#c-police"
><TT
CLASS="constant"
>policer</TT
></A
> exists in the Linux traffic
                                control implementation only as part of a
                                <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
>.</TD
></TR
><TR
><TD
WIDTH="25%"
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="elements.html#e-dropping"
>dropping</A
></TD
><TD
WIDTH="75%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>To <A
HREF="components.html#c-drop"
><TT
CLASS="constant"
>drop</TT
></A
> traffic requires a
                                <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
> with a <A
HREF="components.html#c-police"
><TT
CLASS="constant"
>policer</TT
></A
> which
                                uses <SPAN
CLASS="QUOTE"
>"drop"</SPAN
> as an action.</TD
></TR
><TR
><TD
WIDTH="25%"
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="elements.html#e-marking"
>marking</A
></TD
><TD
WIDTH="75%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>The <TT
CLASS="constant"
>dsmark</TT
> <A
HREF="components.html#c-qdisc"
><TT
CLASS="constant"
>qdisc</TT
></A
> is used for
                                marking.</TD
></TR
></TBODY
></TABLE
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="c-qdisc"
></A
>4.1. <TT
CLASS="constant"
>qdisc</TT
></H2
><P
>&#13;      Simply put, a qdisc is a scheduler
      (<A
HREF="elements.html#e-scheduling"
>Section 3.2</A
>).  Every output interface needs a
      scheduler of some kind, and the default scheduler is a FIFO.
      Other qdiscs available under Linux will rearrange the packets entering
      the scheduler's queue in accordance with that scheduler's rules.
    </P
><P
>&#13;      The qdisc is the major building block on which all of Linux traffic
      control is built, and is also called a queuing discipline.
    </P
><P
>&#13;      The <A
HREF="classful-qdiscs.html"
>classful qdiscs</A
> can contain <A
HREF="components.html#c-class"
><TT
CLASS="constant"
>class</TT
></A
>es, and provide a handle
      to which to attach <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
>s.  There is no prohibition on using a
      classful qdisc without child classes, although this will usually consume
      cycles and other system resources for no benefit.
    </P
><P
>&#13;      The <A
HREF="classless-qdiscs.html"
>classless qdiscs</A
> can contain no classes, nor is it possible to
      attach filter to a classless qdisc.  Because a classless qdisc contains
      no children of any kind, there is no utility to <A
HREF="elements.html#e-classifying"
>classifying</A
>.
      This means that no filter can be attached to a classless qdisc.
    </P
><P
>&#13;      A source of terminology confusion is the usage of the terms
      <TT
CLASS="constant"
>root</TT
> qdisc and <TT
CLASS="constant"
>ingress</TT
> qdisc.  These are not
      really queuing disciplines, but rather locations onto which traffic
      control structures can be attached for egress (outbound traffic) and
      ingress (inbound traffic).
    </P
><P
>&#13;      Each interface contains both. The primary and more common is the
      egress qdisc, known as the <TT
CLASS="constant"
>root</TT
> qdisc.  It can contain any
      of the queuing disciplines (<A
HREF="components.html#c-qdisc"
><TT
CLASS="constant"
>qdisc</TT
></A
>s) with potential
      <A
HREF="components.html#c-class"
><TT
CLASS="constant"
>class</TT
></A
>es and class structures.  The overwhelming majority of
      documentation applies to the <TT
CLASS="constant"
>root</TT
> qdisc and its children.  Traffic
      transmitted on an interface traverses the egress or <TT
CLASS="constant"
>root</TT
> qdisc.
    </P
><P
>&#13;      For traffic accepted on an interface, the <TT
CLASS="constant"
>ingress</TT
> qdisc is traversed.
      With its limited utility, it allows no child <A
HREF="components.html#c-class"
><TT
CLASS="constant"
>class</TT
></A
> to be
      created, and only exists as an object onto which a <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
> can be
      attached.  For practical purposes, the <TT
CLASS="constant"
>ingress</TT
> qdisc is merely a
      convenient object onto which to attach a <A
HREF="components.html#c-police"
><TT
CLASS="constant"
>policer</TT
></A
> to limit the
      amount of traffic accepted on a network interface.
    </P
><P
>&#13;      In short, you can do much more with an egress qdisc because it contains
      a real qdisc and the full power of the traffic control system.  An
      <TT
CLASS="constant"
>ingress</TT
> qdisc can only support a policer.  The remainder of the
      documentation will concern itself with traffic control structures
      attached to the <TT
CLASS="constant"
>root</TT
> qdisc unless otherwise specified.
    </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="c-class"
></A
>4.2. <TT
CLASS="constant"
>class</TT
></H2
><P
>&#13;      Classes only exist inside a classful <A
HREF="components.html#c-qdisc"
><TT
CLASS="constant"
>qdisc</TT
></A
> (<I
CLASS="foreignphrase"
>e.g.</I
>, <A
HREF="classful-qdiscs.html#qc-htb"
>HTB</A
>
      and <A
HREF="classful-qdiscs.html#qc-cbq"
>CBQ</A
>).  Classes are immensely flexible and can always
      contain either multiple children classes or a single child qdisc
      <A
NAME="AEN422"
HREF="#FTN.AEN422"
><SPAN
CLASS="footnote"
>[1]</SPAN
></A
>.
      There is no prohibition against a class containing a classful qdisc
      itself, which facilitates tremendously complex traffic control
      scenarios.
    </P
><P
>&#13;      Any class can also have an arbitrary number of <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
>s attached
      to it, which allows the selection of a child class or the use of a
      filter to reclassify or drop traffic entering a particular class.
    </P
><P
>&#13;      A leaf class is a terminal class in a qdisc.  It contains a qdisc
      (default <A
HREF="classless-qdiscs.html#qs-fifo"
>FIFO</A
>) and will never contain a child class.  Any
      class which contains a child class is an inner class (or root class) and
      not a leaf class.
    </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="c-filter"
></A
>4.3. <TT
CLASS="constant"
>filter</TT
></H2
><P
>&#13;      The filter is the most complex component in the Linux
      traffic control system.  The filter provides a convenient mechanism for
      gluing together several of the key elements of traffic control.  The
      simplest and most obvious role of the filter is to classify
      (see <A
HREF="elements.html#e-classifying"
>Section 3.3</A
>) packets.  Linux filters allow the
      user to classify packets into an output queue with either several
      different filters or a single filter.
    </P
><P
></P
><UL
><LI
><P
>&#13;          A filter must contain a <A
HREF="components.html#c-classifier"
><TT
CLASS="constant"
>classifier</TT
></A
> phrase.
        </P
></LI
><LI
><P
>&#13;          A filter may contain a <A
HREF="components.html#c-police"
><TT
CLASS="constant"
>policer</TT
></A
> phrase.
        </P
></LI
></UL
><P
>&#13;      Filters can be attached either to classful <A
HREF="components.html#c-qdisc"
><TT
CLASS="constant"
>qdisc</TT
></A
>s or to
      <A
HREF="components.html#c-class"
><TT
CLASS="constant"
>class</TT
></A
>es, however the enqueued packet always enters the root
      qdisc first.  After the filter attached to the root qdisc has been
      traversed, the packet may be directed to any subclasses (which can have
      their own filters) where the packet may undergo further classification.
    </P
><P
>&#13;    </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="c-classifier"
></A
>4.4. classifier</H2
><P
>&#13;      Filter objects, which can be manipulated using <A
HREF="software.html#s-iproute2-tc"
><B
CLASS="command"
>tc</B
></A
>, can use several
      different classifying mechanisms, the most common of which is the
      <TT
CLASS="constant"
>u32</TT
> classifier.  The <TT
CLASS="constant"
>u32</TT
> classifier allows the user to
      select packets based on attributes of the packet.
    </P
><P
>&#13;      The classifiers are tools which can be used as part of a <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
>
      to identify characteristics of a packet or a packet's metadata.  The
      Linux classfier object is a direct analogue to the basic operation and
      elemental mechanism of traffic control <A
HREF="elements.html#e-classifying"
>classifying</A
>.
    </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="c-police"
></A
>4.5. policer</H2
><P
>&#13;      This elemental mechanism is only used in Linux traffic control as part
      of a <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
>.  A policer calls one action above and another
      action below the specified rate.  Clever use of policers can simulate
      a three-color meter.  See also
      <A
HREF="diagram.html"
>Section 10</A
>.
    </P
><P
>&#13;      Although both <A
HREF="elements.html#e-policing"
>policing</A
> and <A
HREF="elements.html#e-shaping"
>shaping</A
> are basic
      elements of traffic control for limiting bandwidth usage a policer will
      never delay traffic.  It can only perform an action based on specified
      criteria.  See also
      <A
HREF="software.html#ex-s-iproute2-tc-filter"
>Example 5</A
>.
    </P
><P
>&#13;    </P
><P
>&#13;    </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="c-drop"
></A
>4.6. <TT
CLASS="constant"
>drop</TT
></H2
><P
>&#13;      This basic traffic control mechanism is only used in Linux traffic
      control as part of a <A
HREF="components.html#c-police"
><TT
CLASS="constant"
>policer</TT
></A
>.  Any policer attached to
      any <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
> could have a <A
HREF="components.html#c-drop"
><TT
CLASS="constant"
>drop</TT
></A
> action.
    </P
><DIV
CLASS="note"
><P
></P
><TABLE
CLASS="note"
WIDTH="100%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/note.gif"
HSPACE="5"
ALT="Note"></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>The only place in the Linux traffic control system where a packet can be
      explicitly dropped is a policer.  A policer can limit packets enqueued
      at a specific rate, or it can be configured to drop all traffic matching
      a particular pattern
      <A
NAME="AEN483"
HREF="#FTN.AEN483"
><SPAN
CLASS="footnote"
>[2]</SPAN
></A
>.
    </TD
></TR
></TABLE
></DIV
><P
>&#13;      There are, however, places within the traffic control system where a
      packet may be dropped as a side effect.  For example, a packet will be
      dropped if the scheduler employed uses this method to control flows as
      the <A
HREF="classless-qdiscs.html#qs-gred"
>GRED</A
> does.
    </P
><P
>&#13;      Also, a shaper or scheduler which runs out of its allocated buffer space
      may have to drop a packet during a particularly bursty or overloaded
      period.
    </P
><P
>&#13;    </P
></DIV
><DIV
CLASS="section"
><H2
CLASS="section"
><A
NAME="c-handle"
></A
>4.7. <TT
CLASS="constant"
>handle</TT
></H2
><P
>&#13;      Every <A
HREF="components.html#c-class"
><TT
CLASS="constant"
>class</TT
></A
> and classful <A
HREF="components.html#c-qdisc"
><TT
CLASS="constant"
>qdisc</TT
></A
> (see also
      <A
HREF="classful-qdiscs.html"
>Section 7</A
>) requires a unique identifier within
      the traffic control structure.  This unique identifier is known as a
      handle and has two constituent members, a major number and a minor
      number.  These numbers can be assigned arbitrarily by the user in
      accordance with the following rules
      <A
NAME="AEN505"
HREF="#FTN.AEN505"
><SPAN
CLASS="footnote"
>[3]</SPAN
></A
>.
    </P
><P
>&#13;    </P
><P
></P
><DIV
CLASS="variablelist"
><P
><B
>The numbering of handles for classes and qdiscs</B
></P
><DL
><DT
><TT
CLASS="parameter"
><I
>major</I
></TT
></DT
><DD
><P
>&#13;            This parameter is completely free of meaning to the kernel.  The
            user may use an arbitrary numbering scheme, however all objects in
            the traffic control structure with the same parent must share a
            <TT
CLASS="parameter"
><I
>major</I
></TT
> handle number.  Conventional
            numbering schemes start at 1 for objects attached directly to the
            <TT
CLASS="constant"
>root</TT
> qdisc.
          </P
></DD
><DT
><TT
CLASS="parameter"
><I
>minor</I
></TT
></DT
><DD
><P
>&#13;            This parameter unambiguously identifies the object as a qdisc if
            <TT
CLASS="parameter"
><I
>minor</I
></TT
> is 0.  Any other value identifies the
            object as a class.  All classes sharing a parent must have unique
            <TT
CLASS="parameter"
><I
>minor</I
></TT
> numbers.
          </P
></DD
></DL
></DIV
><P
>&#13;      The special handle ffff:0 is reserved for the <TT
CLASS="constant"
>ingress</TT
> qdisc.
    </P
><P
>&#13;      The handle is used as the target in <TT
CLASS="parameter"
><I
>classid</I
></TT
> and
      <TT
CLASS="parameter"
><I
>flowid</I
></TT
> phrases of <B
CLASS="command"
>tc</B
> <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
> statements.
      These handles are external identifiers for the objects, usable by
      userland applications.  The kernel maintains internal identifiers for
      each object.
    </P
></DIV
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN422"
HREF="components.html#AEN422"
><SPAN
CLASS="footnote"
>[1]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>&#13;          A classful qdisc can only have children classes of its type.  For
          example, an HTB qdisc can only have HTB classes as children.  A CBQ
          qdisc cannot have HTB classes as children.
        </P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN483"
HREF="components.html#AEN483"
><SPAN
CLASS="footnote"
>[2]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>&#13;          In this case, you'll have a <A
HREF="components.html#c-filter"
><TT
CLASS="constant"
>filter</TT
></A
> which uses a
          <A
HREF="components.html#c-classifier"
><TT
CLASS="constant"
>classifier</TT
></A
> to select the packets you wish to drop.  Then
          you'll use a <A
HREF="components.html#c-police"
><TT
CLASS="constant"
>policer</TT
></A
> with a with a drop action like this
          <B
CLASS="command"
>police rate 1bps burst 1 action drop/drop</B
>.
        </P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN505"
HREF="components.html#AEN505"
><SPAN
CLASS="footnote"
>[3]</SPAN
></A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>&#13;          I do not know the range nor base of these numbers.  I believe they
          are u32 hexadecimal, but need to confirm this.
        </P
></TD
></TR
></TABLE
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="elements.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="software.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Traditional Elements of Traffic Control</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Software and Tools</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>