IEEE 802.15.4 - MAC Frame Generation and Decoding

This example shows how to generate and decode MAC frames of the IEEE® 802.15.4™ standard [ 1 ] using the Communications Toolbox™ Library for the ZigBee® Protocol.

Background

The IEEE 802.15.4 standard specifies the MAC and PHY layers of Low-Rate Wireless Personal Area Networks (LR-WPANs) [ 1 ]. The IEEE 802.15.4 MAC and PHY layers provide the basis of other higher-layer standards, such as ZigBee, WirelessHart®, 6LoWPAN and MiWi. Such standards find application in home automation and sensor networking and are highly relevant to the Internet of Things (IoT) trend.

Architecture

The IEEE 802.15.4 MAC layer inserts a MAC header and a MAC footer before and after a network-layer frame, respectively. The MAC footer contains a CRC check.

A lrwpan.MACFrameConfig configuration object is used both in generating and decoding IEEE 802.15.4 MAC frames. Such objects describe a MAC frame and specify its frame type and all applicable properties. The lrwpan.MACFrameGenerator function accepts a lrwpan.MACFrameConfig object describing the frame, and optionally a MAC-layer payload (NET-layer frame) in bytes (two-characters), and outputs the MAC frame in bits. The lrwpan.MACFrameDecoder function accepts a MAC Protocol Data Unit (MPDU) in bits and outputs a lrwpan.MACFrameConfig object describing the frame and possibly a NET-layer frame in bytes. Clause 5 in [ 1 ] describes the MAC frame formats.