Last active
March 20, 2019 19:23
-
-
Save 1player/fba5775fe0780af310a3 to your computer and use it in GitHub Desktop.
OpenWRT SQM script for bandwidth limited class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- 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 | |
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
Rev 2: updated to use a police filter, which is more appropriate to the use case.