LinuxQuestions.org
Visit Jeremy's Blog.
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 04-22-2013, 11:25 PM   #1
psycroptic
Member
 
Registered: Aug 2011
Location: USA
Distribution: ArchLinux - 3.0 kernel
Posts: 348

Rep: Reputation: Disabled
using tc with htb to limit speed - speeds not exact


so i have a simple startup script which uses tc and iptables to limit maximum bandwidth usage of certain adresses/subnets. here it is:

Code:
tc qdisc add dev internal root handle 1: htb default 1
tc class add dev internal parent 1: classid 1:1 htb rate 51.03mbit ceil 51.03mbit
tc class add dev internal parent 1: classid 1:2 htb rate 32.5mbit ceil 32.5mbit

tc qdisc add dev external root handle 1: htb default 1
tc class add dev external parent 1: classid 1:2 htb rate 4.15mbit ceil 4.15mbit

tc qdisc add dev wifi root handle 1: htb default 1
tc class add dev wifi parent 1: classid 1:2 htb rate 20.51mbit ceil 20.51mbit



iptables -t mangle -A POSTROUTING -o internal -d 172.16.16.15 -j CLASSIFY --set-class 1:2
iptables -t mangle -A POSTROUTING -o external -s 172.16.16.15 -j CLASSIFY --set-class 1:2
iptables -t mangle -A POSTROUTING -o external -s 192.168.192.0/24 -j CLASSIFY --set-class 1:2
iptables -t mangle -A POSTROUTING -o wifi -d 192.168.192.0/24 -j CLASSIFY --set-class 1:2
the original idea is this. I have a 50mbps down/10mbps up comcast cable internet connection, and this is the linux router PC; it has 3 ethernet connections. dev "external" is the interface connected w/static ip to the cable modem, "internal" is my personal internal LAN carrying the bulk of the internet traffic, and a public "wifi" interface which is a separate network intended for public wifi usage.

my intention is to limit all uploads to exactly 10mbps, downloads on the internal LAN to exactly 50mbps, to set the public wifi to a max of 20mbps download, to set my roomates connection (statically set to 172.16.16.15) to a max of 30mbps download, and to set both my roomate and the public wifi to 4mbps upload to internet.

however, using the htb "rate" and "ceil" options set to these exact numbers yielded lower than expected numbers on measured traffic (for example, limiting all internal downloads to "rate 50mbps ceil 50mbps" had an actual transfer measure of around 48mbps), so as you can see, i have had to tweak the numbers to be slightly higher than the ideal values i'm aiming for.

so is this normal? or am i missing something, and to get exact htb values you have to do something else?
 
Old 04-23-2013, 03:16 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,727

Rep: Reputation: 143Reputation: 143
How do you measure transfer rate? Do you know the tool you use measure on layer 2 or 3 rate. They are a little different.
 
Old 04-23-2013, 09:21 PM   #3
psycroptic
Member
 
Registered: Aug 2011
Location: USA
Distribution: ArchLinux - 3.0 kernel
Posts: 348

Original Poster
Rep: Reputation: Disabled
right now i'm using wget...
 
Old 04-24-2013, 03:23 PM   #4
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,727

Rep: Reputation: 143Reputation: 143
My guess, wget measure L4 speed. So 48mbps against 50mbps is normal.
 
Old 04-24-2013, 07:10 PM   #5
psycroptic
Member
 
Registered: Aug 2011
Location: USA
Distribution: ArchLinux - 3.0 kernel
Posts: 348

Original Poster
Rep: Reputation: Disabled
interesting. thanks for the info.
 
  


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
Speed limit Itaaki Linux - Networking 2 01-21-2011 05:51 AM
Limit speed X.Cyclop Linux - Wireless Networking 3 12-18-2010 01:56 PM
limit bandwidth rate for scp using tc htb Linux abhelp Linux - Networking 9 08-20-2010 10:45 AM
HTB Problem - bandwidth limit Bart007 Linux - Networking 4 08-15-2006 08:17 AM
HTB as a child of another HTB - doesn't work ddaas Linux - Networking 5 07-25-2005 04:21 AM

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

All times are GMT -5. The time now is 07:11 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration