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

Revision 11187, 11.3 KB (checked in by bittorrent, 4 months ago)

updated bep32

Line 
1BEP: 32
2Title: BitTorrent DHT Extensions for IPv6
3Version: $Revision$
4Last-Modified: $Date$
5Author:  Juliusz Chroboczek <jch@pps.jussieu.fr>
6Status:  Draft
7Type:    Standards Track
8Requires: 5
9Content-Type: text/x-rst
10Created: 14-Oct-2009
11Post-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
15Abstract
16========
17
18This document describes a set of extensions to the BitTorrent DHT
19[#BEP-5]_ to allow operation over IPv6.
20
21
22Introduction
23============
24
25The address exhaustion of the IPv4 Internet, and the coincident deployment
26of Network Address Translation (NAT) devices, severely limits the
27performance of the BitTorrent protocol by making an increasing number of
28peers unreachable.  The simple and efficient solution to this problem is to
29deploy BitTorrent over the IPv6 protocol, which does not suffer from
30address exhaustion.
31
32A number of extensions (mostly undocumented) to the BitTorrent
33protocol have been defined in order to allow it to operate over IPv6.
34Unfortunately, these extensions only allow locating IPv6 peers by
35using trackers or through peer exchange -- but not from the DHT.  This
36document describes the procedures and message formats used in the IPv6
37DHT.
38
39
40Operation
41=========
42
43There are two distinct DHTs: the IPv4 DHT, and the IPv6 DHT.
44
45The two DHTs are independent, meaning that no IPv6 data is stored in the
46IPv4 DHT, and, conversely, no IPv4 data is stored in the IPv6 DHT.  A node
47wishing to participate in both DHTs must maintain two distinct routing
48tables, one for IPv4 and one for IPv6.
49
50While this is not strictly necessary, a node should use the same node
51id in both tables.  This simplifies implementation and debugging, and
52slightly increases efficiency in the case where the two DHTs are
53mostly congruent.
54
55Usually, messages only carry data in the address family implied by the
56network layer protocol.  In the case of the find_nodes and get_peers
57requests, however, the requestor may optionally request that the reply
58should contain IPv4 node information, IPv6 node information, or both.
59
60
61Single-protocol nodes
62---------------------
63
64A single-protocol node (IPv4 or IPv6) only participates in one DHT.  Such
65a node does not need to explicitly request data in a given family -- the
66data provided by default is exactly what it needs.
67
68
69Dual-stack nodes
70----------------
71
72While conceptually equivalent to a pair of single-protocol nodes,
73a dual-stack (IPv4 and IPv6) node can make bootstrap faster and
74improve the reliability of the protocol by "leaking" data between the
75two DHTs, as described in the following sections.
76
77
78Bootstrapping
79'''''''''''''
80
81A dual-stack node that is bootstrapping its DHT will send find_nodes
82requests in order to populate its routing tables.  In order to accelerate
83this process, it should request both IPv4 and IPv6 node information.
84
85
86Steady-state operation
87''''''''''''''''''''''
88
89Once bootstrap is successful, a node should normally only request IPv4
90node information from IPv4 nodes, and IPv6 node information from IPv6
91nodes.  Requesting node information for both address families in all
92requests is unlikely to provide useful information, and hence
93increases network traffic with no benefit.
94
95In order to increase the reliability of the DHT after a single-protocol
96network outage, however, a node may *ocasionally* send a request for
97IPv4 node information to an IPv6 node, or a request for IPv6 node
98information to an IPv4 node.
99
100
101Maximum packet size
102-------------------
103
104A node obeying this specification must not send UDP datagrams with
105a payload larger than 1024 octets, and must be able to receive UDP
106datagrams with a payload of 1024 octets or less.  (In the interest of
107robustness, a node should be able to receive datagrams with larger
108payloads.)
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
121Source address selection
122------------------------
123
124The IPv6 DHT should use a socket bound to one of the host's global
125unicast IPv6 addresses rather than the "unspecified address" (::/128).
126When selecting to which address to bind, Teredo addresses (addresses
127in 2001:0000::/32) should be avoided if other global unicast addresses
128are 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
147Changes to the BitTorrent protocol
148==================================
149
150The PORT message, as defined in BEP-5, is extended to work over both
151IPv4 and IPv6.  The information provided by the PORT message only
152applies to the address it was sent from; this implies that a PORT
153message sent over IPv4 only advertises participation in the IPv4 DHT,
154and a PORT message sent over IPv6 only advertises participation in the
155IPv6 DHT.
156
157Multihomed hosts should take care to only send PORT messages over
158connections established from the address on which they participate in
159the 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
170Changes and extensions to existing messages
171===========================================
172
173Changes to existing parameters
174------------------------------
175
176values
177''''''
178
179In a reply sent over IPv4, the "values" parameter contains a list of
180strings, each of which contains compact format IPv4 contact
181information for a single peer.
182
183In a reply sent over IPv6, "values" contains a list of strings, each
184of which contains compact format IPv6 contact information for a single
185peer.
186
187Implementations of this specification must be able to properly parse
188hybrid "values" lists -- lists containing an arbitrary mixture of
1896-octet IPv4 values and 18-octet IPv6 values.  However, implementations
190should not send such hybrid lists, and must not send hybrid lists in
191a 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
198New parameters
199--------------
200
201nodes6
202''''''
203
204The "nodes6" parameter is analogous to the "nodes" parameter: when
205present, it carries a string containing the compact IPv6 node
206information for the 8 closest good nodes in the sending node's IPv6
207routing table.  This parameter is allowed in replies to the find_nodes
208and get_peers messages (see below).
209
210
211want
212''''
213
214The "want" parameter is allowed in the find_nodes and get_peers requests,
215and governs the presence or absence of the "nodes" and "nodes6" parameters
216in the requested reply.  Its value is a list of one or more strings, which
217may 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
223For future extensibility, other strings may be present in the list,
224and 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
232Changes to message semantics
233----------------------------
234
235find_nodes and get_peers
236''''''''''''''''''''''''
237
238A node sending a find_nodes or get_peers request may include a "want"
239parameter containing one or both of the strings "n4" or "n6".  A node
240replying to a find_nodes or get_peers request that includes a "want"
241parameter should include a "nodes" parameter if the request's "want"
242parameter contained the string "n4", and should include a "nodes6"
243parameter if the request's "want" parameter contained the string "n6".
244
245In the absence of a "want" parameter, the reply should include "nodes"
246if the request was sent over IPv4, and should include "nodes6" if the
247request 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
255When a node receives a get_peers request and it has peer contact
256information for the matching address family and info-hash, it should
257additionally include a "values" parameter containing a list of 6-octet
258strings if the request was sent over IPv4, and a list of 18-octet
259strings if the request was sent over IPv6.
260
261A reply sent over IPv4 should not contain 18-octet IPv6 contact
262information, and a reply sent over IPv6 should not contain 6-octet
263IPv4 contact information.  In other words, the "want" parameter only
264governs the presence of the "nodes" and "nodes6" parameters, not the
265interpretation 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
275announce_peers
276''''''''''''''
277
278The syntax of the announce_peers request and reply are unchanged.  This
279implies that an announce_peers request sent over IPv4 may only advertise an
280IPv4 address, and an announce_peers request sent over IPv6 may only
281advertise an IPv6 address.
282
283
284Acknowledgements
285================
286
287I gratefully acknowledge the help of *The 8472* and *arvid* in
288developing this specification.
289
290
291References
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
306Copyright
307=========
308
309This 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
Note: See TracBrowser for help on using the browser.