Search code examples
contikirpl

Add a new bit in packet


For example, there are two nodes A and B. A will send some IPv6 packets to B. Can I add a new bit to the packets as a feature of each packet like the packet ID, so I can distinguish these packets by it.


Solution

  • If you are using RPL, you can probably use some bits in the RPL hop-by-hop extension header for this purpose. Check the structure struct uip_ext_hdr_opt_rpl - it has a member variable flags, not all bits of which are currently used. The relevant code that sets and reads this header is in the file rpl-ext-header.c under net.

    It's probably possible to also use some of the IEEE 802.15.4 header bits or even IPv6 main header bits for your purposes, but that will break compatibility with these standards, and might be more trickly to implement that doing something on top of the higher-level RPL header.

    If you absolutely don't want to break compatibility with anything, I think the only safe option is to add your own IPv6 extension header. That will be safer, but less space-efficient.