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

Revision 11151, 3.3 KB (checked in by dave, 18 months ago)

Insert missing "the."

Line 
1BEP: 23
2Title: Tracker Returns Compact Peer Lists
3Version: $Revision$
4Last-Modified: $Date$
5Author:  David Harrison <dave@bittorrent.com>
6Status:  Accepted
7Type:    Standards track
8Content-Type: text/x-rst
9Created: 12-May-2008
10Post-History:
11
12
13Abstract
14========
15
16To reduce the size of tracker responses and to reduce memory and
17computational requirements in trackers, trackers may return
18peers as a packed string rather than as a bencoded list.
19
20The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
21NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED",  "MAY", and
22"OPTIONAL" in this document are to be interpreted as described in
23IETF RFC 2119 [#RFC-2119]_.
24
25
26Overview
27========
28
29In BitTorrent as described in BEP 3 [#BEP-3]_, peers wishing to
30transfer a file contact a central tracker.  This tracker returns a
31list of peers that are currently transferring the file.  The list of
32peers is implemented as a list of bencoded dicts.  Each dict in the
33list contains three fields: *peer id*, *ip*, and *port*.  The *peer
34id* is 20 bytes plus 3 bytes bencoding overhead.  The *ip* is a string
35containing a domain name or an IP address, and an integer port number.
36The *ip* is variable length, but since in its longest form it is a
37domain name it cannot exceed 255 bytes [#RFC-1034]_ plus 4 bytes
38bencoding overhead.  Bencoded integers are also variable length but
39since it is a port number, it cannot be more than 7 bytes including
40bencoding overhead.  Thus,
41
42::
43
44  total peer list length in bytes < n * ( 23 + 259 + 7 ) 
45
46It is common now to use a compact format where each peer is represented
47using only 6 bytes.  The first 4 bytes contain the 32-bit ipv4 address.
48The remaining two bytes contain the port number.  Both address and port
49use network-byte order.
50
51It is SUGGESTED that trackers return compact format by default.
52By including *compact=0* in the announce URL, the client advises the
53tracker that is prefers the original format described in [#BEP-3]_, and
54analogously *compact=1* advises the tracker that the client prefers
55compact format.  However the *compact* key-value pair is only
56advisory: the tracker MAY return using either format.  *compact* is
57advisory so that trackers may support only the compact format.
58However, clients MUST continue to support both.
59
60For example,
61
62::
63
64  GET /announce?peer_id=aaaaaaaaaaaaaaaaaaaa&info_hash=aaaaaaaaaaaaaaaaaaaa
65  &port=6881&left=0&downloaded=100&uploaded=0&compact=1
66
67The compact format uses the same *peers* key in the bencoded tracker
68response, but the value is a bencoded string rather than a bencoded
69list.
70
71The peer id does not appear in the compact format.  The format has been
72in use for years and the lack of a peer id has posed no problems.
73
74This compact format is supported by BitTorrent mainline, Azureus,
75libtorrent, uTorrent, and probably most other clients.
76
77
78References
79==========
80
81.. [#BEP-3] BEP_0003. The BitTorrent Protocol Specification. Cohen.
82   (http://www.bittorrent.org/beps/bep_0003.html)
83
84.. [#RFC-1034] RFC-1034. DOMAIN NAMES - CONCEPTS AND FACILITIES. Mockapetris,
85   November 1987. (http://tools.ietf.org/html/rfc1034)
86
87.. [#RFC-2119] RFC-2119. (http://www.ietf.org/rfc/rfc2119.txt)
88
89
90Copyright
91=========
92
93This document has been placed in the public domain.
94
95
96
97..
98   Local Variables:
99   mode: indented-text
100   indent-tabs-mode: nil
101   sentence-end-double-space: t
102   fill-column: 70
103   coding: utf-8
104   End:
105
Note: See TracBrowser for help on using the browser.