[p2p-hackers] Re: Control network file transfer rate
Raphael Manfredi
Raphael_Manfredi at pobox.com
Thu Feb 23 16:53:25 UTC 2006
Quoting Greg Bildson <gbildson at limepeer.com> from ml.p2p.hackers:
:You might want to look at our BandwidthThrottle, ThrottledOutputStream
:classes and the use of BandwidthThrottle elsewhere (HTTPDownloader,
:NormalUploadState, etc). We built off of some earlier FreeNet techniques.
:There is some added complexity along the way but I believe we handle things
:elegantly overall.
Doing b/w allocation on a per-stream basis is sub-optimal and may lead
to non-full utilization of the configured total b/w.
If you can read C, thre's a more complex bandwidth scheduler at:
http://tinyurl.com/q3toe
Start with bsched_heartbeat(). The idea is the scheduler knows
the whole set of file descriptors that want to emit. But not all
can emit at some time (kernel buffers full or flow-controlled), so
the b/w is more evenly distributed among the other files.
Also, from the application layer, you can control how much you
write, but you have really no control on what TCP will do (retransmits,
ACKs, etc...). So all you can do is try to emit *on average* what
the user has configured.
Hence the use of EMA in the code trying to balance things to absorb
peaks.
Raphael
More information about the P2p-hackers
mailing list