throughput networking estimation
===

How could I estimate the instantaneous throughput ? For example, in a way similar to what the browser does when downloading a file. It's not just a mean throughput, but rather the an instantaneous estimation, maybe with a 'moving average'. I'm looking for the algorithm, but you can specify it in c++. Ideally, it would not involve a thread (i.e., being continuously refreshed, say every second) but rather be only evaluated when the value is asked. 