[bittorrent] structure of multifile bittorrent file

Harold Feit dwknight at depthstrike.com
Fri Apr 9 19:05:12 EDT 2010


Multiple files that are smaller than a single piece are all contained
within the piece.

Cross-file pieces occur when the last byte of a file does not fall
exactly on piece boundaries.

Song Zhang 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.
No.
http://wiki.theory.org/BitTorrentSpecification#Info_in_Multiple_File_Mode
You generate a cross file piece when you hit a file boundary within a
piece boundary. Only one piece is generated.
> 
> 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 ?
Requests are made in 16384 byte blocks chosen by piece index then by
block index within the piece.
> 
> 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