Solved

How do I detect the network speed of a visitor?

Posted on 2006-06-28
4
216 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now