From: "Some Clown" Date: Wed, 16 Feb 2005 00:18:57 +0000 Subject: [LARTC] VOIP Challenges... Message-Id: <20050216001928.D7B28408D@outpost.ds9a.nl> MIME-Version: 1 Content-Type: multipart/mixed; boundary="----=_NextPart_000_003E_01C5137A.0D8958D0" List-Id: To: lartc@vger.kernel.org This is a multi-part message in MIME format. ------=_NextPart_000_003E_01C5137A.0D8958D0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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] # 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 # Set packet queue much smaller than default (100): 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 # 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 # 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.) 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 # 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 ## 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) 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 # 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 # 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 # 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 # 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 ####################### ## DOWNSTREAM CONFIG ## ####################### # 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 # 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 # "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 # 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 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 ------=_NextPart_000_003E_01C5137A.0D8958D0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Greetings -=20
 
I'm = new to QoS, so=20 please be gentle (and yes, I've RTFM, though I don't understand every = bit of=20 it)
 
Here's the thing; I've tried several = scripts--simple and=20 complex--for classifying my Vonage traffic into a high-priority queue, = but no=20 matter what I do it doesn't seem to work.  Right now I'm using the = HTB=20 script I'll include below, which is a mashing together of several = scripts I've=20 found along with a lot of the LARTC HOWTO stuff.  Bottom line; = if I=20 load up my *outbound* connection and then try to make a Vonage call, my = voice is=20 so chopped up at the other end that noone can understand = me.
 
If = it makes a=20 difference, I *am* getting a few errors when I run this script, but I'm = a=20 relative newbie to QoS so I'm not sure where my errors lie.  I also = thought=20 that I might be having trouble with my MARKs in IPTABLES, so I tossed in = a line=20 to filter based on IP DST/SRC instead of relying on the marks (in a = different,=20 working IPTABLES script).
 
Any=20 ideas?
 
Thanks.
 
--------- snip=20 -----------------
#!/bin/sh
 
DOWNLINK=3D"2800"
UPLINK=3D"240"
DEV=3D"eth0"
DEV2=3D"e= th1"
CEILING=3D$[100*$UPLINK/100]
MISC_RATE=3D$[90*$CEILING/100]
 
# = Clean existing=20 down and uplink qdiscs, hide errors
tc qdisc del dev $DEV=20 root      2> /dev/null > /dev/null
tc = qdisc=20 del dev $DEV ingress   2> /dev/null >=20 /dev/null
 
# = Set packet queue=20 much smaller than default (100):
ip link set dev $DEV2 qlen=20 10
 

## UPLINK ##
 
# Install root HTB; default traffic to 1:20
tc qdisc add dev = $DEV root=20 handle 1: htb r2q 1 default 20
 
# Shape everything at $CEILING speed - preventing huge queues = in
# Cable=20 modem which tend to destroy latency
tc class add dev $DEV parent 1: = classid=20 1:1 htb rate ${CEILING}kbit
 
# Set up some branches for things
# 1:10 - High priority, = interactive=20 traffic, ICMP ECHO, TCP ACK
# 1:20 - Web, mail, standard stuff
# = 1:30 -=20 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=20 64kbit ceil ${UPLINK}kbit prio 2
tc class add dev $DEV parent 1:1 = classid=20 1:30 htb rate 64kbit ceil ${UPLINK}kbit prio 3
 
# All get Stochastic Fairness (except VOIP)
tc qdisc add dev = $DEV parent=20 1:10 handle 10: sfq perturb 10
tc qdisc add dev $DEV parent 1:20 = handle 20:=20 sfq perturb 10
tc qdisc add dev $DEV parent 1:30 handle 30: sfq = perturb=20 10
 
## FILTERS ##
 
# VOIP traffic in 1:0 (i.e. skip the HTB entirely and drop it = directly into=20 the interface queue)
# MARKS (FROM=20 IPTABLES):
#      =20 VONAGE         =20 (1)
#      =20 SSH           &nbs= p;=20 (2)
#      =20 WoW           &nbs= p;=20 (3)
#      =20 TeamSpeak      =20 (4)
#      =20 Shareaza        (20)
 
