LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-08-2008, 08:26 PM   #1
niels.horn
Senior Member
 
Registered: Mar 2007
Location: Rio de Janeiro - Brazil
Distribution: Slackware64-current
Posts: 1,004

Rep: Reputation: 91
Lightbulb Bandwidth limiting / Traffic Shaping with Slackware 12.1 and CBQ


Hi to all,

I was having a problem on my network at home, where I have the following setup:
1) My desktop (Slackware 12.1) which is also sort of a file server
2) My wife's desktop (Slackware 12.0) with a large number of documents
3) My notebook from my job (Windows XP, but with Cygwin) with a huge amount of files I cannot afford to lose.
4) My two kids' desktops with some files

I have several scripts running to synchronize directories with rsync so that each important file is saved on at least two computers.
Example: my wife's computers has a script in cron that syncs her files to my desktop (almost always on-line), etc...

The problem: sometimes there is a lot to synchronize and then my network gets clogged and I cannot access anything else (like browsing the internet).
With rsync I could limit the use of bandwith with the --bwlimit option, but then if two computers are syncing at the same time, it still gets clogged.

So I started looking for a better solution, trying to do some "traffic-shaping". The solution was using "cbq", which is included with Slackware. Since it was a bit of a hassle to get it working, I decided to write a little HOW-TO here:

1) Setting up cbq
cbq is a script that is included with iproute2.
We have to copy it to /sbin and make it executable:
Code:
cp /usr/doc/iproute2-2.6.16-060323/examples/cbq.init-v0.7.3 /sbin/cbq
chmod +x /sbin/cbq
cbq expects its configuration files in /etc/sysconfig/cbq
If this directory doesn't exist, create it:
Code:
mkdir /etc/sysconfig/cbq
2) Creating the rules-file
cbq reads files in /etc/sysconfig/cbq with the following names:
cbq-nnnn.yyy where:
  • nnnn: is a hexadecimal number from 0002 to ffff
  • yyy: is the name of your network interface, like eth0, eth1, etc
In my case, the network interface for my local network is eth1, so I created "cbq-0002.eth1"
Here is the contents of my file:
Code:
DEVICE=eth1,100Mbit,10Mbit
RATE=5000Kbit
WEIGHT=500Kbit
PRIO=5
RULE=192.168.1.110:873,192.168.1.0/24
BOUNDED=no
ISOLATED=no
Some explanations:
  • DEVICE: the interface you want to limit, with its real speed and its weight (1/10 of the max. speed)
  • RATE: the bandwith you want to offer for this particular application / port / address
  • WEIGHT: 1/10 of the RATE
  • PRIO: Priority setting. 5 is default
  • RULE: source,destination --> in my case 192.168.1.110 is my desktop, 873 is the port rsync uses
  • BOUNDED: Default no, used if you have other filters
  • ISOLATED: 'no' means that the rate can be used by other traffic if not in use

3) Starting the bandwith-limiting
Use cbq compile to prepare the new filters or after you alter your cbq-nnnn.yyy files.
Then use cbq start to start your traffic-shaping!
To always start cbq, include it in your rc.local script.

You can monitor your results with iptraf

More information can be found using "man tc-cbq".
 
Old 08-09-2008, 03:42 AM   #2
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Nice piece of information that goes beyond the all-day stories, Niels. I learnt something new ;-)

Eric
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Traffic shaping (limiting outgoing bandwidth of all TCP-traffic except FTP/HTTP) ffkodd Linux - Networking 3 10-25-2008 12:09 AM
cbq traffic shaping edgjerp Linux - Networking 1 10-16-2007 05:06 AM
Bandwidth Shaping using CBQ sussane Linux - Networking 0 08-01-2007 05:40 AM
Bandwidth Limiting Using CBQ..problem :( hasnain Linux - Networking 1 03-04-2006 02:17 PM
Bandwidth limiting using cbq - UL only barlent Linux - Networking 0 04-30-2003 12:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 03:15 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