Solved

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

Posted on 2006-07-20
3
269 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now