View Feed
group-icon
Coffee Room
Discuss anything here - everything that you wish to discuss with fellow engineers.
12838 Members
Join this group to post and comment.
Kaustubh Katdare
Kaustubh Katdare • Oct 31, 2008

How does 'resume download' work?

I've had my experience of losing about 600 mb of ubuntu .iso file while downloading from the Internet. So I'm now thinking can anyone explain how the 'resume download' works?

What I want to know is this -

1. How does server/client software keep track of bytes transferred. I've noted that the server must also support 'resume download' functionality.

2. How does the download resumes exactly the place where the download was paused [​IMG].

I think not many have ever cared to know how it works.
parihar888
parihar888 • Oct 31, 2008
hi big k

while sending any msg or any data like resume at both end of server / client
the is a role play of parity bit in the header if both the bits received at the end are same then downloading is OK ,.,.
sriramchandrk
sriramchandrk • Nov 3, 2008
1. Let me start with how download manager gets to know the size of the requesed file and if server supports resume download.

Similar to GET header to get the required html page, we have something called as HEAD header.

When you send a HEAD request for an URL we get a set of values for the URL

Example: if you want to know details of
https://www.wgz.org/chromatic/perl/IntroTestMore.pdf

Send a head command to the URL
the response will be
Date: Mon, 03 Nov 2008 06:29:09 GMT
Accept-Ranges: bytes
ETag: "156046f-11889-3a578cd2bf2c0"
Server: Apache
Content-Length: 71817
Content-Type: application/pdf
Last-Modified: Thu, 11 Jul 2002 04:53:07 GMT
Client-Date: Mon, 03 Nov 2008 06:29:10 GMT
Client-Peer: 167.168.132.148:8080
Client-Response-Num: 1
Intresting Values:Accept-Ranges, Content-Length

Accept-Ranges: bytes 'tells that server is ready to give files part by part as requested!'

If this doesn't appear then most probably the server will not allow resume download.

Content-Length:71817
This tells the size of the pdf file. Useful to find how much is still left to download while resuming. (infact from which byte we need to download.

2. Now since download manager knows that this server supports download by parts(resuming as well).

Explaining Steps done by Download manager(for only one split):
1. Connects to www.wgz.org on port 80(where ever http is running) using a tcp connection.
2. Sends following text.

GET /chromatic/perl/IntroTestMore.pdf\n\n
3. The server starts sending some headers followed with file contents.
4. If you stop the download though the interface given the
- download manager disconnects the connectino
- prepares the temp file for the file downloaded (partly) and also keeps a track for how much got downloaded for example let it be 10000 bytes.


Resuming!:
Now when you click on resume download the download manager does:
Step 1. same as above
2. Sends the following text
GET /chromatic/perl/IntroTestMore.pdf\n
RANGE: bytes-unit = 10001\n\n
here bytes-unit specifies from which byte the files is required.
There are called range byte headers.

3. The server starts sending some headers followed with file contents(starting from 10001 byte instead of from beginning of file!).
4. Download manager starts appending the bytes recieved to previous temp
file.
5. Once total file is downloaded the DM changes the temp file to actual file name which could be used (file is now usable).

You can see http rfc for more details.


Now you could think how the splits work.
Actuall each download manager thread downloads part of file by specifying ranges and once everyone is done they join all the splits to give a complete file.
Thanks & Regards
Sriram

Share this content on your social channels -