/* * Simply commented example of a tcng traffic control file. * * Martin A. Brown * * Example of tcng using class selection path. Output from tcc will generate * tc code which can be run on the shaping machine. * * Usage, see if the file compiles, and if so, shoot tcc's output through your * favorite shell: * * $ tcc -c shape20030310.tcc \ * > && { echo "tc qdisc del dev eth0 root"; tcc shape20030310.tcc; } | bash * */ /* * I would wager dollars to doughnuts that most tcng files will include * these two files, which provide more human readable terms for many * attributes and objects operated on in traffic control situations * */ #include "fields.tc" #include "ports.tc" /* * And naturally, you can define your own variables for later reference * */ #define INTERFACE eth0 /* * Notes on the syntax below: * * The "egress" keyword is synonomous with "dsmark" and allows us to configure * the filters at the top of the script in a single location. This is the * reason for the iproute2/Config change causing support for DiffServ and * dsmark. * * Within the queueing discipline (root = htb qdisc), we can nest classes, * and specify the bandwidth available for each class. If a parameter is * omitted, it inherits the parameter value from the parent class. * */ dev INTERFACE { egress { /* section in which we configure the filters */ class ( <$ssh> ) if tcp_sport == 22 && ip_tos_delay == 1 ; class ( <$audio> ) if tcp_sport == 554 || tcp_dport == 7070 ; /* note that numbers and names are acceptable */ class ( <$bulk> ) \ if tcp_sport == PORT_SSH || tcp_dport == PORT_HTTP ; class ( <$other> ) if 1 ; /* select anything leftover */ /* section in which we configure the qdiscs and classes */ htb () { class ( rate 600kbps, ceil 600kbps ) { $ssh = class ( rate 64kbps, ceil 128kbps ) ; $audio = class ( rate 128kbps, ceil 128kbps ) ; $bulk = class ( rate 256kbps, ceil 512kbps ) ; $other = class ( rate 128kbps, ceil 384kbps ) ; } } } } /* * For those who are seeing linux traffic control for the first time, you are * very lucky; don't ever look back (if you can help it). * * For those who are accustomed to "tc" style traffic control, it may take * some adjusting to get used to the tcng language conventions, but one great * annoyance has been rectified. See this chart for the summary: * * tcng syntax English equivalent tc syntax * ----------- -------------------- --------- * bps bits per second bit * Bps bytes per second bps (!) * kbps kilobits per second kbit * kBps kilobytes per second kbps * * Thankfully, this non-intuitive vestige and remnant of the tc syntax * has been eliminated in the tcng language! Free at last! * * For more on the tcng language, consult tcng.ps, generated in the complete * build of the tcng and tcsim software. * */