1. Current Location: Home >  Router Encyclopedia >  Break point relay and packet capture: Range and 206 work together so well, disconnect and keep going

Break point relay and packet capture: Range and 206 work together so well, disconnect and keep going

Breakpoint resume schematic: Range requests to split into 4 segments in parallel to download and reassemble the original file, md5 matches, 206 and 416 status code dialogue

Last month, I helped my cousin install a Feiniu image, and with over four GB, 97% of the time his device tripped. After the call, he stared at the downloader's "Continue" button and asked: Should I start over from the beginning, or continue from 97%? If you start over, is the app showing '3.9G downloaded' just a scam?

I used to be vague about this too. After watching it carefully, I finally understood: resume at breakpoint isn't a magic invented by the downloader itself, but a pair of partners written long ago in the HTTP protocol—the Range request header and the 206 status code. Today, I'll break down this duo and explain it clearly, and also explain why multithreaded downloaders are fast.

First, break down the three "cut sections" so they don't get

mixed up.

Continuing the chat break point can easily be confused with the other two "cut pieces," so draw a clear line first.

One is packet fragmentation at the cable level. Your broadband MTU is 1500, but large packets need to be disassembled at the network layer. That's a matter between routers, not the downloader. Previously, I wrote an article about specifically what MTU means.

The other is that the application layer cuts its own blocks. Video sites split a video into thousands of 10-second files—that's HLS's way of playing. How can you just drag the progress bar and count through videos? 64 clips were cut in 10 minutes. BT downloads also split into 1MB blocks themselves, each with fingerprint verification, the magnetic link is the same set you can see. The "blocks" from these two companies are real, independent files, each set up separately.

But HTTP breakpoint resume is different: there's only one complete file on the server, and no one has cut it. The downloader says in the request, "I only want bytes to bytes," and the server cuts a segment from the same file for you on the spot. The files haven't changed; what changes are the way you want.

How does Range request

arise? How does the server respond

?

I used a 39,050-byte graph from my own site to run an experiment, adding a line of Range to the request header to see how the server responds.

For the first 1024 bytes, write Range: bytes = 0-1023. The first line of the server's reply is 206 Partial Content—note it's not 200, 200 means "the entire file is for you," and 206 is "The part you wanted." Followed by a line of Content-Range: bytes 0-1023/39050. The 0-1023 before the slash is the segment actually given this time, and the 39050 after the slash is the total length of the text. When it landed, it was exactly 1024 bytes—not a cent more.

If you want a tail, write Range: bytes=38026-, leave the ending in, the server will automatically fill in to the end of the file. The reply is still 206, Content-Range: bytes 38026-39049/39050, landing 1024 bytes. There is also a variant of this "no beginning to write": bytes = -1024 means "last 1024 bytes," which is popular when the downloader checks file endings.

What if it's a segment that doesn't exist? I deliberately set bytes = 99999-, so the total files are only 39,050. The server replied with a 416, with Content-Range: bytes */39050 in the reply—the asterisk means "The paragraph you want doesn't exist, but the whole text is this long, do it yourself."

This 416 Eye Whites have another clever use. I ran wget -c again on a fully downloaded file. It locally recorded "39050 bytes," so it asked for bytes=39050-—from the end of the file, which means it got a segment that doesn't exist. Server returns to 416, carrying bytes */39050. Wget understood as soon as it appeared: the file length I wanted was exactly the file length, not a single byte missing, downloaded and done. In the resume log, 'confirm complete' is done just like this—not by counting bytes until it's enough, but by asking for one more time, letting the server stamp it with 416. 206 is responsible for stamping Duan and 416. These two brothers mentioned their names in the status code ledger 404 and 502. This is where they actually work.

By the way, I previously wrote that HTTP has encryption layers difference between HTTP and https. The rules for the range segments are the same under both protocols, and what you see when capturing packets is the same.

Before resuming the transfer code: Is the file still the same file

?

I know it's about to be a segment. How do you reconnect the disconnected download? Actually, it's just three steps: the downloader stores the number of downloaded bytes locally. For example, if it drops to 3.9G and it breaks, resume by sending Range: bytes=4187593088-. The server pays from the breakpoint backward, and the received bytes are appended directly to the end of the local file.

But here's a hidden pitfall: Are the files on the server still the same as before? If the webmaster updates the file in the middle and you have 3.9GB as the old version's head, then the new version's tail, you can piece together a mismatched mess, installing the system and causing a ghost.

So before continuing the story, you need to check the code. The first time I downloaded, the response header included two credentials: ETag and Last-Modified—in my experiment, it was etag: "6ac4ef6d-988a" plus a modification time. When resuming transfer, the downloader brings back these two credentials as they are. The server pairs: if they match, 206 will continue to provide them; If not, just give you 200 and give you the whole new file, which is basically forcing a new beginning. This set of credentials is from the same group as the 304 used for browser caching. the webpage always displays old content, the article explains how they work.

The most intuitive command line is wget -c, which continues where it breaks; curl corresponds to curl -C -, with a horizontal bar indicating "You calculate the breakpoint position yourself." The browser uses this system for direct download, but it doesn't show you the process.

What is a multithreaded downloader doing: cutting into 4 segments and piecing them back. I tested MD5

and understood Range, and the trump card of multithreaded downloaders is revealed. So-called 8 threads and 16 threads mean dividing the total file length by the number of threads, sending a range of different threads per thread, pulling in parallel, and finally splintering a file locally.

I split the 39050-byte diagram into 4 segments and conducted a back-to-back experiment: Thread 1 needs 0-9762, Thread 2 needs 9763-19525, Thread 3 needs 19526-29287, Thread 4 needs 29288-39049. Four requests are sent simultaneously, each pulling back bytes 9763, 9763, 9762, and 9762 bytes, then concatenating them in order, resulting in 39,050 bytes. Then compare it with the fully downloaded original file with MD5—ce42d41f3e6ac0080839fa144a6702d2, both are exactly the same. Byte-level restoration with no check-in patches in between because every segment is cut from the original file.

So why does multithreading seem fast? To be honest, it doesn't have a 'speed-up'; your broadband is still the same bandwidth, bandwidth, negotiated speed, and actual speed are basically Tier 3 accounts 。 What it does is fill up the pipe: during single-threaded downloads, if the server limits a single connection to 500KB/s, or if there is idle waiting during transmission, the pipeline is wasted; Each of the 8 connections is limited to 500KB/s, which adds up to 4MB/s. In the early days, the "acceleration" hype about download tools mostly involved looping connections and speed limits. Currently, BT downloaders also have a built-in segmented approach: In the NAS downloader article, the connection counts you see when downloading qBittorrent are the actual parallel block pulling on the other end.

Some things are inherently unrenewable

,

and not all downloads can. Three conditions must be met for resumed transfer at breakpoints: the server recognizes the Range, the file is stationary, and the downloader records progress.

I tried using a test interface, and the request clearly sent a 'Range' in the header, but the person ignored it and replied to 200, stuffing the entire file from scratch. This is a server that doesn't support Range—note it doesn't get errors, silently downgrade to full retransmission, you might think it's a resumption, but you've already started over. Some free cloud drive users limit speed, with single-thread speeds of several hundred KB, relying on not recognizing Range or limiting multi-threading. Membership "acceleration" basically means opening up these loopholes.

There's another type that can't be continued: dynamically generated content. Some pages are only formed at the moment of request; the two requests produce different things, the byte position doesn't match, the Etag doesn't match, so you have to take the whole copy. The method is simple: check if the first response header contains Accept-Ranges: bytes. If it does, it clearly indicates price marking supports segmentation; If not, it's probably the server's fault.

A table to wrap up

situation? Can you ? the breakpoint to to replace the password with the , files resumption. If the files change midway, delete and reinstall . Video
Who's working behind the scenes in yourintervene
Download the breakpoint and "continue," then continue fromRange request + 206 response + EtagRange download source. Don't force it with a browser
Multithreaded downloads are several times faster than single-threading. Multiple ranges run in parallel, and the speed limit of 8-16 threads is sufficient for single connections. If multiple servers continue transfer
may not be installed or opened afterthe first and last versions—don't trust the files that came together
Click to continue, find progress reset to zero, restart server 200, full volume, don't recognize range, change download tool or source, membership acceleration is also the same path
drag progress bar instantly responds to player range, only pull that segment without intervention, innate

Wrap up the order: for large files, first confirm that the response header contains Accept-Ranges: bytes before downloading; If the download is interrupted, don't delete half of the local file. Click Resume; Before installing the system after continuing the transfer, I checked the official MD5 and took ten seconds to avoid realizing the assembly was broken halfway through. My cousin's one was 97%. Later, wget -c finished in three minutes, and the previous 3.9G was worth buying a byte.

Read More


Copyright Notice Scan to read on mobile
All Rights Reserved: 《SHUNOT》 => 《Break point relay and packet capture: Range and 206 work together so well, disconnect and keep going》
Article URL: https://www.shunot.com/en/lybk/1156.html
Unless otherwise stated, all articles are original by 《SHUNOT》. Reposting is welcome! Please indicate the original URL when reposting, thank you.

Contact Us

Online Consultation: Click here to send me a message

WeChat ID: master_135

Scan to follow