cmisip
2005-Apr-10 01:47 UTC
[Asterisk-Users] Can you comment on this Qos script? How does one shape RTP?
I got this from the voip wiki but the original script didn't seem to
work right so I fiddled with it a little bit. I am no expert so maybe
someone can look at it for errors. This is for my cable connection. So
far asterisk seems to use 1:10 while all other traffic uses 1:102. How
does one packet shape RTP?
Thanks for any help.
#!/bin/sh
TCOP="add"
IPTOP="-A"
if [ "$1" == "stop" ]; then
echo "Stopping..."
TCOP="del"
IPTOP="-D"
fi
# +---------+
# | root 1: |
# +---------+
# |
# +----------------------------+
# | class 1:1 |
# +----------------------------+
# | | |
# +----+ +----+ +----+
# |1:10| |1:20| |1:30|
# +----+ +----+ +----+
# |
# +--------+--------+
# | | |
# +-----+ +-----+ +-----+
# |1:100| |1:101| |1:102|
# +-----+ +-----+ +-----+
# 1:10 is the class for VOIP traffic, pfifo qdisc
# 1:20 is for bulk traffic (htb, leaves use sfq)
# 1:30 is the class that interactive and TCP SYN/ACK traffic (sfq qdisc)
# 1:20 is further split up into different kinds of bulk traffic: web,
mail and
# everything else. 1:100-102 fight amongst themselves for their slice
of excess
# bandwidth, and in turn 1:10,20 and 30 then fight for any excess above
their
# minimum rates.
# which interface to throw all this on (cable)
IF=eth0
# ceil is 75% of max rate (768kbps)
# rate is 65% of max rate
RATE=500
CEIL=576
/sbin/tc qdisc ${TCOP} dev ${IF} root handle 1: htb default 102
/sbin/tc class ${TCOP} dev ${IF} parent 1: classid 1:1 htb rate
${RATE}kbit ceil ${CEIL}kbit
/sbin/tc class ${TCOP} dev ${IF} parent 1:1 classid 1:10 htb rate
64kbit ceil ${RATE}kbit prio 0
/sbin/tc class ${TCOP} dev ${IF} parent 1:1 classid 1:20 htb rate
64kbit ceil ${RATE}kbit prio 1
/sbin/tc class ${TCOP} dev ${IF} parent 1:20 classid 1:100 htb rate
${RATE}kbit prio 1
/sbin/tc class ${TCOP} dev ${IF} parent 1:20 classid 1:101 htb rate
${RATE}kbit prio 1
/sbin/tc class ${TCOP} dev ${IF} parent 1:20 classid 1:102 htb rate
${RATE}kbit prio 4
/sbin/tc qdisc ${TCOP} dev ${IF} parent 1:10 handle 10: pfifo
/sbin/tc qdisc ${TCOP} dev ${IF} parent 1:100 handle 100: sfq perturb 10
/sbin/tc qdisc ${TCOP} dev ${IF} parent 1:101 handle 101: sfq perturb 10
/sbin/tc qdisc ${TCOP} dev ${IF} parent 1:102 handle 102: sfq perturb 10
# IAX send to 1:10
/sbin/tc filter ${TCOP} dev ${IF} protocol ip parent 1:0 prio 0 u32
match ip dport 4569 0xffff flowid 1:10
# SIP send to 1:10
/sbin/tc filter ${TCOP} dev ${IF} protocol ip parent 1:0 prio 0 u32
match ip dport 5060 0xffff flowid 1:10
Doug Lytle
2005-Apr-10 05:29 UTC
[Asterisk-Users] Can you comment on this Qos script? How does one shape RTP?
cmisip wrote:>far asterisk seems to use 1:10 while all other traffic uses 1:102. How >does one packet shape RTP? > >Thanks for any help. > > > > ># +---------+ ># | root 1: | ># +---------+ ># | ># +----------------------------+ ># | class 1:1 | ># +----------------------------+ ># | | | ># +----+ +----+ +----+ ># |1:10| |1:20| |1:30| ># +----+ +----+ +----+ ># | ># +--------+--------+ ># | | | ># +-----+ +-----+ +-----+ ># |1:100| |1:101| |1:102| ># +-----+ +-----+ +-----+ > > >I'm using the same script, but I found it searching Google. Yours seems to be incomplete. My script follows: #!/bin/sh TCOP="add" IPTOP="-A" if [ "$1" == "stop" ]; then echo "Stopping..." TCOP="del" IPTOP="-D" fi # +---------+ # | root 1: | # +---------+ # | # +----------------------------+ # | class 1:1 | # +----------------------------+ # | | | # +----+ +----+ +----+ # |1:10| |1:20| |1:30| # +----+ +----+ +----+ # | # +--------+--------+ # | | | # +-----+ +-----+ +-----+ # |1:100| |1:101| |1:102| # +-----+ +-----+ +-----+ # 1:10 is the class for VOIP traffic, pfifo qdisc # 1:20 is for bulk traffic (htb, leaves use sfq) # 1:30 is the class that interactive and TCP SYN/ACK traffic (sfq qdisc) # 1:20 is further split up into different kinds of bulk traffic: web, mail and # everything else. 1:100-102 fight amongst themselves for their slice of excess # bandwidth, and in turn 1:10,20 and 30 then fight for any excess above their # minimum rates. # which interface to throw all this on (DSL) IF=eth2 # ceil is 75% of max rate (768kbps) # rate is 65% of max rate # we don't let it go to 100% because we don't want the DSL modem (Pairgain MegaBit Modem 300S) # to have a ton of packets in their buffers. *we* want to do the buffering. RATE=576 CEIL=640 #RATE=450 #CEIL=500 tc qdisc ${TCOP} dev ${IF} root handle 1: htb default 102 tc class ${TCOP} dev ${IF} parent 1: classid 1:1 htb rate ${RATE}kbit ceil ${CEIL}kbit tc class ${TCOP} dev ${IF} parent 1:1 classid 1:10 htb rate 64kbit ceil ${RATE}kbit prio 1 tc class ${TCOP} dev ${IF} parent 1:1 classid 1:20 htb rate 64kbit ceil ${RATE}kbit prio 2 tc class ${TCOP} dev ${IF} parent 1:20 classid 1:100 htb rate ${RATE}kbit tc class ${TCOP} dev ${IF} parent 1:20 classid 1:101 htb rate ${RATE}kbit tc class ${TCOP} dev ${IF} parent 1:20 classid 1:102 htb rate ${RATE}kbit tc qdisc ${TCOP} dev ${IF} parent 1:10 handle 10: pfifo tc qdisc ${TCOP} dev ${IF} parent 1:100 handle 100: sfq perturb 10 tc qdisc ${TCOP} dev ${IF} parent 1:101 handle 101: sfq perturb 10 tc qdisc ${TCOP} dev ${IF} parent 1:102 handle 102: sfq perturb 10 tc filter ${TCOP} dev ${IF} parent 1:0 protocol ip prio 1 handle 1 fw classid 1:10 tc filter ${TCOP} dev ${IF} parent 1:0 protocol ip prio 4 handle 4 fw classid 1:100 # IAX2 prio 0. iptables -t mangle ${IPTOP} PREROUTING -p udp -m udp --dport 4569 -j MARK --set-mark 0x1 iptables -t mangle ${IPTOP} PREROUTING -p udp -m udp --dport 4569 -j RETURN # everything else goes into lowest priority (best effort). iptables -t mangle ${IPTOP} PREROUTING -j MARK --set-mark 0x4 iptables -t mangle ${IPTOP} OUTPUT -j MARK --set-mark 0x4 Doug
Andrew Kohlsmith
2005-Apr-10 08:05 UTC
[Asterisk-Users] Can you comment on this Qos script? How does one shape RTP?
On April 10, 2005 04:47 am, cmisip wrote:> I got this from the voip wiki but the original script didn't seem to > work right so I fiddled with it a little bit. I am no expert so maybe > someone can look at it for errors. This is for my cable connection. So > far asterisk seems to use 1:10 while all other traffic uses 1:102. How > does one packet shape RTP?That looks like my rc.tc script. The most up to date version is at http://www.mixdown.ca/~andrew/dump/rc.tc. Please note that it only tries to make things happy for IAX2. It should be fairly easy to add RTP packet detection and to throw them into the same queue. -A.
Sean Kennedy
2005-Apr-11 07:08 UTC
[Asterisk-Users] Can you comment on this Qos script? How does one shape RTP?
Honestly, the best script I've ever found is the wondershaper script ( google it ). I tried the correct one posted in this thread, tried modifying it, but in the end I just used wondershaper. Does a great job. My only fear is it doesn't specifically target IAX2 traffic as high priority, but I can modify it later to do so if needed. On a 192 line I am able to get 4 ulaw ( IAX2 ) calls out with no noticable problems. Along with someone streaming a shoutcast station ( sigh ). The station broke up, but the calls didn't. cmisip wrote:>I got this from the voip wiki but the original script didn't seem to >work right so I fiddled with it a little bit. I am no expert so maybe >someone can look at it for errors. This is for my cable connection. So >far asterisk seems to use 1:10 while all other traffic uses 1:102. How >does one packet shape RTP? > >Thanks for any help. >