Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Prioritization Traffic HTB+PRIO+TBF
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
jackal_br
n00b
n00b


Joined: 31 Mar 2004
Posts: 18

PostPosted: Thu Nov 03, 2005 1:29 am    Post subject: Prioritization Traffic HTB+PRIO+TBF Reply with quote

After having read about QOS and htb, I'm trying to build a script wich uses the PRIO with htb.
My problem is that my uploads is killing my downloads and web browsing freezes constantly while using bittorrent.
So I thought to implement a queue with gives low priority to p2p traffic.
This is my network topology:

Internet <--> cable modem <--> eth0 <--> linux gateway <--> eth1

and the script that I builded, based here http://www.voip-info.org/wiki/view/QoS+with+Linux+using+PRIO+and+HTB

Code:

#!/bin/bash
TC=/sbin/tc
IPTABLES="/sbin/iptables"
DOWNLINK="270"
UPLINK="220"
DEV="eth0"
RATE=270
CEIL=250

if [ "$1" = "status" ]
then
       $TC -s qdisc ls dev $DEV
       $TC -s class ls dev $DEV
       exit
fi


# 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

if [ "$1" = "stop" ]
then
        exit
fi

###### uplink

$TC qdisc add dev ${DEV} root handle 1: tbf rate ${UPLINK}kbit latency 50ms burst 1540
$TC qdisc add dev ${DEV} parent 1: handle 10: prio
$TC qdisc add dev ${DEV} parent 10:1 handle 100: pfifo
$TC qdisc add dev ${DEV} parent 10:2 handle 200: htb
$TC qdisc add dev ${DEV} parent 10:3 handle 300: sfq perturb 10

$TC class add dev ${DEV} parent 200: classid 200:1 htb rate ${UPLINK}kbit

$TC class add dev ${DEV} parent 200:1 classid 200:10 htb rate $[25*$UPLINK/100]kbit ceil ${CEIL}kbit prio 1
$TC class add dev ${DEV} parent 200:1 classid 200:20 htb rate $[30*$UPLINK/100]kbit ceil ${CEIL}kbit prio 2
$TC class add dev ${DEV} parent 200:1 classid 200:30 htb rate $[25*$UPLINK/100]kbit ceil ${CEIL}kbit prio 3
$TC class add dev ${DEV} parent 200:1 classid 200:40 htb rate $[20*$UPLINK/100]kbit ceil ${CEIL}kbit prio 4

$TC qdisc add dev ${DEV} parent 200:10 handle 2001: sfq perturb 10
$TC qdisc add dev ${DEV} parent 200:20 handle 2002: sfq perturb 10
$TC qdisc add dev ${DEV} parent 200:30 handle 2003: sfq perturb 10
$TC qdisc add dev ${DEV} parent 200:40 handle 2004: sfq perturb 10

# Band 1
#
# To speed up downloads while an upload is going on, put ACK packets in
# the interactive band:
$TC filter add dev ${DEV} parent 10:0 protocol ip prio 2 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 10:1

# VoIP traffic always get first in line (my ATA tags them with TOS 0x68 or 0xb8)
#$TC filter add dev ${DEV} parent 10:0 prio 3 protocol ip u32 \
#      match ip tos 0x68 0xff \
#      flowid 10:1

#$TC filter add dev ${DEV} parent 10:0 prio 4 protocol ip u32 \
#     match ip tos 0xb8 0xff \
#     flowid 10:1

# Band 3
#
# p2p
#$TC filter add dev ${DEV} parent 10:0 protocol ip prio 2 handle 1 fw \
#    classid 10:3

#Band 2
#
# All non urgent traffic on band 2
$TC filter add dev ${DEV} parent 10:0 protocol ip prio 3 u32 \
    match ip src 0.0.0.0/0 \
    flowid 10:2

# TOS Minimum Delay
$TC filter add dev ${DEV} parent 200: protocol ip prio 10 u32 \
    match ip tos 0x10 0xff \
    flowid 200:10

# ICMP (ip protocol 1) in the interactive class
$TC filter add dev ${DEV} parent 200: protocol ip prio 11 u32 \
    match ip protocol 1 0xff \
    flowid 200:10

# dns
$TC filter add dev ${DEV} parent 200: protocol ip prio 12 u32 \
    match ip sport 53 0xffff \
    flowid 200:10

