mapa17 / Eruliaf

A BitTorrent like overlay peer simulator
GNU General Public License v3.0
1 stars 0 forks source link

Create torrent class #4

Closed mapa17 closed 12 years ago

mapa17 commented 12 years ago

Create a torrent class which describes different torrent properties like

Torrent size ( bytes ) Block size ( bytes ) Piece size (bytes )

And a binary bitmap of pieces

mapa17 commented 12 years ago

Implemented a torrent class that can be parameterized in the size of the torrent ( bytes ).

Block size and the number of pieces per torrent is fixed. Hence the number of blocks per piece is calculated depending on the torrent size.

blockSize = 512 bytes nPieces = 500

e.g. nBlocksPerPiece = (TorrentSize/nPieces) / blockSize

A dictionary is keeping track of the pieces downloaded and finished. Helper methods can be called to receive a subset of the piece set containing either only the finished, the downloading or the empty pieces.