Sanko Robinson


Net::BitTorrent::Protocol::BEP09 - Packet Utilities for BEP09: The Extention for Peers to Send Metadata Files


The purpose of this extension is to allow clients to join a swarm and complete a download without the need of downloading a .torrent file first. This extension instead allows clients to download the metadata from peers. It makes it possible to support magnet links, a link on a web page only containing enough information to join the swarm (the info hash).

This metadata extiontion uses the extention protocol to advertise its existence. It adds the ut_metadata entry to the m dictionary in the extention header handshake message. It also adds metadata_size to the handshake message (not the m dictionary) specifiying an integer value of the number of bytes of the metadata.

Importing From Net::BitTorrent::Protocol::BEP09

By default, nothing is exported.

You may import any of the following or use one or more of these tag:


Imports everything. If you're importing anything, this is probably what you want.


Imports the functions which generate messages.

Note that there are no parser functions as the packets generated for BEP09 are simple bencoded hashes. Use the bedecoder in BEP03.


This extention is very simple; there's a single request packet type and only two possible reply packet types:

build_metadata_request( $index )

Generates an appropriate request for a subpiece of the torrent's metadata.

build_metadata_data( $index, $piece )

Generates an appropriate reply to a request query.

build_metadata_reject( $index, $piece )

Generates an appropriate reply to a request query if the requested piece is not available.

Magnet URI Format

The magnet URI format is:


Where info-hash is the infohash, hex encoded, for a total of 40 characters. For compatability with existing links in the wild, clients should also support the 32 character base32 encoded infohash.

See Also

BEP 09: Extention for Peers to Send Metadata Files


Sanko Robinson <> -


License and Legal

Copyright (C) 2010-2014 by Sanko Robinson <>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.

Neither this module nor the Author is affiliated with BitTorrent, Inc.