[BitTorrent] Really random?

Arvid Norberg c99ang at cs.umu.se
Wed Jul 14 17:47:13 EDT 2004

John Prevost wrote:
>>This is, roughly, the algorithm I employ in libtorrent, I'm pretty sure
>>it's the same for all clients supporting this kind of storage.
> *blink*
> Well, I can tell you for a fact that neither the standard Python
> client nor Azureus do it that way.  They just make use of sparse
> files--they seek to the position of the received data and write it
> out.  The OS decides whether or not the file is fully allocated to
> that size or if only the blocks needed for the data actually written
> are used.  (Both Unices and Windows 2k do support sparse files, not
> sure about other OSs.)

Wouldn't it take a long time to scan a file (when resuming) if you just 
got the last piece of, say, a 4 gig file? Or do those clients also ask 
for which parts of the file that are actually writen?

I believe John Hoffman's client (TheSHADOW's client) was the first one 
to support this no-preallocate-mode, and I also believe that this was 
the algorithm he used.

I haven't looked into anyones source code, this is just what I've heard 
off the irc channel.

> The system you describe sounds... rather hairy, really.  When you scan
> a file to see what has been received so far, do you scan each piece
> and see if its hash is in the list to recall which piece it is?  Or do
> you write the information about which pieces reside where to a file
> somewhere?  How do you handle multi-file torrents?

I scan at the start and caches the piece index at each slot, and then 
remember which piece is stored where.

the mapping of slots to actual files is beneath another layer of 

Arvid Norberg

------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70

Yahoo! Groups Links

<*> To visit your group on the web, go to:

<*> To unsubscribe from this group, send an email to:
    BitTorrent-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

More information about the BitTorrent mailing list