| Text | |
1 23 45 67 89 1011 1213 1415 1617 1819 2021 2223 2425 2627 | #!/bin/bash # ConfigurationDSL_STATS=/run/shm/dsl_info/dsl_info # Making sure DSL stats are available [[ -f "$DSL_STATS" ]] && { # Calculating upstream limit - 95% of the current bandwidth to cope with overhead limit="$(awk '/Current upstream/ { split($0, data, "|"); upload = (data[2] / 8) * (95 / 100); print upload }' "$DSL_STATS")" } # Making sure at least a conservative limit is set[[ -z $limit || $limit == "" ]] && limit=900 # Giving ppp0 a proper queue length so prioritisation can actually happen, rather than dropping everything... is 3 by default! ifconfig ppp0 txqueuelen 100 # Add initial HTB qdisc on the roottc qdisc add dev ppp0 root handle 1: htb default 1 # Actually add the HTB class that limits upload to 95% of sync rate (deals with overhead) tc class add dev ppp0 parent 1:0 classid 1:1 htb rate "$limit"kibps ceil "$limit"kibps # Add a prio qdisc to this class to then use TOS to prioritise the packets into 3 bands, only dequeuing from higher ones when all the lower bands are emptiedtc qdisc add dev ppp0 parent 1:1 handle 100: prio |
Separate init.d bash and AWK scripts take care of logging into the Huawei Gateway to pull the stats and dump in a useful form. TOS is already set in the originating programs or forced via iptables rules (e.g. SSH likes to downgrade TOS as soon as you run a command, so needs to be forced to Minimize-Delay).
This script resides in '/etc/ppp/ip-up.d' so runs when the ppp interface appears - otherwise nothing is persisted.
So far this basic shaping looks to be doing the job - my main source of documentation has been Journey to the Center of the Linux Kernel: Traffic Control, Shaping and QoS.
One thing I've noted is where to involve CoDel, the recent anti-bufferbloat queuing discipline - none of the CoDel qdiscs talk about TOS, which is what I want to prioritise my traffic by - presumably by using HTB and prio queues 100 packets long, I cant just stick a CoDel queue on the end to make it magically better - and is only 100 packets long worth considering bufferbloat over...



Pages in this thread:
Print Thread
