April 21, 2019

Giving VoIP Traffic the Green Light, Part 3 - page 3

Wondershaper Status: Clearing the Queue

  • July 10, 2006
  • By Carla Schroder

I had hopes of condensing the finer points of traffic shaping into a brilliant, digestible, yet comprehensive how-to, but it's proved more difficult than I anticipated. Perhaps the subject simply doesn't lend itself to this sort of treatment, because it is complex and abstract. Instead we'll take a look at an excellent script written by Carceri, QoS with Linux using PRIO and HTB.

This is a complete drop-in, modified Wondershaper script. There are four lines that you need to modify:


We already know what to do with the first two. RATE is the maximum speed for an entire class and all of its children. CEIL is the maximum rate at which a child class can send, if the parent has spare bandwidth. CEIL can not be larger than RATE. (You can find all these definitions in man tc-htb.)

A class is a set of instructions that define actions, like this example from the script that defines the parent class:

$TC qdisc add dev ${DEV} root handle 1: tbf rate ${RATE}kbit burst 4k latency 30ms 

There is an excellent diagram at the bottom of the page that shows the different classes and relationships clearly. So you can see that there are two different types of classes: PRIO and HTB.

PRIO is short for priority. The lowest priority fields tell which packets get to go first. Classes don't do anything by themselves; they are called by filters, as this example shows:

# VoIP traffic always get first in line (my ATA tags them with TOS 0x68 or 0xb8) 
$TC filter add dev ${DEV} parent 10:0 prio 3 protocol ip u32  
    match ip tos 0x68 0xff  
    flowid 10:1 

HTB is "Hierarchy Token Bucket." (I told you this was abstract!) To quote the man page: "HTB shapes traffic based on the Token Bucket Filter algorithm which does not depend on interface characteristics and so does not need to know the underlying bandwidth of the outgoing interface." This is one of the HTB classes in the script:

$TC class add dev ${DEV} parent 200:1 classid 200:30 htb  

    rate $[2*$CEIL/100]kbit ceil ${CEIL}kbit burst 2k prio 3 

What does this all mean to you? It means you can go a long way just by fiddling with the RATE and CEIL variables. However, I do encourage you to study the script, man tc-htb, and especially Chapter 9 of the Linux Advanced Routing & Traffic Control HOWTO, which is well-written and clearly explains all the different terms and concepts.

Traffic-shaping is probably the most difficult aspect of networking to learn. Next week we'll get back to doing fun things with Asterisk, which is a whole lot easier.


This article originally appeared on VoIP Planet, a JupiterWeb site.

Most Popular LinuxPlanet Stories