Search code examples
ipcontikicontiki-ngicmpv6

How does contiki os map an IP address to a MAC address


How does contiki os map an IP address to a MAC address, and where is this stored?

I know the basics of ICMPv6 and RPL but once the network is built, when sending an IPv6 packet, how is the MAC address of the next hop known? I assume that a Neighbor Solicitation message is not sent every time. Also, on Cooja, the only ICMPv6 messages I see are RPL messages.

I tried to find the answer by grep, google search and in the doc but I couldn't find it.


Solution

  • There is a uIP neighbor data structure called uip_ds6_nbr_t. These structures are kept in Contiki neighbor tables. When the mapping from an IPv6 address to a MAC address is needed, the code first calls uip_ds6_nbr_lookup(ipv6_address) to find the neighbor, then uses the neighbor to find the link-layer address, by calling the function uip_ds6_nbr_get_ll(nbr).