A Deep Dive into OpenThread: Optimizing IoT Connectivity
The advent of the Internet of Things (IoT) has revolutionized how devices interact, communicate, and collaborate. Central to this transformation is Thread, an IPv6-based mesh networking protocol designed specifically for low-power IoT devices operating in IEEE 802.15.4 wireless mesh networks, often referred to as Wireless Personal Area Networks (WPANs). Released by Google, OpenThread is an open-source implementation of this protocol, leveraging the 6LoWPAN protocol stack (IPv6 over Low Power Wireless Personal Area Networks), making it an ideal solution for both home automation and Industry 4.0 applications.
OpenThread’s open-source nature and OS and platform-agnostic design enable broad adoption and flexibility, allowing it to seamlessly integrate with a variety of hardware and software environments. Its low power consumption, scalability to support hundreds of devices, and the ability to extend network coverage up to 4 km in open areas further enhance its appeal. Supported by industry giants such as Amazon, Google, Espressif, Nordic, STMicroelectronics, NXP, Infineon, and many more, OpenThread stands out as a robust, reliable, and efficient choice for modern IoT deployments.
This will be a multipart guide. In this part, we will deep dive into OpenThread concepts. In the next part, we will create an OpenThread network. I have tried to make this guide more understandable by using home automation examples. So, let’s get started.
Open Thread network model
Note: IEEE 802.15.4 standard covers protocol low-cost, low-data-rate wireless access technology. Mostly iot devices that operate on batteries. Some of the protocol that comes under IEEE 802.15.4 are Zigbee, 6LoWPAN, Thread, WirelessHart.
Why Openthread?
In the rapidly evolving world of IoT, numerous networking protocols exist, each designed with specific use cases in mind. However, this abundance of protocols has created a fragmented landscape where each hardware manufacturer introduces its own networking standards and APIs. This fragmentation makes it challenging for users to manage and control all their IoT devices from a single interface, leading to compatibility issues and increased complexity.
To address this issue, the industry required an open-source protocol that hardware manufacturers could easily adopt and integrate into their devices. This need led to the collaboration of industry leaders to develop a standard protocol called Thread. OpenThread is an open-source implementation of the Thread protocol, providing a versatile and accessible solution for IoT networking.
OpenThread’s design allows it to be easily incorporated into other application protocols, such as Matter, further enhancing its utility and flexibility. This standardization has significantly benefited manufacturers, who now have a unified protocol to follow, simplifying the development process and ensuring interoperability across devices.
Nest, a pioneer in IoT, has driven the adoption of Thread, leveraging its IoT-specific features to make Thread a cornerstone of IoT transformation. OpenThread implements all features defined in the Thread Specification, making it a comprehensive solution for modern IoT networks. Some of the key features of Thread include:
- Simplicity: Easy installation, startup, and operation make Thread user-friendly and accessible.
- Security: All devices in a Thread network are authenticated, and all communications are encrypted, ensuring robust security.
- Reliability: Thread’s self-healing mesh networking eliminates single points of failure and employs spread-spectrum techniques to resist interference.
- Efficiency: Low-power Thread devices can operate on battery power for years, enhancing energy efficiency.
- Scalability: Thread networks can scale up to hundreds of devices, accommodating expansive IoT ecosystems.
OpenThread’s ability to integrate seamlessly with other protocols and its robust feature set have positioned it at the centre of IoT innovation. By providing a standardized, open-source solution, OpenThread simplifies the development process for manufacturers and enhances the end-user experience by ensuring compatibility and reliability across a wide range of devices.
In the next section, we will explore the OpenThread network architecture. The hierarchy might sound complex at first, but it can be simplified. Imagine a network with various nodes interacting with routers, which then connect to gateways to access the internet. This analogy will help you understand the hierarchical structure of the OpenThread network.
Open Thread Node Roles
Thread nodes with forwarding roles are categorized into two parts Router(Parent) and END(child) device.
Forwarding role: The forwarding role means the router and end devices can transfer the packet or flow the packet from the network to the end device and vice versa
Router
- Forward packet to end devices
- Provide service to the new joiners to join the network.
- Always in transceiver mode.
End Device
- Communicate with only one router.
- Each router can add up to 511 nodes.
- NO forwarding and can disable transceiver.
Based on the concept of router and end device and their forwarding roles. They can be categorized into 2 device types.
Full Thread Device
These devices can act as a
- Router
- Router eligible end device(REED): can be assigned the router role. For example, if a new end device wants to join but is out of the range of the router. Then REED aka router eligible end device can take up the router’s role to commission this new device to the network.
- Full End Device(FED): cannot be promoted to a Router.
The radio of the Full Thread device should always be on. They are responsible for growing the network and Ipv6 mapping.
Note: The REED devices can become routers when a new device comes to join. The router can become an end device if no end device is connected to it.
Minimal Thread Device
This device can act as a
- Sleeping End device SED: Radio of SED is normally disabled, but occasionally wakes up to the poll message.
- Minimal end device MED: The transceiver of MED is always on.
Thread Leader
In a Thread network, the Thread Leader plays a crucial role in managing and maintaining the network. A single leader can manage 32 routers. It is responsible for several key functions that ensure the network’s stability and efficiency.
Key Roles and Responsibilities of a Thread Leader:
- Network Management: The Thread Leader manages the allocation of router IDs and maintains the network’s routing table. This ensures that data packets are efficiently routed to their destinations within the network.
- Partitioning: If the Thread network experiences partitioning, the Leader helps in reassigning router IDs and maintaining network functionality within each partition.
- Border Router Configuration: The Leader configures the border routers, which connect the Thread network to other IP-based networks, such as the Internet.
- Network Parameters Maintenance: The Leader maintains and distributes critical network parameters, such as network prefixes and commissioning data, to all devices in the network. This ensures consistent network behaviour and configuration.
Border router
In a Thread network, the Border Router serves as a crucial interface between the Thread network and other IP-based networks, such as the Internet.
Key Roles and Responsibilities of a Border Router:
- Network Gateway: The Border Router acts as a gateway, facilitating communication between the Thread network and other IP-based networks. This allows devices within the Thread network to communicate with external devices and services.
- Addressing and Routing: The Border Router manages IPv6 address assignments for devices within the Thread network and handles the routing of data packets between the Thread network and external networks. This ensures that data reaches its intended destination efficiently.
- Network Security: It provides security mechanisms to protect the network from unauthorized access and ensures secure communication between the Thread network and external networks.
Note: When some of the thread devices are not in range of each other they can be partitioned. This means some of the nodes containing thread leader, router and end device can be in partition A and leftover devices can make their partition B and later when they come in range they can merge back to make a single network.
IPv6 Addressing
Why addressing:
Addressing is done to identify nodes in the network, we can understand it better by making it analogous to our home address. Our home address has components like house number, locality, state and country. The thread also follows the same rule. We will understand this in a later section.
Why IPv6 for addressing:
- Unlike IPv4 which is 32-bit long, IPv6 is 128-bit long and thus can generate (3.4×10³⁸) unique addresses.
- The address format of Ipv4 is like “192.168.0.1” and IPv6 is like “2001:0db8:85a3:0000:0000:8a2e:0370:7334”. In simpler terms, this means IPv6 can accommodate more components of address for better identification. Like each address before and after “:” (colon) can resemble a unique component. you will understand it better when we take the concept of thread.
Scopes of thread network for unicast addressing
There are three scopes in a Thread network for unicast addressing:
- Link-Local — all interfaces reachable by a single radio transmission
- Mesh-Local — all interfaces reachable within the same Thread network
- Global — all interfaces reachable from outside a Thread network
The first two scopes correspond to prefixes designated by a Thread network. Link-Local has prefixes of fe80::/16, while Mesh-Local has prefixes of fd00::/8.
Now let’s take an example to understand it better,
Example of scopes of thread network
Imagine a smart home with several IoT devices connected via a Thread network:
- Devices: Smart light bulbs, thermostats, security sensors, a smart home hub, and a border router connecting the Thread network to the internet.
- Network Segments: Various rooms in the house represent different network segments. Like the living room, bedroom etc.
Link-Local Addresses
Scope:
These addresses are only valid within a single link (local network segment). When devices power up they are configured link-local addresses to communicate with nearby devices. Devices in the same network segment or let’s say same room communicate using this address. Like temperature sensor in the bedroom can communicate with the thermostat to turn on when the temperature is low. So in this case This communication stays within the living room segment.
In this case, the end device can directly communicate via a router.
Link-local Prefix and example
Link-local addresses start with the prefix “fe80::/16”. Like smart thermostat in the bedroom will have the address “fe80::abcd:ef12:3456:7890”.
Mesh-Local Addresses
Scope
These addresses are valid throughout the entire Thread network, allowing devices to communicate across different segments. Like device in the Bedroom can communicate with the living room using this mesh local address. Like LDR sensor in the Balcony can communicate with the blinds in the living room to open when daylight.
Now in this case the message routes through various intermediate devices. If direct communication is not available.
Mesh-local Prefix and example
Link-local addresses start with the prefix “fd00::/8”. Like blinds in the living room will have the address “fd00:abcd::abcd:ef12:3456:7890”.
Global Addresses
Scope
These addresses are routable on the global internet, allowing devices to communicate with external networks. Devices use global unicast addresses to communicate with devices and services outside the Thread network. A border router assigns global unicast addresses to Thread devices, enabling internet access.
Global Prefix and example
Global addresses start with the prefix “2001::/16”. Like smart thermostat in the bedroom will have the address “2001:0db8:85a3::8a2e:0370:abcd”.
Types of IPv6 address and address generation
So, from the above example, it is sure that, each thread device can have one or more Ipv6 addresses because any of these thread devices can be a part of link-local, mesh-local or even global. So each address has a different function depending upon its scope and network topology. Some of the common identifiers or IPv6 unicast addresses are
Link-Local Address (LLA):
Scope: Link-Local Address has a link-local scope as mentioned in the last segment. The address is generated by adding IID to the link-local prefix.
Example: fe80::54db:881c:3845:57f4 link-local prefix + IID
IID: Based on 802.15.4 Extended Address
Mesh-Local EID (ML-EID)
Scope: Mesh -Local EID has a mesh-local scope as mentioned in the last segment. The address is generated by adding IID to the mesh local prefix. This is also called a Unique local address.
Example: fe80::54db:881c:3845:57f4 mesh local prefix + IID
IID: Random, chosen after commissioning is complete.
Routing Locator(RLOC)
Scope: RLOC has a mesh-local scope as mentioned in the last segment. Identifies a Thread interface, based on its location in the network topology. The address is generated by adding IID to the Mesh local prefix and 16-bit RLOC.
Example: fe80::54db:881c:3845:57f4 mesh local prefix + IID +RLOC16(16 bit id which contains router-id and client id)
IID: 0000:00ff:fe00:RLOC16
Anycast Locator (ALOC)
Identifies a Thread interface via RLOC lookup, when the RLOC of a destination is unknown.
Example : fde5:8dba:82e1:1::ff:fe00:fc01
IID: 0000:00ff:fe00:fcXX
Global Unicast Address(GUA)
An EID that identifies a Thread interface on a global scope, beyond a Thread network.
Example: 2000::54db:881c:3845:57f4
IID: SLAAC — Randomly assigned by the device itself DHCP — Assigned by a DHCPv6 server Manual — Assigned by the application layer
Thread Network Discovery and Formation
Thread networks are identified by three unique identifiers:
PAN ID (Personal Area Network Identifier)
A 16-bit identifier is used to distinguish between different Thread networks within the same radio range. It ensures that devices join the correct network. The PAN ID must be unique within the radio range to avoid conflicts.
Example: 0x1234.
XPAN ID (Extended PAN ID)
A 64-bit identifier that uniquely identifies a Thread network. It provides a more globally unique identifier than the PAN ID, reducing the chance of network conflicts.
Example: 0x123456789ABCDEF0.
Network Name
A human-readable ASCII string that names the Thread network. It makes it easier for users to identify and manage the network. The name can be up to 16 characters long.
Example: MyHomeNetwork.
Mesh Link Establishment (MLE)
Mesh Link Establishment (MLE) is a protocol used by Thread devices to establish and maintain secure links with neighbouring devices. It handles the discovery, establishment, and maintenance of these links, ensuring robust and reliable communication within the mesh network. The MLE Process includes the following steps.
Discovery
Devices send MLE advertisements to discover neighbours and learn about the network topology. These advertisements include information such as link quality, device capabilities, and available routes.
Link Establishment
Devices exchange MLE messages to establish links with neighbours. This involves the exchange of security credentials and link parameters.
Link Maintenance
Devices periodically send MLE advertisements to maintain established links. This helps detect any changes in link quality or network topology.
Creating a New Thread Network
Creating a new Thread network involves setting up a Leader device that initializes and manages the network. Here are the steps:
Select a Leader Device
Choose a device to act as the Leader. The Leader is responsible for network configuration and management.
Set Unique Identifiers:
Configure the PAN ID, XPAN ID, and Network Name for the new network. For Example: PAN ID: 0x1234, XPAN ID: 0x123456789ABCDEF0, Network Name: MyHomeNetwork
Start the Network:
The Leader device starts the network, advertising its presence using MLE advertisements.
Configure Security:
Set up security credentials (network key) that devices will use to join the network. e.g., “0x00112233445566778899AABBCCDDEEFF.”
Add Devices:
Other devices can now discover and join the network using the configured PAN ID, XPAN ID, and security credentials.
Joining an Existing Thread Network
Joining an existing Thread network involves discovering the network and securely joining it. Here are the steps:
Scan for Networks
The joining device scans for available networks by listening for MLE advertisements from neighboring devices.
Select a Network
The device selects a network based on the PAN ID, XPAN ID, and Network Name advertised by neighbouring devices.
Establish Secure Link
The device exchanges MLE messages with a neighbouring device to establish a secure link. This involves the exchange of security credentials (network key) to authenticate the device.
Obtain Network Parameters
The joining device receives network parameters such as the network prefix and routing information from the Leader or a neighbouring router.
Complete Joining
The device finalizes the joining process by configuring its network settings and starting to participate in the mesh network.
Conclusion
OpenThread is a powerful and adaptable solution for a wide range of IoT applications. Its IPv6-based architecture, low power consumption, and impressive scalability make it a top choice for developers. I hope this blog helped you understand the concepts of OpenThread. We will come up with more blogs on OpenThread. Stay tuned.