A communications layers: 802.15.4 and ZigBee

IEEE 802.15.4

This standard defines a communication layer at level 2 in the OSI (Open System Interconnection) model. Its main purpose is to let the communication between two devices.It was created by the Institute of Electrical and Electronics Engineers (IEEE), entity which main task is to set standards so that technological developments can count with a common platform of rules to be set over. In the Waspmote and SquidBee devices this protocol is set using the XBee 802.15.4 OEM Digi module.

ZigBee

This standard defines a communication layer at level 3 and uppers in the OSI model. Its main purpose is to create a network topology (hierarchy) to let a number of devices communicate among them and to set extra communication features such as authentication, encryption, association and in the upper layer application services. It was created by a set of companies which form the ZigBee Alliance. In the Waspmote and SquidBee devices this protocol is set using the XBee ZB Digi module.

Understanding 802.15.4

As mentioned before this protocol lies over the level 2 of the OSI. This layer is called the Data Link. Here the digital information units (bits) are managed and organized to become electromagnetic impulses (waves) on the lower level, the physical one. This layer is similar to others known ones such as the 802.11 (commercially named under Wifi technologies) or the common Ethernet (802.3). The  frequencies defined in the standard are spread among 27 different channels divided  in three main bands:

  – 868.0 – 868.6MHz   -> 1 channel     (Europe)
– 902.0-928.0MHz     -> 10 channels  (EEUU)
– 2.40-2.48GHz         -> 16 channels  (Worldwide)

Three different XBee transceivers are used in the Waspmote and SquidBee to provide communication in these frequencies:

  – 868MHz
– 900MHz
– 2.40GHz  -> XBee 802.15.4 OEM / XBee ZB

Bit Rates:

 – 868.0 – 868.6MHz   -> 20/100/250 Kb/s
– 902.0-928.0MHz     -> 40/250 Kb/s
– 2.40-2.48GHz         -> 250 Kb/s

Why is 802.15.4 good against noise?

It used Direct Sequence Spread Spectrum (DSSS) to modulate the information before being sent to the physical layer. Basically, each bit of information to be transmitted is modulated into 4 different signals (another kind of bits alphabet), this process causes the total information to be transmitted to occupy a larger bandwidth but it uses a lower spectral power density for each signal.

This causes less interference in the frequency bands used and improves the Signal to Noise Ratio (SNR) in the receiver due to the fact that is easier to detect and decode the message which is being sent by the transmitter.

There are different DSSS modulations depending on the hardware physical limits of the circuit and number of symbols which can be processed at a given time. Binary Phase Shift Keying (BPSK), Offset Quadrature Phase Shift Keying (O-QPSK) and Parallel Sequence Spread Spectrum (PSSS) let communication from bandwidths from 20Kb/s to 250Kb/s.

Why is 802.15.4 good against interferences?

802.15.4 uses two techniques to avoid all the nodes start emitting at the same time: CSMA-CA and GTS.

The most common is the Carrier Sense Multiple Access-Collision Avoidance (CSMA-CA). This method is described as follows: each node listen the medium prior to transmit. If the energy found higher of a specific level the node the transceiver waits during a random time (including in an interval) and tries again. There is a parameter defined in the standard: macMinBE which sets the back-off  exponent to be used when calculating this time slot.

The second one is Guarantee Time Slots (GTS). This systems uses a centralized node (PAN coordinator) which gives slots of time to each node so that any knows when they have to transmit. There are 16 possible slots of time. As a first step a node must to send to the PAN coordinator a GTS request message, as response the coordinador will send a beacon message containing the slot allocated and the number os slots assigned. Waspmote and SquidBee use the CSMA-CA method due to the fact that it is inherent to each mote and does not depend on a central server. There area some special frames like the ACK packets which doesn’t  require this method to be performed.

