Connection Speed

Phreak

Well-known member
Joined
Jun 7, 2002
Messages
62
Location
Iowa, United States
Anyone have any idea how you could detect the connection speed of someone viewing your website?

AND calculate the estimated time for a download of a certain file. I thought about trying to ping the ip of the connection and do some math, but thats not a correct way to configure bandwidth. Anyone have any ideas about how to accomplish this?
 
Nice idea, but I think firewall and proxy problems would make any such attempt not worth it.
 
I found this Javascript function and it seems to be working. If anybody finds any flaws in it, PLEASE let me know. I cant seem to find any.

<html>

<head><!-- Do not cache this page -->

<meta http-equiv="Pragma" content="no-cache">
<title>Speed Test - Graphics</title>
</head>
<!-- This function computes the time it took to load up the page -->
<script language="JavaScript">
function results()
{
var time2, timed, thruput, title

time2 = new Date()

//Calc difference and convert from msec to sec.
timed = (time2.getTime()-time1.getTime()) / 1000

/* Calc Kbps using formula:

[throughput (in Kbps)] = [file size (in bytes)] * 8 / [elapsed time] / 1000

*/
thruput = (225455 * 8) / timed / 1000

document.open() // Stops the page from loading.
document.close() // Turns off the hourglass.

title = "Speed Test - Graphics"
document.write("<html><meta http-equiv=Pragma content=no-cache><title>" + title + "</title>")
document.write("<body bgcolor=#FFFFFF>")
document.write("<h1 align=center>" + title + "</h1>")
document.write("<font size=4><center>Loaded 225,455 bytes in " + (timed) + " seconds.</center>")
document.write("<center>Your throughput is <B>" + Math.round(thruput) + "</B> Kbps.</center></font>")
document.write("<hr noshade>")
document.write("<p align=center>" + document.location + ">Run Test Again</a></p>")
document.write("</html>")
}
</script>


<body onload="results()" bgcolor="#FFFFFF">
<!-- Start timer -->
<script language="JavaScript">
time1 = new Date()
</script>


<p align="center"><big><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Speed
Test - Graphics</b></font></big></p>
<p align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Loading
225,455 bytes (compressed JPEG)... please wait.</font></b></p>

<hr noshade>
<font face="Arial, Helvetica, sans-serif">
<!-- defeat the browsers image cache by appending a timestamp -->
<script language="JavaScript">
imgLocation = "images/test.jpg" + "?" + time1.getTime()
document.write("<p align=center><img src=" + imgLocation + " align=center width=256 height=256 alt=Loading 225,455

bytes...></p>")

</script>
</font>
<hr noshade>
</body>
</html>
 
Back
Top