Greetings -
I'm new to QoS, so
please be gentle (and yes, I've RTFM, though I don't understand every bit of
it)
Here's the thing; I've tried several scripts--simple and
complex--for classifying my Vonage traffic into a high-priority queue, but no
matter what I do it doesn't seem to work. Right now I'm using the HTB
script I'll include below, which is a mashing together of several scripts I've
found along with a lot of the LARTC HOWTO stuff. Bottom line; if I
load up my *outbound* connection and then try to make a Vonage call, my voice is
so chopped up at the other end that noone can understand me.
If it makes a
difference, I *am* getting a few errors when I run this script, but I'm a
relative newbie to QoS so I'm not sure where my errors lie. I also thought
that I might be having trouble with my MARKs in IPTABLES, so I tossed in a line
to filter based on IP DST/SRC instead of relying on the marks (in a different,
working IPTABLES script).
Any
ideas?
Thanks.
--------- snip
-----------------
#!/bin/sh
DOWNLINK="2800"
UPLINK="240"
DEV="eth0"
DEV2="eth1"
CEILING=$[100*$UPLINK/100]
MISC_RATE=$[90*$CEILING/100]
UPLINK="240"
DEV="eth0"
DEV2="eth1"
CEILING=$[100*$UPLINK/100]
MISC_RATE=$[90*$CEILING/100]
# Clean existing
down and uplink qdiscs, hide errors
tc qdisc del dev $DEV root 2> /dev/null > /dev/null
tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null
tc qdisc del dev $DEV root 2> /dev/null > /dev/null
tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null
# Set packet queue
much smaller than default (100):
ip link set dev $DEV2 qlen 10
ip link set dev $DEV2 qlen 10
## UPLINK ##
# Install root HTB; default traffic to 1:20
tc qdisc add dev $DEV root handle 1: htb r2q 1 default 20
tc qdisc add dev $DEV root handle 1: htb r2q 1 default 20
# Shape everything at $CEILING speed - preventing huge queues in
# Cable modem which tend to destroy latency
tc class add dev $DEV parent 1: classid 1:1 htb rate ${CEILING}kbit
# Cable modem which tend to destroy latency
tc class add dev $DEV parent 1: classid 1:1 htb rate ${CEILING}kbit
# Set up some branches for things
# 1:10 - High priority, interactive traffic, ICMP ECHO, TCP ACK
# 1:20 - Web, mail, standard stuff
# 1:30 - Everything else (Shareaza, etc.)
# 1:10 - High priority, interactive traffic, ICMP ECHO, TCP ACK
# 1:20 - Web, mail, standard stuff
# 1:30 - Everything else (Shareaza, etc.)
tc class add dev $DEV parent 1:1 classid 1:10 htb rate 128kbit ceil
${UPLINK}kbit prio 1
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 64kbit ceil ${UPLINK}kbit prio 2
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 64kbit ceil ${UPLINK}kbit prio 3
tc class add dev $DEV parent 1:1 classid 1:20 htb rate 64kbit ceil ${UPLINK}kbit prio 2
tc class add dev $DEV parent 1:1 classid 1:30 htb rate 64kbit ceil ${UPLINK}kbit prio 3
# All get Stochastic Fairness (except VOIP)
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10
## FILTERS ##
# VOIP traffic in 1:0 (i.e. skip the HTB entirely and drop it directly into
the interface queue)
# MARKS (FROM IPTABLES):
# VONAGE (1)
# SSH (2)
# WoW (3)
# TeamSpeak (4)
# Shareaza (20)
# MARKS (FROM IPTABLES):
# VONAGE (1)
# SSH (2)
# WoW (3)
# TeamSpeak (4)
# Shareaza (20)
tc filter add dev $DEV parent 1:0 protocol ip prio 1 handle 1 fw flowid
1:0
tc filter add dev $DEV parent 1:0 protocol ip prio 2 handle 2 fw flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 3 handle 3 fw flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 4 handle 4 fw flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 50 handle 20 fw flowid 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 2 handle 2 fw flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 3 handle 3 fw flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 4 handle 4 fw flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 50 handle 20 fw flowid 1:30
# TOS Minimum Delay (ssh, NOT scp) in 1:10, ICMP (impress the ladies), AH,
DNS
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip tos 0x10 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 11 u32 match ip protocol 1 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 12 u32 match ip protocol 47 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 13 u32 match ip protocol 50 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 14 u32 match ip sport 53 0xffff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 15 u32 match ip dport 53 0xffff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match ip tos 0x10 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 11 u32 match ip protocol 1 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 12 u32 match ip protocol 47 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 13 u32 match ip protocol 50 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 14 u32 match ip sport 53 0xffff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 15 u32 match ip dport 53 0xffff flowid 1:10
# To speed up downloads while uploading, put ACKs in the interactive
class
tc filter add dev $DEV parent 1: protocol ip prio 5 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: protocol ip prio 5 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
# VOIP Test - If this works, then it appears that our MARKing in IPTABLES
is getting @#$@#$ somewhere
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.1.110 flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip src 192.168.1.110 flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip dst 192.168.1.110 flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 1 u32 match ip src 192.168.1.110 flowid 1:10
# Low-priority
tc filter add dev $DEV parent 1:0 protocol ip prio 40 u32 match ip dport 25 0xffff flowid 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 41 u32 match ip sport 25 0xffff flowid 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 42 u32 match ip sport 110 0xffff flowid 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 43 u32 match ip sport 143 0xffff flowid 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 40 u32 match ip dport 25 0xffff flowid 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 41 u32 match ip sport 25 0xffff flowid 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 42 u32 match ip sport 110 0xffff flowid 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 43 u32 match ip sport 143 0xffff flowid 1:30
#######################
## DOWNSTREAM CONFIG ##
#######################
## DOWNSTREAM CONFIG ##
#######################
# Ingress
tc qdisc add dev $DEV handle ffff: ingress
tc qdisc add dev $DEV handle ffff: ingress
# VOIP
tc qdisc add dev $DEV parent ffff: protocol ip prio 90 handle 1 fw flowid :1
tc qdisc add dev $DEV parent ffff: protocol ip prio 90 handle 1 fw flowid :1
# Filter *everything* to it (0.0.0.0/0), drop whatever comes in too
fast
tc filter add dev $DEV parent ffff: protocol ip prio 91 u32 match ip src \
0.0.0.0/0 police rate $[80*$DOWNLINK/100]kbit burst 10k drop flowid :1
tc filter add dev $DEV parent ffff: protocol ip prio 91 u32 match ip src \
0.0.0.0/0 police rate $[80*$DOWNLINK/100]kbit burst 10k drop flowid :1
# "Shift" the priority map "down" so that we have higher priority for VOIP
traffic. Even
# packets leaving the ethernet interface will give priority to VOIP traffic (we hope).
# default priomap ---------------------------------------- 1 2 1 1 2 2 2 2 0 0 0 0 1 1 1 1
tc qdisc add dev $DEV2 root handle 1: prio bands 3 priomap 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2
# packets leaving the ethernet interface will give priority to VOIP traffic (we hope).
# default priomap ---------------------------------------- 1 2 1 1 2 2 2 2 0 0 0 0 1 1 1 1
tc qdisc add dev $DEV2 root handle 1: prio bands 3 priomap 2 2 2 2 2 2 2 2 1 1 1 1 2 2 2 2
# Define the queues, without any kind of rate limiting
tc qdisc add dev $DEV2 parent 1:1 handle 10: pfifo
tc qdisc add dev $DEV2 parent 1:2 handle 20: sfq
tc qdisc add dev $DEV2 parent 1:3 handle 30: sfq
tc qdisc add dev $DEV2 parent 1:1 handle 10: pfifo
tc qdisc add dev $DEV2 parent 1:2 handle 20: sfq
tc qdisc add dev $DEV2 parent 1:3 handle 30: sfq
tc filter add dev $DEV2 parent 1: protocol ip prio 5 handle 1 fw flowid
1:1
tc filter add dev $DEV2 parent 1: protocol ip prio 21 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:2
tc filter add dev $DEV2 parent 1: protocol ip prio 44 u32 match ip dport 25 0xffff flowid 1:2
tc filter add dev $DEV2 parent 1: protocol ip prio 45 u32 match ip sport 25 0xffff flowid 1:2
tc filter add dev $DEV2 parent 1: protocol ip prio 99 handle 20 fw flowid 1:3
tc filter add dev $DEV2 parent 1: protocol ip prio 21 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:2
tc filter add dev $DEV2 parent 1: protocol ip prio 44 u32 match ip dport 25 0xffff flowid 1:2
tc filter add dev $DEV2 parent 1: protocol ip prio 45 u32 match ip sport 25 0xffff flowid 1:2
tc filter add dev $DEV2 parent 1: protocol ip prio 99 handle 20 fw flowid 1:3