One of the functionalities implemented in 802.15.4 is the channel energy scan (PLME-ED request). The idea is to be able to know how much energy (activity/noise/interferences) there is in one (or several channels) prior to start using it. This way we can save energy choosing free channels when setting the network. There are three different behaviors when facing the energy detection issue:

  – Energy: scan the channels and report the energy found. It doesn’t matter if it is caused by other ZigBee nodes or by another technology or noise. Just report if the spectrum is being used. Only when the value received is below a certain threshold we will transmit.

 – Carrier Sense (CCA): scan the medium and report if there are 802.15.4 transmissions. Only when the channel is free we will transmit.

 – CCA + Energy: scan the medium and report if there are 802.15.4 transmissions above the energy threshold specified. If not we will use the channel.

Why is 802.15.4 a low consumption protocol?

It is ready to work with low-duty cicles. It means the transceiver can be sleeping most of the time (up to 99% on average) while the receiving and sending tasks can be set to take just a small part of the devices’ energy. This percentage depends on the kind of communication model used. If beacon mode is used (star or PAN networks) the minimum amount of time used to transmit/receive this frames will increase the total time the transceiver is used. Waspmote can be synchronized so that he network can have duty cicles much lower. They can be sleeping for minutes or hours and wake up all at the same time to perform an Adhoc communication creating a mesh network just when really needed.

Transmission Power and Reception Sensibility for the 802.15.4 transceivers

802.15.4 sets the minimum amount of energy needed to transmit in -3dBm, (0’5 mW) and the minimum sensibility in the receiver is -92dBm (6’3 * e-10 mW). Waspmote radio module has a variable transmission power strength of 0dBm (1mW) in XBee 802.15.4  OEM and 20dBm (100mW) in the XBee-Pro 802.15.4 OEM, both values are higher than the minimum set in the 802.15.4 Standard. Regarding the reception sensibility , the XBee shows -92Bm (6’3 * e-10 mW) and -100dBm (1 * 1e-10mW) the XBee-Pro flavor.
This means we will detect any packet which reach us with a energy of as low as 0’000000000063mW for the XBee and 0’00000000001mW for the XBee-Pro.

What is there on top of 802.15.4?

There are several protocols which use 802.15.4 as its MAC layer. The most known is ZigBee, although there are a lot of them:

 – Wireless HART: It is the wireless version of the HART protocol which is the most used in the automation and industrial applications which require real time. It uses Time Synchronized Mesh Protocol (TSMP). A “time coordinator” node is required in order to assign the time slot to all the motes.

– ISA – SP100: It also centers in the process and factory automation. It is being developed by the Systems and Automation Society (ISA) and tries to be an standard for this kind of projects.

 – IETF IPv6 – LoWPAN: As the same name points it is the implementation of the IPv6 stack on top of 802.15.4 to let any device be accessible and access from and to Internet.
New Mesh protocols: A lot of different mesh protocols are being implemented by companies over the 802.15.4 MAC layer. One example is the Digi’s own mesh protocol (DigiMesh), which is though to be a completely distributed mesh protocol where all the nodes can sleep and route their brother’s packets. Waspmote and SquidBee support also the DigiMesh protocol when the XBee 802.15.4 OEM module is chosen . Paper about the DigiMesh implementation: DigiMesh-whitePaper.pdf.

Understanding ZigBee

ZigBee offers basically four kinds of different services:

  – Extra Encription services (application and network keys implement extra 128b AES encryption)

 – Association and authentication (only valid nodes can join to the network).

 – Routing protocol: AODV, a reactive ad hoc protocol has been implemented to perform the data routing and forwarding process to any node in the network.

 – Application Services: An abstract concept called “cluster” is introduced. Each node belongs to a predefined cluster and can take a predefined number of actions. Example: the “house light system cluster” can perform two actions: “turn the lights on”, and “turn the lights off”.

ZigBee is a layer thought to organize the network. The first thing a node (route or end device) which want to join the network has to do is to ask to the coordinator for a network address (16b), as part of the association process. All the information in the network is routed using this address and not the 64b MAC address. In this step authentication and encryption procedures are performed.

