root/dotorg/trunk/html/beps/bep_0028.rst

Revision 11180, 5.7 KB (checked in by bittorrent, 5 months ago)

Add a section on not hammering bad trackers

Line 
1BEP: 28
2Title: Tracker exchange extension
3Version: $Revision$
4Last-Modified: $Date$
5Author:  Arvid Norberg <arvid@bittorrent.com>
6Status:  Draft
7Type:    Standards Track
8Content-Type: text/x-rst
9Created: 26-Nov-2008
10Post-History: 15-Oct-2009: Add a section on not hammering bad trackers
11
12Tracker exchange extension
13==========================
14
15This extension makes it possible for BitTorrent peers to learn about new
16trackers for a swarm they have joined. Ideally ending up with every peer
17knowing about every tracker used for the torrent.
18
19rationale
20---------
21
22There are mainly two scenarios where it's desirable for a peer to learn
23about trackers that other peers are using:
24
251. 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
302. 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
35This extension is designed to have minimal impact on the common case of every
36peer knowing of the exact same trackers. This case is recognized as
37the dominant case, and is important to not add any penalty in terms of
38bandwidth, since that might deter implementors from adopting this extension.
39
40.. _`BEP 9`: http://www.bittorrent.org/beps/bep_0009.html
41
42definitions
43===========
44
45In 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
48assumed to be good) or a tracker that we have received over the TEX protocol
49*and* received a successful response from.
50
51The tracker list used by this extension is hence different from the tracker
52list used by the client itself, since it does not include some trackers that
53we have never successfully announced with. This list of trackers is the only
54list of verified trackers referred to in this extension, unless explicitly
55stated otherwise.
56
57The extension message is used to send *changes* to the tracker list to other
58peers. If the peers have different tracker lists on handshake, the first
59message MUST contain the full list of trackers. Any subsequent message SHOULD
60only contain added trackers. If the peers have the same tracker list when
61connecting, the first extension message SHOULD only contain added trackers.
62
63
64extension header
65================
66
67The tracker exchange extension (TEX for short) uses the extension protocol
68(specified in `BEP 10`_) to advertize support. It adds the "lt_tex" entry
69to the "m" dictionary in the extension header hand-shake message. This identifies
70the message code used for this message. It also adds "tr" to the handshake message
71specifying 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
75Example extension handshake message::
76
77{'m': {'lt_tex', 3}, 'tr': '426c8fe69d59ce85626177749d66e864cc39a82d'}
78
79Note that the string under the 'tr' key is *binary*. It is printed as a hex encoded
80string here for clarity. It is always supposed to be 20 bytes.
81
82The tracker list hash is computed as follows:
83
841. All tracker urls are put in a list
852. 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
943. The list of urls is sorted in ascending lexicographical order. Where each byte
95   is interpreted as its ascii value, and sorted by it.
964. 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
101The wording "SHOULD" in point 2 means that an implementation that skips this step
102is assumed to work efficiently in the vast majority of cases, but might be slightly
103more susceptible to attacks.
104
105The tracker list hash in the handshake is used to compare with ones own tracker list.
106In most cases it is assumed that this hash will be the same for both peers. If this is
107the case, the client SHOULD assume that the peers have the same list, and not send a
108full tracker list message.
109
110
111extension message
112=================
113
114The extension message is sent on a regular interval. It is recommended not to be sent
115more often than every 2 minutes.
116
117Any message that does not contain any new trackers SHOULD be omitted (i.e. not sent
118at all).
119
120The extension message is bencoded and contains a single key: ``added`` which is a list
121of strings. Each string is the url of a tracker that was added since the last update.
122
123example message::
124
125        { 'added': ['http://tracker.bittorrent.com/announce', 'http://tracker2.bittorrent.com'] }
126
127trackers
128========
129
130Trackers discovered through this protocol SHOULD be treated with a certain amount of
131suspicion. Since the source of a tracker exchange message cannot be trusted, an
132implementation SHOULD have a lower number of retries before giving up entirely.
133
134Also, as specified under the definitions_ section, a tracker that has not worked
135should 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
Note: See TracBrowser for help on using the browser.