#!/usr/bin/perl
#
# Adam Pribyl, covex@ahoj.fsik.cvut.cz
#


print "Content-type: text/html\n\n";

print "<HTML><HEAD><META HTTP-EQUIV=Pragma CONTENT=no-cache></HEAD><BODY>\n";

#nocache!


$tm1 = time;
$kb = 1024;
$nkb = 768;		# size of transfer test file

$svrtimeout = 30; 	# httpd server timeout in seconds

$lospd = $nkb/$svrtimeout;

print "If no speed information is given then either your connection is too slow (< $lospd kB/s) or you are experiencing signal dropouts. ";

for ($f = 1; $f <= $nkb; $f++) {
    print "<!--";
    for ($g = 1; $g <= ($kb/2-9) ; $g++) { print "00"; }
    print "-->. ";
}
$tm2 = time;
print "\n<P>";
print "Approximate download bandwidth speed of your connection is: ";
#to not divide accidentaly by zero we accept inacurrancy of 0.001s
$speed = $nkb*$kb/($tm2-$tm1+0.001);
$speedkb = $speed/$kb;
$speedkbb = $speedkb*8;
printf "%.2f B/s = %.2f kB/s = %.2f kb/s\n", $speed, $speedkb, $speedkbb;
$date = `date`;
print "<BR>$date\n<BR>";
print "<A HREF=\"http://bbs.cvut.cz/~covex/czfree/index.html\#bander\">Bander speed test</A>\n";

print "</BODY></HTML>";
