Good Ol' tc

Tuesday, August 30, 2005, at 08:04PM

By Eric Richardson

For the last few years I've run the USC waterski team. This year I've finally acknowledged that I'm way too busy to do a good job at that and have passed it off to someone else. I still have a good number of connections to the team, though, one of which is the fact that the mailing list still runs off my email server.

That just sort of dawned on me tonight when the new president sent out an email to the list that had 4mb of attachments. Or rather I should say he's still sending it, since qmail-qread shows it about 50/50 between done and not done for the list's 350 or so members.

Each time something like this happens I have to refigure out how to set up traffic shaping. Today the answer was to rate limit traffic destined for port 25 (SMTP) to 300kbit. :

sudo /sbin/tc class add dev eth0 parent 1:1 \
classid 1:12 htb rate 200kbit ceil 300kbit prio 0;
sudo /sbin/tc qdisc add dev eth0 parent 1:12 \
handle 12: sfq perturb 1; 
sudo /sbin/tc filter add dev eth0 protocol ip \
parent 1:0 pref 2 u32 match ip dport 25 0xfffe \
flowid 1:12

I have no clue if that's the proper way to do it, but it's working. My pings have gone from 1200ms back down to a more fun 80 - 100ms.