문제

I'm trying to understand the process inside BitTorrent and implement something similar. However, I still don't know the process of piece selection and transfer. How can each peer know that which peer has which file piece? Does each peer need to ask each other whether it has the requested piece or not all the time?

I have also heard about "rarest piece first" approach, which tries to get rarer piece before. How to get these information without wasting network traffic?

Thank you.

도움이 되었습니까?

해결책

This is done with two messages: bitfield and have.

  • After two peers perform a handshake, they can optionally send bitfields as their first messages, which compactly represent all of their completed blocks.

  • Once a peer successfully downloads and verifies a block, they broadcast a have message to all of their connected peers, letting them know which block they just completed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top