contiki-os/contiki — pull request #318 by sdawans (2013-07-31 10:16:58+00:00)
Title: Inserts missing IPv6 Hop-By-Hop RPL Option at first hop

Currently, the RPL Hop-by-Hop option [**RFC6553**](http://tools.ietf.org/html/rfc6553#section-3) is not inserted at the IP sender. It is only inserted at the first hop, by the first forwarder, then updated along the path.

**RFC6553** allows to carry information on RPL in the data packet IPv6 headers, which are needed for datapath validation. For example, the `O` (Down) bit + SenderRank allows a forwarder to detect loops.

0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Option Type | Opt Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|O|R|F|0|0|0|0|0| RPLInstanceID | SenderRank |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| (sub-TLVs) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

As you can see there's also the **RPLInstanceID** field, which tells the forwarder on which instance the packet is meant to be routed. It is there for multi-instance networks where routers are expected to maintain a route for each destination, on each instance. The Instance reflects a routing objective - it's expected that the IP sender chooses on which Instance to send a packet based on the application needs (QoS).

This fix inserts the option at the first hop, since the first forwarder cannot guess what Instance to route on. The `default_instance->instance_id` is used, as before. Choosing a specific instance would need to be adressed in a larger contribution (we would need to provide interfaces for applications to register instances and use them...).

I have exported 2 pcap files to show what I'm talking about. Node 4 sends a UDP packet to node 1 along a 3-hop path (`4 --> 3 --> 2 --> 1`). Compare the first message of each:

* [**bad.pcap**](https://docs.google.com/file/d/0B7eNZa51wTU0Z2g3X3F4dnZNWTQ/edit?usp=sharing)
* [**good.pcap**](https://docs.google.com/file/d/0B7eNZa51wTU0ckFlcXMtNGY0ZkE/edit?usp=sharing)