0

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.

1 Answer 1

2

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...

2
  • Thanks, I gave a thumbs up. I have played with the code a little and I like. I am splitting hairs a little, but I think it should be used with a large file size; the way I understand TCP is there is 2 'hello' ACKs and 1 request ACK before a file is finally transfered. That's three trips before data starts moving on the fourth ACK. I think a large file size might make this negligable though. Am I wrong in my understanding (anyone)? How would just the file transfer time be measured? I still need to measure upload time as well.
    – John R
    Nov 3, 2011 at 22:53
  • Glad it's useful. For our purposes we are mostly interested in variations from "typical" (as opposed to the actual numbers) as a way of flagging performance changes/problems on the LAN vs. problems with a users desktop. I would think a larger filesize would provide a more accurate measure. I don't see how you could split out the handshaking vs. file transfer times in the browser as that's happening at a lower level in the networking stack.
    – gsiems
    Nov 4, 2011 at 2:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .