How to access Zigbee MAC diagnostic counters from app code?

I have a semi-working app which executes Zigbee commands that it receives from other nodes, but the latency is sometimes unacceptably high.  I would like to check some of the diagnostic counters to see if they offer a clue as to what is happening in the lower layers (e.g. corrupted packets, retransmissions, etc.):

/* MAC diagnostics info */
typedef ZB_PACKED_PRE struct zb_mac_diagnostic_info_s
{
zb_uint32_t mac_rx_bcast; /* A counter that is incremented each time
* the MAC layer receives a broadcast. */
zb_uint32_t mac_tx_bcast; /* A counter that is incremented each time
* the MAC layer transmits a broadcast. */
zb_uint32_t mac_rx_ucast; /* A counter that is incremented each time the
* MAC layer receives a unicast. */

/* These 3 counters are required not to break
* ZDO channel management logic that
* uses normalized counters values.
*/
zb_uint32_t mac_tx_ucast_total_zcl; /* The same as mac_tx_ucast_total, but non-normalized */
zb_uint16_t mac_tx_ucast_failures_zcl; /* The same as mac_tx_ucast_failures, but non-normalized */
zb_uint16_t mac_tx_ucast_retries_zcl; /* The same as mac_tx_ucast_retries, but non-normalized*/

zb_uint16_t mac_tx_ucast_total; /* Total number of Mac Tx Transactions to
* attempt to send a message (but not
* counting retries) */
zb_uint16_t mac_tx_ucast_failures; /* Total number of failed Tx
* Transactions. So if the Mac send a
* single packet, it will be retried 4
* times without ack, that counts as 1 failure */
zb_uint16_t mac_tx_ucast_retries; /* Total number of Mac Retries regardles of
* whether the transaction resulted in
* success or failure. */

zb_uint16_t phy_to_mac_que_lim_reached; /* A counter that is incremented each time when MAC RX queue if full. */

zb_uint16_t mac_validate_drop_cnt; /* How many times the packet was dropped at the packet
* validation stage for length or bad formatting. */

zb_uint16_t phy_cca_fail_count; /* Number of the PHY layer was unable
* to transmit due to a failed CCA */

zb_uint8_t period_of_time; /* Time period over which MACTx results are measured */
zb_uint8_t last_msg_lqi; /* LQI value of the last received packet */
zb_int8_t last_msg_rssi; /* RSSI value of the last received packet */
} ZB_PACKED_STRUCT
zb_mac_diagnostic_info_t;

Currently I am trying this:

#include <zb_zcl_diagnostics.h>
LOG_INF("last_msg_rssi = %d", diagnostics_ctx_zcl.mac_data.last_msg_rssi);

Unfortunately this value is never updated; it remains 0 forever.  In zcl_general_commands.c I see functions like zb_zcl_sync_stats() that ask ZBOSS to update the counters, however nothing relevant seems to be exported to user applications.

What is the recommended API for getting access to these counters?

Do I need to add a diagnostics cluster to my app and then query it over Zigbee?  And if so, what tools do you typically use on the client side?

Parents
  • Hi, 

    I haven't used the diagnostic cluster before, so I don't know why last_msg_rssi remains 0. There are other ways you can get RSSI of other devices or neighbors as well. For neighbors, you can use the neighbor table, as there are fields for RSSI and LQI of a neighbor there. You can also use zb_zdo_get_diag_data(). For the neighbor table, you can iterate through the entire neighbor table and check for each entry, but for zb_zdo_get_diag_data() they need to know the short address of the device they want to get RSSI of.

    If you want to check for corrupted packets, retransmissions, etc. the best way to do this would be to get a sniffer log to inspect the network and packets.

    Regards,
    Amanda

  • I do have a sniffer set up, but I don't know how to make it quantify the number of anomalous events.  For instance, it's useful to be able to say "X percent of receive attempts got a failed FCS" or "X percent of transmit attempts required a retransmission" and compare this between different nodes, board types, antenna types, etc.

    This is the sort of criteria I would give to a QA team as well: it's almost impossible for a wireless product to transmit/receive perfectly 100% of the time under all conditions, so you set an acceptable error rate, and flag regressions if that rate is exceeded.

    How do I filter for retransmissions when viewing a sniffer log in wireshark?

Reply
  • I do have a sniffer set up, but I don't know how to make it quantify the number of anomalous events.  For instance, it's useful to be able to say "X percent of receive attempts got a failed FCS" or "X percent of transmit attempts required a retransmission" and compare this between different nodes, board types, antenna types, etc.

    This is the sort of criteria I would give to a QA team as well: it's almost impossible for a wireless product to transmit/receive perfectly 100% of the time under all conditions, so you set an acceptable error rate, and flag regressions if that rate is exceeded.

    How do I filter for retransmissions when viewing a sniffer log in wireshark?

Children
Related