[bittorrent] structure of multifile bittorrent file

Alan McGovern alan.mcgovern at gmail.com
Fri Apr 9 19:09:52 EDT 2010


In the bittorrent protocol you treat all the files in your torrent as
if they were one continuous file. This single continous file is split
into pieces (in your case of size 256kb) and hashed. The final piece
will be <= 256kB. It has no special handling except for the fact that
it is not guaranteed to be exactly 'PieceLength' bytes in size as all
other pieces are. In all other ways, the last piece is identical to
every other piece.

Blocks are always 16kB (as per defacto standard) except for the very
last block which will be <= 16kB. As before, this has no special
handling except for the fact its size may be less than 16kB whereas
all other blocks are guaranteed to be 16kB in length. In all other
ways it is identical to other blocks

Hope that helps.

Alan.

On Fri, Apr 9, 2010 at 10:51 PM, Song Zhang <songzhang2008 at gmail.com> wrote:
> Hi,
> I have a question about the structure of multifile torrent file
> for example, I have two files a and b, and put them into one directory. I am
> trying to create one torrent file including the contents of these two files.
> I am wondering how the system handling the last piece less than 256k for
> each file of a and b,
> size(a) = n * 256k + a1
> size(b) = m * 256k + b1
> a1 and b1 above all less than 256k
> the question is:
> 1. when generating torrent files, for the ”pieces“ part of info dictionary
> of torrent file, there should be two SHA1 value from pieces less than 256k,
> right ?  Although the SHA1 value of each piece (no matter greater or less
> than 256k) is always 20bytes.
> 2. but I don't understand during the data transfer period, the pieces are
> divided into blocks and how to handle these pieces less than 256k ?
> thanks a lot for the help !!
> _______________________________________________
> BitTorrent mailing list
> BitTorrent at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/bittorrent
>
>



More information about the BitTorrent mailing list