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 ?
1 Answer
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.