LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-16-2009, 10:00 AM   #1
landysaccount
Member
 
Registered: Sep 2008
Location: Dominican Republic
Distribution: Debian
Posts: 188

Rep: Reputation: 18
Question Help with TC Traffic Shaping


Hello.

I have a problem using tc in Debian. I've tried to register to the lart mailing list but, some how I can't.

Well, the problem I'm experiencing is that I wrote a small script to test traffic shaping but, it doesn't seem to work.

$iptables -t mangle -F
$iptables -t mangle -Z

$iptables -t mangle -A FORWARD -s 192.168.2.74 -j MARK --set-mark 2
$iptables -t mangle -A FORWARD -d 192.168.2.74 -j MARK --set-mark 2

$iptables -t mangle -A FORWARD -s 192.168.2.101 -j MARK --set-mark 1
$iptables -t mangle -A FORWARD -d 192.168.2.101 -j MARK --set-mark 1

$iptables -t mangle -A FORWARD -s 192.168.2.104 -j MARK --set-mark 1
$iptables -t mangle -A FORWARD -d 192.168.2.104 -j MARK --set-mark 1

$iptables -t mangle -A FORWARD -s 192.168.2.106 -j MARK --set-mark 1
$iptables -t mangle -A FORWARD -d 192.168.2.106 -j MARK --set-mark 1

$iptables -t mangle -A FORWARD -s 192.168.2.105 -j MARK --set-mark 1
$iptables -t mangle -A FORWARD -d 192.168.2.105 -j MARK --set-mark 1

$tc qdisc del dev eth1 root

$tc qdisc add dev eth1 root handle 1: htb

# Classes
$tc class add dev eth1 parent 1: classid 1:1 htb rate 200kbit ceil 200kbit
$tc class add dev eth1 parent 1:1 classid 1:2 htb rate 100kbit ceil 100kbit

#Filters
$tc filter add dev eth1 protocol ip parent 1:0 handle 2 fw classid 1:2

$tc filter add dev eth1 protocol ip parent 1:0 handle 1 fw classid 1:1

exit 0

According to other how to's this is supposed to assign 200kbps to those with firewall mark 1 and 100kbps to those with firewall mark 2.

When I type: tc -s class ls dev eth1
I don't get any statistic and everyone in still can download to the max (1.5mbps).

What am I doing wrong? Please help.
 
Old 05-09-2009, 06:14 PM   #2
rayfordj
Member
 
Registered: Feb 2008
Location: Texas
Distribution: Fedora, RHEL, CentOS
Posts: 488

Rep: Reputation: 78
Is eth1 your LAN interface or your Internet-bound interface?

If you want to throttle clients' downloads on your LAN you want to shape on the LAN interface. If you want to throttle clients' uploads, use ISP-side interface.
While you can police an interface (ingress) it is not as robust as shaping (egress).

While you can use fwmark it may not be necessary for you.
See if you have better results in limiting when calling the IP from tc and go from there.
Code:
tc qdisc add dev eth1 root handle 1: htb default 10
tc class add dev eth1 parent 1: classid 1:1 htb rate 2mbit quantum 3000 burst 15k
tc class add dev eth1 parent 1:1 classid 1:10 htb rate 2mbit quantum 1500 burst 15k
tc class add dev eth1 parent 1:1 classid 1:20 htb rate 200kbit ceil 200kbit quantum 1500 burst 15k
tc class add dev eth1 parent 1:1 classid 1:30 htb rate 100kbit ceil 100kbit quantum 1500 burst 15k
tc class add dev eth1 parent 1:1 classid 1:40 htb rate 32kbit ceil 64kbit quantum 1500 burst 15k

tc qdisc add dev eth1 parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev eth1 parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev eth1 parent 1:30 handle 30: sfq perturb 10
tc qdisc add dev eth1 parent 1:40 handle 40: sfq perturb 10

# 1:20 200kbit with 200kbit ceil
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.2.74/32 flowid 1:20
# 1:30 100kbit with 100kbit ceil
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.2.101/32 flowid 1:30
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.2.102/32 flowid 1:30
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.2.103/32 flowid 1:30
# 1:40 gets 32kbit with 64kbit ceil
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.2.104/32 flowid 1:40

# anything not explicitly defined gets 1:10
# 1:10 2mbit
I think I have that right...

 
  


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 netguy2000 Linux - Networking 1 05-13-2009 07:48 AM
Problem with Traffic Shaping and HTTP Traffic. redvivi Linux - Networking 1 11-29-2008 12:23 PM
Traffic shaping (limiting outgoing bandwidth of all TCP-traffic except FTP/HTTP) ffkodd Linux - Networking 3 10-25-2008 12:09 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

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

All times are GMT -5. The time now is 11:44 PM.

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