Archive for June, 2006

First steps for bandwidth management

June 29th, 2006 by tripledes

I’ve been messing a little with QoS on Linux, I’m using my WRT54GS with OpenWRT’s release candidate 5 (whiterussian) which provides the needed command line tools (tc and iptables) and needed kernel modules too.

The thing starts defining a qdisc which provides the root point on the flow of traffic control, declaring the device where the queues are going to apply, the algorithm we want to use, etc:

tc qdisc add dev $UPDEV root handle 1: htb default 10

With this line I declare a queue discipline based on HTB applied on $UPDEV which point on the tree is 1: (1:0). After a root we have to define a class:

tc class add dev $UPDEV parent 1: classid 1:1 htb rate ${UPLINK}kbit ceil ${UPLINK}kbit burst 6k

This class is defined as child of the root (1:) node and has got id 1:1, uses HTB and can get all the bandwidth declared by ${UPLINK}. The burst statement is quite interesting cause it will help to hold packets when over-limits come.

Now it’s time to start classifying the packets:

tc class add dev $UPDEV parent 1:1 classid 1:20 htb rate 100kbit ceil ${UPLINK}kbit prio 0

Here I reserved 100kbps from my upload bandwidth  for the class 1:20 child of 1:1, it could borrow the whole up link if needed and takes priority 0 which is the highest one.

All we have to do now is to write a filter line which will define the handle used by iptables to mark the packets, a relation between a classid and a mark.

tc filter add dev ${UPDEV} parent 1: protocol ip prio 1 handle 1 fw classid 1:20

As can be read here I defined the filter which indicates that packets marked with 1 has to be flowed by the class id 1:20. Then the needed iptables rule:

iptables -t mangle -A PREROUTING -s ${IPADDR} -p tcp --sport ${PORTNUM} -j MARK --set-mark 0x1

Now watch the packets going through the class defined with the following command:

tc -s class show dev ${UPDEV}

So…is it working? :)

Freevo!

June 4th, 2006 by tripledes

After some days working on it I have finally got Freevo working with my Hauppauge 350. The little project started installing Gentoo Linux using two 40GiB UDMA100 disks using the RAID-1 software provided by Linux kernel, following this wiki entry. The hardware I’ve used is quite normal:

  • CPU: AMD Athlon XP 2400+
  • RAM: 3×512MiB DDR400 Kingston
  • HD: 2×40GiB Seagate, 1×200GiB Maxtor
  • Case: Thermaltake Tenor
  • Mother Board: Asus A7N8X-Deluxe
  • Capturer: Hauppauge pvr-350
  • WLAN: D-link DWL-G520
  • DVDRW: NEC ND-3520A
  • PCI IDE: Silicon Image 680 ATA133
  • Screen: Philips 170B 17″ TFT

Before buying the Thermaltake Tenor I was using the Swing one, but after seeing how well it’s doing I decided it should look little more to a media center, take a look to the pics.

The two 40GiB disks are holding the whole operating system and home directories letting the 200GiB one for recordings, music and things don’t change often.

The screen might look little small but our living room is not big, it fits enough but if the prizes keep going down we’ll get a bigger one in a near future.

Once I clean up the configuration files I’ll post again with a more detailed explanation about how everything works together.