linux-admin.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* HTB issue with modem 56k
@ 2003-10-06 15:01 Gustavo Guillermo
  0 siblings, 0 replies; only message in thread
From: Gustavo Guillermo @ 2003-10-06 15:01 UTC (permalink / raw)
  To: linux-admin, gus_est_prgms

Hi everyone, I'm trying to do the same as in DSL eth configurations with 
an htb script. But something is weird because at the atomic point of 
enabling nothing goes up or down, but if I set up like if was an 128kbits 
connection let transfers but is not useful.

Kernel is 2.4.21-pre5
but I tried with 2.4.23-pre4 too.
Modem is a standard PCTEL softmodem, working fine, and fast.

Here is the script that I used for. Is a modified version to allow calcs 
about burst. Works fine with more than 256kbits.

Tips are welcome

---------------SCRIPT-------------------------
./qos.htb set 

#!/usr/bin/perl
$DOWN=256;
$UP=128;
$DEV="ppp0";
$QOS=1;#EL RATIO DE REALIDAD
#$DEV="eth0";

# low priority OUTGOING traffic - you can leave this blank if you want
# low priority source netmasks
$NOPRIOHOSTSRC="";

# low priority destination netmasks
$NOPRIOHOSTDST="";

# low priority source ports
$NOPRIOPORTSRC="4662 4672";

# Puertos de destino de baja prioridad
$NOPRIOPORTDST="4662 4672";

#OVERRIDE DE ARGUMENTOS DE ENTRADA
    foreach (@ARGV){
    if($_=~/\-\-(.*)=(.*)/i){
	#print "\$1:$1\n\$2:$2\n";
	$param=$1;$arg=$2;
	if ($param eq "up"){$UP=$arg;}
	if ($param eq "iface"){$DEV=$arg;}
	if ($param eq "down"){$DOWN=$arg;}
	if ($param eq "qos"){$QOS=$arg;}
	if ($param eq "noprioportsrc"){$NOPRIOPORTSRC=$arg;}
	if ($param eq "noprioportdst"){$NOPRIOPORTDST=$arg;}
	if ($param eq "nopriohostsrc"){$NOPRIOHOSTSRC=$arg;}
	if ($param eq "nopriohostdst"){$NOPRIOHOSTDST=$arg;}
    }#end argv
    }

#CALCULOS DEL BURST y LAS CAIDAS
$DOWNLINK=$DOWN*800/1024*$QOS;
$UPLINK=$UP*220/256*$QOS;
$BURSTDOWN=$DOWN*10/1024*$QOS;
$BURSTUP=$UP*4/256*$QOS;

Params();

if ($ARGV[0] eq "status"){
	system("tc -s qdisc ls dev $DEV");
	system("tc -s class ls dev $DEV");
	exit(0);
}

if ($ARGV[0] eq "clear"){
Clear();
exit(0);
}

if ($ARGV[0] eq "set"){
Set();
exit(0);
}

#if ($ARGV[0] neq "elp" or $ARGV[0] eq ""){
print "USAR qos.htb [status|clear|set] [--opcion=valor]\n";
#}



sub Params(){
print "INTERFASE\t\t:$DEV\n";
print "QOS\t\t\t:$QOS\n";
print "Subida\t\t\t:$UP\k\n";
print "Subida lim\t\t:$UPLINK\k\n";
print "Subida /_\\\t\t:$BURSTUP\k\n";
print "Bajada\t\t\t:$DOWN\k\n";
print "Bajada lim\t\t:$DOWNLINK\k\n";
print "Bajada /_\\\t\t:$BURSTDOWN\k\n";
print "Baja prioridad [-p\t:$NOPRIOPORTSRC\n";
print "Baja prioridad [-n\t:$NOPRIOHOSTSRC\n";
print "Baja prioridad -]p\t:$NOPRIOPORTDST\n";
print "Baja prioridad -]n\t:$NOPRIOHOSTDST\n";
print "\n";
}

sub Clear(){
system("tc qdisc del dev $DEV root    2> /dev/null > /dev/null");
system("tc qdisc del dev $DEV ingress 2> /dev/null > /dev/null");
print "Reglas limpias - algoritmo HTB\n";
}

