How speed limit on BitTorrent protocol works?

0

I am curious about the BitTorrent protocol. A lot of software implemants this protocol like µTorrent, Vuze, qBittorent...

Each of these software purpose a functionnality : Speed limit.

For example, If my maximum donwload speed is 3000 KB/s, I can limit the speed at 1500 KB/s or 500 KB/s without diminuate the number of source (seed). How this speed limits works ?

Anonyme

Posted 2020-01-04T10:36:49.817

Reputation: 120

Answers

4

I can't say for sure if all of these programs do it in the same way, but I looked at the libtorrent source-code (which is the library used by most of them to implement the BitTorrent protocol) a few years ago and libtorrent handles it like this:

The library maintains an avarage upload and download number while it is doing its work. When the limit (either upload or download) is reached the software simply holds operation for a short time-period, until the average upload/download drops a bit below the limit and then it resumes again.
It doesn't just drop traffic when the limit is reached. Especially downloads of chunks that started just before the download limit came into effect will still be received.
This also means it will never hover exactly on the limit, but it will overshoot a little bit, drop below, overshoot again, etc.
Holding operation for downloads means: Simply NOT requesting a new chunk to download from any peer. For uploads it means refusing requests for uploads from other clients. (The BitTorrent protocol has provisions for telling the other end "I have that chunk for you but not right now. Try again later.")

P.S. There are some exceptions to the logic above. Especially for "slow movers" with a very low amount of peers, that are in some cases allowed through anyway so they have a better chance of propagating through the BitTorrent network.

P.S. P.S. In was 3-4 years ago I went through the libtorrent source, but to my knowledge this hasn't really changed much and my information is still valid.

Tonny

Posted 2020-01-04T10:36:49.817

Reputation: 19 919

Nice explanation. – Moab – 2020-01-04T16:07:51.233