LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 09-16-2006, 07:15 PM   #1
large_satchell
LQ Newbie
 
Registered: Jul 2006
Posts: 17

Rep: Reputation: 0
bandwidth throttling??


I cannot find a working way to throttle my bandwidth in linux. In windoze I use NetLimiter Pro and it works like a charm. The problem is, the software I use to download stuff (lots o stuff ) will just download at a steady 5 Mb/s maxing out my entire connection. I want to set it at 300k/s (2.5 Mb/s).

So far I have tried cbq.init. It's complicated as heck, and doesnt work for me as far as I can tell. Even after I recompiled my kernel with all the packet queing stuff it still doesnt work.

Is there a way to do this with netfilter/iptables?

It's the INCOMING bandwidth I want to limit, not the outgoing. And my PC does not route packets, its just a standalone FC5 box.

Last edited by large_satchell; 09-16-2006 at 07:17 PM.
 
Old 09-16-2006, 08:01 PM   #2
nuxrl
Member
 
Registered: Jun 2006
Location: NY, USA
Distribution: Slackware, Arch
Posts: 176

Rep: Reputation: 35
Check "tc" to see if it's what you need.
 
Old 09-16-2006, 09:47 PM   #3
large_satchell
LQ Newbie
 
Registered: Jul 2006
Posts: 17

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nuxrl
Check "tc" to see if it's what you need.
Too effing complicated. I just want to limit incoming bandwidth to 300k/s, not setup all sorts of packet classes, QoS, etc, etc, etc...
 
Old 09-17-2006, 03:42 AM   #4
large_satchell
LQ Newbie
 
Registered: Jul 2006
Posts: 17

Original Poster
Rep: Reputation: 0
yeah, im so l33t i solved my own problem:

Code:
#!/bin/bash 

#in Kbits/sec
DONLOADLIMIT=4000
DEV=eth0

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

if [ "$1" = "stop" ]
then
	tc qdisc del dev $DEV root    2> /dev/null > /dev/null
	tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null
	exit
fi

# clean existing filter
tc qdisc del dev $DEV root    2> /dev/null > /dev/null
tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null

########## downlink #############
# attach ingress policer:

tc qdisc add dev $DEV handle ffff: ingress

# filter *everything* to it (0.0.0.0/0), drop everything that's
# coming in too fast:

tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match ip src \
   0.0.0.0/0 match ip sport 0x0077 0xffff  police rate ${DONLOADLIMIT}kbit burst 10k drop flowid :1
(remove the 'match ip sport 0x0077 0xffff' to limit all traffic, instead of just port 119.)
 
Old 09-17-2006, 04:22 PM   #5
large_satchell
LQ Newbie
 
Registered: Jul 2006
Posts: 17

Original Poster
Rep: Reputation: 0
Damn, the script i posted works, but it basically just drops the incoming packets until the rate is correct. Is there a better way to throttle INCOMING data (without dropping tons of packets) ?
 
Old 09-18-2006, 10:51 AM   #6
andrewdodsworth
Member
 
Registered: Oct 2003
Location: United Kingdom
Distribution: SuSE 10.0 - 11.4
Posts: 347

Rep: Reputation: 30
Although this method does drop packets they're only in respect of your download - if you set your limit to 50% of your maximum download bandwidth the unused bit will get used by other people. However, although I had limited success with this sort of stuff the problem is that you need to set the limit bandwidth below the available bandwidth of your download supplier. As that can vary according to the number of users downloading, time of day etc. you either need to set the limit very small or be prepared to adjust it. I have a similar script to yours which I call passing a max bandwidth parameter.

I must say that in the end I couldn't be bothered as the aggro from other users when they got lag and trying to download 5 CD's of the latest SuSE linux at 100K (rather than 6M) was too painful. I therefore pinch all the bandwidth overnight when I need to do a big download!
 
Old 09-20-2006, 02:41 AM   #7
large_satchell
LQ Newbie
 
Registered: Jul 2006
Posts: 17

