Solved

What would be the most accurate method/procedure for accurately testing and displaying bandwidth?

Posted on 2006-07-20
3
271 Views
Last Modified: 2010-04-17
I realize that there are a lot of services online that can test bandwidth.  But, I'm curious what the best way to accurately program this would be for display on an ASP page...

0
Comment
Question by:boudog13
  • 2
3 Comments
 
LVL 15

Expert Comment

by:bpmurray
ID: 17146625
The basic algorithm is to measure the time it takes to download and to upload a blob of data, usually a file. The larger the file, the more accurate the measurement since you can average the time more easily. For example if you download a 10MB file in 20 sec, that amounts to 500KB/s, or 4Mb/s.

However, the accuracy is dependant on distance between the client and server. If there are a lot of hops, latency can be an issue.

Display, on the other hand, is really trivial - you simply set the value into the display.
0
 

Author Comment

by:boudog13
ID: 17195388
Is it possible to count hops and factor this into the calculation?

Can this be done using a scripting language like JavaScript?
0
 
LVL 15

Accepted Solution

by:
bpmurray earned 250 total points
ID: 17195737
I don't think you can count the hops, but I would expect to use JavaScript to send the files. Copying a file locally would require that you download a file of known size e.g. through an XMLHttpRequest, or by setting the src attribute on an IMG tag. For example, you could do this:

<HTML><HEAD>
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<SCRIPT type="text/javascript">

var XHR = null;
var start = new Date();
var fileLocation = "http://whatever.com/foo.txt";   // Put your filename here ...
var fileSize = 132110;                                         // ... and the file's size

function TimeDownload() {
    // branch for native XMLHttpRequest object
    if (window.XMLHttpRequest) {
        XHR = new XMLHttpRequest();
    // branch for IE/Windows ActiveX version
    } else if (window.ActiveXObject) {
         try {
            XHR = new ActiveXObject("Msxml2.XMLHTTP");
         } catch(e) {
            try {
                XHR = new ActiveXObject("Microsoft.XMLHTTP");
            } catch(e) {
                // nothing
            }
        }
    }
    if (XHR) { // The XHR is created OK
        XHR.onreadystatechange = function() {
            if (XHR.readyState == 4 && XHR.status == 200) {
               var end = new Date();
               var elapsed = end - start;
               alert(fileSize + "bytes took: " + elapsed + " milliseconds");
            }
        }
        XHR.open("GET", fileLocation, true);
        XHR.send("");
    }
}
</SCRIPT>
</HEAD><BODY>
<IMG alt="This is where the file is copied" id="myImg" />
<BR />
<INPUT type="button" onclick="TimeDownload();" value="Time Downloads" />
</BODY> </HTML>

0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question