sub Set(){
#Dispositivo HTB raiz
Clear();
system("tc qdisc add dev $DEV root handle 1: htb default 20");
DownLink();
UpLink();
print "Reglas establecidas - algoritmo HTB\n";
}

sub UpLink(){
# shape everything at $UPLINK speed - this prevents huge queues in your
# DSL modem which destroy latency:

system("tc class add dev $DEV parent 1: classid 1:1 htb rate $UPLINK\kbit 
burst $BURSTUP\k");

# high prio class 1:10:

system("tc class add dev $DEV parent 1:1 classid 1:10 htb rate 
$UPLINK\kbit burst $BURSTUP\k prio 1");

# bulk & default class 1:20 - gets slightly less traffic,
# and a lower priority:

$TRATE=9*$UPLINK/10;
system("tc class add dev $DEV parent 1:1 classid 1:20 htb rate 
$TRATE\kbit burst $BURSTUP\k prio 2");

$TRATE=8*$UPLINK/10;
system("tc class add dev $DEV parent 1:1 classid 1:30 htb rate 
$TRATE\kbit burst $BURSTUP\k prio 2");

# all get Stochastic Fairness:
system("tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10");
system("tc qdisc add dev $DEV parent 1:20 handle 20: sfq perturb 10");
system("tc qdisc add dev $DEV parent 1:30 handle 30: sfq perturb 10");

# TOS Minimum Delay (ssh, NOT scp) in 1:10:

system("tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match 
ip tos 0x10 0xff  flowid 1:10");

# ICMP (ip protocol 1) in the interactive class 1:10 so we
# can do measurements & impress our friends:
system("tc filter add dev $DEV parent 1:0 protocol ip prio 10 u32 match 
ip protocol 1 0xff flowid 1:10");

# To speed up downloads while an upload is going on, put ACK packets in
# the interactive class:

system("tc filter add dev $DEV parent 1: protocol ip prio 10 u32 match ip 
protocol 6 0xff match u8 0x05 0x0f at 0 match u16 0x0000 0xffc0 at 2 
match u8 0x10 0xff at 33 flowid 1:10");

# rest is 'non-interactive' ie 'bulk' and ends up in 1:20

# some traffic however suffers a worse fate

@np=split /\ /,$NOPRIOPORTDST;
foreach(@np){
system("tc filter add dev $DEV parent 1: protocol ip prio 14 u32 match ip 
dport $_ 0xffff flowid 1:30");
}

@np=split /\ /,$NOPRIOPORTSRC;
foreach(@np){
system("tc filter add dev $DEV parent 1: protocol ip prio 15 u32 match ip 
sport $_ 0xffff flowid 1:30");
}

@np=split /\ /,$NOPRIOHOSTSRC;
foreach(@np){
system("tc filter add dev $DEV parent 1: protocol ip prio 16 u32 match ip 
src $_ flowid 1:30");
}

@np=split /\ /,$NOPRIOHOSTDST;
foreach(@np){
system("tc filter add dev $DEV parent 1: protocol ip prio 17 u32 match ip 
dst $_ flowid 1:30");
}

# rest is 'non-interactive' ie 'bulk' and ends up in 1:20

system("tc filter add dev $DEV parent 1: protocol ip prio 18 u32 match ip 
dst 0.0.0.0/0 flowid 1:20");


}#Fin del Uplink

sub DownLink(){
########## downlink #############
# slow downloads down to somewhat less than the real speed  to prevent 
# queuing at our ISP. Tune to see how high you can set it.
# ISPs tend to have *huge* queues to make sure big downloads are fast
#
# attach ingress policer:

system("tc qdisc add dev $DEV handle ffff: ingress");

# filter *everything* to it (0.0.0.0/0), drop everything that's
# coming in too fast:

system("tc filter add dev $DEV parent ffff: protocol ip prio 50 u32 match 
ip src 0.0.0.0/0 police rate $DOWNLINK\kbit burst $BURSTDOWN\k drop 
flowid :1");
}#Fin del downlink

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-10-06 15:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-06 15:01 HTB issue with modem 56k Gustavo Guillermo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).