?
Solved

How do I detect the network speed of a visitor?

Posted on 2006-06-28
4
Medium Priority
?
226 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 2000 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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

650 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