# ssh
$TC filter add dev ${DEV} parent 200: protocol ip prio 13 u32 \
       match ip sport 22 0xffff \
       flowid 200:10

# vnc
$TC filter add dev ${DEV} parent 200: protocol ip prio 20 u32
       match ip sport 5900 0xffff \
       flowid 200:20

# http
$TC filter add dev ${DEV} parent 200: protocol ip prio 30 u32
       match ip sport 80 0xffff \
       flowid 200:30

# rest is 'non-interactive' ie 'bulk' and ends up in the default queue
$TC filter add dev ${DEV} parent 200: protocol ip prio 40 u32 \
       match ip src 0.0.0.0/0 \
       flowid 200:40


Is not working as planned. The p2p uploads keeps high. Why interactive traffic isn't gets sent first ?
It seems that PRIO is not working, or the queue is get empty to fast.

I don't know if I got the wrong ideia about the filters.

Any help I would appreciate.
Back to top
View user's profile Send private message
jackal_br
n00b
n00b


Joined: 31 Mar 2004
Posts: 18

PostPosted: Thu Nov 03, 2005 1:41 am    Post subject: Reply with quote

this part of the code I comment for some tests but I'm using it uncomment together whith iptables MARKS that seem to be putting the packets in the right band (10:3).
but prio doesn't makes its job.

Code:

# p2p
#$TC filter add dev ${DEV} parent 10:0 protocol ip prio 2 handle 1 fw \
#    classid 10:3


Any body?
Back to top
View user's profile Send private message
jackal_br
n00b
n00b


Joined: 31 Mar 2004
Posts: 18

PostPosted: Sat Nov 05, 2005 5:56 pm    Post subject: Reply with quote

I made some tests here with a more simple version:
Code:

#  clean eth0
tc qdisc del dev eth0 root

tc qdisc add dev eth0 root handle 1: tbf rate 160kbit latency 50ms burst 1540
tc qdisc add dev eth0 parent 1: handle 10: prio
tc qdisc add dev eth0 parent 10:1 handle 100: pfifo
tc qdisc add dev eth0 parent 10:2 handle 200: htb
tc qdisc add dev eth0 parent 10:3 handle 300: sfq

tc class add dev eth0 parent 200: classid 200:1 htb rate 160kbit

# p2p
tc filter add dev eth0 parent 10: protocol ip prio 2 handle 1 fw classid 10:3

tc filter add dev eth0 parent 10: protocol ip prio 3 u32 match ip src 0.0.0.0/0 flowid 10:2


This works great. P2P traffic comes close to zero when upload a file with ftp. (exactly what I want)
But when I add a new filter to use the 200:1 class, like this:
Code:

tc filter add dev eth0 parent 200: protocol ip prio 20 u32 match ip src 0.0.0.0/0 flowid 200:1

the packages really goes to 200:1 as Its shows here:

# tc -s class ls dev eth0
.
.
.
class htb 200:1 root prio 0 rate 160000bit ceil 160000bit burst 1679b cburst 1679b
Sent 2306549 bytes 2176 pkt (dropped 0, overlimits 0 requeues 0)
rate 160520bit 19pps backlog 0b 66p requeues 0
lended: 4049 borrowed: 0 giants: 0
tokens: -149053 ctokens: -149053

but now, prioritization traffic does not woks anymore, band 10:2 does not gets more priority than 10:3.
I don't know if I'm being clearly.
Htb can be a class of prio or just the opposite ?
Please somebody help me.
Back to top
View user's profile Send private message
Moloch
Apprentice
Apprentice


Joined: 17 Mar 2003
Posts: 293
Location: Albuquerque, NM, US

PostPosted: Wed Jan 04, 2006 11:24 pm    Post subject: Reply with quote

I have the exact same issues. I've hacked away at my own script so much it just became a mess. So I really have nothing to show for. Lately I've been using the tc settings that come bundled with shorewall 3.x, but there is no improvement. I really just want a straight priority setup. Where anything with a lower priority can be starved by traffic with a higher priority. It seems qos is more designed to give every queue a chance even with a lower priority. When I give the lower quality queues a guaranteed rate of something like 2k but the ceil rather high. It doesn't seem to cut it off properly at the guaranteed rate.

My next step is to see if I can get better results by tweaking cbq. Not sure when I'll get a chance though.
_________________
Understanding is a three-edged sword: your side, their side, and the truth. --Kosh
1010011010
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum