Search code examples
javabittorrenttorrent

BitTorrent sequential piece download


I am trying o implement a bit torrent client in Java that downloads pieces sequentially. the idea is that It can let me play downloaded media content(videos and songs) content before the actual download is finished.

Is it possible to do this with the bit torrent protocol?


Solution

  • Is it possible to do this with the bit torrent protocol?

    Yes, but it is discouraged since it makes bittorrent as a whole less efficient.

    Read section 2.4 of the bittorrent economics paper, especially subsection 2.4.2 titled Rarest First why it is important to randomize piece selection.

    That said, if you can determine a swarm is healthy (high minimum piece availability, high sustained download rate) then you can dedicate part of your download bandwidth to sequential piece selection if and when sequential downloading is needed.

    This can be best achieved by implementing a virtual filesystem (via FUSE or java's nio2 filesystem API) that downloads pieces on demand. When there is no demand then there won't be a need to fetch sequentially either.