This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Polling for broadcast messages in ZStack

Other Parts Discussed in Thread: Z-STACK

Hi everybody,

We're using ZStack-2.5.0 on CC2530s in a star network, with battery-powered end devices talking to USB powered routers (that is, every end device is at a depth of 1 and no router has a parent).  We'd like to be able to have each router query its end-device children for information, but we're having trouble getting the routers to respond to poll requests after they send out a broadcast message.

We finally got polling working in unicast (because the depth of all of our end devices is 1, we had been using AF_SKIP_ROUTING in AF_DataRequest(), but this did nothing except prevent messages from being held for sleeping end devices, so we're now using AF_TX_OPTIONS_NONE).  However, when we try to send the same message as a broadcast (address 0xFFFF, addrMode = afAddrBroadcast) nothing happens when the end-device issues a poll request.

Is there a way to ensure that a router will hold a broadcast message for sleeping end devices?  According to the ZStack Developer's Guide, when broadcasting to 0xFFFF "the message will be sent to all devices in the network (includes sleeping devices). For sleeping devices, the message is held at its parent until the sleeping device polls for it or the message is timed out (NWK_INDIRECT_MSG_TIMEOUT in f8wConfig.cfg)".  I have a feeling there's some compiler option we're missing or some parameter of AF_DataRequest() we're not using right, but I can't seem to find where the issue is.

If there's any info I can give you folks that would give you a better idea of what might be wrong, please let me know.

Thanks,

Hank

  • As I remember, the default value of NWK_INDIRECT_MSG_TIMEOUT is 7 which means the message will be only hold for 7 ms on the parents. I would suggest you to enlarge this value to at least more than device polling rate.

  • Thanks for the quick reply!

    I spent a long time looking at those different polling parameters, and if I understood them right (which, admittedly, I may not have done) that 7 means the messages are held for 7 seconds (NWK_INDIRECT_MSG_TIMEOUT X CNT_RTG_TIMER X RTG_TIMER_INTERVAL = 7 X 1 X 1000 = 7000 ms).  And with the current parameters, it works just fine for polling if I send the message unicast, just not if I send the message as a broadcast.  Would the router hold messages for different lengths of time for broadcast messages vs. unicast messages?

  • In Z-Stack Compile Options.pdf, it says that NWK_INDIRECT_MSG_TIMEOUT means Number of milliseconds the parent of a polling End Device will hold a message. However, the document might be wrong. As I remember, the broadcast data seems not kept on coordinator or router. It is no grantee that ZED can receive broadcast message.

  • Hmm, you're right, it does say that.  I tried significantly increasing NWK_INDIRECT_MSG_TIMEOUT (to 7000) as well as significantly decreasing POLL_RATE on the end device (to 10ms), but it still doesn't receive any broadcast messages.  (I should note, by the way, that if I set RxOnIdle to TRUE, it will receive broadcast messages, which is why I think it's an issue with polling and not something else).

    I'm beginning to think that broadcast data isn't kept for polling, although the developer's guide suggests otherwise, and I thought I saw postings in the forum saying that people had gotten polling of broadcast messages to work.  If it doesn't save broadcast messages, will I just have to do something like iterate through the list of associated devices and unicast messages to each?

  • In my projects, I always use unicast to send messages to ZED and I would suggest you compliant to it.

  • Cool, I'll give that a try then.  Thanks for your help!

  • Did you ever get this to work? I'm having the same problem and would like to know if it's true that broadcast messages (including group messages) are not saved for polling devices.
  • Broadcast/multicast data won't be stored on ZC/ZR and you should use unicast to send data to ZED.
  • Zstack's lack of broadcasting functionality for sleeping end devices is quite problematic as I see it and I really can't understand why TI has chosen not to include it. Those of you that's been around for some time, remember that the old 2006 stack could handle broadcasts to end devices quite well.

    To give an example how serious it can get: we all know that routers have a tendency to change their network address now and then (how and why that happens has been covered in detail in this forum). To give an example: a typical sensor network consists of hundreds of sensors all pushing their data frequently to a gateway with e.g. network address 0x1234. Suddenly, the gateway changes it's address. It doesn't happen often but in our experience, the likelihood is in the order of 1-10% per month - and the larger the network is, the more likely it gets. The gateway will announce the change via a broadcast to all devices in the network - but since the stack doesn't handle broadcasts to sleeping end devices - the sensors won't know what just happened - they will continue to unicast their data to an empty mailbox at address 0x1234 that no longer has any owner.

    Sure, if you have APS ACK turned on, the end device will eventually know something bad happened and might issue a new service discovery to find the gateway again, but that's a process that involves flooding the network with a broadcast storm. And having hundreds of sensors do this simultaneously - that means goodnight. Further, most people I know of turn off the APS ACK in order to get a more deterministic network where the battery life time of the sensors can be predicted.

    How to fix above situation then? The way we've done it is to force the gateway to reclaim its previous address once a address change is triggered. Right or wrong? It works nicely but it's not really according to the ZigBee specs, but the lack of broadcast mechanism in zstack isn't either. At least, our little trick allows all our networks to have 100% uptime, and critical signals like alarms etc always gets through. That didn't always happen before and our maintenance cost for keeping the networks alive then were huge.

    If I may have a new years wish: please TI, reinstate the broadcast mechanism for end devices. That would simplify life tremendously for us application specialists and help us to minimize "special solutions".
  • As I know, this is about Zigbee spec and no Zigbee solution vendor would keep broadcast message on ZC/ZR.

  • Well, the 2006 stack did handle broadcasts to end devices and the new stack doesn't.

    I don't find anywhere in the ZigBee specs that broadcasts should be excluded for end devices. If I'm wrong, please indicate what part in the specs I've missed. The general understanding is that a broadcast message is a message that is meant for all modules on any given PAN. TI's own Developer's guide amplifies this further by stating:

    "3.3.3 Broadcast
    This address mode is used when the application wants to send a packet to all devices in the network. The address mode is set to AddrBroadcast and the destination address can be set to one of the following broadcast addresses:
    NWK_BROADCAST_SHORTADDR_DEVALL (0xFFFF) – the message will be sent to all devices in the network (includes sleeping devices). For sleeping devices, the message is held at its parent until the sleeping device polls for it or the message is timed out (NWK_INDIRECT_MSG_TIMEOUT in f8wConfig.cfg)."

    I think that says it....
  • The default BCAST_DELIVERY_TIME is 30. You can try to enlarge BCAST_DELIVERY_TIME.

    Set the value too short, and routers cannot keep track of what they have already heard and just keep re-broadcasting a message, bringing the throughput on the channel to its knees with the re-broadcast storm, until the message hops counts it down to zero.

    Set the value too long, and you cannot send a broadcast very often becuase the memory gets filled up with all of the broadcasts being held.
  • Hi YiKai,
    I don't think BCAST_DELIVERY_TIME has anything to do with the subject matter.
    The subject matter is that routers doesn't hold broadcast messages for sleeping devices despite TI's manual says they do and TI's algorithm stated in nwk_globals.c for the holding time is evidently false.
    Comment from TI is appreciated.
    Best Magnus B
  • Hi Chen,

                   how could ZC check  Msg(ManufacturerName,HWRevision)of all the device in the network,

                   unicast ? or broadcast ? 

                   if ZED was on PM2 mode,  and POLLRATE is 60S? how could ZC make sure the ZED will get the read MSG?

  • In my application, I use unicast from ZC to ZED. If there is no APS ack from ZED, I would resend the message.
  • Can't be done that way in zstack unless ZC keeps a table of all end devices in the network and unicast a read command to every one. That would be impractical and error prone since we know that sudden address changes may occur accidently in zstack so those tables will get corrupted over time.

    The way to do what you want to do is instead to have each ZED push their messages to the ZC at regular intervals, e.g. as a zcl write or zcl report command.

    The next question is then: how to keep track of all ZED's and to know who is who. You can't rely on the short address as a unique identifier since it may change. Include a unique identifier in the message instead, e.g. the device's MAC-address which is guaranteed to be unique.

    /m
  • Hi Bolmsjo,

         do you means the ZED should send the MSG(which included its base device information and use MAC address?) to ZC again and again for letting ZC knows which device is on the network?

         if like that ,should we make a timeout event every 60s for achieve it in coding?

  • Hi The Seven,

    You can implement supervision signal sent from ZED to ZC. I won't suggest 60 seconds duration to send supervision signal because it would use up ZED's battery very soon. However, this depends how fast you want your system detects any device doesn't exist in your system. For example, if you have to know any device is out of radio coverage not longer than 5 minutes, than you have to send supervision no more than 5 minutes.

  • Hi Chen
    could you please tell me the detail of Sending supervision signal?
    is that like ZONE sending the alarm MSG which only enable SS_IAS_ZONE_STATUS_SUPERVISION_REPORTS_YES ?

    Anyways,Zigbee recommended that a end device should poll its parents every 60s in the IndirectPollRate Note.
    when the device wake up ,is that different on power using between receiving data and sending data ?


    and my question is which ways should be more reliable to knows the surroundings of network 。

    ZC search every ZED activtly or ZED report to ZC in cycle?
  • 1. Yes, you can enable SS_IAS_ZONE_STATUS_SUPERVISION_REPORTS_YES bit and send IAS Zone report periodically as supervision signal.
    2. Yes, polling is much more power efficiency than sending message like IAS zone report. However, if your application use ZC to inquiry ZED and wait ZED's response to know the existence of ZED, ZED still has to send message like IAS zone attribute read response. I think the power consumption in this alternative is close to send IAS zone report directly.
    3. Form my point of view, both alternative are reliable if your application implement retry mechanism.
  • Thank you, Magnus. This is exactly how I read the documentation, and I lost a couple days trying to figure out why my end devices were not getting messages that were broadcast, when they were getting messages that were unicast. I had made sure that the BCAST_DELIVERY_TIME was fine, checked that it was being received when the ZED had the receiver_on_when_idle flag on, played with different settings on the AF_DataRequest flags, I was stumped. The documentation clearly leads one to believe that broadcasting to end devices is possible, or at least it doesn't say it doesn't work, especially since there are separate flags for all devices and router+coordinator devices, which means to me that when the all devices flag is set for a broadcast, then end devices should get them.

    Anyway, now that I know I can get around the problem, and I hope this thread is helpful to those in the future who also wish to broadcast messages to children end devices.

  • Hi Seven,
    Yes, that's would I would do, i.e. to have the ZED push a message to the ZC at regular intervals, not have the ZC asking for data and then the ZED respond to that. Keep it simple. And no APS ACK if you don't must. ZigBee's automatic MAC-ack is sufficient for most cases.

    The ZED reporting doesn't have to be very often. To send a report every 60 second seems to overdo it unless your application needs fast data. In our applications we typically let the ZED's push data to the ZC every 10 minute even if there is nothing to report, just so that the ZC "knows" the ZED is alive. If the ZED is a simple sensor, we also turn off polling to preserve battery life time. No need to use polling since sensors usually are just dumb sensors and there is usually no need to send data to dumb sensors (by the way - they can't receive a broadcasts anyway due to zstack limitations). You'll be amazed how much battery you'll save by turning off the poll. You'll double life time at least.

    If the ZED needs data from the ZC? Well - send it unicast since broadcast won't work for sleeping ZEDs. What if you don't know the short address of the ZED? (remember short addresses are not static). Send the data to routers instead as a broadcast so that routers have a copy of the data (routers will hear the broadcast). Then have the ZED ask for that specific data from its parent now and then. That's a way to "emulate" a broadcast to ZED's. It works fine but requires some coding from your side. I've actually seen a TI note on that but I don't remember where I saw it.

    Best /m
  • Hi Magnus!

         Thanks for you reply!

         but i have different idea of your.

         1.  Turn off polling to preserve battery life time in sample sensor node is not good for User Experience,it seems we need to cut some functions.

               How could we let the consumer knows how many sensor is working now ?

               And how could consumer knows when should be change the battery?

               As you said "You'll be amazed how much battery you'll save by turning off the poll. You'll double life time at least."

               yes i will ,i do really care about the  User Experience!

        2.    Send the data to routers and let rounter keeps the Msg ,then  resend the Msg to   ZED (when wake up)

               if there is not any router, how could we do ?

    Best Regards!

  • Hi Seven

    Number of sensors: the ZC knows because all ZED's reports to it - so customers can request a summary report from the ZC

    Battery change: if a sensor no longer reports, the ZC will detect this (reports missing) and may notice the user. Another way is to include battery voltage in the reporting to the ZC and notify user when voltage drops. On the other hand - if you use Li-battery you want see a voltage drop before the battery dies - in that case you need to monitor battery status in another way. 

    User experience: don't know what you mean. Users usually don't care about polling

    If you only have the ZC, then its a star network where ZC is the parent and all ZED's will be listed in ZC's assocation table so you can just scan through that table and unicast directly to each and every ZED (but then you need to have the poll turned on).

    Best /m

  • Hi Magnus~

         Maybe i make a mistake of your opinion.

         Do you mean turn off polling but report  activly to its parent in cycle?

  • Hi Seven,

    My take is: keep it as simple as possible. Polling yes if you need 2-way communication between the sleeping device and the parent. But if you really don't need 2-way communication, leave it out - just let the device report its message and then go back to sleep. Regardless of which method you choose, an end device will anyway poll its parent a single time in conjunction with transmitting the message so even with polling turned off, there is always a kind of two-way communication enabled, although not so frequent as a regular poll would be.

    Polling / no polling also touches the robustness of the system. Nobody wants a system where end devices suddenly dies because the battery drained prematurely and unexpectedly. The upside of skipping poll is: you'll get a more deterministic system with few uncertainties built in, meaning that you'll easily double the battery life time to perhaps 20 year or more. Although a battery in itself only cost a few dollar, to change it can easily cost 100 USD or more (you have to call in maintenance people and so on....), so battery life time is in my mind the most critical factor of all. 

    On robustness: Wireless technologies are inherently susceptible to disturbances and one must accept that messages doesn't always get through and design for it. How many times a poll may fail before an end device will start a rejoin (a rejoin event is very costly from battery standpoint) is set by MAX_POLL_FAILURE_RETRIES (default is 3 which in my opinion is way to small). One can therefore argue that a no-poll unit will always be more robust than a polled unit because the number of possible failures / rejoins will always be much smaller during its lifetime. Same thing with APS ACK which from a theoretical standpoint is a nice feature but from a battery standpoint pretty dangerous. Use it when you must but else leave it out. If you're not cautious, APS-ACK can cause your battery to go down faster than you can blink.

    Best / m