This forum has been archived. All content is frozen. Please use KDE Discuss instead.

DSCP

Tags: None
(comma "," separated)
Guffen
Registered Member
Posts
55
Karma
0

DSCP

Thu Dec 27, 2007 9:27 pm
I've read about DSCP on wikipedia (http://en.wikipedia.org/wiki/DSCP and http://en.wikipedia.org/wiki/DiffServ), and from what I can read, it tries to specify what kind of traffic IP-packages are carrying, and if it's high or low bandwidth, or if it needs low latency, etc.
But what is the best/proper value for torrent traffic? I assume it should be high bandwidth/traffic, and high latency.
George
Moderator
Posts
5421
Karma
1

Wed Jan 02, 2008 5:18 pm
Something like that, ideally you would just want your bittorrent traffic to not interfere with other traffic.
Guffen
Registered Member
Posts
55
Karma
0

Wed Jan 02, 2008 11:26 pm
You (or anyone else reading this) wouldn't happen to know which decimal value this would be? The wikipedia page is kind of incomplete, and I don't feel like digging through the RFC's now ;)
George
Moderator
Posts
5421
Karma
1

Sat Jan 05, 2008 2:17 pm
There isn't really a specific value for this, and your ISP and your router will probably ignore this field anyway.

However you can use it to setup local quality of service using the commandline tool tc. If your router allows this sort of advanced quality of service stuff, you can set it up there also.

With tc you can setup a bunch of htb queues on a network interface and then you can use the DSCP values set in KT to get your bittorrent traffic in the right queue. In such a situation the actual value doesn't matter all that much, you just pick one and use that for all bittorrent traffic.

You can find more information about tc and htb queues here :

http://luxik.cdi.cz/~devik/qos/htb/manual/userg.htm
Guffen
Registered Member
Posts
55
Karma
0

Sat Jan 05, 2008 4:10 pm
Thanks for that guide.
mocksoul
Registered Member
Posts
1
Karma
0

Fri Feb 08, 2008 4:42 pm
Note that you can only use DHCP+iptables+tc for outgoing packets. Usage example is fairly simple if you familiar with iptables packet mangling. For example, if you set DHCP for torrent packets to 30:

Code: Select all
PRIONONE=0
PRIONORM=1
PRIOTORRENT=2

iptables -t mangle -A OUTPUT -p tcp -o ppp0 -m dscp --dscp 30 -j CONNMARK --set-mark $PRIOTORRENT -m comment --comment "Mark outgoing ktorrent conns"
iptables -t mangle -A OUTPUT -p tcp -o ppp0 -m connmark --mark $PRIOTORRENT -j CONNMARK --restore-mark -m comment --comment "Copy connection mark to packet (OUT)"
iptables -t mangle -A INPUT -p tcp -i ppp0 -m connmark --mark $PRIOTORRENT -j CONNMARK --restore-mark -m comment --comment "Copy connection mark to packet (IN)"


This will mark all torrent packets except for connections maded by outside. To mark them too you must use marking by your torrent port (because all incoming connections will be maded to that port). If it is one of 6881-6889:

Code: Select all
iptables -t mangle -A INPUT -m mark --mark $PRIONONE -p tcp -i ppp0 --dport 6881:6889 -j MARK --set-mark $PRIOTORRENT


Note that we check only packets which are not marked already (PRIONONE). You can also set CONNMARK here and it will be copied to packet mark in rules above.

After that all packets related to torrent should be marked by PRIOTORRENT (2). After that you will need to add some queuing disciplines. This is a bit more difficult to understand.

Code: Select all
PRIONONE=0
PRIOTORRENT=2

IF=ppp0

MAXRATE=2560kbit # if you have 2.5mbit OUTGOING connection
RATETORRENT=256kbit # minimal rate for torrent traffic

# refer to tc manual for explantation
QUANTUM1=12187
QUANTUM2=8625

BURST=8k
CBURST=3k
TORRENTBURST=4k # max burst rate for torrent
TORRENTCBURST=2k

ifconfig $IF txqueuelen 16

# reset root qdisc
tc qdisc del dev $IF root handle 1:0 htb default 103 r2q 1
tc qdisc add dev $IF root handle 1:0 htb default 103 r2q 1

# set root class
tc class add dev $IF parent 1:0 classid 1:1 htb rate $MAXRATE burst $BURST cburst $CBURST

# subclasses for our traffic
tc class add dev $IF parent 1:1 classid 1:101 htb rate $MAXRATE ceil $MAXRATE quantum $QUANTUM1 burst $BURST cburst $CBURST prio $PRIONONE
tc class add dev $IF parent 1:1 classid 1:102 htb rate $RATETORRENT ceil $MAXRATE quantum $QUANTUM2 burst $TORRENTBURST cburst $TORRENTCBURST prio $PRIOTORRENT

# filter packets and forward to classes
tc qdisc add dev $IF parent 1:0 protocol ip prio $PRIONONE handle $PRIONONE fw classid 1:101
tc qdisc add dev $IF parent 1:0 protocol ip prio $PRIOTORRENT handle $PRIOTORRENT fw classid 1:102

# add queue disciplines
tc qdisc add dev $IF parent 1:101 sfq perturb 16 quantum $QUANTUM1
tc qdisc add dev $IF parent 1:102 sfq perturb 16 quantum $QUANTUM2


The result will be: torrent packets will take all available 2.5mbit connection untill any other packets will be scheduled to send. In that case - other packets will be send with 2.5mbit-256kbit rate and torrent packets - 256kbit.

This is extremely useful if you try to use torrent in dedicated server, because torrent traffic does not slowdown ssh connections to shell. I had tested this scheme (although really I have 6 traffic classifications on my server - in above example there are only two) - it's working perfectly.

CISCO station which can do that costs ~5000$ :).

To control incoming traffic you must have router and setup there same queue disciplines for OUTGOING traffic to your machine(s). For controlling local traffic you can also try to use ingress policing, but I dont recommend that:

Code: Select all
# reset
tc qdisc del dev $IF handle ffff: ingress
tc qdisc add dev $IF handle ffff: ingress

tc filter add dev $IF parent ffff: protocol ip prio $PRIONONE handle $PRIONONE fw police rate $MAXRATE burst $BURST drop flowid :1
tc filter add dev $IF parent ffff: protocol ip prio $PRIOTORRENT handle $PRIOTORRENT fw police rate $RATETORRENT burst $TORRENTBURST drop flowid :1


That will drop all packets which come faster than desired rate. And sender (hopefully) should slowdown. But in real world this work for several fast connections, but not for dozens with random speeds. That will drop a lot of packets (which anyway hurt your bandwidth) and speed will be less than possible max.

Have fun! :).


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]