datasheets.com EBN.com EDN.com EETimes.com Embedded.com PlanetAnalog.com TechOnline.com  
Events
UBM Tech
UBM Tech

Design Article

ZigBee applications - Part 1: Sending and receiving data

Drew Gislason

7/2/2010 6:23 AM EDT

Sending and Receiving Data
4.1 Sending and Receiving Data
The whole point of a wireless network is to send reliable data between nodes in the network, and ZigBee makes it easy. The ZigBee network automatically figures out how to route the data from one node to another with the maximum chance of success.

To send data from one node to another in the Freescale platform, for example, simply call:

AF_DataRequest(&addrInfo, iDataSize, pPtrToData, NULL);

That's it. ZigBee takes care of the rest!

ZigBee uses standard networking terms for data transmission, as defined by IEEE. This includes:

• Data Request (which means to transmit data)

• Data Confirm (which means the acknowledgment of a data request)

• Data Indication (which means to receive data)

Data requests are initiated by the application, as shown in Figure 4.1. A data confirm is the direct result of a data request: Each time an application generates a data request, it will receive exactly one data confirm to indicate the success (or failure) of that request. A data indication, however, may arrive at any time.

Figure 4.1: ZigBee Data Requests

Data requests come in a variety of flavors. The options include:

• Unicast with end-to-end acknowledgment

• Unicast without end-to-end acknowledgment

• Broadcast

• Groupcast/Multicast

Unicasts are transmitted from one node to exactly one other node. Unless the nodes are neighbors (within radio range of each other), route discovery takes place the first time these nodes speak together. If end-to-end is acknowledged, the unicast will be retried up to three times, perhaps even initiating a new route discovery if the old route is broken.

Broadcasts are transmitted from one node to all of the nodes in the network, within a sender-definable radius.

Groupcasts, and the upcoming Multicast in ZigBee 2007, broadcast to a specific set of nodes. Any node (actually, any endpoint, but I'll explain it in detail later) not part of the group will discard the packet. For example, assume the dark nodes in Figure 4.2 belong to group A. If a node groupcasts to group A, the packet will reach the applications in these specific nodes and no others.

Figure 4.2: ZigBee Groups

The example in the next subsection, Example 1-1 ZigBee Data Requests, demonstrates how to initiate all these various data request mechanisms, and how it looks from the standpoint of data indication.

While this chapter describes how to use ZigBee unicasts, broadcasts, and groupcasts, if you would like to understand how they work from a stack standpoint, see Chapter 7, "The ZigBee Networking Layer."

ZigBee is an asynchronous protocol; any node may transmit or receive data at any time. When a user flips a light switch, the data is sent immediately, even if that light switch is a battery-powered device designed to run for years on a couple of AAAs. If you have read the 802.15.4 specification, you may have read about beacons. ZigBee is beaconless.

Due to the nature of ZigBee, one thing that is difficult to predict is packet latency. A good rule of thumb is to assume that transmitting a packet requires about 10 milliseconds per hop. The difficulty comes in when retries or route discoveries are needed. Route discoveries require a broadcast across the network and the initiating node must wait until the results are received. Retries come in the form of both per-hop MAC retries and endto-end APS retries.

In Figure 4.3, a node is transmitting to another node, four hops away. Expect the packet to be received 40 ms later (on average) with the acknowledgment returning 80 ms later.

Figure 4.3: ZigBee Latency

When using acknowledged unicast data requests, up to three end-to-end retries occur with approximately a 1.5-second delay between each. This means the latency could be, in the worst case, nearly five seconds for a packet to successfully be delivered, or to indicate to the application that it failed to get through. Freescale BeeStack allows the duration between retries to be adjusted through the gApsAckWaitDuration_c property in BeeStackConfiguration.h.

ZigBee applications must allow for a broad range of latency for the worst-case scenarios.

The size of the packet doesn't affect latency much if the channel is fairly clean, as the random wait times dwarf the transmission times. But, if the channel is particularly noisy, then the length of the packet exponentially increases the chance of retries, which means an increase in latency.

A good policy is to keep the packet length as short as possible for the given transmission. Keeping packets short is good for two reasons: decreasing latency and reducing bandwidth usage, allowing more for other applications. Granted, if you are transferring bulk data, send as much as you can to reduce the number of packets, but for other kinds of data, think about how to keep it short.

ZigBee data transmission options include: unicast, broadcast, and groupcast.

Keep data transmissions as short as possible.





snicolasss

7/6/2010 12:31 PM EDT

Nice Book!
Drew is almost the only one who knows the easy way to explain real ZigBee.

Sign in to Reply



jorgemendez

7/7/2010 10:30 PM EDT

Great info, very very helpful.

Sign in to Reply



Har8951

7/9/2010 11:30 PM EDT

Nice book to start of with zigbee.....

I have been working on this protocol since a month and have few queries

What does it mean by zigbee end devices are in sleep mode most of the time. Is it the the radio is completely shut down or just it is in low power mode like LPM1 in CC2520????



If so if one tries to communicate with the end device and the end device is sleeping acoording to zigbee standard the router or coordinator buffers messages for its child devices but for how long???????? because in this case if one requests data from end device then it will not respond at all and one might require more RAM space and if network is large enough then imagine....

According to beacon enabled networks the end device wakes up at regular interval but what about non beacon mode. Then i have to keep my end device active all the time in non beacon networks which contradicts that zigbee is low power protocol.



I have confusion in this concept.





regards,
har8951

Sign in to Reply



Tim.Gillman

8/30/2010 1:34 AM EDT

To find out more about ZigBee and Wireless Sensor Networking, go to Drew's website: www.sanjuansw.com

Sign in to Reply



uanatol

4/21/2012 8:15 PM EDT

The phrase "A data indication means a node is receiving data from another node" tells
absolutely nothing. What does "indication" means ?
Does it means receiving data by the node ?
If so, where is the "sending data" primitive ?
I think we should avoid using terms that are
not intuitive, even if they were introduced in
OSI model 30 years ago.

Sign in to Reply



Please sign in to post comment

Navigate to related information

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)