On the Atari it seems reasonable to start on a clear b&w screen even for non-CTK...
[contiki-2.x.git] / doc / uip6-doc.txt
blob2c9c2aabec2a631e0c8c76deba3a1f6243e76014
1 /**
2 \addtogroup uip
3 @{
4 */
6 /**
7  * \defgroup uip6 uIP IPv6 specific features
8  * @{
9 The uIP IPv6 stack provides new Internet communication abilities to Contiki. 
10 This document describes Ipv6 specific features. For features that
11 are common to the IPv4 and IPv6 code please refer to \ref uip "uIP".
13 <HR>
15 \section intro Introduction
16 Ipv6 is to replace IPv4 in a near future. Indeed, to move to a real
17 <em> Internet of Things </em> a larger address space is required. This extended
18 address space (2^128 instead of 2^32) is one of the key features of
19 IPv6 together with its simplified header format, its improved support
20 for extensions and options, and its new QoS and security capabilities.
22 The uip IPv6 stack implementation targets constrained devices such as
23 sensors. The code size is around 11.5Kbyte and the RAM usage around
24 1.7Kbyte (see \ref size "below" for more detailed information). 
25 Our implementation follows closely RFC 4294 <em>IPv6 Node Requirements</em>
26 whose goal is to allow "IPv6 to function well and
27 interoperate in a large number of situations and deployments".
29 The implementation currently does not support any router features (it does not forward packets, send RAs...)
31 <HR>
33 \section protocol IPv6 Protocol Implementation
34 This section gives a short overview of the different protocols that
35 are part of the uIP IPv6 stack. A complete description can be found in the
36 corresponding IETF standards which are available at
37 http://www.ietf.org/rfc.html.
39 \note The #UIP_CONF_IPV6 compilation flag is used to enable IPv6 (and
40 disable IPv4). It is also recommended to set #UIP_CONF_IPV6_CHECKS to
41 1 if one cannot guarantee that the incoming packets are correctly formed. 
43 \subsection ipv6 IPv6 (RFC 2460)
44 The IP packets are processed in the #uip_process function.
45 After a few validity checks on the IPv6 header, the extension headers
46 are processed until an upper layer (ICMPv6, UDP or TCP) header is found. 
47 We support 4 extension headers:
48 \li Hop-by-Hop Options: this header is used to carry optional
49 information that need to be examined only by a packet's destination node.
50 \li Routing: this header is used by an IPv6 source to list one or more
51 intermediate nodes to be "visited" on the way to a packet's destination.
52 \li Fragment: this header is used when a large packet is divided into
53 smaller fragments.
54 \li Destination Options: this header is used to carry optional
55 information that need be examined only by a packet's destination node
56 The Authentication and ESP headers are not currently supported.
58 The IPv6 header, extension headers, and options are defined in uip.h.
60 Although we can receive packets with the extension headers listed
61 above, we do not offer support to send packets with extension headers.
64 <b>Fragment Reassembly</b><br>
65 This part of the code is very similar to the \ref ipreass "IPv4 fragmentation code". The only difference is that the fragmented packet
66 is not assumed to be a TCP packet. As a result, we use a different
67 %timer to time-out reassembly if all fragments have not been received
68 after #UIP_REASS_MAXAGE = 60s.
69 \note Fragment reassembly is enabled if #UIP_CONF_REASSEMBLY is set to 1.
70 \note We can only reassemble packet of at most #UIP_LINK_MTU = 1280
71 bytes as we do not have larger buffers.
74 \subsection address Interface and Addressing (RFC 4291, RFC 4861 p.51, RFC 4862 p.10)
75 An IPv6 address has 128 bits and is defined as follows:
76 \code
77 typedef union uip_ip6addr_t {
78   u8_t  u8[16]
79   u16_t u16[8];
80 } uip_ip6addr_t;
81 \endcode
83 We assume that each node has a <em>single interface</em> of type
84 #uip_netif. 
86 Each interface can have up to #UIP_NETIF_MAX_ADDRESSES unicast IPv6
87 addresses including its link-local address. It also has a
88 solicited-node multicast address. We assume that the unicast
89 addresses are obtained via \ref autoconf "stateless address autoconfiguration" 
90 so that the solicited-node address is the same for all the
91 unicast addresses. Indeed, the solicited-node multicast address
92 is formed by combining the prefix FF02::1:FF00:0/104 and the
93 last 24-bits of the corresponding IPv6 address. When using stateless address
94 autoconfiguration these bits are always equal to the last 24-bits of
95 the link-layer address. 
97 \subsection multicast Multicast support
98 We do not support applications using multicast. Nevertheless, our node
99 should join the all-nodes multicast address, as well as its solicited-node
100 multicast address. Joining the all-nodes multicast address does not
101 require any action. Joining the solicited-node multicast address is
102 done using Multicast Listener Discovery (MLD or MLDv2). More exactly,
103 the node should send a MLD report packet. However this step can be
104 safely skipped and we do so.
106 \subsection nd Neighbor Discovery (RFC 4861)
107 "IPv6 nodes on the same link use Neighbor Discovery to discover each
108 other's presence, to determine each other's link-layer addresses, to
109 find routers, and to maintain reachability information about the paths
110 to active neighbors" (citation from the abstract of RFC
111 4861). 
113 \note  In IPv6 terminology, a \em link is a communication medium over
114 which nodes can communicate at the link layer, i.e., the layer
115 immediately below IP (e.g.: ethernet, 802.11, etc.). Neighbors are
116 thus nodes attached to the same link.
118 Neighbor Discovery (ND) replaces ARP in IPv4 but does much
119 more.
121 <b>Neighbor discovery messages </b><br>
123 \li Neighbor Solicitation (NS)\n
124 Sent by a node during duplicate address detection, address resolution or
125 %neighbor unreachability detection (see explanations below).\n
126 Possible option: Source link-layer address
127 \li Neighbor Advertisement (NA)\n
128 Sent by a node in response to a NS.\n
129 Possible option: Target link-layer address
130 \li Router Advertisement (RA)\n
131 Sent periodically by routers to advertise their presence together with
132 various link and Internet parameters.\n
133 Possible options: Source link-layer address, MTU, Prefix Information
134 \li Router Solicitation (RS)\n
135 Sent by a host to request routers to generate a RA immediately rather
136 than at their next scheduled time. Received RS are discarded.\n
137 Possible option: Source link-layer address
138 \li Redirect Message\n
139 Not supported
141 The structures corresponding to the different message headers and
142 options are in uip-nd6.h. The functions used to send / %process this
143 messages are also described in uip-nd6.h although the actual code is in
144 uip-nd6-io.c.
146 <b>Neighbor discovery structures </b><br>
147 We use the following %neighbor discovery structures (declared in uip-nd6.c):
148 \li A <em>%neighbor cache</em> with entries of type #uip_nd6_neighbor
149 \li A <em>prefix list</em> with entries of type #uip_nd6_prefix
150 \li A <em>default router list</em> with entries of type #uip_nd6_defrouter 
152 Each of this structure has its own add, remove and lookup
153 functions. To update an entry in a ND structure, we first do a lookup
154 to obtain a pointer to the entry, we then directly modify the
155 different entry fields.
157 <b>Neighbor discovery processes </b><br>
158 \li Address resolution\n
159 Determine the link-layer address of a %neighbor given its IPv6 address.\n
160 -> send a NS (done in #tcpip_ipv6_output). 
161 \li Neighbor unreachability detection\n
162 Verify that a neighbor is still reachable via a cached link-layer
163 address.\n
164 -> send a NS (done in #uip_nd6_periodic). 
165 \li Next-hop determination\n
166 Map an IPv6 destination address into the IPv6 address of the %neighbor
167 to which traffic for the destination should be sent.\n
168 -> look at on-link prefixes, if the destination is not on-link,
169 choose a default router, else send directly (done in #tcpip_ipv6_output).
170 \li Router, prefix, and parameter discovery\n
171 Update the list of default routers, on-link prefixes, and the network
172 parameters.\n
173 -> receive a RA (see #uip_nd6_io_ra_input).
175 \subsection autoconf Stateless Address Autoconfiguration (RFC 4862)
176 RFC 4862 defines two main processes:
177 \li Duplicate Address Detection (DAD)\n
178 Make sure that an address the node wished to use is not already in use
179 by another node.\n
180 -> send a NS (done in #uip_netif_dad)
181 \li Address Autoconfiguration\n
182 Configure an address for an interface by combining a received prefix
183 and the interface ID (see #uip_netif_addr_add). The interface ID is
184 obtained from the link-layer address using #uip_netif_get_interface_id.\n
185 -> Receive a RA with a prefix information option that has the
186 autonomous flag set. 
188 When an interface becomes active, its link-local address is created
189 by combining the FE80::0/64 prefix and the interface ID. DAD is then
190 performed for this link-local address. Available routers are
191 discovered by sending up to #UIP_ND6_MAX_RTR_SOLICITATIONS RS
192 packets. Address autoconfiguration is then performed based on the
193 prefix information received in the RA. The interface initialization is
194 performed in #uip_netif_init.
196 \subsection icmpv6 ICMPv6 (RFC 4443)
197 We support ICMPv6 Error messages as well as Echo Reply and Echo Request
198 messages. The application used for sending Echo Requests (see ping6.c)
199 is not part of the IP stack. 
201 \note RFC 4443 stipulates that 'Every ICMPv6 error message MUST
202 include as much of the IPv6 offending (invoking) packet as
203 possible'. In a constrained environment this is not very resource
204 friendly.
206 The ICMPv6 message headers and constants are defined in uip-icmp6.h. 
208 <HR>
210 \section timers IPv6 Timers and Processes
211 The IPv6 stack (like the IPv4 stack) is a Contiki process
212 \code
213 PROCESS(tcpip_process, "TCP/IP stack");
214 \endcode
215 In addition to the \ref mainloop "periodic timer" that is used by TCP,
216 five IPv6 specific timers are attached to this %process:
217 \li The #uip_nd6_timer_periodic is used for periodic checking of the
218 %neighbor discovery structures. 
219 \li The #uip_netif_timer_dad is used to properly paced the Neighbor
220 Solicitation packets sent for Duplicate Address Detection.
221 \li The #uip_netif_timer_rs is use to delay the sending of Router Solicitations
222 packets in particular during the router discovery %process.
223 \li The #uip_netif_timer_periodic is used to periodically check the
224 validity of the addresses attached to the network interface. 
225 \li The #uip_reass_timer is used to time-out the fragment reassembly
226 %process.
229 Both #uip_nd6_timer_periodic and #uip_netif_timer_periodic run continuously. 
230 This could be avoided by using callback timers to handle ND and Netif structures timeouts.
232 <HR>
234 \section compileflags Compile time flags and variables
235 This section just lists all IPv6 related compile time flags. Each flag 
236 function is documented in this page in the appropriate section.
237 \code
238 /*Boolean flags*/
239 UIP_CONF_IPV6        
240 UIP_CONF_IPV6_CHECKS
241 UIP_CONF_IPV6_QUEUE_PKT 
242 UIP_CONF_IPV6_REASSEMBLY        
243 /*Integer flags*/
244 UIP_NETIF_MAX_ADDRESSES 
245 UIP_ND6_MAX_PREFIXES   
246 UIP_ND6_MAX_NEIGHBORS   
247 UIP_ND6_MAX_DEFROUTER  
248 \endcode
250 <HR>
252 \section buffers IPv6 Buffers
253 The IPv6 code uses the same \ref memory "single global buffer" as the
254 IPv4 code. This buffer should be large enough to contain one 
255 packet of maximum size, i.e., #UIP_LINK_MTU = 1280 bytes. When \ref
256 reass "fragment reassembly" is enabled an additional buffer of the
257 same size is used. 
259 The only difference with the IPv4 code is the per %neighbor buffering
260 that is available when  #UIP_CONF_QUEUE_PKT is set to 1. This
261 additional buffering is used to queue one packet per %neighbor while
262 performing address resolution for it. This is a very costly feature as
263 it increases the RAM usage by approximately #UIP_ND6_MAX_NEIGHBORS *
264 #UIP_LINK_MTU bytes.
266 <HR>
268 \section size IPv6 Code Size
270 \note We used Atmel's RAVEN boards with the Atmega1284P MCU (128Kbyte
271 of flash and 16Kbyte of SRAM)  to benchmark
272 our code. These numbers are obtained using 'avr-gcc 4.2.2 (WinAVR
273 20071221)'. Elf is the output format.
275 \note The following compilation flags were used:
276 \code
277 UIP_CONF_IPV6            1      
278 UIP_CONF_IPV6_CHECKS     1      
279 UIP_CONF_IPV6_QUEUE_PKT  0      
280 UIP_CONF_IPV6_REASSEMBLY 0      
282 UIP_NETIF_MAX_ADDRESSES 3
283 UIP_ND6_MAX_PREFIXES    3
284 UIP_ND6_MAX_NEIGHBORS   4
285 UIP_ND6_MAX_DEFROUTER   2
286 \endcode
288 The total IPv6 code size is approximately 11.5Kbyte and the RAM usage around
289 1.8Kbyte. For an additional NEIGHBOR count 35bytes, 25 for an additional
290 PREFIX, 7 for an additional DEFROUTER, and 25 for an additional ADDRESS. 
292 <HR>
294 \section l2 IPv6 Link Layer dependencies
295 The IPv6 stack can potentially run on very different link layers
296 (ethernet, 802.15.4, 802.11, etc).
297 The link-layer influences the following IP layer objects:
298 \li #uip_lladdr_t, the link-layer address type, and its length,
299 #UIP_LLADDR_LEN.
300 \code
301 struct uip_eth_addr {
302   u8_t addr[6];
304 typedef struct uip_eth_addr uip_lladdr_t;
305 #define UIP_LLADDR_LEN 6
306 \endcode
307 \li #uip_lladdr, the link-layer address of the node.
308 \code
309 uip_lladdr_t uip_lladdr = {{0x00,0x06,0x98,0x00,0x02,0x32}};
310 \endcode
311 \li #UIP_ND6_OPT_LLAO_LEN, the length of the link-layer option in the
312 different ND messages
314 Moreover, #tcpip_output should point to the
315 link-layer function used to send a packet. Similarly, the link-layer
316 should call #tcpip_input when an IP packet is received.
318 The code corresponding to the desired link layer is selected at
319 compilation time (see for example the #UIP_LL_802154 flag).
321 <HR>
323 \section l45 IPv6 interaction with upper layers
324 The TCP and the UDP protocol are part of the \ref uip "uIP" stack and were left
325 unchanged by the IPv6 implementation.
326 For the application layer, please refer to the \ref api "application program interface".
328 <HR>
330 \section compliance IPv6 compliance
331 \subsection rfc4294 IPv6 Node Requirements, RFC4294
332 This section describes which parts of RFC4294 we are compliant with. For each section, we put between brackets the requirement level.\n
333 When all IPv6 related compile flags are set, our stack is fully compliant with RFC4294 (i.e. we implemement all the MUSTs), except for MLD support and redirect function support.\n
334 \note RFC4294 is currently being updated by IETF 6man WG. One of the important points for us in the update is that after discussion on the 6man mailing list, IPSec support will become a SHOULD (was a MUST).\n
336 <b>Sub IP layer</b><br>
337 We support RFC2464 transmission of IPv6 packets over Ethernet\n
338 We will soon support RFC4944 transmission of IPv6 packets over 802.15.4\n
340 <b>IP layer</b><br>
342 \li IPv6 RFC2460 (MUST): When the compile flags UIP_CONF_IPV6_CHECKS and UIP_CONF_REASSEMBLY are set, full support
343 \li Neighbor Discovery RFC4861 (MUST): When the UIP_CONF_CHECKS and UIP_CONF_QUEUE_PKT flag are set, full support except redirect function
344 \li Address Autoconfiguration RFC4862 (MUST): When the UIP_CONF_CHECKS flag is set, full support except sending MLD report (see MLD)
345 \li Path MTU Discovery RFC 1981 (SHOULD): no support
346 \li Jumbograms RFC 2675 (MAY): no support
347 \li ICMPv6 RFC 4443 (MUST): full support
348 \li IPv6 addressing architecture RFC 3513 (MUST): full support
349 \li Privacy extensions for address autoconfiguration RFC 3041 (SHOULD): no support.
350 \li Default Address Selection RFC 3484 (MUST): full support. 
351 \li MLDv1 (RFC 2710) and MLDv2 (RFC 3810) (conditional MUST applying here): no support. As we run IPv6 over Multicast or broadcast capable links (Ethernet or 802.15.4), the conditional MUST applies. We should be able to send an MLD report when joining a solicited node multicast group at address configuration time. This will be available in a later release.
353 <b>DNS (RFC 1034, 1035, 3152, 3363, 3596) and DHCPv6 (RFC 3315) (conditional MUST)</b><br>
354 no support
356 <b>IPv4 Transition mechanisms RFC 4213 (conditional MUST)</b><br>
357 no support
359 <b>Mobile IP RFC 3775 (MAY / SHOULD)</b><br>
360 no support
362 <b>IPSec RFC 4301 4302 4303 2410 2404 2451 3602(MUSTs) 4305 (SHOULD)</b><br>
363 no support
365 <b>SNMP (MAY)</b><br>
366 no support
369 \subsection ipv6ready IPv6 certification through ipv6ready alliance
370 IPv6ready is the certification authority for IPv6 implementations (http://www.ipv6ready.org). It delivers two certificates (phase 1 and phase 2).\n
371 When all the IPv6 related compile flags are set, we pass all the tests for phase 1.\n
372 We pass all the tests for phase 2 except:
373 \li the tests related to the redirect function
374 \li the tests related to PMTU discovery
375 \li test v6LC1.3.2C: A "bug" in the test suite (fragmentation states are not deleted after test v6LC1.3.2B) makes us fail this test unless we run it individually.
376 \li 5.1.3: UDP port unreachable (the UDP message is too large for our implementation and the UDP code does not send any ICMP error message)
379 <HR>
382 /** @} */
383 /** @} */