Skip to contentSkip to conversation

IP based bandwith limit

LARTC Christoph Petersen 5 participants 12 messages Oct 18, 2004 – Oct 19, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

i've following problem. One of our gateway router, which connects some of our customers should have bandwith limit.

So customer A with IP XX should have 2 Mbit, customer B with IP YY should have 10 Mbit. There is no need of borrowing bandwith so no fairness needed.

My simple question: with which technique should I manage this shaping? Or is there any existing project which provides this allready?

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

#1 lore raw

Hi!

Again, beware, that I am new to this myself, but if there is no borrowing necessary, does that mean you have more than 12 Mbit to hand out. If so, I assume you have one interface per customer, in which case you could use tbf on each interface. If both customers are behind the same interface you could use htb and lower the ceiling per customer, which has the same effect, with a filter rule for each customer --> class, based on ip address.

Hope this helps, correct me if I am wrong.

.peter

Quoted 9 lines · Christoph Petersen

Hi,

i've following problem. One of our gateway router, which connects some of our customers should have bandwith limit.

So customer A with IP XX should have 2 Mbit, customer B with IP YY should have 10 Mbit. There is no need of borrowing bandwith so no fairness needed.

Quoted 9 lines

My simple question: with which technique should I manage this shaping? Or is there any existing project which provides this allready?

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

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

#2 lore raw
In reply to Christoph Petersen

Hi,

unfortunately there is only one interface for the customers. My problem is to limit the up AND down speed in dependence to each other.

So customer A get a bandwith of 2Mbit this is up AND down so if he downloads with 1Mbit he gets a max upload speed of 1Mbit.

I've tried it with htb like this:

#!/bin/sh
TC=/sbin/tc
DEV=eth0

$TC qdisc add dev $DEV root handle 1 htb default 90
$TC qdisc add dev $DEV handle ffff: ingress
$TC class add dev $DEV parent 1: classid 1:2 htb rate 100Mbit burst 6k

$TC class add dev $DEV parent 1:2 classid 1:10 htb rate 10kbps ceil 10kbps

$TC filter add dev $DEV parent 1:0 protocol ip prio 100 u32 \
    match ip dst 192.168.1.19 \
    classid 1:10

$TC filter add dev $DEV parent ffff: protocol ip prio 50 u32 \
match ip src 192.168.1.19 \
police rate 10kbps burst 10k drop flowid 1:10

this is my internal test. But it wouldn't work with dependence to each other...

Greets
Christoph

Quoted 10 lines · Peter Huetmannsberger

Hi!

Again, beware, that I am new to this myself, but if there is no borrowing necessary, does that mean you have more than 12 Mbit to hand out. If so, I assume you have one interface per customer, in which case you could use tbf on each interface. If both customers are behind the same interface you could use htb and lower the ceiling per customer, which has the same effect, with a filter rule for each customer --> class, based on ip address.

Quoted 34 lines

Hope this helps, correct me if I am wrong.

.peter

Quoted 20 lines · Christoph Petersen

Hi,

i've following problem. One of our gateway router, which connects some of our customers should have bandwith limit.

So customer A with IP XX should have 2 Mbit, customer B with IP YY should have 10 Mbit. There is no need of borrowing bandwith so no fairness needed.

My simple question: with which technique should I manage this shaping? Or is there any existing project which provides this allready?

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

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

#3 lore raw
In reply to Christoph Petersen

Hi

like I said, I am new too, so take this with a grain of salt.

Quoted 2 lines

unfortunately there is only one interface for the customers. My problem is to limit the up AND down speed in dependence to each other.

Downloads become uploads on your internal interface!

so if eth0 is your external interface a download would be INCOMING on eth0 but as it is going on to your internal interface (e.g. eth1) it becomes an upload to your customer. So incoming traffic from the internet to your customers is outgoing on eth1.

