[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1171
  • Last Modified:

Detect internet speed with php

Is it possible to know the internet speed of the visitors with php?
0
siva_siva
Asked:
siva_siva
  • 4
1 Solution
 
keteracelCommented:
I found this in http://www.2wire.com/bandwidth/initialmeter.php

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

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

<script>
<!--
      time      = new Date();
      starttime = time.getTime();
// -->
</script>
<!-- a large amount of data here.... try a shakespeare play? -->
<script>
<!--
      time          = new Date();
      endtime       = time.getTime();
      if (endtime == starttime)
            {downloadtime = 0
            }
      else
      {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;
      document.location.href=nextpage
// -->
</script>
</body>
</html>

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.
0
 
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...
0
 
keteracelCommented:
I've tried it 5 times:

3.08Mbps
3.17Mbps
3.13Mbps
3.13Mbps
3.19Mbps

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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
keteracelCommented:
Might be worth doing several tests, throwing away the fastest and slowest, then average the rest. Give you a better metric.
0
 
nizsmoDeveloperCommented:
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 :-)
0
 
keteracelCommented:
Well you'd ideally start with a small file then increase it to get more accurate results for faster bandwidths.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now