How does the client divide the file?

47 views Asked by At

The way I understand the torrent file format is that it contains a field pieces, which specifies a hash list of each piece's SHA-1 hash. But, does it specify how large each piece should be and at which byte the division should occur? How does the client know how to divide the original file?

Thanks

1

There are 1 answers

1
StilesCrisis On BEST ANSWER

You are looking for the "piece length" in the Info dictionary. Every piece is of equal length except for the final piece, which is irregular. The number of pieces is thus determined by 'ceil( total length / piece size )'.

https://wiki.theory.org/BitTorrentSpecification#Info_Dictionary