Solved

How do I detect the network speed of a visitor?

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

17 Experts available now in Live!

Get 1:1 Help Now