| 1 | <?xml version="1.0" encoding="utf-8" ?> |
|---|
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|---|
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|---|
| 4 | <head> |
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|---|
| 6 | <meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" /> |
|---|
| 7 | <title></title> |
|---|
| 8 | <link rel="stylesheet" href="../css/bep.css" type="text/css" /> |
|---|
| 9 | </head> |
|---|
| 10 | <body> |
|---|
| 11 | <div class="document"> |
|---|
| 12 | |
|---|
| 13 | <div id="upper" class="clear"> |
|---|
| 14 | <div id="wrap"> |
|---|
| 15 | <div id="header"> |
|---|
| 16 | <h1><a href="../index.html">BitTorrent<span>.org</span></a></h1> |
|---|
| 17 | </div> |
|---|
| 18 | <div id="nav"> |
|---|
| 19 | <ul> |
|---|
| 20 | <li><a href="../index.html">Home</a></li> |
|---|
| 21 | <li><a href="../introduction.html">For Users</a></li> |
|---|
| 22 | <li><a href="bep_0000.html"><span>For Developers</span></a></li> |
|---|
| 23 | <!-- <li><a href="./blog">Blog</a></li> --> |
|---|
| 24 | <li><a href="http://forum.bittorrent.org"> Forums </li> |
|---|
| 25 | <li><a href="../donate.html">Donate!</a></li> |
|---|
| 26 | </ul> |
|---|
| 27 | </div> <!-- nav --> |
|---|
| 28 | <!-- ### Begin Content ### --> |
|---|
| 29 | <div id="second"> |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | <table class="rfc2822 docutils field-list" frame="void" rules="none"> |
|---|
| 34 | <col class="field-name" /> |
|---|
| 35 | <col class="field-body" /> |
|---|
| 36 | <tbody valign="top"> |
|---|
| 37 | <tr class="field"><th class="field-name">BEP:</th><td class="field-body">23</td> |
|---|
| 38 | </tr> |
|---|
| 39 | <tr class="field"><th class="field-name">Title:</th><td class="field-body">Tracker Returns Compact Peer Lists</td> |
|---|
| 40 | </tr> |
|---|
| 41 | <tr class="field"><th class="field-name">Version:</th><td class="field-body">11117</td> |
|---|
| 42 | </tr> |
|---|
| 43 | <tr class="field"><th class="field-name">Last-Modified:</th><td class="field-body"><a class="reference external" href="http://bittorrent.org/trac/browser/dotorg/trunk/html/beps/bep_0023.rst">2008-08-05 18:54:24 -0700 (Tue, 05 Aug 2008)</a></td> |
|---|
| 44 | </tr> |
|---|
| 45 | <tr class="field"><th class="field-name">Author:</th><td class="field-body">David Harrison <dave at bittorrent.com></td> |
|---|
| 46 | </tr> |
|---|
| 47 | <tr class="field"><th class="field-name">Status:</th><td class="field-body">Accepted</td> |
|---|
| 48 | </tr> |
|---|
| 49 | <tr class="field"><th class="field-name">Type:</th><td class="field-body">Standards track</td> |
|---|
| 50 | </tr> |
|---|
| 51 | <tr class="field"><th class="field-name">Content-Type:</th><td class="field-body"><a class="reference external" href="http://www.bittorrent.org/beps/bep-0012">text/x-rst</a></td> |
|---|
| 52 | </tr> |
|---|
| 53 | <tr class="field"><th class="field-name">Created:</th><td class="field-body">12-May-2008</td> |
|---|
| 54 | </tr> |
|---|
| 55 | <tr class="field"><th class="field-name">Post-History:</th><td class="field-body"></td> |
|---|
| 56 | </tr> |
|---|
| 57 | </tbody> |
|---|
| 58 | </table> |
|---|
| 59 | <hr /> |
|---|
| 60 | <div class="contents topic" id="contents"> |
|---|
| 61 | <p class="topic-title first">Contents</p> |
|---|
| 62 | <ul class="simple"> |
|---|
| 63 | <li><a class="reference internal" href="#abstract" id="id5">Abstract</a></li> |
|---|
| 64 | <li><a class="reference internal" href="#overview" id="id6">Overview</a></li> |
|---|
| 65 | <li><a class="reference internal" href="#references" id="id7">References</a></li> |
|---|
| 66 | <li><a class="reference internal" href="#copyright" id="id8">Copyright</a></li> |
|---|
| 67 | </ul> |
|---|
| 68 | </div> |
|---|
| 69 | <div class="section" id="abstract"> |
|---|
| 70 | <h1>Abstract</h1> |
|---|
| 71 | <p>To reduce the size of tracker responses and to reduce memory and |
|---|
| 72 | computational requirements in trackers, trackers may return |
|---|
| 73 | peers as a packed string rather than as a bencoded list.</p> |
|---|
| 74 | <p>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL |
|---|
| 75 | NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and |
|---|
| 76 | "OPTIONAL" in this document are to be interpreted as described in |
|---|
| 77 | IETF <a class="reference external" href="http://www.faqs.org/rfcs/rfc2119.html">RFC 2119</a> <a class="footnote-reference" href="#rfc-2119" id="id1">[3]</a>.</p> |
|---|
| 78 | </div> |
|---|
| 79 | <div class="section" id="overview"> |
|---|
| 80 | <h1>Overview</h1> |
|---|
| 81 | <p>In BitTorrent as described in BEP 3 <a class="footnote-reference" href="#bep-3" id="id2">[1]</a>, peers wishing to |
|---|
| 82 | transfer a file contact a central tracker. This tracker returns a |
|---|
| 83 | list of peers that are currently transferring the file. The list of |
|---|
| 84 | peers is implemented as a list of bencoded dicts. Each dict in the |
|---|
| 85 | list contains three fields: <em>peer id</em>, <em>ip</em>, and <em>port</em>. The <em>peer |
|---|
| 86 | id</em> is 20 bytes plus 3 bytes bencoding overhead. The <em>ip</em> is a string |
|---|
| 87 | containing a domain name or an IP address, and an integer port number. |
|---|
| 88 | The <em>ip</em> is variable length, but since in its longest form it is a |
|---|
| 89 | domain name it cannot exceed 255 bytes <a class="footnote-reference" href="#rfc-1034" id="id3">[2]</a> plus 4 bytes |
|---|
| 90 | bencoding overhead. Bencoded integers are also variable length but |
|---|
| 91 | since it is a port number, it cannot be more than 7 bytes including |
|---|
| 92 | bencoding overhead. Thus,</p> |
|---|
| 93 | <pre class="literal-block"> |
|---|
| 94 | total peer list length in bytes < n * ( 23 + 259 + 7 ) |
|---|
| 95 | </pre> |
|---|
| 96 | <p>It is common now to use a compact format where each peer is represented |
|---|
| 97 | using only 6 bytes. The first 4 bytes contain the 32-bit ipv4 address. |
|---|
| 98 | The remaining two bytes contain the port number. Both address and port |
|---|
| 99 | use network-byte order.</p> |
|---|
| 100 | <p>When the client's announce URL contains <em>compact=1</em> the tracker MAY |
|---|
| 101 | return the peers using compact format. When <em>compact=0</em> or it is not |
|---|
| 102 | specified then the tracker MUST return using the original format |
|---|
| 103 | described in <a class="footnote-reference" href="#bep-3" id="id4">[1]</a>. For example,</p> |
|---|
| 104 | <pre class="literal-block"> |
|---|
| 105 | GET /announce?peer_id=aaaaaaaaaaaaaaaaaaaa&info_hash=aaaaaaaaaaaaaaaaaaaa |
|---|
| 106 | &port=6881&left=0&downloaded=100&uploaded=0&compact=1 |
|---|
| 107 | </pre> |
|---|
| 108 | <p>The compact format uses the same <em>peers</em> key in the bencoded tracker |
|---|
| 109 | response, but the value is a bencoded string rather than a bencoded |
|---|
| 110 | list.</p> |
|---|
| 111 | <p>The peer id does not appear in the compact format. The format has been |
|---|
| 112 | in use for years and the lack of a peer id has posed no problems.</p> |
|---|
| 113 | <p>This compact format is supported by BitTorrent mainline, Azureus, |
|---|
| 114 | libtorrent, uTorrent, and probably most other clients.</p> |
|---|
| 115 | </div> |
|---|
| 116 | <div class="section" id="references"> |
|---|
| 117 | <h1>References</h1> |
|---|
| 118 | <table class="docutils footnote" frame="void" id="bep-3" rules="none"> |
|---|
| 119 | <colgroup><col class="label" /><col /></colgroup> |
|---|
| 120 | <tbody valign="top"> |
|---|
| 121 | <tr><td class="label">[1]</td><td><em>(<a class="fn-backref" href="#id2">1</a>, <a class="fn-backref" href="#id4">2</a>)</em> BEP_0003. The BitTorrent Protocol Specification. Cohen. |
|---|
| 122 | (<a class="reference external" href="http://www.bittorrent.org/beps/bep_0003.html">http://www.bittorrent.org/beps/bep_0003.html</a>)</td></tr> |
|---|
| 123 | </tbody> |
|---|
| 124 | </table> |
|---|
| 125 | <table class="docutils footnote" frame="void" id="rfc-1034" rules="none"> |
|---|
| 126 | <colgroup><col class="label" /><col /></colgroup> |
|---|
| 127 | <tbody valign="top"> |
|---|
| 128 | <tr><td class="label"><a class="fn-backref" href="#id3">[2]</a></td><td><a class="reference external" href="http://www.faqs.org/rfcs/rfc1034.html">RFC-1034</a>. DOMAIN NAMES - CONCEPTS AND FACILITIES. Mockapetris, |
|---|
| 129 | November 1987. (<a class="reference external" href="http://tools.ietf.org/html/rfc1034">http://tools.ietf.org/html/rfc1034</a>)</td></tr> |
|---|
| 130 | </tbody> |
|---|
| 131 | </table> |
|---|
| 132 | <table class="docutils footnote" frame="void" id="rfc-2119" rules="none"> |
|---|
| 133 | <colgroup><col class="label" /><col /></colgroup> |
|---|
| 134 | <tbody valign="top"> |
|---|
| 135 | <tr><td class="label"><a class="fn-backref" href="#id1">[3]</a></td><td><a class="reference external" href="http://www.faqs.org/rfcs/rfc2119.html">RFC-2119</a>. (<a class="reference external" href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a>)</td></tr> |
|---|
| 136 | </tbody> |
|---|
| 137 | </table> |
|---|
| 138 | </div> |
|---|
| 139 | <div class="section" id="copyright"> |
|---|
| 140 | <h1>Copyright</h1> |
|---|
| 141 | <p>This document has been placed in the public domain.</p> |
|---|
| 142 | <!-- Local Variables: |
|---|
| 143 | mode: indented-text |
|---|
| 144 | indent-tabs-mode: nil |
|---|
| 145 | sentence-end-double-space: t |
|---|
| 146 | fill-column: 70 |
|---|
| 147 | coding: utf-8 |
|---|
| 148 | End: --> |
|---|
| 149 | </div> |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | </div> |
|---|
| 153 | <div id="footer"> |
|---|
| 154 | <hr/> |
|---|
| 155 | </div> |
|---|
| 156 | |
|---|
| 157 | </div> |
|---|
| 158 | </body> |
|---|
| 159 | </html> |
|---|