How Partial Torrent Downloading Works

When downloading a multi-file torrent, users often choose to download only specific files rather than the entire package. This article explains the underlying mechanics of partial file downloading in the BitTorrent protocol, detailing how files are mapped into fixed-size pieces, why shared boundary pieces exist, and how clients request and manage selective data from the swarm.

Files vs. Pieces in the BitTorrent Protocol

The BitTorrent protocol does not treat a torrent as a collection of separate, individual files during transfer. Instead, it views the entire content of a torrent as a single, continuous stream of raw bytes. This byte stream is divided into uniform, fixed-size chunks called pieces, which typically range from 256 KB to 16 MB or more.

When creating a torrent: 1. All files are concatenated virtually in a predefined order. 2. The entire continuous stream is sliced into equal piece lengths. 3. A cryptographic hash (usually SHA-1 or SHA-256) is generated for each piece and stored in the .torrent metadata file.

Because piece sizes are fixed and files are variable in size, piece boundaries rarely align perfectly with file boundaries.

The Piece Boundary Overlap

The core challenge in partial file downloading is the boundary piece. When a file does not end exactly on a piece boundary, the remainder of that piece contains the beginning of the next file in the sequence.

Because BitTorrent verifies integrity at the piece level—not the file level—a client cannot verify half a piece. If you select only File A, and the final piece of File A overlaps with the start of File B, the client must download the entire piece to verify its cryptographic hash.

Handling Overlapping Data

Modern BitTorrent clients handle this unwanted boundary data in a few ways: * Part Files (.parts): Many clients create a hidden or temporary part file to store boundary pieces without cluttering the user’s directory with partially downloaded unwanted files. * Direct File Allocation: Some clients create the unselected file on disk, but only write the few kilobytes necessary to store the boundary piece, leaving the rest of the file empty.

How the Client Manages Selective Requests

When a user unchecks a file, the client adjusts its download strategy:

  1. Mapping: The client determines which piece indices cover the selected files.
  2. Prioritization: Pieces strictly belonging to unselected files are marked with a priority of zero (“Do Not Download”). Pieces containing requested file data are marked for retrieval.
  3. Peer Requests: The client communicates with peers in the swarm and sends REQUEST messages exclusively for the piece indices associated with the selected files (including necessary boundary pieces).
  4. Bitfield Updates: As pieces are completed and verified, the client updates its internal piece map (bitfield) and announces availability to peers, allowing it to upload (seed) the pieces it has obtained.

Seeding While Partially Downloaded

A client that has downloaded only specific files can still act as a seeder for those portions of the torrent. While it cannot achieve full “Seed” status (100% completion of the entire torrent), it acts as a “Partial Seeder,” sharing the completed pieces it possesses with other peers in the swarm who need them.