I am bit confused about the PIECE size specification in BitTorrent protocol. To be specific, the torrent metainfo file, I am experimenting with, says that each piece should be 65536 bytes (except the last one which is (total_file_size - remaining bytes)). But the length of PIECE messages arriving is 16384 bytes, with the same number of pieces as specified by metainfo file. It happens with every torrent - PIECE size specified by metainfo file is different from the size of PIECE messages arriving. Am I missing something in the protocol ?
migrated from stackoverflow.com Jun 7 '11 at 13:53
This question came from our site for professional and enthusiast programmers.
The PIECE message is used to transfer a part of a piece, which is commonly called a block. Most implementations seem to use a block size of 16K, which explains the behaviour you observed. The block size is set in each REQEUEST message.
For more information on this part of the BitTorrent protocol, I highly recommend this wiki page.