Calculating Bandwidth

How to calculate bandwidth?

A bit of background: Bandwidth is the maximum amount of data that can be transmitted per unit of time. Bandwidth these days is typically expressed in megabits per second. That said, bandwidth connections can be symmetrical meaning that upload and download capacity is the same, or asymmetrical where the download and upload capacity is not the same. For asymmetrical connections (which includes most broadband connections) the upload capacity is smaller than the download capacity, yet it is the faster download capacity that is normally quoted.

Tx and Rx rates are also expressed in bits per second.

As a first approximation I would take the higher of the Tx and Rx rate and call that your bandwidth requirement.

Better would be to say that your bandwidth requirement equals your Rx (receiver) rate for download and Tx (transmission) rate for upload. (Remembering that most broadband connections are asynchronous, and the upload rate is often hidden away in the small print.)

In reality you never want to run at 100% of your bandwidth and there are always other things on the network that use your bandwidth, so give yourself a margin on top.

weird result calculating memory bandwidth from a nvprof output

Compiler was optimising away memory reads. It was pointed out by Robert Crovella. Thank you for your help - I would never guess it.

Detailed:

My compiler was optimising away val variable and by extension memory reads.

Calculating bandwidth speed of data sent/received over a socket?

The best you're probably going to be able to easily do is to record when you start writing and then count bytes you've successfully sent to the Socket.getOutputStream.write() method. For a small amount of data, that will be very inaccurate as it's just filling up the OS's transmission buffer which will initially take bytes much faster than it actually sends them.

It should amortize to essentially the correct rate over a fairly large amount of data, however.

Formula for Calculating bandwidth

First of all for precision's sake, you should use 1000.0 to convert to seconds since you are assigning your bandwidth to a float variable:

float bandwidth = (contentLength / (endTime-startTime)) / 1000.0;

Now since your contentLength is measured in bytes, you need to convert to bits (Kb, Mb, etc). There are 8 bits to each byte and socontentLength*8 converts bytes to bits.

Kilo->Mega->Giga ->... scale conversion for the unit of bits is on the order of 1000 which means converting bits to Megabits requires a division by 1000*1000. All this put together should yield:

int bits = contentLength * 8;
int megabits = contentLength / (1000*1000); //Megabits
float seconds = endTime-startTime / 1000.0;
float bandwidth = (megabits / seconds); //Megabits-per-second (Mbps)

EDIT #1: If bandwidth is denominated by Bytes/Time (like KB/s for example), scale conversion is on the order of 1024

int bytes = contentLength;
int kilobytes = contentLength / 1024; //Kilobytes

EDIT #2: The definition of "Mega" and "Kilo" etc. when talking in terms of bandwidth can be somewhat ambiguous I am realizing. Often times 1024 (210) and 1000 (103) may be used interchangeably (most likely an accident). For many cases 1024 may be favored as the order of magnitude when calculating bandwidth as memory storage space on computers is measured in base 2. However network bandwidth is usually controlled by the clock speed of a CPU which regulates the transmission of bits, and this rate is measured in hertz (MHz to be exact) which is on the order of magnitude of 1000, not 1024. However in most cases, these two numbers are close enough to not produce significant error.

Formula to calculate bandwidth used in Java

I ended up using this formula:


long bandwidthUsed = (totalBytes / 1024) / elapsedTimeSeconds;

Calculating the bandwidth between a client and the server?

If you are trying to figure out how much bandwidth your proposed 30-second plan is consuming, a rough guesstimate is page size * number of executions in a minute (in your case, 2) divided by 60 (number of seconds in a minute), times 8 (number of bits in a byte) for bits per second. Does not include overhead.

If you want to know what your server load is, there are better tools for that, and you can roll your own if you wish. See http://www.codeproject.com/KB/aspnet/JavascriptBandwidthMeter.aspx



Related Topics



Leave a reply



Submit