nRF51 IoT SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Creating IPv6 addresses

This user guide explains how to create an IPv6 address and its interface identifier (IID) from the Bluetooth Device address. You should be familiar with the IPv6 addressing model as defined in specification RFC4291 to understand the following content.

MAC to IPv6 Script

The following script provides an automatic transformation between Bluetooth device addresses and IPv6 addresses.

MAC:
Prefix:
IPv6:

Link-Local addresses

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, global address must be created; see RADVD for Linux 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 similar role like an IPv4 local address, for example, 192.168.0.0/16.

Creating an IPv6 Link-Local address

Creating an IPv6 link local address includes 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

For example, consider the following 48-bit public Bluetooth address: 00:11:22:33:44:55

lla_1.png
Figure 1. Bluetooth device address.

Step 1. Creating a Modified EUI-64 address

The first step is to 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 2. Modified EUI-64 address.

Step 2. Creating an IID

The second step is to set the address as globally unique. This is done 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 3. Interface ID.

Step 3. Creating a Link-Local address

The last step is to add the Link-Local prefix FE80::/10 to the IID.

lla_4.png
Figure 4. 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.