if you do this on eth1:
--------------
#!/bin/bash
tc qdisc add dev eth1 root handle 1: htb default 20
tc class add dev eth1 parent 1: classid 1:1 htb rate 90mbit burst 15k tc class add dev eth1 parent 1:1 classid 1:10 htb rate 10mbit
prio 0 burst 15k
tc class add dev eth1 parent 1:1 classid 1:20 htb rate 1mbit ceil 1mbit
burst 6k prio 1
U32="tc filter add dev eth1 protocol ip parent 1:0 prio 0 u32" $U32 match ip dst 192.168.1.19 flowid 1:10
---------------

Then you have split the traffic into two classes:

one for the preferred customer, who gets 10Mbit and a default for all the other traffic, which gets 1Mbit. It still leaves a lot of bandwidth unused! (79 Mbit)

I have made the experience (which cost me an awful lot of time) that assuming the interface woudl produce excactly 100Mbit is a mistake and htb does unexpected things. It is probably bets to lower the parent class trafic 1: to something about 10% below your actual internet connection, even on your internal interface. (Please correct me if I am completely wrong!) I used iptraf to have a look on the throughput.

You would have to do something similar for actual uploads from your customers to the internet on eth0, but as you probably nat the traffic I am not certain what you would do there! Anyone else?

greetings,

.peter

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

#4 lore raw
In reply to Christoph Petersen

Hi,

okay, but I think I have some problems understanding the interaction between upload and download. How I have to define my traffic classes to match upload and download depending on each other?

Greets
Christoph

Quoted 45 lines · Peter Huetmannsberger

Hi

like I said, I am new too, so take this with a grain of salt.

Quoted 4 lines

unfortunately there is only one interface for the customers. My problem is to limit the up AND down speed in dependence to each other.

Downloads become uploads on your internal interface!

so if eth0 is your external interface a download would be INCOMING on eth0 but as it is going on to your internal interface (e.g. eth1) it becomes an upload to your customer. So incoming traffic from the internet to your customers is outgoing on eth1.

if you do this on eth1:
--------------
#!/bin/bash
tc qdisc add dev eth1 root handle 1: htb default 20
tc class add dev eth1 parent 1: classid 1:1 htb rate 90mbit burst 15k tc class add dev eth1 parent 1:1 classid 1:10 htb rate 10mbit
prio 0 burst 15k
tc class add dev eth1 parent 1:1 classid 1:20 htb rate 1mbit ceil 1mbit
burst 6k prio 1
U32="tc filter add dev eth1 protocol ip parent 1:0 prio 0 u32" $U32 match ip dst 192.168.1.19 flowid 1:10
---------------

Then you have split the traffic into two classes:

one for the preferred customer, who gets 10Mbit and a default for all the other traffic, which gets 1Mbit. It still leaves a lot of bandwidth unused! (79 Mbit)

I have made the experience (which cost me an awful lot of time) that assuming the interface woudl produce excactly 100Mbit is a mistake and htb does unexpected things. It is probably bets to lower the parent class trafic 1: to something about 10% below your actual internet connection, even on your internal interface. (Please correct me if I am completely wrong!) I used iptraf to have a look on the throughput.

Quoted 12 lines

You would have to do something similar for actual uploads from your customers to the internet on eth0, but as you probably nat the traffic I am not certain what you would do there! Anyone else?

greetings,

.peter

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

#5 lore raw
In reply to Christoph Petersen

Am Monday 18 October 2004 16:28 schrieb Christoph Petersen:

Quoted 3 lines

okay, but I think I have some problems understanding the interaction between upload and download. How I have to define my traffic classes to match upload and download depending on each other?

That's not easy to do at all. You'd have to use the one and the same class to put both up- and download traffic in (both as outgoing traffic on the same device). Usually this can't be done. Maybe it's possible with IMQ?

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

#6 lore raw
In reply to Christoph Petersen

Hi,

with htb and ingress I was been able to shape the bandwith to fit my wishes. But it's the same problem: I couldn't clue download and upload together so I was been able to shape upload to 10kbps and download too. But when I download some file and upload in the same time I was getting 10kbps on each line...

Greets
Christoph

Quoted 9 lines · Andreas Klauer

Am Monday 18 October 2004 16:28 schrieb Christoph Petersen:

