Tcng

FIXMEs:

  • the rate limiting in this example is *wrong*.
  • explanations need improving.

TCNG (Traffic Control Next Generation) is a wrapper tool around TC ( Traffic Control). Its intended to be much easier to use, while being able to output to multiple formats (not just TC codes).

To use it, you will need to install the tcng package.

The syntax is relatively easy, with C and C++ style comments.

C style

/* C style slash-star-comment-star-slash */ comments
/* These can either be single line */
/* Or you can
   spread them out over
   several lines */

C++ style

// C style slash-slash comments
// Handy for single line comments but not usable over multiple lines

Bash style

# Bash style Hash comments
# Comments DO NOT WORK. # is used for includes 

In this example, we will set up a single outbound device (eth1).

myTCNG.sh

/*
 * Example TCNG configuration file
 */

// These include some standard definitions
#include "fields.tc"
#include "ports.tc"

// These are our nics (the two interfaces in this system)
#define LOCALNIC eth0
#define REDNIC1  eth1


dev REDNIC1 {
    egress {
        // Filters
        // Interactive SSH - something we need low-latency.
        class ( <\$intssh> )    if ip_tos_delay == 1 && tcp_sport == PORT_SSH ;
        // Bulk data - SSH (SCP/SFTP) and HTTP. We don't need instant responses from this.
        class ( <\$bulk> )      if tcp_sport == PORT_HTTP || tcp_sport == PORT_SSH ;
        // Other data - anything we don't have a filter for above.
        class ( <\$other> )     if 1; /* Always returns true. Leftover packets */

        // Configure how much bandwidth the classes get
        htb () {
            // Rate is how much is reserved, ceil is how much it can use max
            class ( rate 100Mbps, ceil 100Mbps ) {
                // Allow $intssh to use up to 1Mbps, but make sure there's always 128kbps available
                \$intssh    = class ( rate 128kbps, ceil 1Mbps ) ;
                // For bulk and other, there is always 1Mbps available, and they top out at 99Mbps.
                \$bulk      = class ( rate 1Mbps, ceil 99Mbps ) ;
                \$other     = class ( rate 1Mbps, ceil 99Mbps ) ;
            }
        }
    }
}

Useful links:

linux-ip and tldp (see links section) both have extremely helpful guides/example code. However, both give some wrong advice in relation to the ordering of classes. This is discussed at mail-archive and spenneberg.

CategoryCleanup

Tcng (last edited 2008-08-06 16:20:56 by localhost)