nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Creating link-local IPv6 addresses

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

Creating an IPv6 link-local address comprises three steps:

  1. Transforming the Bluetooth device address into Modified EUI-64 format
  2. Transforming the Modified EUI-64 address into an IID
  3. Transforming the IID into a link-local address
Note
The steps differ is the Bluetooth Device address is public, and hence globally unique or random, private one.

Random Static Address

For example, consider the following 48-bit random static Bluetooth address: C0:11:22:33:44:55

lla_1_rs.png
Figure 1. Bluetooth device address - random static.

Step 1. Creating a Modified EUI-64 address

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.

lla_2_rs.png
Figure 2. Modified EUI-64 address.

Step 2. Creating an IID

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.

Note
The XOR operation is common for public and random address.
lla_3_rs.png
Figure 3. Interface ID.

Step 3. Creating a link-local address

Add the link-local prefix FE80::/10 to the IID.

lla_4_rs.png
Figure 4. Link-local address.

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.

Public Address

lla_1.png
Figure 5. Bluetooth device address - public.

Step 1. Creating a Modified EUI-64 address

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.

lla_2.png
Figure 6. Modified EUI-64 address.

Step 2. Creating an IID

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.

lla_3.png
Figure 7. Interface ID.

Step 3. Creating a link-local address

Add the link-local prefix FE80::/10 to the IID.

lla_4.png
Figure 8. Link-local address.

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.