Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question

migrated from 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.

share|improve this answer

You must log in to answer this question.