Once a node has joined to the network can send information to its brothers through the routers which are always awake waiting for the packets. When the router gets the packet and the destination is in its radio of signal, the router first looks if the destination end device is awake or slept. In the first case the router sends the packet to the end device, however if it is sleeping, the router will bufferize the packet untill the end device node gets awake and ask for news to the router.

Is ZigBee a mesh protocol?

To answer this question we have to clarify what the mesh concept means. Let’s see first how a ZigBee network works.

There are three kinds of nodes in a ZigBee network:

  – Coordinator: is the “master” device, it governs all the networ

 – Routers: they route the information which sent by the end devices

 – End device: (the motes): they are the sensor nodes, the ones which take the information from the environment

Coordinator and routes can not be battery powered, motes can. ZigBee creates star topologies. There are some basic rules:

 – The end devices connect to a router or a coordinator.

 – The routers can connect among them and with the coordinator.

 – The routers and coordinators can not sleep. They have to save in their buffer the packets which go to the end devices.

 – The end devices can sleep.

The concept “Mesh Network” relays in the Ad hoc communications, also called peer to peer (P2P). This means all the devices in the network can communicate with each other directly. They have to be able to discover each other and send broadcast messages to all the brothers (“hello!, is there anybody out there?”). They have to be able to create networks like the one represented in the image below.

ZigBee creates start network topologies, not mesh ones. To create a completely mesh network such as the one showed in the image below all the nodes have to have the same role, all of them have to be “end devices + routers” so that they can route their brothers information and sleep when no action is required (saving energy). The DigiMesh protocol (over 802.15.4) sets a completely distributed network where all the nodes talk among them using p2p (equal to equal) datagrams.

Triple Security in ZigBee: Link, Network and Application layer Encryptions

ZigBee implements two extra security layers on top of the 802.15.4 one: the Network and Application security layers. XBee ZigBee modules integrated in Waspmote also implement these two extra security layers.

ZigBee networks need a coordinator to work. If encryption is enabled on the coordinator, then it will apply a security policy to the network when it is created.

Enabling security adds an authentication step to the joining process. For instance, after a router joins a network, it must then obtain the network security key to become authenticated. If the device cannot obtain the network security key, authentication fails, and the device leaves the network since it cannot communicate with anyone on the network.

First of all, the security must be enabled using the following function:

xbeeZB.encryptionMode(1);

Security should be enabled on all nodes, not only on the Coordinator.

XBee ZigBee networks may work using a node as a Trust Center.

A Trust Center (TC) is a single device that is responsible for determining who may join the network. If a TC is enabled it must approve each router or end device which want join the network. If a router allows a new device to join the network, the router sends a notification to the TC that a join has occurred. The TC instructs the router to either authenticate the newly joined device or to force the device to leave. A TC is required for some public ZigBee profiles.

To use the TC in a ZigBee network, the coordinator should set the “use trust center” bit correctly in the ‘Encryption Options’ parameter before starting a network. Only the coordinator can serve as a TC.

Waspmote API allows you to set a Coordinator as a TC sing the following function:

xbeeZB.setEncryptionOptions(2):

XBee ZigBee networks may use three different keys:

  • Link Key: it is used to send the ‘Network Key’ cyphered. If this key is set to zero, then the key will be sent without cyphering to the joining nodes. Setting this key using Waspmote API is as simple as:

xbeeZB.setLinkKey(“link_key_secret_”);

 

  • Network Key: it is used to cypher all the data sent within the network. Setting this key using Waspmote API is as simple as:

xbeeZB.setNetworkKey(“network_key_encr”);

  • Application Key: it is used to cypher the data at the application layer. It is unique between each pair of nodes. This key is not configurable, though we must specify if it is going to be used or not with the following function:

xbeeZB.setAPSencryption(XBEE_ON);

