Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have been using uTorrent for a long time. I have used its "force recheck" feature countless time. Every time it surprises me how uTorrent successfully detects which parts of the file had been downloaded and which parts are yet to be downloaded. It checks them even if you are not connected to internet; so I presume that it doesn't download any data from internet to do this check.

Can you please explain me how this "force recheck" feature works. I think that a hash for every single piece is kept in the .torrent file; but I'm not sure, it is just a guess. I searched in Google with keywords "torrent file format" to find the file format of .torrent files, but instead it returned a lot of torrent search results. So Google is not my friend this time. Please explain it to me.

share|improve this question
1  
Your guess is correct. –  David Schwartz Nov 15 '12 at 13:48
add comment

1 Answer

up vote 2 down vote accepted

As I understand it, the torrent file contains a hash for each piece of the file you are downloading. It simply checks the hashes for each piece you think you have, against the checklist. Much like when you download a torrent, any piece that does not match is discarded.

In more detail, based off the bitorrent specifications you have your downloaded file, 'piece length' and 'pieces'. Piece length is the size of each piece, and pieces is simply the sha1 sum of each piece, appended to the previous piece to form a long string.

To simplify things, lets assume you preallocated the file, and you basically have a large 'padded' file of equal length to your source file. First, based off piece length, the program gets the first n bits of the file, and does a SHA1 sum. It then compares the SHA1 sum of the file to the corresponding part of 'pieces'. If they match, we're good. Else, its marked as no good and discarded.

share|improve this answer
    
Except that when you download over HTTP/FTP, the integrity is not usually checked automatically (unless you have a custom patching program that automatically runs a hash and compares it against the expected hash). Also, if the hash doesn't match for a normal download, you have to discard the entire file, not just a piece of it. –  allquixotic Nov 15 '12 at 13:43
    
oh, we're assuming bittorrent from the question arn't we? –  Journeyman Geek Nov 15 '12 at 13:45
    
you edited your answer... the original answer said something like "just like downloads" –  allquixotic Nov 15 '12 at 13:51
    
I meant torrent downloads and bad chunks - I only added in the last two paragraphs cause I wasn't happy with the original answer –  Journeyman Geek Nov 15 '12 at 13:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.