Skip to contentSkip to conversation

Bandwidth Limiting using HTB?

LARTC Gerry Weaver 1 participant 2 messages May 23, 2004 – May 24, 2004

lore
Share & tools
lore
#0 lore raw

Hello All,

I've been playing around with HTB and reading the various lists for information on how to limit bandwidth on a particular ip or mac address. If I understand correctly, in order to use HTB for this, I would have to create a separate root class for each ip address that I wanted to limit. I have tried this and it seems to work. This seems okay for a few ips, but seems excessive for 100+ addresses. Especially if you wanted to add some interactive traffic shaping. Is this how it's done or is there a better approach?

Thanks in advance,

Gerry

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

#1 lore raw

Hi,

Thanks for the reply. I guess it would be best to provide a little more detail on the problem.

I've got 100+ users. Each of these users have a particular level/speed of service. These range from 128kbit to 1024kbit. I need a way to set a limit for each user based on their level/speed of service. My initial approach was to use 2 machines set up as bridges. One would handle limiting and the other would do shaping. There are currently 2 T1s supporting this.

I did the following:

WAN_IFACE="eth0"
WAN_RATE="3mbit"

# add root qdisc
tc qdisc add dev $WAN_IFACE root handle 1: htb default 1:2
# add main link ( I assume this will slow the interface down to 3mbit? )
tc class add dev $WAN_IFACE parent 1: classid 1:1 htb rate $WAN_RATE
# typical user
tc class add dev $WAN_IFACE parent 1:1 classid 1:2 htb rate 128kbit
...

tc filter add dev $WAN_IFACE parent 1:1 protocol ip prio16 u32 match ip src 192.168.1.1 \ flowid 1:2
...

If my understanding is correct this should limit the bandwidth of ip address 192.168.1.1 to 128kbit?

Any other unclassified traffic should also be limited to 128kbit?

I'm new to this. Do the above lines look correct?

Thanks,
Gerry

Quoted 53 lines · Adrian Vasile

There are 2 ways:
1. as you said, each ip has its own class. this approach is used by an ISP that I know and works great (if you have the bandwidth).
2. you classify traffic. each type with its own class (eg. http class, ftp class and so on). here we have a (small) problem. if you have bandwidth hogs (p2p) it is possible that they'll eat up most of the bandwidth or other services (eg http) be confused with p2p traffic. and all this match-making would consume some cpu.

I'm open to suggestions. which is better 1 or 2?

------------------------------------------------------------------------

Subject:
[LARTC] Bandwidth Limiting using HTB?
From:
Gerry Weaver <[email protected]>
Date:
Sun, 23 May 2004 18:47:34 -0500
To:
[email protected]

To:
[email protected]

Hello All,

I've been playing around with HTB and reading the various lists for information on how to limit bandwidth on a particular ip or mac address. If I understand correctly, in order to use HTB for this, I would have to create a separate root class for each ip address that I wanted to limit. I have tried this and it seems to work. This seems okay for a few ips, but seems excessive for 100+ addresses. Especially if you wanted to add some interactive traffic shaping. Is this how it's done or is there a better approach?

Thanks in advance,

Gerry

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/

Signature · 11 lines
Gerry Weaver

IT-Pro Corp.

Office: (254) 883-9040
Mobile: (512) 663-9550
Fax   : (254) 883-9041

_______________________________________________
LARTC mailing list / [email protected]
http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/