Modules define a network key and a link key (trust center link key). Both keys are 128-bits and are used to apply AES encryption to RF packets.

The coordinator selects a network security key using the ‘Encryption Key’ parameter. Similarly, the coordinator must also specify a link key using the ‘Link Key’ parameter.

When a new device wants to join a secure network, it must obtain the network key from the Coordinator. The coordinator will either transmit the network key in clear, or it can encrypt the network key using a pre-installed link key. If the ‘Encryption Options’ bit is set to transmit the network key unencrypted, or if the ‘Link Key’ parameter is set to 0 on the coordinator (select a random link key), the coordinator will transmit the network key in  clear (unencrypted). Otherwise, if the ‘Encryption Options’ bit is not set and ‘Link Key’ is > 0, the coordinator will encrypt the network key with the link key and transmit the network key encrypted to any joining devices.

If a joining device does not have the right preconfigured link key, and the network key is being sent encrypted, then the joining device will not be able to join the network.
Network security requires a 32-bit frame counter to be maintained by each device. This frame counter is incremented after each transmission and cannot wrap to 0. If a neighbour receives a transmission with a frame counter that is less than or equal to the last received frame counter, the packet will be discarded.

To prevent an eventual lockup where the frame counter on a device reaches 0xFFFFFFFF, the network key should be periodically updated on all devices in the network. To update the network key in the network, the coordinator should issue the ‘Encryption Key’ parameter with a new security key. This will send a broadcast retransmission throughout the network causing the frame counters on all devices to reset to 0, and causing devices to begin using the new network key. All devices will also retain the previous key for a short time until everyone has switched to the new key.

Enabling security decreases the Payload as the below figure shows, however it is worth paying for this decrease of information transmitted while ensuring the privacy of our network.

 

@16bit Unicast

Broadcast

Encrypted (no APS)

66 Bytes

84 Bytes

Encrypted (APS)

62 Bytes

80 Bytes

NO Encrypted 74 Bytes 92 Bytes

 

What is the difference between ZigBee and ZigBee-Pro?

Read the ZigBee vs ZigBee-Pro article.

What is the difference between ZigBee certified and ZigBee compliance?

Read the ZigBee Compliance vs ZigBee Certified article.

802.15.4 Versus ZigBee, summarizing…

  • 802.15.4 is thought to be a protocol to get point to point and energy efficient communications.
  • ZigBee definces extra services (start topology routing, encryption, application services) over 802.15.4.
  • ZigBee creates semi-centralized networks where just the end devices can sleep
  • Different completely distributed mesh algorithms are being used over 802.15.4 is the protocol used to create

Both Waspmote and SquidBee benefit from all the 802.15.4, ZigBee and DigiMesh protocols and support all the frequency bands 869MHz, 900MHz and 2.4GHz.

802.15.4 / ZigBee Frequently Answers and Questions (FAQ)

  • Can the 802.15.4 sensor motes talk each other directly? Yes. They can send packets directly to any of their brothers which are in range.
  • Can the ZigBee sensor motes talk each other directly? No. The sensor motes can not talk each other directly. They have to do it through a router or coordinator device
  • Can the 802.15.4 nodes live with batteries? Yes- The point here is to find a synchronization algorithm which makes all of them send and recive at the same time. The DigiMesh protocol
  • Can the Zigbee nodes live with batteries? Not all, at least the routers and coordinator must be plug powered. The en devices can be battery powered
  • Can 802.15.4 nodes and ZigBee ones communicate? No. As pointed before, they have different communication methologies an procedures

XBee 802.15.4 OEM vs XBee ZB vs ZNet2.5 Comparative

  • What are the differences among the XBee 802.15.4 OEM, XBee ZB and XBee ZNet 2.5?
  • Are they compatible?
  • Can I upgrade the firmware which is running on this modules?
  • Can I transform them from one kind to another?

All the answers are answered on the following article XBee 802.15.4 OEM vs XBee ZB vs ZNet2.5 Comparative article.

External References: