![]() |
nRF51 IoT SDK
|
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.
The following script provides an automatic transformation between Bluetooth device addresses and IPv6 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 includes three steps:
For example, consider the following 48-bit public Bluetooth address: 00:11:22:33:44:55
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.
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.
The last step is to 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.