OpenWrt Forum Archive

Topic: Help on QoS script to downgrade traffic from one host

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

Dear all,

I have my OpenWRT router connected via Ethernet to a DSL modem (eth1). My DSL has 1Mbps downstream and 128Kbps upstream. I have a host with IP 192.168.1.22 that I would like to downgrade to lowest priority and let all the other traffic in high priority. However, I want to let the low prio host grab all the bandwidth if he is the only one.

In order to accomplish the above I am trying to follow the traditional approach of throttling the upstream traffic between the OpenWRT and the DSL modem in order to own the queues, and then apply HTB in the OpenWRT router.

Next, I paste the script that I am using which is not working as I expect. What I would expect is that if the low priority host is downloading something, and I start a download in another host, then this other host should grab almost all the bandwidth, however this is not what happens.

Any advice on what am I doing wrong, or on how to debug my script would be greatly appreciated.

Best Regards

Daniel

My script:
------------------------------------------------------------------------------------------------------------
#!/bin/sh

UL_IFACE="eth1"
UL_SPEED="115kbps"
HIGH_PRIO_UL_SPEED="110kbps"
LOW_PRIO_UL_SPEED="5kbps"
LOW_PRIO_HOST="192.168.1.22"

insmod sch_htb
insmod sch_sfq

tc qdisc add dev $UL_IFACE root handle 1: htb default 11
tc class add dev $UL_IFACE parent 1: classid 1:1 htb rate $UL_SPEED ceil $UL_SPEED
tc class add dev $UL_IFACE parent 1:1 classid 1:10 htb rate $LOW_PRIO_UL_SPEED ceil $HIGH_PRIO_UL_SPEED
tc class add dev $UL_IFACE parent 1:1 classid 1:11 htb rate $HIGH_PRIO_UL_SPEED ceil $HIGH_PRIO_UL_SPEED
tc qdisc add dev $UL_IFACE parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $UL_IFACE parent 1:11 handle 11: sfq perturb 10

iptables -t mangle -A POSTROUTING -o $UL_IFACE -s $LOW_PRIO_HOST -j CLASSIFY --set-class 1:10

------------------------------------------------------------------------------------------------------------

The script executes with no problem,  and this is the output of the "tc show" command:

------------------------------------------------------------------------------------------------------------

root@OpenWrt:~/Traffic_Control_Scripts# tc -s -d class show dev eth1
class htb 1:11 parent 1:1 leaf 11: prio 0 quantum 11000 rate 880000bit ceil 880000bit burst 1599b/8 mpu 0b overhead 0b cburst 1599b/8 mpu 0b overhead 0b level 0
Sent 247 bytes 5 pkt (dropped 0, overlimits 0 requeues 0)
rate 112bit 0pps backlog 0b 0p requeues 0
lended: 5 borrowed: 0 giants: 0
tokens: 219312 ctokens: 219312

class htb 1:10 parent 1:1 leaf 10: prio 0 quantum 1000 rate 40000bit ceil 880000bit burst 1600b/8 mpu 0b overhead 0b cburst 1599b/8 mpu 0b overhead 0b level 0
Sent 118064 bytes 773 pkt (dropped 0, overlimits 0 requeues 0)
rate 42320bit 35pps backlog 0b 0p requeues 0
lended: 422 borrowed: 351 giants: 0
tokens: -394761 ctokens: 205687

class htb 1:1 root rate 920000bit ceil 920000bit burst 1599b/8 mpu 0b overhead 0b cburst 1599b/8 mpu 0b overhead 0b level 7
Sent 118311 bytes 778 pkt (dropped 0, overlimits 0 requeues 0)
rate 42424bit 35pps backlog 0b 0p requeues 0
lended: 351 borrowed: 0 giants: 0
tokens: 196750 ctokens: 196750

------------------------------------------------------------------------------------------------------------

In your tc output there are only 247 bytes send from the 1:11 class. So all the traffic goes to 1:10??

The discussion might have continued from here.