| 1 | BEP: 32 |
|---|
| 2 | Title: BitTorrent DHT Extensions for IPv6 |
|---|
| 3 | Version: $Revision$ |
|---|
| 4 | Last-Modified: $Date$ |
|---|
| 5 | Author: Juliusz Chroboczek <jch@pps.jussieu.fr> |
|---|
| 6 | Status: Draft |
|---|
| 7 | Type: Standards Track |
|---|
| 8 | Requires: 5 |
|---|
| 9 | Content-Type: text/x-rst |
|---|
| 10 | Created: 14-Oct-2009 |
|---|
| 11 | Post-History: 15-Oct-2009: Promote same ID in IPv6 and IPv4 nodes. Drop values6. Added some rationales |
|---|
| 12 | 11-Nov-2011: Change want to be a list of flags. Add nodes about MTU and source address selection. Define behaviour of PORT message. |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | Abstract |
|---|
| 16 | ======== |
|---|
| 17 | |
|---|
| 18 | This document describes a set of extensions to the BitTorrent DHT |
|---|
| 19 | [#BEP-5]_ to allow operation over IPv6. |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | Introduction |
|---|
| 23 | ============ |
|---|
| 24 | |
|---|
| 25 | The address exhaustion of the IPv4 Internet, and the coincident deployment |
|---|
| 26 | of Network Address Translation (NAT) devices, severely limits the |
|---|
| 27 | performance of the BitTorrent protocol by making an increasing number of |
|---|
| 28 | peers unreachable. The simple and efficient solution to this problem is to |
|---|
| 29 | deploy BitTorrent over the IPv6 protocol, which does not suffer from |
|---|
| 30 | address exhaustion. |
|---|
| 31 | |
|---|
| 32 | A number of extensions (mostly undocumented) to the BitTorrent |
|---|
| 33 | protocol have been defined in order to allow it to operate over IPv6. |
|---|
| 34 | Unfortunately, these extensions only allow locating IPv6 peers by |
|---|
| 35 | using trackers or through peer exchange -- but not from the DHT. This |
|---|
| 36 | document describes the procedures and message formats used in the IPv6 |
|---|
| 37 | DHT. |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | Operation |
|---|
| 41 | ========= |
|---|
| 42 | |
|---|
| 43 | There are two distinct DHTs: the IPv4 DHT, and the IPv6 DHT. |
|---|
| 44 | |
|---|
| 45 | The two DHTs are independent, meaning that no IPv6 data is stored in the |
|---|
| 46 | IPv4 DHT, and, conversely, no IPv4 data is stored in the IPv6 DHT. A node |
|---|
| 47 | wishing to participate in both DHTs must maintain two distinct routing |
|---|
| 48 | tables, one for IPv4 and one for IPv6. |
|---|
| 49 | |
|---|
| 50 | While this is not strictly necessary, a node should use the same node |
|---|
| 51 | id in both tables. This simplifies implementation and debugging, and |
|---|
| 52 | slightly increases efficiency in the case where the two DHTs are |
|---|
| 53 | mostly congruent. |
|---|
| 54 | |
|---|
| 55 | Usually, messages only carry data in the address family implied by the |
|---|
| 56 | network layer protocol. In the case of the find_nodes and get_peers |
|---|
| 57 | requests, however, the requestor may optionally request that the reply |
|---|
| 58 | should contain IPv4 node information, IPv6 node information, or both. |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | Single-protocol nodes |
|---|
| 62 | --------------------- |
|---|
| 63 | |
|---|
| 64 | A single-protocol node (IPv4 or IPv6) only participates in one DHT. Such |
|---|
| 65 | a node does not need to explicitly request data in a given family -- the |
|---|
| 66 | data provided by default is exactly what it needs. |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | Dual-stack nodes |
|---|
| 70 | ---------------- |
|---|
| 71 | |
|---|
| 72 | While conceptually equivalent to a pair of single-protocol nodes, |
|---|
| 73 | a dual-stack (IPv4 and IPv6) node can make bootstrap faster and |
|---|
| 74 | improve the reliability of the protocol by "leaking" data between the |
|---|
| 75 | two DHTs, as described in the following sections. |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | Bootstrapping |
|---|
| 79 | ''''''''''''' |
|---|
| 80 | |
|---|
| 81 | A dual-stack node that is bootstrapping its DHT will send find_nodes |
|---|
| 82 | requests in order to populate its routing tables. In order to accelerate |
|---|
| 83 | this process, it should request both IPv4 and IPv6 node information. |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | Steady-state operation |
|---|
| 87 | '''''''''''''''''''''' |
|---|
| 88 | |
|---|
| 89 | Once bootstrap is successful, a node should normally only request IPv4 |
|---|
| 90 | node information from IPv4 nodes, and IPv6 node information from IPv6 |
|---|
| 91 | nodes. Requesting node information for both address families in all |
|---|
| 92 | requests is unlikely to provide useful information, and hence |
|---|
| 93 | increases network traffic with no benefit. |
|---|
| 94 | |
|---|
| 95 | In order to increase the reliability of the DHT after a single-protocol |
|---|
| 96 | network outage, however, a node may *ocasionally* send a request for |
|---|
| 97 | IPv4 node information to an IPv6 node, or a request for IPv6 node |
|---|
| 98 | information to an IPv4 node. |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | Maximum packet size |
|---|
| 102 | ------------------- |
|---|
| 103 | |
|---|
| 104 | A node obeying this specification must not send UDP datagrams with |
|---|
| 105 | a payload larger than 1024 octets, and must be able to receive UDP |
|---|
| 106 | datagrams with a payload of 1024 octets or less. (In the interest of |
|---|
| 107 | robustness, a node should be able to receive datagrams with larger |
|---|
| 108 | payloads.) |
|---|
| 109 | |
|---|
| 110 | **Rationale**: a UDP datagram with a payload of 1024 octets easily |
|---|
| 111 | fits within the IPv6 minimum maximum packet size, which is 1280 |
|---|
| 112 | octets [#IPv6]_. In particular, such a packet will cross a Teredo |
|---|
| 113 | tunnel with no fragmentation. |
|---|
| 114 | |
|---|
| 115 | In principle, IPv4 nodes might be unable to reassemble packets |
|---|
| 116 | larger than 576 octets [#IPv4]_; in practice, however, due to the |
|---|
| 117 | predominance of Ethernet networks, all IPv4 nodes are able to |
|---|
| 118 | reassemble packets up to 1500 octets. |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | Source address selection |
|---|
| 122 | ------------------------ |
|---|
| 123 | |
|---|
| 124 | The IPv6 DHT should use a socket bound to one of the host's global |
|---|
| 125 | unicast IPv6 addresses rather than the "unspecified address" (::/128). |
|---|
| 126 | When selecting to which address to bind, Teredo addresses (addresses |
|---|
| 127 | in 2001:0000::/32) should be avoided if other global unicast addresses |
|---|
| 128 | are available. |
|---|
| 129 | |
|---|
| 130 | **Rationale**: The DHT relies on the publicly visible IP address of |
|---|
| 131 | each node to remain constant. Since multi-homing is common in IPv6, |
|---|
| 132 | it is particularly important to bind the IPv6 socket to a well-defined |
|---|
| 133 | address. |
|---|
| 134 | |
|---|
| 135 | While Teredo traffic can, in principle, be more efficient than |
|---|
| 136 | native traffic, especially when speaking to other Teredo hosts, |
|---|
| 137 | experience shows that Teredo routing tends to be brittle; hence, |
|---|
| 138 | Teredo addresses should be avoided whenever possible. |
|---|
| 139 | |
|---|
| 140 | The same issues apply to multi-homed IPv4 hosts. However, in IPv4 |
|---|
| 141 | multi-homing is not as common as in IPv6, and in the presence of NAT |
|---|
| 142 | the issues are somewhat more complicated, so this specification |
|---|
| 143 | refrains from making any recommendations about binding of IPv4 |
|---|
| 144 | sockets. |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | Changes to the BitTorrent protocol |
|---|
| 148 | ================================== |
|---|
| 149 | |
|---|
| 150 | The PORT message, as defined in BEP-5, is extended to work over both |
|---|
| 151 | IPv4 and IPv6. The information provided by the PORT message only |
|---|
| 152 | applies to the address it was sent from; this implies that a PORT |
|---|
| 153 | message sent over IPv4 only advertises participation in the IPv4 DHT, |
|---|
| 154 | and a PORT message sent over IPv6 only advertises participation in the |
|---|
| 155 | IPv6 DHT. |
|---|
| 156 | |
|---|
| 157 | Multihomed hosts should take care to only send PORT messages over |
|---|
| 158 | connections established from the address on which they participate in |
|---|
| 159 | the DHT. |
|---|
| 160 | |
|---|
| 161 | **Rationale**: in the presence of the LTEP extension negotiation |
|---|
| 162 | protocol [#BEP-10]_, which advertises a peer's addresses across |
|---|
| 163 | address families, it would in principle be possible to use the PORT |
|---|
| 164 | message for both address families. However, since an implementation |
|---|
| 165 | need not participate in both DHTs, nor use the same port in both |
|---|
| 166 | DHTs, this specification leaves the role of bridging the two DHTs to |
|---|
| 167 | the 'find_nodes' message (see below). |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | Changes and extensions to existing messages |
|---|
| 171 | =========================================== |
|---|
| 172 | |
|---|
| 173 | Changes to existing parameters |
|---|
| 174 | ------------------------------ |
|---|
| 175 | |
|---|
| 176 | values |
|---|
| 177 | '''''' |
|---|
| 178 | |
|---|
| 179 | In a reply sent over IPv4, the "values" parameter contains a list of |
|---|
| 180 | strings, each of which contains compact format IPv4 contact |
|---|
| 181 | information for a single peer. |
|---|
| 182 | |
|---|
| 183 | In a reply sent over IPv6, "values" contains a list of strings, each |
|---|
| 184 | of which contains compact format IPv6 contact information for a single |
|---|
| 185 | peer. |
|---|
| 186 | |
|---|
| 187 | Implementations of this specification must be able to properly parse |
|---|
| 188 | hybrid "values" lists -- lists containing an arbitrary mixture of |
|---|
| 189 | 6-octet IPv4 values and 18-octet IPv6 values. However, implementations |
|---|
| 190 | should not send such hybrid lists, and must not send hybrid lists in |
|---|
| 191 | a reply to an IPv4 request that doesn't contain a "want" parameter. |
|---|
| 192 | |
|---|
| 193 | **Rationale**: a request sent over IPv4 with no "want" parameter |
|---|
| 194 | could originate from a node that implements plain BEP-5, and which |
|---|
| 195 | might therefore be unable to parse a hybrid list. |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | New parameters |
|---|
| 199 | -------------- |
|---|
| 200 | |
|---|
| 201 | nodes6 |
|---|
| 202 | '''''' |
|---|
| 203 | |
|---|
| 204 | The "nodes6" parameter is analogous to the "nodes" parameter: when |
|---|
| 205 | present, it carries a string containing the compact IPv6 node |
|---|
| 206 | information for the 8 closest good nodes in the sending node's IPv6 |
|---|
| 207 | routing table. This parameter is allowed in replies to the find_nodes |
|---|
| 208 | and get_peers messages (see below). |
|---|
| 209 | |
|---|
| 210 | |
|---|
| 211 | want |
|---|
| 212 | '''' |
|---|
| 213 | |
|---|
| 214 | The "want" parameter is allowed in the find_nodes and get_peers requests, |
|---|
| 215 | and governs the presence or absence of the "nodes" and "nodes6" parameters |
|---|
| 216 | in the requested reply. Its value is a list of one or more strings, which |
|---|
| 217 | may include |
|---|
| 218 | |
|---|
| 219 | * "n4": the node requests the presence of a "nodes" key; |
|---|
| 220 | |
|---|
| 221 | * "n6": the node requests the presence of a "nodes6" key. |
|---|
| 222 | |
|---|
| 223 | For future extensibility, other strings may be present in the list, |
|---|
| 224 | and must be silently ignored on reception. |
|---|
| 225 | |
|---|
| 226 | **Rationale**: the "want" parameter is not intended to carry random |
|---|
| 227 | sundry flags, which can simply be included in the top-level |
|---|
| 228 | dictionary of the message. Extending the "want" parameter without |
|---|
| 229 | good reason is not recommended. |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | Changes to message semantics |
|---|
| 233 | ---------------------------- |
|---|
| 234 | |
|---|
| 235 | find_nodes and get_peers |
|---|
| 236 | '''''''''''''''''''''''' |
|---|
| 237 | |
|---|
| 238 | A node sending a find_nodes or get_peers request may include a "want" |
|---|
| 239 | parameter containing one or both of the strings "n4" or "n6". A node |
|---|
| 240 | replying to a find_nodes or get_peers request that includes a "want" |
|---|
| 241 | parameter should include a "nodes" parameter if the request's "want" |
|---|
| 242 | parameter contained the string "n4", and should include a "nodes6" |
|---|
| 243 | parameter if the request's "want" parameter contained the string "n6". |
|---|
| 244 | |
|---|
| 245 | In the absence of a "want" parameter, the reply should include "nodes" |
|---|
| 246 | if the request was sent over IPv4, and should include "nodes6" if the |
|---|
| 247 | request was sent over IPv6. |
|---|
| 248 | |
|---|
| 249 | **Rationale**: this is an incompatible change to the protocol |
|---|
| 250 | defined in BEP-5, which specifies that "nodes" and "values" are |
|---|
| 251 | mutually exclusive. However, this change makes the DHT more |
|---|
| 252 | reliable, and has been deployed by most implementations with no |
|---|
| 253 | negative effects. |
|---|
| 254 | |
|---|
| 255 | When a node receives a get_peers request and it has peer contact |
|---|
| 256 | information for the matching address family and info-hash, it should |
|---|
| 257 | additionally include a "values" parameter containing a list of 6-octet |
|---|
| 258 | strings if the request was sent over IPv4, and a list of 18-octet |
|---|
| 259 | strings if the request was sent over IPv6. |
|---|
| 260 | |
|---|
| 261 | A reply sent over IPv4 should not contain 18-octet IPv6 contact |
|---|
| 262 | information, and a reply sent over IPv6 should not contain 6-octet |
|---|
| 263 | IPv4 contact information. In other words, the "want" parameter only |
|---|
| 264 | governs the presence of the "nodes" and "nodes6" parameters, not the |
|---|
| 265 | interpretation of "values". |
|---|
| 266 | |
|---|
| 267 | **Rationale**: if the requesting node is a single-stack node, it has |
|---|
| 268 | no interest in values of the other address family. If the |
|---|
| 269 | requesting node is a dual-stack node, then it must perform the two |
|---|
| 270 | announces in parallel; providing both sets of data in both sets of |
|---|
| 271 | replies merely increases the amount of traffic without giving any |
|---|
| 272 | extra information. |
|---|
| 273 | |
|---|
| 274 | |
|---|
| 275 | announce_peers |
|---|
| 276 | '''''''''''''' |
|---|
| 277 | |
|---|
| 278 | The syntax of the announce_peers request and reply are unchanged. This |
|---|
| 279 | implies that an announce_peers request sent over IPv4 may only advertise an |
|---|
| 280 | IPv4 address, and an announce_peers request sent over IPv6 may only |
|---|
| 281 | advertise an IPv6 address. |
|---|
| 282 | |
|---|
| 283 | |
|---|
| 284 | Acknowledgements |
|---|
| 285 | ================ |
|---|
| 286 | |
|---|
| 287 | I gratefully acknowledge the help of *The 8472* and *arvid* in |
|---|
| 288 | developing this specification. |
|---|
| 289 | |
|---|
| 290 | |
|---|
| 291 | References |
|---|
| 292 | ========== |
|---|
| 293 | |
|---|
| 294 | .. [#BEP-5] BEP_0005. DHT Protocol. |
|---|
| 295 | (http://www.bittorrent.org/beps/bep_0005.html) |
|---|
| 296 | |
|---|
| 297 | .. [#BEP-10] BEP_0010. Extension Protocol. |
|---|
| 298 | (http://www.bittorrent.org/beps/bep_0010.html) |
|---|
| 299 | |
|---|
| 300 | .. [#IPv6] RFC 2460. Internet Protocol, Version 6 (IPv6) Specification. |
|---|
| 301 | S. Deering, R. Hinden. December 1998. |
|---|
| 302 | |
|---|
| 303 | .. [#IPv4] RFC 791. Internet Protocol. J. Postel. September 1981. |
|---|
| 304 | |
|---|
| 305 | |
|---|
| 306 | Copyright |
|---|
| 307 | ========= |
|---|
| 308 | |
|---|
| 309 | This document is in the public domain. |
|---|
| 310 | |
|---|
| 311 | |
|---|
| 312 | .. |
|---|
| 313 | Local Variables: |
|---|
| 314 | mode: indented-text |
|---|
| 315 | indent-tabs-mode: nil |
|---|
| 316 | sentence-end-double-space: t |
|---|
| 317 | fill-column: 70 |
|---|
| 318 | coding: utf-8 |
|---|
| 319 | End: |
|---|
| 320 | |
|---|