Main Content

ZigbeeNET Frame Generation and Decoding

此示例显示了如何使用Zigbee®和UWB使用Communications Toolbox™库来生成和解码Zigbee规范的网络帧[1].

Background

The ZigBee standard specifies the network (NET or NWK) and application (APP or APL) layers for low-rate wireless personal area networks. These NET- and APP-layer specifications build upon the PHY and MAC specifications of IEEE® 802.15.4™ [2]. ZigBee devices find application in home automation and sensor networking and are highly relevant to the Internet of Things (IoT) trend.

Architecture

Azigbee.NETFrameConfigconfiguration object is used both in generating and decoding ZigBee NET frames. Such objects describe a NET-layer frame and specify its frame type and all applicable properties. Thezigbee.NETFrameGeneratorfunction accepts a zigbee.NETFrameConfig object describing the frame, and optionally a NET-layer payload (APP-layer frame) in bytes (two-characters), and outputs the NET frame in bytes. Thezigbee.NETFrameDecoderfunction accepts a NET Protocol Data Unit (NPDU) in bytes and outputs a zigbee.NETFrameConfig object describing the frame and possibly a NET-layer frame in bytes. Clause 3.3 in [1] describes the NET frame formats.

Decoding NET Frames of Home Automation ZigBee Radios

This section decodes NET frames transmitted from a commercial ZigBee radio enabling home automation, and captured using a USRP® B200-mini radio and the通信工具箱支持包USRP®r金宝appadio.

Thezigbee.NETFrameDecoder功能可以解码Net-Layer Zigbee数据框架和Net-Command框架类型的标题。

loadzigbeeNETCaptures% netFrame[netConfig, netPayload] = zigbee.NETFrameDecoder(netFrame); netConfig
netConfig = NETFrameConfig with properties: FrameType: 'Data' ProtocolVersion: 'ZigBee 2007' SequenceNumber: 212 Addressing: SourceAddress: '0000' DestinationAddress: '35EA' IEEEAddressing: 'None' Security: Security: 1 DataEncryption: 0 MICLength: 0 KeyIdentifier:'Network' ExtendedNonce: 1 FrameCounter: 193458 SecuritySourceAddress: '24FD5B00000014B6' KeySequence: 0 Routing: Radius: 30 DiscoverRoute: 1 SourceRouting: 1 RelayIndex: 0 RelayList: [0x4 char] Multicast: Multicast: 0

Note that NET-layer decoding indicates that the NET-layer payload is encrypted (Security = true). Security can be used either in the network or the application layer; this frame uses network-layer security. On the one hand, the DataEncryption field is false in the frame and the Message Integrity Code (MIC) length is zero, which indicate that security level #0 is used and that the payload is not encrypted. However, according to the ZigBee standard (Clause 4.4.1.2 in [1]), these two fields areoverwrittenwith values locally stored during network setup. In this case, this frame was secured with security level #5, which means that the NET-payload is encrypted and that the MIC length is 32 bits.

Generating NET Frames

Thezigbee.NETFrameGeneratorfunction can generate unsecure NET-layer ZigBee data frames. The configuration object can be further customized.

netConfig = zigbee.NETFrameConfig('SequenceNumber', 123,'DestinationAddress','E568'); numOctets = 50; payload = dec2hex(randi([0 2^8-1], numOctets, 1), 2); netFrame = zigbee.NETFrameGenerator(netConfig, payload);

进一步探索

您可以进一步探索以下生成器和解码功能以及配置对象:

选定的参考书目

  1. ZigbeeAlliance, ZigBee Specification Document 053474r17, 2007

  2. IEEE 802.15.4-2011 - IEEE Standard for Local and metropolitan area networks--Part 15.4: Low-Rate Wireless Personal Area Networks (LR-WPANs)