views:

572

answers:

2

I have an app that calls my ASP.NET page on my server, every 30 seconds. I want to use this for two purposes:

  1. Graph the uptime of my client
  2. Graph the average bandwidth from my client to the server

What is the best way to calculate the bandwidth (in bytes per second) from the client to the server?

I assume that I record the time, call the page, wait for a response, then get the time again, compare the times and calculate the bandwidth... but how to calculate the bandwidth?

A: 

Calculate it this way: size of file (in KB) / elapsed time (in sec). That gives you KB per second (KB/s). It's a bit different than kbps, but I think it's more useful to the average user. Be sure to use a large enough file. Something large enough where you're pretty sure the elapsed time will be at least a few (3-5 maybe) seconds.

kbyrd
The problem with this, is that if I continue to do it every 30 seconds, I'm going to inadvertingly kill my bandwidth (it is not great as it is). Ideally, I could be very precise and send a very little bit of payload.
Jason
Bandwidth is often very spiky. I wouldn't really trust a little bit of payload. Maybe a better approach it to keep stats on real data sent between the two, and send the file only if not enough data has gone between the client and server.
kbyrd
I understand, but that isn't going to work either. This is an office, and I would have to track all the internet activity, etc...
Jason
+1  A: 

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

Robert Harvey