Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OpenWRT SQM script for bandwidth limited class
--- simple.qos
+++ simple-bwlimit.qos
@@ -77,6 +77,7 @@
BE_RATE=`expr $CEIL / 6` # Min for best effort
BK_RATE=`expr $CEIL / 6` # Min for background
BE_CEIL=`expr $CEIL - 16` # A little slop at the top
+BL_RATE=`expr $CEIL / 100`
LQ="quantum `get_mtu $IFACE $CEIL`"
@@ -87,10 +88,12 @@
$TC class add dev $IFACE parent 1:1 classid 1:11 htb $LQ rate 128kbit ceil ${PRIO_RATE}kbit prio 1 `get_htb_adsll_string`
$TC class add dev $IFACE parent 1:1 classid 1:12 htb $LQ rate ${BE_RATE}kbit ceil ${BE_CEIL}kbit prio 2 `get_htb_adsll_string`
$TC class add dev $IFACE parent 1:1 classid 1:13 htb $LQ rate ${BK_RATE}kbit ceil ${BE_CEIL}kbit prio 3 `get_htb_adsll_string`
+$TC class add dev $IFACE parent 1:1 classid 1:14 htb $LQ rate ${BL_RATE}kbit prio 4 `get_htb_adsll_string`
$TC qdisc add dev $IFACE parent 1:11 handle 110: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${PRIO_RATE}` ${EQDISC_OPTS}
$TC qdisc add dev $IFACE parent 1:12 handle 120: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${BE_RATE}` ${EQDISC_OPTS}
$TC qdisc add dev $IFACE parent 1:13 handle 130: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${BK_RATE}` ${EQDISC_OPTS}
+$TC qdisc add dev $IFACE parent 1:14 handle 140: $QDISC `get_limit ${ELIMIT}` `get_target "${ETARGET}" ${UPLINK}` `get_ecn ${EECN}` `get_quantum 300` `get_flows ${BL_RATE}` ${EQDISC_OPTS}
# Need a catchall rule
@@ -103,6 +106,7 @@
$TC filter add dev $IFACE parent 1:0 protocol ip prio 1 handle 1 fw classid 1:11
$TC filter add dev $IFACE parent 1:0 protocol ip prio 2 handle 2 fw classid 1:12
$TC filter add dev $IFACE parent 1:0 protocol ip prio 3 handle 3 fw classid 1:13
+$TC filter add dev $IFACE parent 1:0 protocol ip prio 14 u32 match mark 4 0xffffffff police rate ${BL_RATE}kbit burst 6k drop flowid 1:14
# ipv6 support. Note that the handle indicates the fw mark bucket that is looked for
@1player

This comment has been minimized.

Copy link
Owner Author

1player commented Jul 24, 2015

Rev 2: updated to use a police filter, which is more appropriate to the use case.

@braian87b

This comment has been minimized.

Copy link

braian87b commented Jan 18, 2017

Line 15 says prio 4
Line 28 says prio 14
it is okay that?
how do I should edit the file to limit the download speed too ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.