Search code examples
linuxunixbandwidth

Bandwidth Calculation in Mbps


Can someone check this calculation?

I want to calculate the speed of my internet connection by downloading a file from a remote server.

My time unit is in 1/60th of a second. Let's say the file on the remote server is 32K.

timeBegin = ticks <- 1/60th of a second since beginning of some date
get.url( file )
timeEnd = ticks

Mbps = ( size of file * 8) / ( timeEnd - timeBegin ) / 60 / 1048576

Does anyone know of a way to test bandwidth (upload/download) from the command line (unix)?


Solution

  • Your calculation is not quite correct, you are missing some parentheses.

    Mbps = ( size of file * 8) / ( ( timeEnd - timeBegin ) / 60 ) / 1048576
    

    I see DasBoot already pointed out some of the potential sources of inaccuracy in this method. I'll just add to #2 that the critical bandwidth limitation may also exist at some hop in between you and the server.