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

Revision 11114, 7.8 kB (checked in by dave, 2 months ago)

Fix broken URL.

Line 
1BEP: 25
2Title: An Alternate BitTorrent Cache Discovery Protocol
3Version: $Revision$
4Last-Modified: $Date$
5Author:  David Harrison <dave@bittorrent.com>, Greg Hazel <greg@bittorrent.com>, Stanislav Shalunov <shalunov@bittorrent.com>
6Status:  Draft
7Type:    Standards track
8Content-Type: text/x-rst
9Created: 20-May-2008
10Post-History: 
11
12Motivation
13==========
14
15Some Internet Service Providers (ISPs) may be interested in deploying
16BitTorrent caches to lower transit costs, reduce internal traffic, and
17improve user experience by speeding up downloads.
18
19A cache is simply a fast peer in the middle of the network. It might
20also have substantial disk space. The client communicates with a cache
21using the normal BitTorrent protocol.
22
23With this extension, BitTorrent clients are able to discover caches
24nearby on the network.  When a cache is present, the user benefits
25from having a high capacity peer from which the user's client
26downloads and to which it can delegate seeding.  When a cache inside
27the user's ISP network seeds on behalf of the client, it frees
28upstream capacity in the user's access network benefiting the user and
29those that share the access network.  When subsequent peers transfer
30from their ISP's cache, the ISP experiences less transit traffic.
31
32This is meant as a simpler alternative than presented in BEP-22
33[#BEP-22]_ though further from the intended usage of the Domain Name
34System (DNS) and existing standards.
35
36The Discovery Mechanism
37=======================
38
39To find the caches for its ISP, a BitTorrent client performs a reverse
40DNS lookup on its external IP address, prepends "bittorrent-tracker"
41and resolves the resulting domain name to find the tracker.
42For example, a host with address 69.107.0.14 obtains the PTR record at
43
44::
45
46  14.0.107.69.in-addr.arpa
47
48The client's host IP address may not match the host's IP address as
49seen outside the client's private network.  We address this in Section
50`Network Address Translators`_.
51
52The PTR resource record returned for this example contains domain name
53
54::
55
56  adsl-69-107-0-14.dsl.pltn13.pacbell.net
57
58The client then resolves the domain name
59
60::
61 
62  bittorrent-tracker.adsl-69-107-0-14.dsl.pltn13.pacbell.net
63
64If no IP address(es) are found, one or more subsequent queries take place as
65described in `Iterative Queries`_.
66
67The returned tracker(s) are called *cache trackers*, but the protocol
68to talk to these trackers is no different from the standard BitTorrent tracker
69protocol described in [#BEP-3]_.
70
71When the BitTorrent client joins a swarm it announces to one or more
72of the trackers referenced in the .torrent file and announces to the
73cache tracker.  The cache tracker returns peers which may be caches or
74other peers that announced the same file to the cache tracker.
75
76A cache is a BitTorrent peer.  A client MAY treat it preferentially.
77 
78Reverse DNS lookups are described in RFC 1034 [#RFC-1034]_.
79
80
81Iterative Queries
82=================
83
84The domain name returned from the reverse DNS lookup is specific to
85the querying host.  In the naive implementation in DNS, there would be
86one bittorrent-tracker A or AAAA resource record for every querying host. 
87The most obvious solution is to use a wildcard of the form::
88
89  bittorrent-tracker.*.pacbell.net
90
91However, section 4.3.3 in [#RFC-1034]_ specifies that wildcards only
92appear as the first label in a domain name.  This restriction was
93lifted in [#RFC-4592]_, but not with semantics applicable to our use
94case.  An asterisk not at the beginning of a domain name is not
95treated like a wildcard.  Only a lookup for the exact domain name
96
97::
98
99  bittorrent-tracker.*.pacbell.net
100
101matches.
102
103We propose an alternative that avoids wildcards and allows
104suborganizations to override mappings provided by parent
105organizations: the peer starts by querying using its fully-qualified
106domain name returned from the reverse DNS lookup, and if this fails
107then it queries again after removing the most specific (leftmost)
108label in the domain name.  For example, if no A/AAAA records are returned
109when querying for
110
111::
112
113  bittorrent-tracker.adsl-69-107-0-14.dsl.pltn13.pacbell.net
114
115then the client queries for
116
117::
118
119  bittorrent-tracker.dsl.pltn13.pacbell.net
120
121and then
122
123::
124
125  bittorrent-tracker.pltn13.pacbell.net
126
127The search removes one label at a time terminating when one or more
128resource records are found or before querying the root domain or
129top-level domains that are not ccTLDs, e.g., .com, .org, .net. We
130avoid querying the root or top-level domains given the low likelihood
131that caches would be defined globally, and thus clients would
132unnecessarily burden the root domain name servers with queries
133generating negative results. We considered stopping before querying
134country-level domains, but a country providing public infrastructure
135might choose to provide caches.
136
137
138Network Address Translators
139===========================
140
141Many hosts on the Internet sit in private networks that connect to the
142Internet via a Network Address Translator (NAT).  Such hosts may have
143an IP address allocated from one of the private IP address ranges
144defined by IANA, e.g., ranges with prefixes 10/8, 172.16/12, and
145192.168/16.  When communicating with hosts outside the private
146network, the NAT translates the private IP to a globally-routable IP
147address.  This globally-routable address is the host's *external IP
148address*.
149
150When finding a cache, the BitTorrent client must use its host's
151external IP address.  A BitTorrent client can obtain its host's
152external IP either from the *external ip* key returned from a tracker
153implementing BEP 24 [#BEP-24]_ or from peers using the *yourip*
154extension defined for the *Extension Protocol* proposed in [#BEP-10]_.
155
156
157Example
158=======
159
160In our example, we use AT&T's PacBell network.  AT&T could implement
161cache discovery by adding the following lines to the zone file for
162pacbell.net,
163
164::
165
166  bittorrent-tracker.pacbell.net.      IN  A   206.13.28.15
167
168Now when a client performs cache discovery, it performs three DNS
169queries removing labels before reaching the domain name pacbell.net,
170at which point the SRV record is returned and the client queries
171tracker.pacbell.net to obtain the domain names of caches.
172
173In Python, the cache tracker's address can be obtained using the following::
174
175  import socket
176 
177  tlds = ["com", "net", "org"]  # add more here.
178 
179  name, aliases, ipaddrs = socket.gethostbyaddr("69.107.0.14")
180  names = name.split('.')
181  while names and names[0] not in tlds:
182     name = "bittorrent-tracker." + ".".join(names)
183     try:
184       ip = socket.gethostbyname(name)
185       break
186     except:
187       del names[0]
188 
189  print "response=", ip
190
191which might generate output like
192
193::
194
195  response='151.164.129.4'
196
197The answer above is fictional since AT&T does not at this time
198implement SRV records for BitTorrent trackers.
199
200References
201==========
202
203.. [#BEP-3] BEP_0003. The BitTorrent Protocol Specification, Cohen
204   http://www.bittorrent.org/beps/bep_0003.html
205
206.. [#BEP-10] BEP_0010.  Extension Protocol. Norberg, Strigeus, Hazel
207   http://www.bittorrent.org/beps/bep_0010.html
208
209.. [#BEP-22] BEP_0022.  BitTorrent Cache Discovery Protocol.  Harrison,
210   Shalunov, Hazel. http://www.bittorrent.org/beps/bep_0010.html
211
212.. [#BEP-24] BEP_0024.  Tracker Returns External IP.  Harrison
213   http://www.bittorrent.org/beps/bep_0024.html
214
215.. [#RFC-1034] RFC-1034.  DOMAIN NAMES - CONCEPTS AND FACILITIES. Mockapetris,
216   November 1987. http://tools.ietf.org/html/rfc1034
217
218.. [#RFC-2782] RFC-2782.  A DNS RR for specifying the location of services (DNS
219   SRV). Gulbrandsen, Vixie, Esibov. February 2000.
220   http://tools.ietf.org/html/rfc2782
221
222.. [#RFC-4592] RFC-4592. The Role of Wildcards in the Domain Name System. Lewis
223   http://www.faqs.org/rfcs/rfc4592.html
224
225
226
227
228Copyright
229=========
230
231This document has been placed in the public domain.
232
233
234
235..
236   Local Variables:
237   mode: indented-text
238   indent-tabs-mode: nil
239   sentence-end-double-space: t
240   fill-column: 70
241   coding: utf-8
242   End:
Note: See TracBrowser for help on using the browser.