[LARTC] Borrowing between HTB classes not working as expectd.
Ryan Castellucci
ryan.castellucci at gmail.com
Sat Nov 12 21:26:23 CET 2005
I'm using a fairly large number of classes, andf borrowing is not
working as expected... I've called this setting it up on an IMQ device
with speed 1200/256 on a 1536/384 line. I'm then throwing a UDP data
transfer at it that gets tossed in one of the class under parent 1:6.
The classification is working fine, but when I try to ping out, ping
times are in the 900ms range, even though pings are classified in the
classes under 1:5, and speeds in classes under 1:4 are well under the
60% they should be getting. Any idea what I've done wrong here? Perl
code to set everything up below, if you comment out the system call,
it'll list off all the tc commands executed. How I wanted this to work
is higher priority classes to get a shot at bandwidth first in excess
of the base rates on all the other classes.
#!/usr/bin/perl -w
use strict;
my $dev = $ARGV[0];
my $speed_down = $ARGV[1];
my $speed_up = $ARGV[2];
my $tc_bin = "/sbin/tc";
tc("qdisc del dev $dev root");
tc("qdisc add dev $dev root handle 1:0 htb r2q 1 default 4");
tc("class add dev $dev parent 1:0 classid 1:2 htb ".
"rate " . int($speed_up * 0.85) . "kbit ".
"ceil " . int($speed_up * 0.85) . "kbit ".
"prio 1 burst 64k");
tc("qdisc add dev $dev parent 1:2 handle 2: sfq perturb 10");
# Critical class
tc("class add dev $dev parent 1:2 classid 1:3 htb ".
"rate " . int($speed_down * 0.05 + 64) . "kbit ".
"ceil " . int($speed_down * 0.05 + 64 +
($speed_up * 0.10)) . "kbit ".
"prio 2 burst 64k");
tc("qdisc add dev $dev parent 1:3 handle 3: sfq perturb 10");
# High class
tc("class add dev $dev parent 1:2 classid 1:4 htb ".
"rate " . int($speed_up * 0.50) . "kbit ".
"ceil " . int($speed_up * 0.95) . "kbit ".
"prio 3 burst 64k");
tc("qdisc add dev $dev parent 1:4 handle 4: sfq perturb 10");
# Med class
tc("class add dev $dev parent 1:2 classid 1:5 htb ".
"rate " . int($speed_up * 0.40) . "kbit ".
"ceil " . int($speed_up * 0.95) . "kbit ".
"prio 5 burst 64k");
tc("qdisc add dev $dev parent 1:5 handle 5: sfq perturb 10");
# Low class
tc("class add dev $dev parent 1:2 classid 1:6 htb ".
"rate " . int($speed_up * 0.10) . "kbit ".
"ceil " . int($speed_up * 0.80) . "kbit ".
"prio 7 burst 64k");
tc("qdisc add dev $dev parent 1:6 handle 6: sfq perturb 10");
for (my $i=100;$i <= 110;$i++)
{
# High class
tc("class add dev $dev parent 1:4 classid 1:" . ($i + 256) . " htb ".
"rate " . int($speed_up * 0.50) . "kbit ".
"ceil " . int($speed_up * 0.95) . "kbit ".
"prio 4 burst 15k");
tc("qdisc add dev $dev parent 1:" . ($i + 256) . " handle " . ($i +
256) . ": sfq perturb 10");
tc("filter add dev $dev protocol ip parent 1: prio 5 handle " .
tohex($i + 256) . " fw flowid 1:" . ($i + 256));
# Med class
tc("class add dev $dev parent 1:5 classid 1:" . ($i + 512) . " htb ".
"rate " . int($speed_up * 0.40) . "kbit ".
"ceil " . int($speed_up * 0.95) . "kbit ".
"prio 6 burst 15k");
tc("qdisc add dev $dev parent 1:" . ($i + 512) . " handle " . ($i +
512) . ": sfq perturb 10");
tc("filter add dev $dev protocol ip parent 1: prio 5 handle " .
tohex($i + 512) . " fw flowid 1:" . ($i + 512));
# Low class
tc("class add dev $dev parent 1:6 classid 1:" . ($i + 768) . " htb ".
"rate " . int($speed_up * 0.10) . "kbit ".
"ceil " . int($speed_up * 0.80) . "kbit ".
"prio 8 burst 15k");
tc("qdisc add dev $dev parent 1:" . ($i + 768) . " handle " . ($i +
768) . ": sfq perturb 10");
tc("filter add dev $dev protocol ip parent 1: prio 5 handle " .
tohex($i + 768) . " fw flowid 1:" . ($i + 768));
}
tc("filter add dev $dev protocol ip parent 1: prio 5 handle 0x3 fw flowid 1:3");
sub tc
{
my $arg = shift;
print "$tc_bin $arg\n";
system($tc_bin,split(/ /,$arg));
}
sub tohex
{
return '0x' . sprintf("%2.2x",shift);
}
--
Ryan Castellucci http://ryanc.org/
More information about the LARTC
mailing list