ut_metadata Torrent Metadata Block Count Guide
The ut_metadata extension (specified in BitTorrent
Enhancement Proposal 9, or BEP 9) allows peers to share
.torrent metadata over magnet links by dividing the
metadata into standardized chunks. The exact number of blocks a metadata
file is split into depends on the total size of its info
dictionary, as the protocol enforces a fixed chunk size of 16 KiB
(16,384 bytes) per block.
The Standard Block Size
Under BEP 9, metadata is not transferred as a single payload.
Instead, the torrent’s raw bencoded info dictionary is
partitioned into discrete pieces:
- Fixed Block Size: 16,384 bytes (16 KiB)
- Final Block: Any remaining bytes smaller than 16 KiB
The total block count is calculated using the formula:
\[\text{Total Blocks} = \lceil \frac{\text{Total Metadata Size in Bytes}}{16384} \rceil\]
Typical Block Counts
The size of a torrent’s metadata depends primarily on the number of
files in the transfer and the total number of piece hashes contained in
the info dictionary.
- Small Torrents (1 Block): Torrents containing a single file or a small number of pieces often have metadata sizes under 16 KiB, requiring only 1 block.
- Average Torrents (2 to 8 Blocks): Most typical multi-file torrents or movies with standard piece sizes have metadata ranging between 30 KiB and 120 KiB, requiring between 2 and 8 blocks.
- Large Torrents (10 to 64+ Blocks): Torrents with tens of thousands of individual files or extremely large piece tables (several hundred gigabytes or terabytes of total data with small piece sizes) can have metadata exceeding 1 MiB, resulting in 64 or more blocks.
How Blocks Are Transferred
When a client initiates a metadata transfer via
ut_metadata:
- Handshake & Size Exchange: The peers negotiate
the extension and advertise the
metadata_sizein bytes. - Block Indexing: The receiving client calculates the
number of blocks and requests them individually by their zero-based
index (e.g., piece
0, piece1, up to pieceN-1). - Reassembly & Verification: Once all blocks are
received, the client concatenates them in order and verifies the
complete
infodictionary against the 20-byte SHA-1 info-hash specified in the magnet link. If the hash matches, the metadata is complete and the regular file download begins.