LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-03-2007, 06:44 AM   #1
netguy2000
Member
 
Registered: Oct 2003
Location: Karachi, PAKISTAN
Distribution: Redhat, Fedora, Open BSD, FreeBSD, SlackWare
Posts: 109

Rep: Reputation: 15
Exclamation Traffic Shaping


Hi all,
After setup of 2 DSL routes ( http://www.linuxquestions.org/questi...d.php?t=580679 )
no I want to configure traffic shping on my LAN side interface so I can setup download and upload traffic for every LAN user IP.
I tried tc command but its toooo difficult and I am unable to understand its all features. please help me if you know any easiest script or web base software for the same need.
I also tried EasyShaper but I received errors in my httpd/error_log file,
( PHP Notice: Undifiend variable: sel64kbit in /var/www/html/easyshape/config.php on line 142 )
and same error for sel128kbit
.
.
.
rm: cannot remove /etc/htb/eth1" no such file or directory
sh: line 1: /usr/local/bin/htb.init-v0.8.5 Permission denied.

Please help me what to do and where to go.

Lots of thanks on every help you support.
 
Old 05-13-2009, 07:48 AM   #2
netguy2000
Member
 
Registered: Oct 2003
Location: Karachi, PAKISTAN
Distribution: Redhat, Fedora, Open BSD, FreeBSD, SlackWare
Posts: 109

Original Poster
Rep: Reputation: 15
Lightbulb

Yoooooo I got the solution,

here is my configuration hope this will work for others too....

In this guide we use multiple routes with traffic shaping, by this we will able to route our desire bandwidth traffic towards our favorite route/ ISP.

In my scenario I have 2 Internet connections from 2 different ISP’s, first Internet connection is of 1 MB and second is of 512kbps. Now I am shaping traffic towards and from these connections with the help of Multi Routing.

Some words before stating:
Handling a link with a known bandwidth
HTB is an ideal qdisc to use on a link with a known bandwidth, because the innermost (root-most) class can be set to the maximum bandwidth available on a given link. Flows can be further subdivided into children classes, allowing either guaranteed bandwidth to particular classes of traffic or allowing preference to specific kinds of traffic.

First we shape traffic:

First we define root Classful Queuing disciplines.

Some words about Classful Queuing:
Classful Queuing Disciplines (qdiscs)
The flexibility and control of Linux traffic control can be unleashed through the agency of the classful qdiscs. Remember that the classful queuing disciplines can have filters attached to them, allowing packets to be directed to particular classes and subqueues.

root@tcrouter:~# tc qdisc add dev eth1 root handle 1:0 htb default 12

Now its time to define “classes” for your “root classful queuing disciplines”. The classful qdiscs can contain classes, and provide a handle to which to attach filters/ sub classes.

root@tcrouter:~# tc class add dev eth1 parent 1:0 classid 1:1 htb rate 819200kbit ceil 819200kbit burst 819200kbit cburst 819200kbit

*(819200kbit = 100 MB)

Next we configure child / sub classes, although this will usually consume cycles and other system resources for no benefit, but good to shape traffic with more efficient way, and facilitates tremendously complex traffic control scenarios. Here we‘ll be limiting the speed of traffic

We can shape traffic in multi ways, with burst or without burst.

Below are sub/ child class example without burst.
root@tcrouter:~# tc class add dev eth1 parent 1:1 classid 1:11 htb rate 512kbit ceil 512kbit
root@tcrouter:~# tc class add dev eth1 parent 1:1 classid 1:12 htb rate 512kbit ceil 512kbit
root@tcrouter:~# tc class add dev eth1 parent 1:1 classid 1:13 htb rate 512kbit ceil 512kbit

Below sub / child class shape traffic with more efficient way and here we define burst and cburst of rate and ceil. This means, when traffic starts transfer through this class it start from burst and shoot to 200kbit then comes normal to 100kbit slowly.

root@tcrouter:~# tc class add dev eth1 parent 1:1 classid 1:14 htb rate 100kbit ceil 100kbit burst 200kbit cburst 200kbit

It’s your choice either you want to configure your sub / child class with burst or not, or you can use both.

Next, its time to configure “filter”:
The filter is the most complex component in the Linux traffic control system. The filter provides a convenient mechanism for gluing together several of the key elements of traffic control. The simplest and most obvious role of the filter is to classify packets.

root@tcrouter:~# tc filter add dev eth1 parent 1:0 prio 0 protocol ip handle 1 fw flowid 1:14

OR you can use tc filter with priority set
e.g.
tc filter add dev eth1 parent 2:0 prio 0 protocol ip handle 101 fw flowid 2:11

root@tcrouter:~# iptables -I POSTROUTING -t mangle -o eth1 -p tcp -s! 192.168.0.0/16 -d 192.168.0.157 -j MARK --set-mark 1

Here comes a send most important step, to route this shaped traffic through our favorite route/ ISP.

Now Add Routing Table for this IP:-

root@tcrouter:~# ip route add default via 210.2.141.97 dev eth0 table Test

root@tcrouter:~# iptables -I PREROUTING -t mangle -i eth1 -p tcp -s 192.168.0.157 -d! 192.168.0.0/16 -j MARK --set-mark 1
 
  


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
Traffic shaping (limiting outgoing bandwidth of all TCP-traffic except FTP/HTTP) ffkodd Linux - Networking 3 10-25-2008 12:09 AM
Traffic Shaping uguoT Linux - Networking 0 02-21-2006 02:02 AM
Traffic shaping shy Linux - Networking 2 11-30-2004 09:51 AM
Traffic Shaping nemesisza Linux - Networking 1 03-21-2004 05:52 PM
Traffic Shaping ?? DocKane Linux - Networking 2 08-24-2001 09:32 AM


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