LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-19-2009, 02:32 PM   #1
sdct989
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
Why tc doesn't shape bandwidth generated by the local machine


I make use of a lot of torrent traffic on my network, and so about a year ago I started using tc htb queuing in conjunction with iptables to give priority to non-torrent traffic. The setup that I use to configure tc is as follows:
Code:
tc qdisc add dev eth0 root handle 1: htb default 60
tc class add dev eth0 parent 1: classid 1:1 htb rate 1850kbit

#Setup classes
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 500kbit ceil 1850kbit prio 0
tc class add dev eth0 parent 1:1 classid 1:20 htb rate 500kbit ceil 1850kbit prio 1
tc class add dev eth0 parent 1:1 classid 1:30 htb rate 500kbit ceil 1850kbit prio 2
tc class add dev eth0 parent 1:1 classid 1:40 htb rate 500kbit ceil 1850kbit prio 3
tc class add dev eth0 parent 1:1 classid 1:50 htb rate 500kbit ceil 1850kbit prio 4
tc class add dev eth0 parent 1:1 classid 1:60 htb rate 320kbit ceil 1850kbit prio 5
As I understand it, it sets up a bunch of classes with different priority levels, and then defaults into a class with the least priority. Then in my iptables script I go through and essentially "white list" traffic that I want given a higher priority. I found this more effective than trying to classify the torrent traffic itself because it jumps across all sorts of ports and destination hosts. I am classifying the good traffic as follows:
Code:
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --syn -m length --length 40:68 -j CLASSIFY  --set-class 1:10
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --tcp-flags ALL SYN,ACK -m length --length 40:68  -j CLASSIFY --set-class 1:10
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --tcp-flags ALL ACK -m length --length 40:100  -j CLASSIFY --set-class 1:10
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --tcp-flags ALL RST -j CLASSIFY --set-class 1:10
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --tcp-flags ALL ACK,RST -j CLASSIFY --set-class 1:10
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --tcp-flags ALL ACK,FIN -j CLASSIFY  --set-class 1:10

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --dport 22 -j CLASSIFY --set-class 1:20
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --sport 22 -j CLASSIFY --set-class 1:20
...
This has been extremely effective. I can let torrents run, do a bandwidth speed test and watch it drop down the torrent traffic to almost nothing, while giving me almost my exact bandwidth allocation reading on the successful speed test.

Where I run into problems is that recently I tried to move my torrent client to my router/gateway/firewall and run it from there. Even though the traffic is still exiting out of my internet interface (eth0) and to my understanding still traversing the POSTROUTING chain (as well as the OUTPUT chain) tc doesn't seem to be touching it. Why does all of the torrent traffic generated locally not get defaulted into the 1:60 class like all of the torrent traffic from the LAN? Let me know if there is any more information I can post. I really appreciate your help, this problem is driving me nuts.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Monitor your Linux computer with machine-generated music LXer Syndicated Linux News 0 11-16-2006 05:21 AM
using cbq.init to shape bandwidth? shrike_912 Linux - Software 1 10-31-2004 11:24 AM
HTB: how to shape the bandwidth the router may consume? meks Linux - Networking 1 04-30-2004 03:42 PM
Hide local functions within a library generated by 'ar' relzok Linux - Newbie 0 03-31-2004 03:51 PM
Redhat 9: Where find errors generated from rc.local ? speedgelb Linux - General 4 01-30-2004 07:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration