I've written a script that shapes traffic into 3 pipes. The first pipe needs to be high priority and always be send first. This works perfectly now on 1 condition. I enter a correct ceil/max bitrate. This script is written to work an a device that will work with lots of different internet connections. The max bitrate can be set, but I prefer to have it working without the need to set a max bitrate. Or if I set a high value like 999mbps the prioritizing still works. Is this possible? And if, how?
Thank you!
Malic
Here is my script:
#!/bin/bash
DEV=$1
UPLINK=$2
DOWNLINK=$3
PORT_CLIENT=$4
PORT_TELNET=$5
PORT_SSH=$7
PORT_RTSP=$6
#erase previous qdiscs
tc qdisc del dev $DEV root
#tc qdisc del dev $DEV ingress
#set root qdisc
tc qdisc add dev $DEV root handle 1:0 htb
#set different pipes, rates and priorities
tc class add dev $DEV parent 1:0 classid 1:1 htb rate ${UPLINK}kbit ceil ${UPLINK}kbit
tc class add dev $DEV parent 1:1 classid 1:10 htb rate $[7*${UPLINK}/10]kbit ceil ${UPLINK}kbit prio 1
tc class add dev $DEV parent 1:1 classid 1:20 htb rate $[2*${UPLINK}/10]kbit ceil ${UPLINK}kbit prio 3
tc class add dev $DEV parent 1:1 classid 1:30 htb rate $[1*${UPLINK}/10]kbit ceil ${UPLINK}kbit prio 4
#unlimited access
#tc class add dev $DEV parent 1:0 classid 1:90 htb rate 100000mbit burst 100000mbit
#stochastic fairness
#tc qdisc add dev $DEV parent 1:10 handle 100: sfq perturb 10
#tc qdisc add dev $DEV parent 1:20 handle 200: sfq perturb 10
#tc qdisc add dev $DEV parent 1:30 handle 300: sfq perturb 10
tc qdisc add dev $DEV parent 1:10 handle 100: pfifo limit 2
tc qdisc add dev $DEV parent 1:20 handle 200: pfifo limit 2
tc qdisc add dev $DEV parent 1:30 handle 300: pfifo limit 2
#filter data streams into pipe1
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip sport $PORT_CLIENT 0xffff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip sport $PORT_TELNET 0xffff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip sport $PORT_SSH 0xffff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip protocol 6 0xff match u8 0x10 0xff at nexthdr+13 flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16 0x0000 0xffc0 at 2 match u8 0x10 0xff at 33 flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip protocol 6 0xff match u32 0x52545350 0xffffffff at 40 flowid 1:10
#filter video streams into pipe2
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip sport $PORT_RTSP 0xffff flowid 1:20
#filter rest into pipe3
tc filter add dev $DEV parent 1:0 protocol ip prio 18 u32 match ip dst 0.0.0.0/0 flowid 1:30