2

I am attempting to create a speed test server that can be used across a LAN with speeds ranging from 10 Mbps (Wi-Fi) up to 10 Gbps (Servers in our datacenter) and can be accessed from Mac, Windows, iOS, and Android.

I'd like to test speed by downloading as much random data as possible over x seconds and calculating the speed based on that.

How can I do this using PHP and JavaScript? (I can use any server-side code if there is a far easier way in another language, I just prefer PHP for it's portability.)

I added a comment about previous solutions I've tried, I'll include there here to make it more clear.

I have attempted 4 other ways to do this previously:

1) speedtest.net's Mini Speed Test Server.

Problem - Requires Flash. Doesn't work with mobile devices.

2) WiseLoop JavaScript Bandwidth Tester

Problem - Not very accurate. More complicated than I need.

3) Generate x files of y MBs random data each in PHP, download the files sequentially, then calculate the average.

Problem - If I choose too small of a file then fast connections aren't as accurate. If I choose large files then slow connections take too long.

4) Generate 1 large file, download it, and calculate speed.

Problem - Takes too long on slow connections. Or has to be too small to effectively test fast connections.
Phillip Boushy
  • 445
  • 1
  • 4
  • 14
  • The easiest way is probably to have a big file that you download, and time how long it takes. You can calculate speed from that. Doesn't matter what language you write it in. Have you tried something like this and ran into a problem? – Krease Aug 05 '15 at 00:17
  • I've tried a few different methods: 1) Generate x random files of y MBs and download each sequentially. Then determine the average. 2) Generate 100 MBs and download it. Then calculate the speed. The problem with these methods is that 3 small files don't give accurate speeds on extremely fast connections (i.e. 10 Gbps) and 1 large file takes forever to download on a slow connection (i.e. 10 Mbps). – Phillip Boushy Aug 05 '15 at 00:27
  • So why not write it as a multi step process: start with 1kb (or some reasonably small amount). If it downloads in under 5 seconds, multiply by 10 and repeat. Keep repeating until you have a useful measurement. For lower bandwidth connections this will max out and stop earlier than the higher bandwidth ones. This is like a combo of attempts 3&4 you added in your edit. As a tangent, remember that at some point, the hard drive will be the bottleneck instead of the network... – Krease Aug 05 '15 at 01:16
  • If I can't find a way to stream "unlimited" data, then I plan on using that mechanism. I was hoping for something that would be extremely flexible and not require me to create files multiple times. – Phillip Boushy Aug 05 '15 at 23:47

1 Answers1

2

Sorry, I'd add a comment instead of an answer, but I don't have enough reputation yet... But maybe speedof.me will work instead of making your own? They have an API that's currently free to use.

Justin McAleer
  • 236
  • 1
  • 9
  • My understanding based on the description of that API is that it actually does the test against the speedof.me servers. We want to run the test against our servers. I could contact them and see what it would cost to host their speed test on a server here, but I'm looking for something that we control internally and can be altered based on our needs over time. – Phillip Boushy Aug 05 '15 at 23:54
  • Understood... maybe you could reverse engineer the client side, then. Their approach seems to take into consideration all of your issues and concerns. Good luck. – Justin McAleer Aug 06 '15 at 00:00