Thottle Linux Network Speed To 56k

July 31, 2009

Author: jart — Originally Posted 222 Days Ago Article Tags « linux networking qos tutorial »

If you have a bit of nostalgia for the "old days" and are running Linux on your desktop, you can use a tool called tc to limit your broadband Internet connection perform as though you were using a 56k modem.

This is pretty cool if you ever wanted to test how quickly your website loads for dial-up users, or if you wanted to play a prank on a friend.

Limit Upload and Download to 56kbit

This script will selectively target HTTP traffic on port 80 only. This way anything you might have running in the background should be relatively safe.

Open up a shell and run the following commands:

# limit upload
sudo tc qdisc add dev eth0 root handle 1: htb default 10
sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 100mbit ceil 100mbit
sudo tc class add dev eth0 parent 1:1 classid 1:10 htb rate 99mbit ceil 100mbit burst 6k prio 1
sudo tc class add dev eth0 parent 1:1 classid 1:20 htb rate 56kbit ceil 56kbit burst 6k prio 2
sudo tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip dport 80 0xffff flowid 1:20

# limit download
sudo tc qdisc add dev eth0 handle ffff: ingress
sudo tc filter add dev eth0 parent ffff: protocol ip prio 20 u32 match ip sport 80 0xffff police rate 56kbit burst 6k drop flowid :1

Go Back to Warp Speed

Wasn't that fun? Run these commands to make everything normal and happy again:

sudo tc qdisc del dev eth0 root
sudo tc qdisc del dev eth0 ingress

Show Statistics

One of these commands is bound to show you something about what's going on. The last one shows you the download shaping statistics which is probably what you want.

sudo tc -s qdisc show dev eth0
sudo tc -s class show dev eth0
sudo tc -s filter show dev eth0
sudo tc -s -d -p filter show dev eth0 parent ffff:

Comments

No comments found.

Post Comment