root / dotorg / v6 / html / beps / bep_0009.rst

Revision 10561, 4.4 kB (checked in by arvid, 11 months ago)

updates to make file to refer to the tempalte.txt. Fixed broken links in bep 0000. Updated wording and added references to metadata extension. Fixed layout of bep 0004

Line 
1BEP: 9
2Title: Metadata Extension
3Version: $Revision$
4Last-Modified: $Date$
5Author:  Greg Hazel <greg@bittorrent.com>, Arvid Norberg <arvid@bittorrent.com>
6Status:  Draft
7Type:    Standards Track
8Created: 31-Jan-2008
9Post-History:
10
11The purpose of this extension is to allow clients to join a swarm and
12complete a download without the need of downloading a .torrent file
13first. This extension instead allows clients to download the metadata
14from peers. It makes it possible to support *magnet links*, a link
15on a web page only containing enough information to join the swarm
16(the info hash).
17
18metadata
19========
20
21This extension only transfers the info-dictionary part of the .torrent
22file. This part can be validated by the info-hash. In this document, that
23part of the .torrent file is referred to as *the metadata*.
24
25The metadata is handled in bocks of 16KiB (65536 Bytes). The metadata blocks
26are indexed starting at 0. All blocks are 16KiB except the last block which may
27be smaller.
28
29extension header
30================
31
32The metadata extension uses the extension protocol (specified in `BEP 0010`_
33) to advertize its existence. It adds the "ut_metadata" entry to the "m"
34dictionary in the extension header hand-shake message. This identifies the
35message code used for this message. It also adds "metadata_size" to the
36handshake message (not the "m" dictionary) specifying an integer value of the
37number of bytes of the metadata.
38
39.. _`BEP 0010`: http://www.bittorrent.org/beps/bep_0010.html
40
41Example extension handshake message::
42
43{'m': {'ut_metadata', 3}, 'metadata_size': 31235}
44
45
46extension message
47=================
48
49The extension messages are bencoded. There are 3 different kinds of messages:
50
510. request
521. data
532. reject
54
55The bencoded messages have a key "msg_type" which value is an integer
56corresponding to the type of message. They also have a key "piece", which
57indicates which part of the metadata this message refers to.
58
59request
60-------
61
62The ``request`` message does not have any additional keys in the dictionary.
63The response to this message, from a peer supporting the extension, is either
64a ``reject`` or a ``data`` message. The response MUST have the same ``piece``
65as the request did.
66
67A peer MUST verify that any piece it sends passes the info-hash verification.
68i.e. until the peer has the entire metadata, it cannot run SHA-1 to verify that
69it yields the same hash as the info-hash. Peers that do not have the entire
70metadata MUST respond with a ``reject`` message to any metadata request.
71
72Example::
73
74        {'msg_type': 0, 'piece': 0}
75        d8:msg_typei0e5:piecei0ee
76
77That request message requests the first metadata piece.
78
79data
80----
81
82The ``data`` message adds another entry to the dictionary, "total_size". This
83key has the same semantics as the "metadata_size" in the extension header. This
84is an integer.
85
86The metadata piece is appended to the bencoded dictionary, it is not a part of
87the dictionary, but it is a part of the message (the length prefix MUST include it).
88
89If the piece is the last piece of the metadata, it may be less than 16kiB. If it
90is not the last piece of the metadata, it MUST be 16kiB.
91
92Example::
93
94        {'msg_type': 1, 'piece': 0, 'total_size': 3425}
95        d8:msg_typei1e5:piecei0e10:total_sizei34256eexxxxxxxx...
96
97The ``x`` represents binary data (the metadata).
98
99reject
100------
101
102The ``reject`` message does not have any additional keys in its message.
103It SHOULD be interpreted as the peer does not have the piece of metadata
104that was requested.
105
106Clients MAY implement flood protection by rejecting ``request`` messages
107after a certain number of them have been served. Typically the number of
108pieces of metadata times a factor.
109
110Example::
111
112        {'msg_type': 2, 'piece': 0}
113        d8:msg_typei1e5:piecei0ee
114
115magnet URI format
116=================
117
118The magnet URI format is::
119
120        magnet:?xt=urn:btih:<info-hash>&dn=<name>&tr=<tracker-url>
121
122<info-hash>
123        Is the info-hash encoded as base32 [#base32]_
124
125``xt`` is the only mandatory parameter. ``dn`` is the display name that may be
126used by the client to display while waiting for metadata. ``tr`` is a tracker
127url, if there is one. If there are multiple trackers, multiple ``tr`` entries
128may be included.
129
130Both ``dn`` and ``tr`` are optional.
131
132If no tracker is specified, the client SHOULD use the DHT (`BEP 0005`_) to acquire peers.
133
134.. [#base32] http://www.ietf.org/rfc/rfc3548.txt
135.. _`BEP 0005`: bep_0005.html
136
137
138..
139   Local Variables:
140   mode: indented-text
141   indent-tabs-mode: nil
142   sentence-end-double-space: t
143   fill-column: 70
144   coding: utf-8
145   End:
Note: See TracBrowser for help on using the browser.