Linux-Based, Open-Source, Speed-Test Module

internetlinuxopen source

I am setting up diagnostic servers on local networks (Redhat 5.5). One requirement is a speed test where users in the network can test the speed of their internet connection (e.g., http://speedtest.net/ ).

I have been given the impression that their are open source solutions that I can use. I'm not sure yet if it makes a difference, but sometimes users might be accessing the speed test through a web page and sometimes the users will get the data from a Java application I am building.

Best Answer

A few years back I just home-rolled a very simple one with a static html file, javascript, and a couple of jpegs. It only does the download speed check (not the ping or upload speed check). The interesting parts of the web page are as follows:

The javascript portion:

<script language="JavaScript" type="text/javascript"><!--

start = 0;
initDone = false;

testImageSize = 680314;
testImageName = 'test_image.jpg';

flippedTestImageSize = 680441;
flippedTestImageName = 'flipped_test_image.jpg';

fileSize = testImageSize;
fileName = testImageName;

document.testimage.src = fileName + '?t=' + start; 

function startTest () {
  start = (new Date()).getTime();
  if (fileName == testImageName) {
    fileSize = flippedTestImageSize;
    fileName = flippedTestImageName;
  }
  else {
    fileSize = testImageSize;
    fileName = testImageName;
  }
  document.testimage.src = fileName + '?t=' + start; 
}


function finishTest () {
  end = (new Date()).getTime();

  secondsTaken = (end - start) / 1000;

  connectSpeed = (Math.floor((((fileSize * 8) / secondsTaken) / (1024 * 1024)) * 10) / 10);

  if (initDone) {
    with(document.testForm){
      downloadTime.value    = secondsTaken;
      imageFileSize.value   = fileSize;
      connectionSpeed.value = connectSpeed;
    }
  }
  else {
    initDone = true;
  }
}

//--></script>

The form:

<form name="testForm">
  <table style="padding: 5px;">
    <tr>

      <td><input type="button" name="dotest" value="Do Test" onClick="startTest()"></td>
    </tr>

    <tr>
      <td class="lbl">Image download time (s):</td>
      <td class="inp"><input type="text" name="downloadTime" readonly="true"></td>
    </tr>

    <tr>

      <td class="lbl">Image size (bytes):</td>
      <td class="inp"><input type="text" name="imageFileSize" readonly="true"></td>
    </tr>

    <tr>
      <td class="lbl">Estimated speed (Mbps):</td>
      <td class="inp"><input type="text" name="connectionSpeed" readonly="true"></td>
    </tr>

  </table>
</form>

And finally, somewhere in the page is:

<img name="testimage" src='test_image.jpg' width="400" alt="" onLoad="finishTest()">

While I have neither the need or interest in making it fancier, I wouldn't think it would be too hard make a page that had some additional bells/buzzers on it...