| 1 | BEP: 28 |
|---|
| 2 | Title: Tracker exchange extension |
|---|
| 3 | Version: $Revision$ |
|---|
| 4 | Last-Modified: $Date$ |
|---|
| 5 | Author: Arvid Norberg <arvid@bittorrent.com> |
|---|
| 6 | Status: Draft |
|---|
| 7 | Type: Standards Track |
|---|
| 8 | Content-Type: text/x-rst |
|---|
| 9 | Created: 26-Nov-2008 |
|---|
| 10 | Post-History: 15-Oct-2009: Add a section on not hammering bad trackers |
|---|
| 11 | |
|---|
| 12 | Tracker exchange extension |
|---|
| 13 | ========================== |
|---|
| 14 | |
|---|
| 15 | This extension makes it possible for BitTorrent peers to learn about new |
|---|
| 16 | trackers for a swarm they have joined. Ideally ending up with every peer |
|---|
| 17 | knowing about every tracker used for the torrent. |
|---|
| 18 | |
|---|
| 19 | rationale |
|---|
| 20 | --------- |
|---|
| 21 | |
|---|
| 22 | There are mainly two scenarios where it's desirable for a peer to learn |
|---|
| 23 | about trackers that other peers are using: |
|---|
| 24 | |
|---|
| 25 | 1. If the peer joined the swarm via a magnet link (`BEP 9`_), bootstrapping |
|---|
| 26 | by joining peers from the DHT. The number of peers that's accessable might |
|---|
| 27 | not be sufficient. Announcing with a tracker could make a significant |
|---|
| 28 | difference for the peer, receiving more peers. |
|---|
| 29 | |
|---|
| 30 | 2. If the tracker the peer joined only know of a small number of peers, but |
|---|
| 31 | there are other peers (acquired from DHT for instance) that are using |
|---|
| 32 | a much more popular tracker, the peer might want to announce with that |
|---|
| 33 | other tracker in order to receive enough peers. |
|---|
| 34 | |
|---|
| 35 | This extension is designed to have minimal impact on the common case of every |
|---|
| 36 | peer knowing of the exact same trackers. This case is recognized as |
|---|
| 37 | the dominant case, and is important to not add any penalty in terms of |
|---|
| 38 | bandwidth, since that might deter implementors from adopting this extension. |
|---|
| 39 | |
|---|
| 40 | .. _`BEP 9`: http://www.bittorrent.org/beps/bep_0009.html |
|---|
| 41 | |
|---|
| 42 | definitions |
|---|
| 43 | =========== |
|---|
| 44 | |
|---|
| 45 | In this extension, every peer has a list of trackers. In this list are only |
|---|
| 46 | *verified trackers*. A verified tracker is a tracker that either was in the |
|---|
| 47 | .torrent file that was loaded (just like without this extension, they are |
|---|
| 48 | assumed to be good) or a tracker that we have received over the TEX protocol |
|---|
| 49 | *and* received a successful response from. |
|---|
| 50 | |
|---|
| 51 | The tracker list used by this extension is hence different from the tracker |
|---|
| 52 | list used by the client itself, since it does not include some trackers that |
|---|
| 53 | we have never successfully announced with. This list of trackers is the only |
|---|
| 54 | list of verified trackers referred to in this extension, unless explicitly |
|---|
| 55 | stated otherwise. |
|---|
| 56 | |
|---|
| 57 | The extension message is used to send *changes* to the tracker list to other |
|---|
| 58 | peers. If the peers have different tracker lists on handshake, the first |
|---|
| 59 | message MUST contain the full list of trackers. Any subsequent message SHOULD |
|---|
| 60 | only contain added trackers. If the peers have the same tracker list when |
|---|
| 61 | connecting, the first extension message SHOULD only contain added trackers. |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | extension header |
|---|
| 65 | ================ |
|---|
| 66 | |
|---|
| 67 | The tracker exchange extension (TEX for short) uses the extension protocol |
|---|
| 68 | (specified in `BEP 10`_) to advertize support. It adds the "lt_tex" entry |
|---|
| 69 | to the "m" dictionary in the extension header hand-shake message. This identifies |
|---|
| 70 | the message code used for this message. It also adds "tr" to the handshake message |
|---|
| 71 | specifying a hash of the current tracker list this peer has for this torrent. |
|---|
| 72 | |
|---|
| 73 | .. _`BEP 10`: http://www.bittorrent.org/beps/bep_0010.html |
|---|
| 74 | |
|---|
| 75 | Example extension handshake message:: |
|---|
| 76 | |
|---|
| 77 | {'m': {'lt_tex', 3}, 'tr': '426c8fe69d59ce85626177749d66e864cc39a82d'} |
|---|
| 78 | |
|---|
| 79 | Note that the string under the 'tr' key is *binary*. It is printed as a hex encoded |
|---|
| 80 | string here for clarity. It is always supposed to be 20 bytes. |
|---|
| 81 | |
|---|
| 82 | The tracker list hash is computed as follows: |
|---|
| 83 | |
|---|
| 84 | 1. All tracker urls are put in a list |
|---|
| 85 | 2. All urls SHOULD be normalized |
|---|
| 86 | |
|---|
| 87 | 1. the protocol part (before the '://') is made lower case |
|---|
| 88 | 2. the hostname is made lower case |
|---|
| 89 | 3. the path and argument components are quote-normalized. Any %-encoding |
|---|
| 90 | that decodes into an ``unreserved`` character (as defined by `RFC 2396`_) |
|---|
| 91 | should be decoded. Any remaining encoded characters should use lower case |
|---|
| 92 | hex encoding. i.e. ``%ff`` instead of ``%FF`` |
|---|
| 93 | |
|---|
| 94 | 3. The list of urls is sorted in ascending lexicographical order. Where each byte |
|---|
| 95 | is interpreted as its ascii value, and sorted by it. |
|---|
| 96 | 4. The SHA-1 hash is constructed of the concatenation of all urls in the order in |
|---|
| 97 | the list. |
|---|
| 98 | |
|---|
| 99 | .. _`RFC 2396`: http://www.ietf.org/rfc/rfc2396.txt |
|---|
| 100 | |
|---|
| 101 | The wording "SHOULD" in point 2 means that an implementation that skips this step |
|---|
| 102 | is assumed to work efficiently in the vast majority of cases, but might be slightly |
|---|
| 103 | more susceptible to attacks. |
|---|
| 104 | |
|---|
| 105 | The tracker list hash in the handshake is used to compare with ones own tracker list. |
|---|
| 106 | In most cases it is assumed that this hash will be the same for both peers. If this is |
|---|
| 107 | the case, the client SHOULD assume that the peers have the same list, and not send a |
|---|
| 108 | full tracker list message. |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | extension message |
|---|
| 112 | ================= |
|---|
| 113 | |
|---|
| 114 | The extension message is sent on a regular interval. It is recommended not to be sent |
|---|
| 115 | more often than every 2 minutes. |
|---|
| 116 | |
|---|
| 117 | Any message that does not contain any new trackers SHOULD be omitted (i.e. not sent |
|---|
| 118 | at all). |
|---|
| 119 | |
|---|
| 120 | The extension message is bencoded and contains a single key: ``added`` which is a list |
|---|
| 121 | of strings. Each string is the url of a tracker that was added since the last update. |
|---|
| 122 | |
|---|
| 123 | example message:: |
|---|
| 124 | |
|---|
| 125 | { 'added': ['http://tracker.bittorrent.com/announce', 'http://tracker2.bittorrent.com'] } |
|---|
| 126 | |
|---|
| 127 | trackers |
|---|
| 128 | ======== |
|---|
| 129 | |
|---|
| 130 | Trackers discovered through this protocol SHOULD be treated with a certain amount of |
|---|
| 131 | suspicion. Since the source of a tracker exchange message cannot be trusted, an |
|---|
| 132 | implementation SHOULD have a lower number of retries before giving up entirely. |
|---|
| 133 | |
|---|
| 134 | Also, as specified under the definitions_ section, a tracker that has not worked |
|---|
| 135 | should never be propagated to other peers over the tracker exchange protocol. |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | .. |
|---|
| 140 | Local Variables: |
|---|
| 141 | mode: indented-text |
|---|
| 142 | indent-tabs-mode: nil |
|---|
| 143 | sentence-end-double-space: t |
|---|
| 144 | fill-column: 70 |
|---|
| 145 | coding: utf-8 |
|---|
| 146 | End: |
|---|
| 147 | |
|---|