OpenWrt Forum Archive

Topic: speed limit for files bigger than 2mb

The content of this topic has been archived on 6 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi, guys
How is it possible to limit download speed for all files bigger than 2 mbytes? I have 7.09 on linksys wrt54gl just for 2 days)
Thank you !

you're looking for TC with HTB (heirarchal token bucket)

http://lartc.org/howto/lartc.qdisc.clas … ml#AEN1072

Change the '15k' burst to 16mbit; the following example very roughly strips their example down to just do the same thing for all traffic instead of making multiple classes.

# tc qdisc add dev eth0 root handle 1: htb default 30
# tc class add dev eth0 parent 1: classid 1:1 htb rate 6mbit burst 16mbit
# tc filter add dev eth0 protocol ip parent 1:0 prio 1 flowid 1:1

thank you for your reply
anything more new-bie friendly? or something to start with?

Unfortunately not - you can read through the HOWTO on lartc.org, but traffic-shaping in Linux is (in my opinion) very poorly documented for non-wizards.

Check into the connbytes match for iptables

netprince wrote:

Check into the connbytes match for iptables

ok, i've read lartc howto, iptables tutorial, well-commented wondershaper script and finaly do understand what you were talking about ))

now i mark all connections (?) within was transfered more than 500kbytes

iptables -t mangle -I PREROUTING -m connbytes \
--connbytes 512000: --connbytes-dir both --connbytes-mode bytes \
-j MARK --set-mark 21

and send it to limited band

echo 'adding main QDISC'
tc qdisc add dev $DEV root handle 1: htb default 20
tc class add dev $DEV parent 1: classid 1:1 htb rate ${RATEUP}kbit

echo 'adding main classes'
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 50kbit ceil 120kbit prio 0
tc class add dev $DEV parent 1:1 classid 1:21 htb rate 5kbit ceil 5kbit prio 1

echo 'adding leaf-qdisc'
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:21 handle 21: sfq perturb 10

echo 'adding filters'
tc filter add dev $DEV parent 1: prio 0 protocol ip handle 21 fw flowid 1:21

but it can be easyly cheated with using smart downloaders.
Is there any new ideas? )

The discussion might have continued from here.