LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 05-17-2010, 03:04 AM   #1
ShadowBlade72
LQ Newbie
 
Registered: May 2010
Posts: 4

Rep: Reputation: 0
Help with TC


I've searched through the forums and found a few threads that kind of helped, but I'm still pretty lost when it comes to TC. I was wondering if anyone could help me out with what I'm trying to do and also break it down and explain what each part of the command does so that I can learn along the way.

What I'm trying to do is limit any connection from source port 6001 to 30KB/s.

I'm currently running a game server and it has no built in bandwidth limiting feature, which means if someone logs in and needs to download the map it destroys my bandwidth for the rest of the servers players. The game server is running on port 6001.

If someone could help me with this, it would be greatly appreciated.
 
Old 05-17-2010, 07:01 AM   #2
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
Try this:
Code:
/sbin/tc qdisc add dev eth0 root handle 1:0 htb default 10
/sbin/tc class add dev eth0 parent 1:0 classid 1:10 htb rate 30kbps ceil 10kbps prio 0
/sbin/tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10
/sbin/iptables -A OUTPUT -t mangle -p tcp --sport 6001 -j MARK --set-mark 10
Please let us know how it goes.

Last edited by SuperJediWombat!; 05-17-2010 at 07:17 AM.
 
Old 05-17-2010, 08:00 AM   #3
ShadowBlade72
LQ Newbie
 
Registered: May 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by SuperJediWombat! View Post
Try this:
Code:
/sbin/tc qdisc add dev eth0 root handle 1:0 htb default 10
/sbin/tc class add dev eth0 parent 1:0 classid 1:10 htb rate 30kbps ceil 10kbps prio 0
/sbin/tc filter add dev eth0 parent 1:0 prio 0 protocol ip handle 10 fw flowid 1:10
/sbin/iptables -A OUTPUT -t mangle -p tcp --sport 6001 -j MARK --set-mark 10
Please let us know how it goes.
Well it worked kind of. It limited all traffic to 10kbps though. I changed ceil 10kbps to ceil 30kbps and it limited all traffic to 30kbps.

I'm guessing it's because the "htb default 10" which tells it to send all unclassified traffic to class 10, which is the classid that is limiting it to 30kbps right?

Edit:
Okay, so I think I fixed my problem by just leaving out the default statement in the first command. Now it only applies the rule to port 6001. Thanks for your help! It seems to be working perfectly!

Could you explain to me what the third line does though. What exactly does the filter line do? Is it just telling it to search through traffic that has the mangle 10 put into the header and apply the rule with flowid 1:10 to it?

Last edited by ShadowBlade72; 05-17-2010 at 03:31 PM.
 
Old 05-17-2010, 03:32 PM   #4
ShadowBlade72
LQ Newbie
 
Registered: May 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ShadowBlade72 View Post
Well it worked kind of. It limited all traffic to 10kbps though. I changed ceil 10kbps to ceil 30kbps and it limited all traffic to 30kbps.

I'm guessing it's because the "htb default 10" which tells it to send all unclassified traffic to class 10, which is the classid that is limiting it to 30kbps right?

Edit:
Okay, so I think I fixed my problem by just leaving out the default statement in the first command. Now it only applies the rule to port 6001. Thanks for your help! It seems to be working perfectly!

Could you explain to me what the third line does though. What exactly does the filter line do? Is it just telling it to search through traffic that has the mangle 10 put into the header and apply the rule with flowid 1:10 to it?
Another Edit: Okay, well it was limiting everyone to a max of 30kbps which made the server lag all to hell for anyone connected. I changed it to rate 30kbps and ceil of 4mbps. I'm hoping this will resolve the issue, but only time will tell.

If anyone could tell me if that is the issue? I want to limit each connection to 30kbps, but allow up to 4mbps (which is my upload max speed).

What I mean:
192.168.1.10:6001 --> 30kbps
192.168.1.11:6001 --> 30kbps
192.168.1.12:6001 --> 30kbps

etc. I just used private IP's as an example to try and show what I meant.

Edit:
Okay, I don't think it's working how I'm trying to get it to work. If anyone could look it over and help me out it would be appreciated.

Last edited by ShadowBlade72; 05-17-2010 at 05:40 PM.
 
Old 05-17-2010, 06:34 PM   #5
SuperJediWombat!
Member
 
Registered: Apr 2009
Location: Perth, Australia
Distribution: Ubuntu/CentOS
Posts: 208

Rep: Reputation: 51
Oh, sorry I misunderstood. Using the htb class above it will shape all traffic from port 6001. You need to look up tbf (token bucket filter) and use that instead, I think that tc-tbf is per connection.

If you have any success, please post the final rules.
 
Old 05-17-2010, 08:53 PM   #6
ShadowBlade72
LQ Newbie
 
Registered: May 2010
Posts: 4

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by SuperJediWombat! View Post
Oh, sorry I misunderstood. Using the htb class above it will shape all traffic from port 6001. You need to look up tbf (token bucket filter) and use that instead, I think that tc-tbf is per connection.

If you have any success, please post the final rules.
Yeah I didn't really explain it well in my first post. I'll let you know if I figure anything out. Thanks for your help so far.
 
Old 05-20-2010, 03:11 PM   #7
alexxxutz
LQ Newbie
 
Registered: Mar 2009
Posts: 19

Rep: Reputation: 0
Any solution? I am looking for that too...
 
  


Reply



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



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

All times are GMT -5. The time now is 11:19 PM.

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