nRF5 IoT SDK
v0.9.0
|
To uniquely identify devices in the network, they must be assigned a link-local IPv6 address. This address is based on the interface identifier (IID), which is derived from the Bluetooth Device address. You should be familiar with the IPv6 addressing model as defined in specification RFC4291 to understand the following content.
Link-local addresses are designed to be used for addressing on a single link for purposes such as automatic address configuration or when no routers are present. Routers are not allowed to forward any packets with link-local source or destination addresses to other links. Therefore, to communicate with the outside world, a global address must be created; see Distributing a global IPv6 prefix for instructions on how to do that.
Link-local addresses contain the prefix FE80::/10 and a 64-bit interface identifier (IID). The link-local address is automatically assigned to the interface and has a role similar to an IPv4 local address, for example, 192.168.0.0/16.
Creating an IPv6 link-local address comprises three steps:
For example, consider the following 48-bit random static Bluetooth address: C0:11:22:33:44:55
Extend the 48-bit address to a 64-bit address, which is used as MAC address in IPv6. To do this, you must add the bytes 0xFF and 0xFE in the middle of the 48-bit address. And set the 7th bit of first octet using 0x02. Therefore, the modifies IID will be C2:11:22:33:44:55.
As the address is not globally unique, the universal/local bit in the IID shall be set to 0. Since the modified EUI-64 has this bit set using OR operation with 0x02, performing XOR operation on this first octet of EUI-64 results provides the desired result.
Add the link-local prefix FE80::/10 to the IID.
So the link-local address for the Bluetooth device address C0:11:22:33:44:55 is FE80:0000:0000:0000:C011:22FF:FE33:4455, or simpler FE80::C011:22FF:FE33:4455.
Extend the 48-bit address to a 64-bit address, which is used as MAC address in IPv6. To do this, you must add the bytes 0xFF and 0xFE in the middle of the 48-bit address.
Set the address as globally unique. Do this by flipping the seventh bit of the first byte. The same result is achieved by an XOR operation with a 0x02 value on the first octet. The resulting ID is the interface identifier.
Add the link-local prefix FE80::/10 to the IID.
So the link-local address for the Bluetooth device address 00:11:22:33:44:55 is FE80:0000:0000:0000:0211:22FF:FE33:4455, or simpler FE80::211:22FF:FE33:4455.