Solved

How do I detect the network speed of a visitor?

Posted on 2006-06-28
4
222 Views
Last Modified: 2013-12-24
Hello,
How do I detect the connection speed of a user that is visiting my page. Baiscally I want to know if they are dial-up, or high-speed of some sort. I need this for an analytics packaage I am writing.

Worth 500 points.

Thanks,
Rick
0
Comment
Question by:richardsimnett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Expert Comment

by:aseusainc
ID: 17006310
You cant get that info directly.  Best you could do is create a bandwidth test, by maybe having them upload a file, and determining the time it took to upload X bytes.  But there is no #users_connection_speed# type variable.
0
 

Author Comment

by:richardsimnett
ID: 17106714
aseusainc,
I have found that the solution is to purchase an aggregate database containing ip ranges, and associated net speeds. Its simply a matter of having this table in a database, and querying the incoming IP against it. It has proven to be about 90% accurate so far.

-Rick
0
 
LVL 7

Expert Comment

by:aseusainc
ID: 17107762
Spiffy, what database did you end up going with?  The ones I saw seemed pretty darn pricey :(
0
 
LVL 1

Accepted Solution

by:
abogothy earned 500 total points
ID: 17210662
I've found a solution which is simple, but gives usable connection speed info. Put lines following lines into php:

function microtime_diff($a, $b) {
list($a_dec, $a_sec) = explode(" ", $a);
list($b_dec, $b_sec) = explode(" ", $b);
return $b_sec - $a_sec + $b_dec - $a_dec;
}

function test_speed($test_size) {
flush();
$start_time = microtime();
$comment = "<!--O-->";
$len = strlen($comment);
for($i = 0; $i < $test_size; $i += $len) {
echo $comment;
}
flush();
$duration = microtime_diff($start_time, microtime());
if($duration != 0) {
return $test_size / $duration / 1024;
}
else {
return log(0);
}
}

$speed = test_speed(1024);
if($speed > 50) { // a fast connection, send more byte for more accuracy
$speed = test_speed(10240);
if($speed > 500) { // a really fast connection, send even more byte for
more accuracy
$speed = test_speed(102400);
}
}
echo sprintf("Download speed is %0.3f kb/s", $speed);
0

Featured Post

Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question