1 | 2 | czfcentos | #!/usr/bin/perl |
2 | | | # |
3 | | | # Adam Pribyl, covex@ahoj.fsik.cvut.cz |
4 | | | # Petr Simandl, www.simandl.cz |
5 | | | |
6 | | | |
7 | | | print "Content-type: text/html\n\n"; |
8 | | | |
9 | | | print "<HTML><HEAD><META HTTP-EQUIV=Pragma CONTENT=no-cache></HEAD><BODY>\n"; |
10 | | | |
11 | | | #nocache! |
12 | | | |
13 | | | |
14 | | | $kb = 1024; |
15 | | | $nkba = 20; # size of a transfer test file |
16 | | | $nkbb = 50; # size of b transfer test file |
17 | | | $nkbc = 100; # size of c transfer test file |
18 | | | $nkbd = 300; # size of d transfer test file |
19 | | | $nkbe = 500; # size of e transfer test file |
20 | | | |
21 | | | $svrtimeout = 30; # httpd server timeout in seconds |
22 | | | |
23 | | | $testtime = 10; #maximum test time |
24 | | | |
25 | | | $lospd = $nkba/$svrtimeout; |
26 | | | |
27 | | | print "<center>\nIf no speed information is given then either your connection is too slow (< $lospd kiB/s) or you are experiencing signal dropouts. <br>\n"; |
28 | | | |
29 | | | print "Sending"; |
30 | | | |
31 | | | $tm1 = time; |
32 | | | |
33 | | | for ($f = 1; $f <= $nkba; $f++) { |
34 | | | print "<!--"; |
35 | | | for ($g = 1; $g <= ($kb/2-9) ; $g++) { print "aa"; } |
36 | | | print "-->. "; |
37 | | | } |
38 | | | $tm2 = time; |
39 | | | $nkb = $nkba; |
40 | | | print "$nkb"; |
41 | | | print "kiB"; |
42 | | | |
43 | | | if ( ($tm2-$tm1) < $testtime ) |
44 | | | { |
45 | | | for ($f = 1; $f <= $nkbb; $f++) { |
46 | | | print "<!--"; |
47 | | | for ($g = 1; $g <= ($kb/2-9) ; $g++) { print "bb"; } |
48 | | | print "-->. "; |
49 | | | } |
50 | | | $tm2 = time; |
51 | | | $nkb = $nkb + $nkbb; |
52 | | | print "$nkb"; |
53 | | | print "kiB"; |
54 | | | } |
55 | | | |
56 | | | if ( ($tm2-$tm1) < $testtime ) |
57 | | | { |
58 | | | for ($f = 1; $f <= $nkbc; $f++) { |
59 | | | print "<!--"; |
60 | | | for ($g = 1; $g <= ($kb/2-9) ; $g++) { print "cc"; } |
61 | | | print "-->. "; |
62 | | | } |
63 | | | $tm2 = time; |
64 | | | $nkb = $nkb + $nkbc; |
65 | | | print "$nkb"; |
66 | | | print "kiB"; |
67 | | | } |
68 | | | |
69 | | | if ( ($tm2-$tm1) < $testtime ) |
70 | | | { |
71 | | | for ($f = 1; $f <= $nkbd; $f++) { |
72 | | | print "<!--"; |
73 | | | for ($g = 1; $g <= ($kb/2-9) ; $g++) { print "dd"; } |
74 | | | print "-->. "; |
75 | | | } |
76 | | | $tm2 = time; |
77 | | | $nkb = $nkb + $nkbd; |
78 | | | print "$nkb"; |
79 | | | print "kiB"; |
80 | | | } |
81 | | | |
82 | | | if ( ($tm2-$tm1) < $testtime ) |
83 | | | { |
84 | | | for ($f = 1; $f <= $nkbe; $f++) { |
85 | | | print "<!--"; |
86 | | | for ($g = 1; $g <= ($kb/2-9) ; $g++) { print "ee"; } |
87 | | | print "-->. "; |
88 | | | } |
89 | | | $tm2 = time; |
90 | | | $nkb = $nkb + $nkbe; |
91 | | | print "$nkb"; |
92 | | | print "kiB"; |
93 | | | } |
94 | | | |
95 | | | print "<br>\n"; |
96 | | | |
97 | | | $adresa = "$ENV{'REMOTE_ADDR'}"; |
98 | | | $server = "$ENV{'SERVER_NAME'}"; |
99 | | | |
100 | | | print "\n<P>"; |
101 | | | $time = ($tm2-$tm1); |
102 | | | printf "Sent $nkb kiB from $server to $adresa in $time seconds<br>\n"; |
103 | | | print "Approximate download bandwidth speed of your connection is: "; |
104 | | | #to not divide accidentaly by zero we accept inacurrancy of 0.001s |
105 | | | $speed = $nkb*$kb/($tm2-$tm1+0.001); |
106 | | | $speedkb = $speed/$kb; |
107 | | | $speedkbps = 8*$speed/$kb; |
108 | | | printf "%.2f B/s = %.2f kiB/s = %.2f kib/s\n", $speed, $speedkb, $speedkbps; |
109 | | | $date = `date`; |
110 | | | print "<BR>$date\n<BR>"; |
111 | | | print "<A HREF=\"http://bbs.cvut.cz/~covex/czfree/index.html\#bander\">Bander speed test</A>\n"; |
112 | | | |
113 | | | print "</center></BODY></HTML>"; |