Solved

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

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This is about my first experience with programming Arduino.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
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 …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

19 Experts available now in Live!

Get 1:1 Help Now