This chapter gives a brief overview of the Thread Networking protocol withexamples from the SimpleLink CC26x2 SDK. This section will present examples using the CLIexample applications seen belowFigure 15.
Device Types and Network Structure¶
In the following sections we will explain; the different roles a device cantake on, the two different device types, and what modes each device type usesto fill a role.
Device Roles¶
Thread devices can take on four roles within a Thread Network; End Device,Router, Leader, Border Router. All devices start as End Devices and arepromoted from there as the network requires.
End Devices connect to a single Router. All traffic to and from the End Devicegoes through its parent Router. If the End Device loses the connection to itsparent Router, it will attempt to find a new parent Router.
Routers connect to other Routers and act as parents to End Devices. Thesedevices transmit, receive, and forward messages around the mesh network.Routers can act as parents to multiple child End Devices; Routers act asproxies for their children when doing networking activities like responding toaddress queries. Routers maintain their next hop and cost to all other Routersin the network. Routers maintain a copy of the active dataset from the Leader.
The Leader of a Thread Network is a Router that has been elected to makedecisions for the Thread Network. These decisions are choices like; the currentactive commissioner, Router upgrading, and more. The Leader is elected by beingthe first Router within a partition.
Border Routers are Routers on the Thread Network with an off-mesh route.Border Routers act as the bridge from the Thread IPv6 network and an adjacentIPv6 network like WiFi or Ethernet networks. Border Routers offer globallyroutable IPv6 prefixes configurable with SLAAC or DHCPv6.
Device Types¶
A Thread device can be either a Full Thread Device or a Minimal Thread Device.An FTD can act as an End Device, a Router, a Leader, or a Border Router. AnMTD is limited to only the End Device role with some configurations allowedto sleep.
With the TI-OpenThread Stack a Full Thread Device can be configured at runtime to be aMinimal Thread Device. However, a Minimal Thread Device has necessary sectionscompiled out so it cannot act as a Full Thread Device. If both flavors ofdevice exist as examples within the SimpleLink CC26x2 SDK they will have the string ftd
ormtd
in the example name. If only one flavor exists, the device type will benoted in the example’s README. Whether a device is an FTD or MTD affects whatOpenThread library projects get linked into the final project.
Device Modes¶
In the CLI example application the command mode
lists the possible modesfunctions that can be enabled or disabled.
With the values:
R | RX on while idle | Set this value to have the receiver always on.Clearing this enables the radio to sleep. |
S | Secure IEEE 802.15.4data requests | Set this value to enable encryption on datarequests to the parent router. Clearing thismay introduce a weak link in the network. DataPolls are only sent when the radio can sleep. |
D | Full Function Device | Indication that this device should act as an802.15.4 FFD. This is required for FTDs. |
N | Full Network Data | Set this to indicate that this device shouldreceive all network data, stable and unstable. |
If a device subscribes to full network data, it will receive both stable andunstable network data. Subscribing to unstable network data will increasenetwork traffic to the device.
Device modes are tied to how that device will behave once it is attached to aThread Network. When an MTD attaches to a Thread Network, it will attach aseither a Minimal End Device (MED) or a Sleepy End Device (SED).If an MTD attaches as a SED, the parent Router is required to buffer messagesfor the SED until it wakes up and polls. When an FTD attaches to a ThreadNetwork it will attach as a Full End Device (FED) or a Router-EligibleEnd Device (REED). If the FTD attaches as a REED, the Thread networkwill make the decision to promote that device to an Active Router roll ifnetwork topology or routing requires.
DeviceType | Device Role | DeviceMode | Description |
---|---|---|---|
FullThreadDevice(FTD) | Router-EligibleEnd Device(REED) | RSDN | A router that is acting as an EndDevice. This node may be promoted toa Router role as the network demands. |
Full End Device(FED) | RSD | A Full Thread Device that has beenlimited to the End Device mode. | |
MinimalThreadDevice(MTD) | Minimal EndDevice (MED) | RS | A Minimal Thread Device that has beenlimited to End Device mode. |
Sleepy EndDevice (SED) | S | An End device that is allowed to turnits receiver off during sleep. | |
” “ |
Working With a Thread Network¶
In this section we will explain how to form, attach, commission and join, withthe CLI example application. It is recommended that you have two CC26x2 LaunchPadwith a cli_ftd
example programmed on them. Open a terminal for eachLaunchPad and follow along with the sections below.
Forming a Network¶
A Thread Network has to start somewhere, this is done by a device forming a newpartition on a channel. This device begins by attempting to attach to a networkthat already exists on the channel and PANID. Since there is not a ThreadNetwork operating there, the device begins the process of forming a ThreadPartition. This is referred to as a singleton network because there is a singledevice in the network.
To show this behavior, follow along with the following code block on one ofyour CLI FTD examples. This will set the device to channel 14
and PANID0xface
. Then start the radio with ifconfig up
, and start Threadnetworking with the thread start
.
Note
The CLI example is not as robust as other interactive consoles like Bash.You may have to press the enter
key to get a prompt >
.
> channel 14Done> panid 0xfaceDone> ifconfig upDone> thread startDone> statedetachedDone> stateleaderDone>
A Thread network is now operating on channel 14
and PANID 0xface
. Youshould be able to see network advertisem*nts over the air from the ThreadDevice. You can use the legacy network scan on another CLI example to see theThread Network.
> scan| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |+---+------------------+------------------+------+------------------+----+-----+-----+> | 0 | OpenThread | dead00beef00cafe | face | ce77ba3a27eef08a | 14 | -29 | 61 |Done
Attaching to a Thread Network¶
To attach to a parent router in a thread network, a device needs to know someinformation about a Thread Network like the channel and masterkey. Thisinformation is supposed to be disseminated to the attaching node through acommissioning process, but we are going to take advantage of the defaults inthe CLI example to show just attaching.
setting | value |
---|---|
Master Key | 00112233445566778899aabbccddeeff |
Extended Pan ID | dead00beef00cafe |
Network Name | OpenThread |
As in the section Forming a Network form a network with one ofthe CLI example applications.
> channel 14Done> panid 0xfaceDone> ifconfig upDone> thread startDone>
On another CLI example follow along below to scan for a network, attach to thenetwork, and ping the link local multicast address.
> scan| J | Network Name | Extended PAN | PAN | MAC Address | Ch | dBm | LQI |+---+------------------+------------------+------+------------------+----+-----+-----+> | 0 | OpenThread | dead00beef00cafe | face | ce77ba3a27eef08a | 14 | -29 | 61 |Done> channel 14Done> panid 0xfaceDone> ifconfig upDone> thread startDone> statechildDone> ping ff02::1> 8 bytes from fe80:0:0:0:cc77:ba3a:27ee:f08a: icmp_seq=1 hlim=64 time=6ms>
The attaching device will go through the same process as the device inForming a Network did when creating a Thread Network partition.Except this time there will be a Thread Network to attach to instead of havingto form one of its own.
Commissioning¶
Commissioning is the process where a new untrusted device is authenticated andsecurely brought onto the Thread Network. Commissioning can be split into twomajor categories, external commissioning and native commissioning. Externalcommissioning would be the case if the commissioner resides off-mesh of theThread Network. External commissioning requires a border agent to relaycommunication to and from on and off mesh. Native commissioning only requireson-mesh nodes, and will be explained here. Consult chapter 8 of the Thread1.1.1 specification for a better overview of the commissioning protocol.
To illustrate commissioning, it is necessary to form a network to commissionwith. Follow along with the following code block on one of your CLI FTDexamples. This will form a Thread Network on channel 14
and PANID0xface
, and start the node as a commissioner. From now on we will refer tothis node as the Commissioner.
Note
The masterkey is set in this example to make it different than the defaultOpenThread masterkey.
> masterkey ffeeddccbbaa99887766554433221100Done> channel 14Done> panid 0xfaceDone> ifconfig upDone> thread startDone> statedetachedDone> stateleaderDone> commissioner startDone>
In a second CLI FTD example, use the command eui64
to discover theCC26x2’s EUI. This will be used by the Commissioner to securely join thisdevice into the Thread Network. From now on we will refer to this device as theJoiner.
> eui6400124b000f6e6131Done>
Now we need to tell the Commissioner to look for a device with the EUI00124b000f6e6131
and some pre-shared key, we will use PPSSKK
. On theCommissioner, follow along with the code block below to add a joiner entry tothe commissioning dataset.
> commissioner joiner add 00124b000f6e6131 PPSSKKDone>
This network is most likely a singleton, so the change in the commissioningdata set will take effect immediately. In a larger network with more nodes theCommissioner would notify the Leader of the change to the commissioning datasetand the Leader would disseminate that information to the Routers in the ThreadNetwork.
Follow along below on the Joiner device to start the discovery and joiningprocess. Then attach to the Thread network now that the information is presenton the Joiner device.
Note
The masterkey commands are only to show that the Thread Masterkey has beenupdated on the Joiner by commissioning.
> masterkey00112233445566778899aabbccddeeffDone> ifconfig upDone> joiner start PPSSKKDone> Join success> masterkeyffeeddccbbaa99887766554433221100Done> thread startDone> statechildDone> ping ff02::1> 8 bytes from fe80:0:0:0:2c31:402d:60a9:6fb9: icmp_seq=1 hlim=64 time=6ms>
Don’t forget to stop the Commissioner so that other commissioners can do theirjob.
> commissioner stopDone>
The Joiner has now been added to the Thread Network.