root / dotorg / trunk / html / beps / bep_0025.html

Revision 11119, 14.5 kB (checked in by dave, 2 months ago)

Regenerate html.

Line 
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">25</td>
38</tr>
39<tr class="field"><th class="field-name">Title:</th><td class="field-body">An Alternate BitTorrent Cache Discovery Protocol</td>
40</tr>
41<tr class="field"><th class="field-name">Version:</th><td class="field-body">11114</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_0025.rst">2008-08-05 17:09:52 -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 &lt;dave&#32;&#97;t&#32;bittorrent.com&gt;, Greg Hazel &lt;greg&#32;&#97;t&#32;bittorrent.com&gt;, Stanislav Shalunov &lt;shalunov&#32;&#97;t&#32;bittorrent.com&gt;</td>
46</tr>
47<tr class="field"><th class="field-name">Status:</th><td class="field-body">Draft</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">20-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="#motivation" id="id8">Motivation</a></li>
64<li><a class="reference internal" href="#the-discovery-mechanism" id="id9">The Discovery Mechanism</a></li>
65<li><a class="reference internal" href="#iterative-queries" id="id10">Iterative Queries</a></li>
66<li><a class="reference internal" href="#network-address-translators" id="id11">Network Address Translators</a></li>
67<li><a class="reference internal" href="#example" id="id12">Example</a></li>
68<li><a class="reference internal" href="#references" id="id13">References</a></li>
69<li><a class="reference internal" href="#copyright" id="id14">Copyright</a></li>
70</ul>
71</div>
72<div class="section" id="motivation">
73<h1>Motivation</h1>
74<p>Some Internet Service Providers (ISPs) may be interested in deploying
75BitTorrent caches to lower transit costs, reduce internal traffic, and
76improve user experience by speeding up downloads.</p>
77<p>A cache is simply a fast peer in the middle of the network. It might
78also have substantial disk space. The client communicates with a cache
79using the normal BitTorrent protocol.</p>
80<p>With this extension, BitTorrent clients are able to discover caches
81nearby on the network.  When a cache is present, the user benefits
82from having a high capacity peer from which the user's client
83downloads and to which it can delegate seeding.  When a cache inside
84the user's ISP network seeds on behalf of the client, it frees
85upstream capacity in the user's access network benefiting the user and
86those that share the access network.  When subsequent peers transfer
87from their ISP's cache, the ISP experiences less transit traffic.</p>
88<p>This is meant as a simpler alternative than presented in BEP-22
89<a class="footnote-reference" href="#bep-22" id="id1">[3]</a> though further from the intended usage of the Domain Name
90System (DNS) and existing standards.</p>
91</div>
92<div class="section" id="the-discovery-mechanism">
93<h1>The Discovery Mechanism</h1>
94<p>To find the caches for its ISP, a BitTorrent client performs a reverse
95DNS lookup on its external IP address, prepends &quot;bittorrent-tracker&quot;
96and resolves the resulting domain name to find the tracker.
97For example, a host with address 69.107.0.14 obtains the PTR record at</p>
98<pre class="literal-block">
9914.0.107.69.in-addr.arpa
100</pre>
101<p>The client's host IP address may not match the host's IP address as
102seen outside the client's private network.  We address this in Section
103<a class="reference internal" href="#network-address-translators">Network Address Translators</a>.</p>
104<p>The PTR resource record returned for this example contains domain name</p>
105<pre class="literal-block">
106adsl-69-107-0-14.dsl.pltn13.pacbell.net
107</pre>
108<p>The client then resolves the domain name</p>
109<pre class="literal-block">
110bittorrent-tracker.adsl-69-107-0-14.dsl.pltn13.pacbell.net
111</pre>
112<p>If no IP address(es) are found, one or more subsequent queries take place as
113described in <a class="reference internal" href="#iterative-queries">Iterative Queries</a>.</p>
114<p>The returned tracker(s) are called <em>cache trackers</em>, but the protocol
115to talk to these trackers is no different from the standard BitTorrent tracker
116protocol described in <a class="footnote-reference" href="#bep-3" id="id2">[1]</a>.</p>
117<p>When the BitTorrent client joins a swarm it announces to one or more
118of the trackers referenced in the .torrent file and announces to the
119cache tracker.  The cache tracker returns peers which may be caches or
120other peers that announced the same file to the cache tracker.</p>
121<p>A cache is a BitTorrent peer.  A client MAY treat it preferentially.</p>
122<p>Reverse DNS lookups are described in <a class="reference external" href="http://www.faqs.org/rfcs/rfc1034.html">RFC 1034</a> <a class="footnote-reference" href="#rfc-1034" id="id3">[5]</a>.</p>
123</div>
124<div class="section" id="iterative-queries">
125<h1>Iterative Queries</h1>
126<p>The domain name returned from the reverse DNS lookup is specific to
127the querying host.  In the naive implementation in DNS, there would be
128one bittorrent-tracker A or AAAA resource record for every querying host.
129The most obvious solution is to use a wildcard of the form:</p>
130<pre class="literal-block">
131bittorrent-tracker.*.pacbell.net
132</pre>
133<p>However, section 4.3.3 in <a class="footnote-reference" href="#rfc-1034" id="id4">[5]</a> specifies that wildcards only
134appear as the first label in a domain name.  This restriction was
135lifted in <a class="footnote-reference" href="#rfc-4592" id="id5">[7]</a>, but not with semantics applicable to our use
136case.  An asterisk not at the beginning of a domain name is not
137treated like a wildcard.  Only a lookup for the exact domain name</p>
138<pre class="literal-block">
139bittorrent-tracker.*.pacbell.net
140</pre>
141<p>matches.</p>
142<p>We propose an alternative that avoids wildcards and allows
143suborganizations to override mappings provided by parent
144organizations: the peer starts by querying using its fully-qualified
145domain name returned from the reverse DNS lookup, and if this fails
146then it queries again after removing the most specific (leftmost)
147label in the domain name.  For example, if no A/AAAA records are returned
148when querying for</p>
149<pre class="literal-block">
150bittorrent-tracker.adsl-69-107-0-14.dsl.pltn13.pacbell.net
151</pre>
152<p>then the client queries for</p>
153<pre class="literal-block">
154bittorrent-tracker.dsl.pltn13.pacbell.net
155</pre>
156<p>and then</p>
157<pre class="literal-block">
158bittorrent-tracker.pltn13.pacbell.net
159</pre>
160<p>The search removes one label at a time terminating when one or more
161resource records are found or before querying the root domain or
162top-level domains that are not ccTLDs, e.g., .com, .org, .net. We
163avoid querying the root or top-level domains given the low likelihood
164that caches would be defined globally, and thus clients would
165unnecessarily burden the root domain name servers with queries
166generating negative results. We considered stopping before querying
167country-level domains, but a country providing public infrastructure
168might choose to provide caches.</p>
169</div>
170<div class="section" id="network-address-translators">
171<h1>Network Address Translators</h1>
172<p>Many hosts on the Internet sit in private networks that connect to the
173Internet via a Network Address Translator (NAT).  Such hosts may have
174an IP address allocated from one of the private IP address ranges
175defined by IANA, e.g., ranges with prefixes 10/8, 172.16/12, and
176192.168/16.  When communicating with hosts outside the private
177network, the NAT translates the private IP to a globally-routable IP
178address.  This globally-routable address is the host's <em>external IP
179address</em>.</p>
180<p>When finding a cache, the BitTorrent client must use its host's
181external IP address.  A BitTorrent client can obtain its host's
182external IP either from the <em>external ip</em> key returned from a tracker
183implementing BEP 24 <a class="footnote-reference" href="#bep-24" id="id6">[4]</a> or from peers using the <em>yourip</em>
184extension defined for the <em>Extension Protocol</em> proposed in <a class="footnote-reference" href="#bep-10" id="id7">[2]</a>.</p>
185</div>
186<div class="section" id="example">
187<h1>Example</h1>
188<p>In our example, we use AT&amp;T's PacBell network.  AT&amp;T could implement
189cache discovery by adding the following lines to the zone file for
190pacbell.net,</p>
191<pre class="literal-block">
192bittorrent-tracker.pacbell.net.      IN  A   206.13.28.15
193</pre>
194<p>Now when a client performs cache discovery, it performs three DNS
195queries removing labels before reaching the domain name pacbell.net,
196at which point the SRV record is returned and the client queries
197tracker.pacbell.net to obtain the domain names of caches.</p>
198<p>In Python, the cache tracker's address can be obtained using the following:</p>
199<pre class="literal-block">
200import socket
201
202tlds = [&quot;com&quot;, &quot;net&quot;, &quot;org&quot;]  # add more here.
203
204name, aliases, ipaddrs = socket.gethostbyaddr(&quot;69.107.0.14&quot;)
205names = name.split('.')
206while names and names[0] not in tlds:
207   name = &quot;bittorrent-tracker.&quot; + &quot;.&quot;.join(names)
208   try:
209     ip = socket.gethostbyname(name)
210     break
211   except:
212     del names[0]
213
214print &quot;response=&quot;, ip
215</pre>
216<p>which might generate output like</p>
217<pre class="literal-block">
218response='151.164.129.4'
219</pre>
220<p>The answer above is fictional since AT&amp;T does not at this time
221implement SRV records for BitTorrent trackers.</p>
222</div>
223<div class="section" id="references">
224<h1>References</h1>
225<table class="docutils footnote" frame="void" id="bep-3" rules="none">
226<colgroup><col class="label" /><col /></colgroup>
227<tbody valign="top">
228<tr><td class="label"><a class="fn-backref" href="#id2">[1]</a></td><td>BEP_0003. The BitTorrent Protocol Specification, Cohen
229<a class="reference external" href="http://www.bittorrent.org/beps/bep_0003.html">http://www.bittorrent.org/beps/bep_0003.html</a></td></tr>
230</tbody>
231</table>
232<table class="docutils footnote" frame="void" id="bep-10" rules="none">
233<colgroup><col class="label" /><col /></colgroup>
234<tbody valign="top">
235<tr><td class="label"><a class="fn-backref" href="#id7">[2]</a></td><td>BEP_0010.  Extension Protocol. Norberg, Strigeus, Hazel
236<a class="reference external" href="http://www.bittorrent.org/beps/bep_0010.html">http://www.bittorrent.org/beps/bep_0010.html</a></td></tr>
237</tbody>
238</table>
239<table class="docutils footnote" frame="void" id="bep-22" rules="none">
240<colgroup><col class="label" /><col /></colgroup>
241<tbody valign="top">
242<tr><td class="label"><a class="fn-backref" href="#id1">[3]</a></td><td>BEP_0022.  BitTorrent Cache Discovery Protocol.  Harrison,
243Shalunov, Hazel. <a class="reference external" href="http://www.bittorrent.org/beps/bep_0010.html">http://www.bittorrent.org/beps/bep_0010.html</a></td></tr>
244</tbody>
245</table>
246<table class="docutils footnote" frame="void" id="bep-24" rules="none">
247<colgroup><col class="label" /><col /></colgroup>
248<tbody valign="top">
249<tr><td class="label"><a class="fn-backref" href="#id6">[4]</a></td><td>BEP_0024.  Tracker Returns External IP.  Harrison
250<a class="reference external" href="http://www.bittorrent.org/beps/bep_0024.html">http://www.bittorrent.org/beps/bep_0024.html</a></td></tr>
251</tbody>
252</table>
253<table class="docutils footnote" frame="void" id="rfc-1034" rules="none">
254<colgroup><col class="label" /><col /></colgroup>
255<tbody valign="top">
256<tr><td class="label">[5]</td><td><em>(<a class="fn-backref" href="#id3">1</a>, <a class="fn-backref" href="#id4">2</a>)</em> <a class="reference external" href="http://www.faqs.org/rfcs/rfc1034.html">RFC-1034</a>.  DOMAIN NAMES - CONCEPTS AND FACILITIES. Mockapetris,
257November 1987. <a class="reference external" href="http://tools.ietf.org/html/rfc1034">http://tools.ietf.org/html/rfc1034</a></td></tr>
258</tbody>
259</table>
260<table class="docutils footnote" frame="void" id="rfc-2782" rules="none">
261<colgroup><col class="label" /><col /></colgroup>
262<tbody valign="top">
263<tr><td class="label">[6]</td><td><a class="reference external" href="http://www.faqs.org/rfcs/rfc2782.html">RFC-2782</a>.  A DNS RR for specifying the location of services (DNS
264SRV). Gulbrandsen, Vixie, Esibov. February 2000.
265<a class="reference external" href="http://tools.ietf.org/html/rfc2782">http://tools.ietf.org/html/rfc2782</a></td></tr>
266</tbody>
267</table>
268<table class="docutils footnote" frame="void" id="rfc-4592" rules="none">
269<colgroup><col class="label" /><col /></colgroup>
270<tbody valign="top">
271<tr><td class="label"><a class="fn-backref" href="#id5">[7]</a></td><td><a class="reference external" href="http://www.faqs.org/rfcs/rfc4592.html">RFC-4592</a>. The Role of Wildcards in the Domain Name System. Lewis
272<a class="reference external" href="http://www.faqs.org/rfcs/rfc4592.html">http://www.faqs.org/rfcs/rfc4592.html</a></td></tr>
273</tbody>
274</table>
275</div>
276<div class="section" id="copyright">
277<h1>Copyright</h1>
278<p>This document has been placed in the public domain.</p>
279<!-- Local Variables:
280mode: indented-text
281indent-tabs-mode: nil
282sentence-end-double-space: t
283fill-column: 70
284coding: utf-8
285End: -->
286</div>
287
288
289</div>
290        <div id="footer">
291<hr/>
292</div>
293
294</div>
295</body>
296</html>
Note: See TracBrowser for help on using the browser.