Original Poster
Rep: Reputation: 0
my download supplier is giganews, and believe me, they can send the data waaaaaaaay faster than you can recieve it. They easily max out my 10Mbps link (about 1200-1300 kBps). I wanted to limit that down to about 350kBps.

I would assume that if I start dropping packets [which is what the ingress policer does], then giganews would throttle down their sending rate until it eventually levels off at 350kBps, but they dont seem to. The rate at which packets are dropped remains constant (and I expected the rate of packet droppage to decrease).

My question is, if giganews is sending me data as fast as possible, and my compter is just dropping packets until the receive rate is 350kBps, isnt that HIGHLY inefficient?

Is there a better way to limit incoming bandwidth??????

???????????????????????????????????

Last edited by large_satchell; 09-20-2006 at 02:43 AM.
 
Old 09-20-2006, 12:35 PM   #8
andrewdodsworth
Member
 
Registered: Oct 2003
Location: United Kingdom
Distribution: SuSE 10.0 - 11.4
Posts: 347

Rep: Reputation: 30
Although it does seem very inefficient if it lets you do multiple downloads without affecting other internet activity and games then it's better than nothing at all. I'll have another go using it myself to see how effective it really is.

Here's a useful link:

http://www.tldp.org/HOWTO/ADSL-Bandw...agement-HOWTO/
 
Old 09-21-2006, 12:51 AM   #9
large_satchell
LQ Newbie
 
Registered: Jul 2006
Posts: 17

Original Poster
Rep: Reputation: 0
yeah, they said what i said:

Quote:
3.5.1. Why Inbound Traffic Limiting isn't all That Good

We want to limit our inbound traffic to avoid filling up the queue at the ISP, which can sometimes buffer as much as 5 seconds worth of data. The problem is that currently the only way to limit inbound TCP traffic is to drop perfectly good packets. These packets have already taking up some share of bandwidth on the ADSL modem only to be dropped by the Linux box in an effort to slow down future packets. These dropped packets will eventually be retransmitted consuming more bandwidth. When we limit traffic, we are limiting the rate of packets which we will accept into our network. Since the actual inbound data rate is somewhere above this because of the packets we drop, we'll actually have to limit our downstream to much lower than the actual rate of the ADSL modem in order to assure low latency. In practice I had to limit my 1.5mbit/s downstream ADSL to 700kbit/sec in order to keep the latency acceptable with 5 concurrent downloads. The more TCP sessions you have, the more bandwidth you'll waste with dropped packets, and the lower you'll have to set your limit rate.

A much better way to control inbound TCP traffic would be TCP window manipulation, but as of this writing there exists no (free) implementation of it for Linux (that I know of...).
however, my script does do a good job, and allows other users to download just fine while i'm downloading too.
 
Old 09-21-2006, 03:04 PM   #10
andrewdodsworth
Member
 
Registered: Oct 2003
Location: United Kingdom
Distribution: SuSE 10.0 - 11.4
Posts: 347

Rep: Reputation: 30
Well tried it again using half available bandwidth as maximum download bandwidth. Appeared to work for a while but then hit same issue with latency increasing to the point that even web browsing stopped working until I paused the download, so need to look further to see what's causing that. Working on self-adjusting script that monitors latency and adjusts download limit dynamically.
 
Old 09-22-2006, 02:54 AM   #11
large_satchell
LQ Newbie
 
Registered: Jul 2006
Posts: 17

Original Poster
Rep: Reputation: 0
The script I posted works flawlessly. I can set it at anything from 50kbps all the way up to 90% of my bandwidth: 4500kbps, and it works perfectly. Of course, my script only throttles incoming data from port 119, because I do all my downloading from usenet.
 
  


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
Bandwidth throttling joeljkp Linux - Networking 4 07-28-2005 01:59 PM
bandwidth throttling greenmeanie Debian 1 07-10-2005 10:06 PM
Bandwidth Throttling... dolvmin Linux - Networking 3 09-21-2004 09:56 AM
Bandwidth Throttling chasingmytail Slackware 6 06-30-2004 11:38 AM
Bandwidth Throttling bg_27 *BSD 3 07-22-2003 09:09 PM


All times are GMT -5. The time now is 09:15 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration