Design
A high-level picture of some of the design of the stack. For the canonical reference on what is really happening, one should always refer to the source.
Memory
The buffering has been the subject of some work, although is still sub-optimal.
Interface Contracts
- send: buffers are passed to the IP layer which have been previously obtained from the buffer pool. The stack owns the buffer until sendDone is signaled.
- receive: buffers are passed to the application from the IP layer. The buffer may be returned to the stack from the receive call, or the application may return NULL, and return the buffer to the pool at some later time.
Routing
Each node acts as an IP router, and maintains a default route towards a "border router". Tree formation is using IPv6 router solicitation and advertisement packets sent using the layer-2 broadcast (0xffff) address, and the IPv6 link-local-all-routers address (ff02::2).
Nodes send router solicitations in two cases:
- bootup
- default route failure
Nodes send advertisements due to two conditions:
- receipt of router solicitations
- change in their hop limit to the border router
Both solicitations are sent using trickle timers which send three packets. There are also provisions for expiring default next-hops which are no longer valid due to mobility or link state changes. Default routes are formed using an additive LQI-based path metric.
Forwarding
Packets are forwarded using a few very simple rules.
- if the packet IPv6 destination is a multicast address, the packet is not forwarded. Next hop for multicast addresses originiating from the node is link-local broadcast (0xffff).
- if the packet contains compressed source route information, the packet is sent to the next hop of the source route and the "current" field of the source routing header is incremented.
- in all other cases, the packet is sent to the default route maintained by the routing component.
If the routing component maintains multiple potential default next hops, the forwarding engine will attempt to use them sequentially for each packet.
Source Routing
Packets may contain source routing information by including a source routing header as a hop-by-hop option following the IP header. This is a non-standard header. It contains a dispatch field which contains a "record route" bit. If this bit is set, the path the packet takes is written into the header, but it is ignored for the purposes of next hop computation. A second dispatch bit, "invalidate", orders the default router to expire link information about the router in the source address field.
