Detect internet speed with php

Is it possible to know the internet speed of the visitors with php?
Who is Participating?
keteracelConnect With a Mentor Commented:
I found this in

it's basically javascript and a large html file but should give a good indication.

<<<----- put your HTML for the page here, saying something like "processing". Include an animated gif to make it look like something's happening....

      time      = new Date();
      starttime = time.getTime();
// -->
<!-- a large amount of data here.... try a shakespeare play? -->
      time          = new Date();
      endtime       = time.getTime();
      if (endtime == starttime)
            {downloadtime = 0
      {downloadtime = (endtime - starttime)/1000;

      kbytes_of_data = 256; //set this to be the amount of data you put between the <!-- and -->
      linespeed     = kbytes_of_data/downloadtime;
      kbps          = (Math.round((linespeed*8)*10*1.024))/10;

      nextpage='meter.php?kbps=' + kbps;
// -->

So this will basically download the page (quite large) and then run the script to determine how long it took. Thus giving an estimated bandwidth. You could do something nicer with AJAX.
siva_sivaAuthor Commented:
Large amount of data means what i want to give in this?

I am also visit that site it display bandwidth speed irregularly.

420 kbps, 190 kbps and 556 kbps etc...
I've tried it 5 times:


It's pretty consistent. Seems like you've got a pretty variable connection. And I guess it will be more variable with smaller connections.

Also note that your internet traffic will not always go through the same route to the same webpage. So sometimes it'll be randomly slower anyway.
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Might be worth doing several tests, throwing away the fastest and slowest, then average the rest. Give you a better metric.
Wouldn't the downside though be that they would have to load the actual tester file? If I was on a 56k connection I wouldn't be too happy about that :-)
Well you'd ideally start with a small file then increase it to get more accurate results for faster bandwidths.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.