tc filter add dev $DEV parent 1:0 protocol ip prio 1 handle 1 fw = flowid=20 1:0
tc filter add dev $DEV parent 1:0 protocol ip prio 2 handle 2 fw = flowid=20 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 3 handle 3 fw = flowid=20 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 4 handle 4 fw = flowid=20 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 50 handle 20 = fw=20 flowid 1:30
 
# TOS Minimum Delay (ssh, NOT scp) in 1:10, ICMP (impress the = ladies), AH,=20 DNS
tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match = ip tos=20 0x10 0xff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip = prio 11=20 u32 match ip protocol 1 0xff flowid 1:10
tc filter add dev $DEV = parent 1:0=20 protocol ip prio 12 u32 match ip protocol 47 0xff flowid 1:10
tc = filter add=20 dev $DEV parent 1:0 protocol ip prio 13 u32 match ip protocol 50 0xff = flowid=20 1:10
tc filter add dev $DEV parent 1:0 protocol ip prio 14 u32 match = ip sport=20 53 0xffff flowid 1:10
tc filter add dev $DEV parent 1:0 protocol ip = prio 15=20 u32 match ip dport 53 0xffff flowid 1:10
 
# To speed up downloads while uploading, put ACKs in the = interactive=20 class
tc filter add dev $DEV parent 1: protocol ip prio 5 u32=20 \
        match ip protocol 6 0xff = \
        match u8 0x05 0x0f at 0=20 \
        match u16 0x0000 0xffc0 = at 2=20 \
        match u8 0x10 0xff at 33 = \
        flowid 1:10
 
# VOIP Test - If this works, then it appears that our MARKing in = IPTABLES=20 is getting @#$@#$ somewhere
tc filter add dev $DEV parent 1:0 = protocol ip=20 prio 1 u32 match ip dst 192.168.1.110 flowid 1:10
tc filter add dev = $DEV=20 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=20 match ip dport 25 0xffff flowid 1:30
tc filter add dev $DEV parent = 1:0=20 protocol ip prio 41 u32 match ip sport 25 0xffff flowid 1:30
tc = filter add=20 dev $DEV parent 1:0 protocol ip prio 42 u32 match ip sport 110 0xffff = flowid=20 1:30
tc filter add dev $DEV parent 1:0 protocol ip prio 43 u32 match = ip sport=20 143 0xffff flowid 1:30
 
#######################
## DOWNSTREAM CONFIG=20 ##
#######################
 
# Ingress
tc qdisc add dev $DEV handle ffff: ingress
 
# VOIP
tc qdisc add dev $DEV parent ffff: protocol ip prio 90 = handle 1=20 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=20 \
        0.0.0.0/0 police rate=20 $[80*$DOWNLINK/100]kbit burst 10k drop flowid :1
 
# "Shift" the priority map "down" so that we have higher priority = for VOIP=20 traffic.  Even
# packets leaving the ethernet interface will = give=20 priority to VOIP traffic (we hope).
# default priomap=20 ---------------------------------------- 1 2 1 1 2 2 2 2 0 0 0 0 1 1 1 = 1
tc=20 qdisc add dev $DEV2 root handle 1: prio bands 3 priomap 2 2 2 2 2 2 2 2 = 1 1 1 1=20 2 2 2 2
 
# Define the queues, without any kind of rate limiting
tc qdisc = add dev=20 $DEV2 parent 1:1 handle 10: pfifo
tc qdisc add dev $DEV2 parent 1:2 = handle=20 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=20 1:1
tc filter add dev $DEV2 parent 1: protocol ip prio 21 u32=20 \
        match ip protocol 6 0xff = \
        match u8 0x05 0x0f at 0=20 \
        match u16 0x0000 0xffc0 = at 2=20 \
        match u8 0x10 0xff at 33 = \
        flowid 1:2
tc filter = add dev=20 $DEV2 parent 1: protocol ip prio 44 u32 match ip dport 25 0xffff flowid=20 1:2
tc filter add dev $DEV2 parent 1: protocol ip prio 45 u32 match = ip sport=20 25 0xffff flowid 1:2
tc filter add dev $DEV2 parent 1: protocol ip = prio 99=20 handle 20 fw flowid 1:3
------=_NextPart_000_003E_01C5137A.0D8958D0-- _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/