[LARTC] How to limit bandwidth by port?

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--=-gpk6OwgCHZ8GZ/NYG88X
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Sat, 2002-12-14 at 03:57, Andrea Rossato wrote:
> DOWNLINK=220
> UPLINK=125
> DEV=ppp0
> 
> tc qdisc add dev $DEV root handle 1: htb default 10
> 
> tc class add dev $DEV parent 1: classid 1:1 htb rate ${UPLINK}kbit burst 6
> 
> tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${UPLINK}kbit \
>     ceil $[UPLINK}kbit burst 6k prio 1
> 
> tc class add dev $DEV parent 1:1 classid 1:20 htb rate $[3*$UPLINK/10]kbit\
>     ceil $[9*$UPLINK/10]kbit burst 6k prio 2
> 
> tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10
> tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10
> 
> tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 \
>          match ip dport 8080 0xffff flowid 1:20
> 
> 
> traffic to dport 80 will get 3/10 of bandwith (with possibility to 
> borrow up to 9/10)
> andrea

Andrea, 

I have another script (attached) Im just wondering how i could implement
the above script into it. Im not the most knowledgable on shaping in
general :)

thanks
-mdew (resent-again)





--=-gpk6OwgCHZ8GZ/NYG88X
Content-Disposition: attachment; filename=shaping
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-sh; name=shaping; charset=ANSI_X3.4-1968

#! /bin/sh

EXT_IFACE=3Deth0

modprobe imq numdevs=3D1
# del the qdisc already loaded (if there)
tc qdisc del dev imq0 root

tc qdisc add dev imq0 handle 1: root htb default 12 r2q 1

#          [ HTB queue ]
#                |
#                |
#              [256]  (class 1:1)
#             /  |  \
#            /   |   \
#           /    |    \
#          /     |     \
#         /      |      \
#     [64]       [64]    [128] (note: these add up the the parent's 256)
#     (1:10)     (1:11)  (1:12)
#       |        |        |
#       |        |        |
#     [sfq]    [sfq]    [sfq]
#     (20:0)   (21:0)   (22:0)
# The main link: 252kbit (less is better)
tc class add dev imq0 parent 1: classid 1:1 htb rate 254kbit
# For 10.0.0.9 - 64kbit all to itself - Paul
tc class add dev imq0 parent 1:1 classid 1:10 htb rate 20kbit burst 1kbit p=
rio 1 ceil 36kbit
# For 10.0.0.2 - 64kbit all to itself - Mark
tc class add dev imq0 parent 1:1 classid 1:11 htb rate 20kbit burst 1kbit p=
rio 1 ceil 60kbit
# For 10.0.0.3 and 10.0.0.8 - 128kbit between them - Ryan - Mike
tc class add dev imq0 parent 1:1 classid 1:12 htb rate 200kbit burst 10kbit=
 prio 1 ceil 252kb
it

# SFQ makes things a bit fairer (in theory)
tc qdisc add dev imq0 parent 1:10 handle 20:0 sfq
tc qdisc add dev imq0 parent 1:11 handle 21:0 sfq
tc qdisc add dev imq0 parent 1:12 handle 22:0 sfq

# Match iptables mark 1 and send to class 1:10 (64kbit A)
tc filter add dev imq0 protocol ip pref 1 parent 1: handle 1 fw classid 1:1=
0
# Match iptables mark 2 and send to class 1:11 (64kbit B)
tc filter add dev imq0 protocol ip pref 2 parent 1: handle 2 fw classid 1:1=
1
# Match iptables mark 3 and send to class 1:12 (128kbit)
tc filter add dev imq0 protocol ip pref 3 parent 1: handle 3 fw classid 1:1=
2

# The IMQ device must be up before this will work...
# ip link set imq0 up (set below)

iptables -t mangle -F
iptables -t mangle -X
iptables -t mangle -N incoming
iptables -t mangle -A incoming -d 10.0.0.9 -j MARK --set-mark 1
iptables -t mangle -A incoming -d 10.0.0.2 -j MARK --set-mark 2
iptables -t mangle -A incoming -m mark --mark 1 -j RETURN
iptables -t mangle -A incoming -m mark --mark 2 -j RETURN
iptables -t mangle -A incoming -j MARK --set-mark 3
iptables -t mangle -A FORWARD -i $EXT_IFACE -j incoming
iptables -t mangle -A FORWARD -i $EXT_IFACE -j IMQ

ip link set imq0 up

tc -s -d class show dev imq0
--=-gpk6OwgCHZ8GZ/NYG88X--



[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux