LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Traffic Shaping (https://www.linuxquestions.org/questions/linux-networking-3/traffic-shaping-581829/)

netguy2000 09-03-2007 06:44 AM

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.

netguy2000 05-13-2009 07:48 AM

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


All times are GMT -5. The time now is 10:13 AM.