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:

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.

How Blocks Are Transferred

When a client initiates a metadata transfer via ut_metadata:

  1. Handshake & Size Exchange: The peers negotiate the extension and advertise the metadata_size in bytes.
  2. Block Indexing: The receiving client calculates the number of blocks and requests them individually by their zero-based index (e.g., piece 0, piece 1, up to piece N-1).
  3. Reassembly & Verification: Once all blocks are received, the client concatenates them in order and verifies the complete info dictionary 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.