Quoted 5 lines

okay, but I think I have some problems understanding the interaction between upload and download. How I have to define my traffic classes to match upload and download depending on each other?

Quoted 12 lines

That's not easy to do at all. You'd have to use the one and the same class to put both up- and download traffic in (both as outgoing traffic on the same device). Usually this can't be done. Maybe it's possible with IMQ?

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

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

#8 lore raw
In reply to Christoph Petersen

Check www.geocities.com/jame_sj

James

Quoted 16 lines

Message: 2
Date: Mon, 18 Oct 2004 11:17:41 +0200
From: Christoph Petersen <[email protected]>
To: [email protected]
Subject: [LARTC] IP based bandwith limit

Hi,

i've following problem. One of our gateway router, which connects some
of our customers should have bandwith limit.

So customer A with IP XX should have 2 Mbit, customer B with IP YY should have 10 Mbit. There is no need of borrowing bandwith so no fairness needed.

Quoted 9 lines

My simple question: with which technique should I manage this shaping?
Or is there any existing project which provides this allready?

Greets
Christoph

--__--__--

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

#9 lore raw
In reply to Christoph Petersen

Hi,

one question - whats the trick behind your marking "flags" (28, 56, ...).

Greets
Christoph

Quoted 28 lines · james jones

Check www.geocities.com/jame_sj

James

Quoted 23 lines

Message: 2
Date: Mon, 18 Oct 2004 11:17:41 +0200
From: Christoph Petersen <[email protected]>
To: [email protected]
Subject: [LARTC] IP based bandwith limit

Hi,

i've following problem. One of our gateway router, which connects some
of our customers should have bandwith limit.

So customer A with IP XX should have 2 Mbit, customer B with IP YY should have 10 Mbit. There is no need of borrowing bandwith so no fairness needed.

My simple question: with which technique should I manage this shaping?
Or is there any existing project which provides this allready?

Greets
Christoph

Quoted 12 lines
Quoted 4 lines

--__--__--

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

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

#10 lore raw
In reply to Christoph Petersen

Hi!

This is a nicely organized script, thank you. If I understand it correctly it stilmeans that there is a bandwidth of 28k for both upload and download though, and not 28k altogether. Or am I wrong?

many thanks,

.peter

Quoted 26 lines · james jones

Check www.geocities.com/jame_sj

James

Quoted 23 lines

Message: 2
Date: Mon, 18 Oct 2004 11:17:41 +0200
From: Christoph Petersen <[email protected]>
To: [email protected]
Subject: [LARTC] IP based bandwith limit

Hi,

i've following problem. One of our gateway router, which connects some
of our customers should have bandwith limit.

So customer A with IP XX should have 2 Mbit, customer B with IP YY should have 10 Mbit. There is no need of borrowing bandwith so no fairness needed.

My simple question: with which technique should I manage this shaping?
Or is there any existing project which provides this allready?

Greets
Christoph

Quoted 7 lines
Quoted 2 lines

--__--__--

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

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

#11 lore raw
In reply to Christoph Petersen

Hi,

some other question - with this setup there are two interfaces. Each interface has two classes. So if I take 1:16 example I've 1.5Mbit for upload and other 1.5Mbit for download. But when I upload with 1.5Mbit how many bandwith there is for download?

Greets
Christoph

Quoted 28 lines · james jones

Check www.geocities.com/jame_sj

James

Quoted 23 lines

Message: 2
Date: Mon, 18 Oct 2004 11:17:41 +0200
From: Christoph Petersen <[email protected]>
To: [email protected]
Subject: [LARTC] IP based bandwith limit

Hi,

i've following problem. One of our gateway router, which connects some
of our customers should have bandwith limit.

So customer A with IP XX should have 2 Mbit, customer B with IP YY should have 10 Mbit. There is no need of borrowing bandwith so no fairness needed.

My simple question: with which technique should I manage this shaping?
Or is there any existing project which provides this allready?

Greets
Christoph

Quoted 12 lines
Quoted 4 lines

--__--__--

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

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