What's new

QoS Script for VPN

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Lynx

Senior Member
Here is my QoS script to deal with a VPN and apply QoS with correct overhead depending on whether the VPN is active or not:
Code:
admin@RT-AX86U-4168:/jffs/scripts# cat /jffs/configs/cake-qos.conf.add
DLIF='br0'
DLOPTIONS='wash dual-dsthost ingress'
ULIF_TUN='tun11'
TUN_PACKET_OVERHEAD='53'
Code:
admin@RT-AX86U-4168:/jffs/scripts# cat qos-start
#!/bin/sh

(
cat <<'ADDTEXT'
#!/bin/sh
source /etc/cake-qos.conf

OVERHEAD_TUN="overhead $(($(echo $OVERHEAD |grep -o -E '[0-9]+' |sed -n '1p')+TUN_PACKET_OVERHEAD)) mpu $(echo $OVERHEAD |grep -o -E '[0-9]+' |sed -n '2p')"

case "$1" in
start)
        if [[ -d /sys/class/net/"$ULIF_TUN" ]]; then
                tc qdisc add dev $ULIF_TUN root cake $ULPRIOQUEUE $ULOPTIONS $ULBW $OVERHEAD_TUN $FRAMING 2>/dev/null
                tc qdisc add dev $DLIF root cake $DLPRIOQUEUE $DLOPTIONS $DLBW $OVERHEAD_TUN $FRAMING 2>/dev/null
        else
                tc qdisc add dev $ULIF root cake $ULPRIOQUEUE $ULOPTIONS $ULBW $OVERHEAD $FRAMING 2>/dev/null
                tc qdisc add dev $DLIF root cake $DLPRIOQUEUE $DLOPTIONS $DLBW $OVERHEAD $FRAMING 2>/dev/null
        fi
        ;;
stop)
        tc qdisc del dev $ULIF root 2>/dev/null
        tc qdisc del dev $ULIF_TUN root 2>/dev/null
        tc qdisc del dev $DLIF root 2>/dev/null
        ;;
*)
esac
ADDTEXT
) > /tmp/qos
With $OVERHEAD set from the GUI as:
Code:
OVERHEAD='overhead 38 mpu 0'
This needs to be replaced by:
Code:
OVERHEAD='overhead {38+$TUN_PACKET_OVERHEAD} mpu 0'
The line:
Code:
OVERHEAD_TUN="overhead $(($(echo $OVERHEAD |grep -o -E '[0-9]+' |sed -n '1p')+TUN_PACKET_OVERHEAD)) mpu $(echo $OVERHEAD |grep -o -E '[0-9]+' |sed -n '2p')"
is a little ugly.
Is there a more efficient way to increment only the first integer by $TUN_PACKET_OVERHEAD?
 
Last edited:
Fetch the overhead value directly from nvram.
Code:
nvram get qos_overhead
 
I found a cool alternative solution:
Code:
OVERHEAD_TUN=$(echo $OVERHEAD | awk '$2=$2+'$TUN_OVERHEAD)
BTW any clue about the correct overhead to use for an LTE 4G connection? I just guessed 38 based on a standard Ethernet packet (without VLAN) which has 26 bytes of overhead and a 12 byte interpacket gap. The OpenWRT guys seem to suggest using '38' when determining the true overhead is highly uncertain.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top