| 1 | BEP: 25 |
|---|
| 2 | Title: An Alternate BitTorrent Cache Discovery Protocol |
|---|
| 3 | Version: $Revision$ |
|---|
| 4 | Last-Modified: $Date$ |
|---|
| 5 | Author: David Harrison <dave@bittorrent.com>, Greg Hazel <greg@bittorrent.com>, Stanislav Shalunov <shalunov@bittorrent.com> |
|---|
| 6 | Status: Draft |
|---|
| 7 | Type: Standards track |
|---|
| 8 | Content-Type: text/x-rst |
|---|
| 9 | Created: 20-May-2008 |
|---|
| 10 | Post-History: |
|---|
| 11 | |
|---|
| 12 | Motivation |
|---|
| 13 | ========== |
|---|
| 14 | |
|---|
| 15 | Some Internet Service Providers (ISPs) may be interested in deploying |
|---|
| 16 | BitTorrent caches to lower transit costs, reduce internal traffic, and |
|---|
| 17 | improve user experience by speeding up downloads. |
|---|
| 18 | |
|---|
| 19 | A cache is simply a fast peer in the middle of the network. It might |
|---|
| 20 | also have substantial disk space. The client communicates with a cache |
|---|
| 21 | using the normal BitTorrent protocol. |
|---|
| 22 | |
|---|
| 23 | With this extension, BitTorrent clients are able to discover caches |
|---|
| 24 | nearby on the network. When a cache is present, the user benefits |
|---|
| 25 | from having a high capacity peer from which the user's client |
|---|
| 26 | downloads and to which it can delegate seeding. When a cache inside |
|---|
| 27 | the user's ISP network seeds on behalf of the client, it frees |
|---|
| 28 | upstream capacity in the user's access network benefiting the user and |
|---|
| 29 | those that share the access network. When subsequent peers transfer |
|---|
| 30 | from their ISP's cache, the ISP experiences less transit traffic. |
|---|
| 31 | |
|---|
| 32 | This is meant as a simpler alternative than presented in BEP-22 |
|---|
| 33 | [#BEP-22]_ though further from the intended usage of the Domain Name |
|---|
| 34 | System (DNS) and existing standards. |
|---|
| 35 | |
|---|
| 36 | The Discovery Mechanism |
|---|
| 37 | ======================= |
|---|
| 38 | |
|---|
| 39 | To find the caches for its ISP, a BitTorrent client performs a reverse |
|---|
| 40 | DNS lookup on its external IP address, prepends "bittorrent-tracker" |
|---|
| 41 | and resolves the resulting domain name to find the tracker. |
|---|
| 42 | For 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 | |
|---|
| 48 | The client's host IP address may not match the host's IP address as |
|---|
| 49 | seen outside the client's private network. We address this in Section |
|---|
| 50 | `Network Address Translators`_. |
|---|
| 51 | |
|---|
| 52 | The PTR resource record returned for this example contains domain name |
|---|
| 53 | |
|---|
| 54 | :: |
|---|
| 55 | |
|---|
| 56 | adsl-69-107-0-14.dsl.pltn13.pacbell.net |
|---|
| 57 | |
|---|
| 58 | The client then resolves the domain name |
|---|
| 59 | |
|---|
| 60 | :: |
|---|
| 61 | |
|---|
| 62 | bittorrent-tracker.adsl-69-107-0-14.dsl.pltn13.pacbell.net |
|---|
| 63 | |
|---|
| 64 | If no IP address(es) are found, one or more subsequent queries take place as |
|---|
| 65 | described in `Iterative Queries`_. |
|---|
| 66 | |
|---|
| 67 | The returned tracker(s) are called *cache trackers*, but the protocol |
|---|
| 68 | to talk to these trackers is no different from the standard BitTorrent tracker |
|---|
| 69 | protocol described in [#BEP-3]_. |
|---|
| 70 | |
|---|
| 71 | When the BitTorrent client joins a swarm it announces to one or more |
|---|
| 72 | of the trackers referenced in the .torrent file and announces to the |
|---|
| 73 | cache tracker. The cache tracker returns peers which may be caches or |
|---|
| 74 | other peers that announced the same file to the cache tracker. |
|---|
| 75 | |
|---|
| 76 | A cache is a BitTorrent peer. A client MAY treat it preferentially. |
|---|
| 77 | |
|---|
| 78 | Reverse DNS lookups are described in RFC 1034 [#RFC-1034]_. |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | Iterative Queries |
|---|
| 82 | ================= |
|---|
| 83 | |
|---|
| 84 | The domain name returned from the reverse DNS lookup is specific to |
|---|
| 85 | the querying host. In the naive implementation in DNS, there would be |
|---|
| 86 | one bittorrent-tracker A or AAAA resource record for every querying host. |
|---|
| 87 | The most obvious solution is to use a wildcard of the form:: |
|---|
| 88 | |
|---|
| 89 | bittorrent-tracker.*.pacbell.net |
|---|
| 90 | |
|---|
| 91 | However, section 4.3.3 in [#RFC-1034]_ specifies that wildcards only |
|---|
| 92 | appear as the first label in a domain name. This restriction was |
|---|
| 93 | lifted in [#RFC-4592]_, but not with semantics applicable to our use |
|---|
| 94 | case. An asterisk not at the beginning of a domain name is not |
|---|
| 95 | treated like a wildcard. Only a lookup for the exact domain name |
|---|
| 96 | |
|---|
| 97 | :: |
|---|
| 98 | |
|---|
| 99 | bittorrent-tracker.*.pacbell.net |
|---|
| 100 | |
|---|
| 101 | matches. |
|---|
| 102 | |
|---|
| 103 | We propose an alternative that avoids wildcards and allows |
|---|
| 104 | suborganizations to override mappings provided by parent |
|---|
| 105 | organizations: the peer starts by querying using its fully-qualified |
|---|
| 106 | domain name returned from the reverse DNS lookup, and if this fails |
|---|
| 107 | then it queries again after removing the most specific (leftmost) |
|---|
| 108 | label in the domain name. For example, if no A/AAAA records are returned |
|---|
| 109 | when querying for |
|---|
| 110 | |
|---|
| 111 | :: |
|---|
| 112 | |
|---|
| 113 | bittorrent-tracker.adsl-69-107-0-14.dsl.pltn13.pacbell.net |
|---|
| 114 | |
|---|
| 115 | then the client queries for |
|---|
| 116 | |
|---|
| 117 | :: |
|---|
| 118 | |
|---|
| 119 | bittorrent-tracker.dsl.pltn13.pacbell.net |
|---|
| 120 | |
|---|
| 121 | and then |
|---|
| 122 | |
|---|
| 123 | :: |
|---|
| 124 | |
|---|
| 125 | bittorrent-tracker.pltn13.pacbell.net |
|---|
| 126 | |
|---|
| 127 | The search removes one label at a time terminating when one or more |
|---|
| 128 | resource records are found or before querying the root domain or |
|---|
| 129 | top-level domains that are not ccTLDs, e.g., .com, .org, .net. We |
|---|
| 130 | avoid querying the root or top-level domains given the low likelihood |
|---|
| 131 | that caches would be defined globally, and thus clients would |
|---|
| 132 | unnecessarily burden the root domain name servers with queries |
|---|
| 133 | generating negative results. We considered stopping before querying |
|---|
| 134 | country-level domains, but a country providing public infrastructure |
|---|
| 135 | might choose to provide caches. |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | Network Address Translators |
|---|
| 139 | =========================== |
|---|
| 140 | |
|---|
| 141 | Many hosts on the Internet sit in private networks that connect to the |
|---|
| 142 | Internet via a Network Address Translator (NAT). Such hosts may have |
|---|
| 143 | an IP address allocated from one of the private IP address ranges |
|---|
| 144 | defined by IANA, e.g., ranges with prefixes 10/8, 172.16/12, and |
|---|
| 145 | 192.168/16. When communicating with hosts outside the private |
|---|
| 146 | network, the NAT translates the private IP to a globally-routable IP |
|---|
| 147 | address. This globally-routable address is the host's *external IP |
|---|
| 148 | address*. |
|---|
| 149 | |
|---|
| 150 | When finding a cache, the BitTorrent client must use its host's |
|---|
| 151 | external IP address. A BitTorrent client can obtain its host's |
|---|
| 152 | external IP either from the *external ip* key returned from a tracker |
|---|
| 153 | implementing BEP 24 [#BEP-24]_ or from peers using the *yourip* |
|---|
| 154 | extension defined for the *Extension Protocol* proposed in [#BEP-10]_. |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | Example |
|---|
| 158 | ======= |
|---|
| 159 | |
|---|
| 160 | In our example, we use AT&T's PacBell network. AT&T could implement |
|---|
| 161 | cache discovery by adding the following lines to the zone file for |
|---|
| 162 | pacbell.net, |
|---|
| 163 | |
|---|
| 164 | :: |
|---|
| 165 | |
|---|
| 166 | bittorrent-tracker.pacbell.net. IN A 206.13.28.15 |
|---|
| 167 | |
|---|
| 168 | Now when a client performs cache discovery, it performs three DNS |
|---|
| 169 | queries removing labels before reaching the domain name pacbell.net, |
|---|
| 170 | at which point the SRV record is returned and the client queries |
|---|
| 171 | tracker.pacbell.net to obtain the domain names of caches. |
|---|
| 172 | |
|---|
| 173 | In 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 | |
|---|
| 191 | which might generate output like |
|---|
| 192 | |
|---|
| 193 | :: |
|---|
| 194 | |
|---|
| 195 | response='151.164.129.4' |
|---|
| 196 | |
|---|
| 197 | The answer above is fictional since AT&T does not at this time |
|---|
| 198 | implement SRV records for BitTorrent trackers. |
|---|
| 199 | |
|---|
| 200 | References |
|---|
| 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 | |
|---|
| 228 | Copyright |
|---|
| 229 | ========= |
|---|
| 230 | |
|---|
| 231 | This 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: |
|---|