LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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
 
LinkBack Search this Thread
Old 07-10-2010, 03:31 AM   #1
auntyjack
LQ Newbie
 
Registered: Oct 2008
Posts: 5

Rep: Reputation: 0
using CLASSIFY target with tbf queue


hi folks

i am routing traffic between an internet connection and an internal
network. i wish to throttle individual users who have exceeded their quota.

initially i have a htb 1:0 attached to the root of my internal
interface. when host 'n' exceeds their quota my script attaches a htb class 1:n with rate = the whole internal bandwidth, 100mbit. then it attaches to this a tbf qdisc n+9:0 with rate = shaped rate, 48kbit. the tbf automatically creates one class n+9:1. the script also then creates a rule in mangle POSTROUTING for that user with -j CLASSIFY --set-class n+9:1

so, for the first shaped user (n=1) i execute:

tc class add dev $internal parent 1:0 classid 1:1 htb rate 100mbit
tc qdisc add dev $internal parent 1:1 handle 10:0 tbf rate 48kbit burst
10kb limit 10kb
iptables -t mangle -A POSTROUTING -d $machIP -j CLASSIFY --set-class 10:1

which makes:

root
qdisc class qdisc class
htb ------ htb ------ tbf ------ tbf
1:0 1:1 10:0 10:1

tc -s -d qdisc show dev eth1 gives:

qdisc htb 1: root r2q 10 default 0 direct_packets_stat 82635 ver 3.17
Sent 41949635 bytes 82635 pkt (dropped 0, overlimits 0 requeues 12)
rate 0bit 0pps backlog 0b 0p requeues 12
qdisc tbf 10: parent 1:1 rate 48000bit burst 10Kb/8 mpu 0b lat 1us
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0

tc -s -d class show dev eth1 gives:

class htb 1:1 root leaf 10: prio 0 quantum 200000 rate 100000Kbit ceil
100000Kbit burst 14087b/8 mpu 0b overhead 0b cburst 14087b/8 mpu 0b overhead
0b level 0
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 0p requeues 0
lended: 0 borrowed: 0 giants: 0
tokens: 1101 ctokens: 1101

class tbf 10:1 parent 10:

iptables -t mangle -L POSTROUTING -n gives:

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
CLASSIFY all -- 0.0.0.0/0 192.168.20.10 CLASSIFY set 10:1

i can see traffic going through the root qdisc alright but nothing's
getting shaped.
can some wonderful person out there show me where i'm going wrong ?

thank you muchly,
aunty
 
Old 07-11-2010, 02:36 AM   #2
kslen
Member
 
Registered: Nov 2008
Distribution: Slackware & LMDE.
Posts: 74

Rep: Reputation: 19
As a novice with tc myself and a person whom should have went to bed many hours ago, please take this information with a grain of salt as I may be incorrect.

But from what I have gathered so far, the root qdisc represents the interface itself. So regardless of packets being classified correctly, the root qdisc will show that traffic is passing through it.

I haven't tried out htb but I have recently managed to get packets flowing through cbq successfully so perhaps the information I've accumulated in this thread can help you getting those packets classified correctly. Look at the very top of my script for my take on the firewall rules.

http://www.linuxquestions.org/questi...-rates-817246/

I'll gladly help more after I get some rest, but until then I wish you the best of luck on your endeavor.
 
  


Reply

Tags
netfilter


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SNAT and QUEUE target: iptables - Encapsulation, decapsulation V4 in V6 the_ionic Linux - Networking 0 12-16-2009 12:44 PM
Guru: criteria to classify a member as such? stf92 LQ Suggestions & Feedback 4 05-28-2009 01:16 PM
A question regarding traffic shaping involving tc-tbf and tc-sfq 05020241 Linux - Networking 3 06-27-2008 06:08 AM
how can I test tbf rules for bandwidth management laeeq38 Linux - Networking 1 08-07-2006 10:08 AM
Classify AMD K5? rayburn Linux - Hardware 3 09-10-2004 02:53 PM


All times are GMT -5. The time now is 01:48 PM.

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
Open Source Consulting | Domain Registration