On Nov 7, 12:15*pm, "D. Stussy" <s...@bde-arc.ampr.org> wrote:
> "banyeer" <bany...@yahoo.com> wrote in message
>
> news:e402d9c4-ec35-4d7f-aef9-(E-Mail Removed)...> Hi Everyone,
> > I met some problems in traffic control with TC.
> > My purpose:
> > 1. Restrict the overall bandwidth.
> > 2. Starve the flows in the lower bands.
> > Based on the following link, I develope the script bellow.
>
> http://linux.derkeiler.com/Newsgroup...working/2004-1...
>
>
>
>
>
> > ####################script##################
> > IPTABLES=/usr/local/sbin/iptables
> > MODPROBE=/sbin/modprobe
> > IP=/usr/sbin/ip
> > TC=/usr/sbin/tc
> > RATE=10
>
> > $IPTABLES -t mangle -D POSTROUTING --dst 192.168.0.1 -j MARK --set-
> > mark 2 &>/dev/null
> > $IPTABLES -t mangle -D POSTROUTING --dst 192.168.0.2 -j MARK --set-
> > mark 3 &>/dev/null
> > $IPTABLES -t mangle -D POSTROUTING -m length --length 0:64 -j MARK --
> > set-mark 1 &>/dev/null
>
> > $TC qdisc del dev eth0 root &>/dev/null
>
> > $IPTABLES -t mangle -A POSTROUTING --dst 192.168.0.1 -j MARK --set-
> > mark 2
> > $IPTABLES -t mangle -A POSTROUTING --dst 192.168.0.2 -j MARK --set-
> > mark 3
> > $IPTABLES -t mangle -A POSTROUTING -m length --length 0:64 -j MARK --
> > set-mark 1
>
> > $TC qdisc add dev eth0 root handle 1:0 htb default 0
> > $TC class add dev eth0 parent 1:0 classid 1:1 htb rate ${RATE}mbit
> > $TC qdisc add dev eth0 parent 1:1 handle 2: prio
>
> > $TC qdisc add dev eth0 parent 2:1 handle 10:0 bfifo limit 64k
> > $TC qdisc add dev eth0 parent 2:2 handle 20:0 bfifo limit 64k
> > $TC qdisc add dev eth0 parent 2:3 handle 30:0 bfifo limit 64k
>
> > $TC filter add dev eth0 parent 1:0 prio 0 protocol ip handle 1 fw
> > flowid 1:1
> > $TC filter add dev eth0 parent 1:0 prio 1 protocol ip handle 2 fw
> > flowid 1:1
> > $TC filter add dev eth0 parent 1:0 prio 2 protocol ip handle 3 fw
> > flowid 1:1
>
> > $TC filter add dev eth0 parent 2:0 prio 0 protocol ip handle 1 fw
> > flowid 2:1
> > $TC filter add dev eth0 parent 2:0 prio 1 protocol ip handle 2 fw
> > flowid 2:2
> > $TC filter add dev eth0 parent 2:0 prio 2 protocol ip handle 3 fw
> > flowid 2:3
>
> > ##########################script################## ##########
>
> > The problem is that if I set RATE to some value less than 20, it works
> > perfectly. *But if I set RATE to some value bigger than 20, It fails
> > to work. *Is there anything wrong with the script?
> > My test environment:
> > MIPS (400HZ)
> > linux 2.6.18
> > iproute2-2.6.15
>
> 1) *By "failing to work," do you mean that the rules are completely ignored
> (i.e. the class counters are NOT incremented), or do you mean that the rules
> are used but the bandwidth used exceeds 20Mbit?
> 2) *In your filter rules, the selection criteria are all the same for each
> set of 3 rules.
> 3) *What happens if you upgrade to the current versions (2.6.27.4 kernel and
> 2.6.26 iproute2)?- Hide quoted text -
>
> - Show quoted text -
1) The rules works when RATE is set to 10, while fails when RATE is
set to 50.
Bellow is the detailed discription.
A) set RATE to 10.
Create 3 flows, 9M(High priority),2M(Medium priority), 2M(Low
priority).
After traffic control, 9M(H), 1M(M), 0M(L). This is just I want.
#tc -s qdis ls dev eth0
qdisc htb 1: r2q 10 default 0 direct_packets_stat 243
Sent 3851532 bytes 3867 pkt (dropped 748, overlimits 4331 requeues 0)
rate 0bit 0pps backlog 0b 137p requeues 0
qdisc prio 2: parent 1:1 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1
1 1
Sent 3609504 bytes 3624 pkt (dropped 748, overlimits 0 requeues 0)
rate 0bit 0pps backlog 0b 137p requeues 0
qdisc bfifo 10: parent 2:1 limit 64Kb
Sent 2970072 bytes 2982 pkt (dropped 0, overlimits 0 requeues 0)
rate 0bit 0pps backlog 8964b 9p requeues 0
qdisc bfifo 20: parent 2:2 limit 64Kb
Sent 565728 bytes 568 pkt (dropped 166, overlimits 0 requeues 0)
rate 0bit 0pps backlog 62748b 63p requeues 0
qdisc bfifo 30: parent 2:3 limit 64Kb
Sent 73704 bytes 74 pkt (dropped 582, overlimits 0 requeues 0)
rate 0bit 0pps backlog 64740b 65p requeues 0
B)
set RATE to 50.
Create 3 flows, 40M(High priority),20M(Medium priority), 20M(Low
priority).
After traffic control, 35M(H), 1M(M), 0M(L). It does not meet my
request.
My anticipate is 40M(H), 20M(M), 0M(L).
#tc -s qdis ls dev eth0
qdisc htb 1: r2q 10 default 0 direct_packets_stat 258
Sent 874083006 bytes 877602 pkt (dropped 975747, overlimits 1375210
requeues 335962)
rate 0bit 0pps backlog 0b 122p requeues 335962
qdisc prio 2: parent 1:1 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1
1 1
Sent 873834624 bytes 877344 pkt (dropped 975747, overlimits 0
requeues 335962)
rate 0bit 0pps backlog 0b 122p requeues 335962
qdisc bfifo 10: parent 2:1 limit 64Kb
Sent 842449668 bytes 845833 pkt (dropped 89972, overlimits 0 requeues
309487)
rate 0bit 0pps backlog 0b 0p requeues 309487
qdisc bfifo 20: parent 2:2 limit 64Kb
Sent 24020532 bytes 24117 pkt (dropped 434613, overlimits 0 requeues
26474)
rate 0bit 0pps backlog 56772b 57p requeues 26474
qdisc bfifo 30: parent 2:3 limit 64Kb
Sent 7364424 bytes 7394 pkt (dropped 451162, overlimits 0 requeues 1)
rate 0bit 0pps backlog 64740b 65p requeues 1
2) The rules are set according to
http://linux.derkeiler.com/Newsgroup...-12/0624..html.
3) I have not upgraded the kernel and iproute2.
Thanks.