主要内容

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]使用ZigBee和UWB的Communications Toolbox™库。

Background

TheIEEE 802.15.4standard specifies theMACPHY.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 asZigbee., 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

IEEE 802.15.4 MAC层分别在网络层帧之前和之后插入MAC头和MAC页脚。MAC页脚包含CRC检查。

Alrwpan.MACFrameConfigconfiguration 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. Thelrwpan.macframeGeneratorfunction 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. Thelrwpan.MACFrameDecoder函数接受一个MAC协议数据单元(MPDU)我n 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.

Decoding MAC Frames of Home Automation ZigBee Radios

This section decodes MAC frames transmitted from commercial ZigBee radios enabling home automation, and captured using a USRP® B200-mini radio and theCommunications Toolbox Support Package for USRP® radio。捕获波形的PHY层已经根据所描述的方法进行解码Recovery of IEEE 802.15.4 OQPSK Signals例子。生成的MPDU存储到MAT文件中:

loadlrwpanmaccaptures.

首先,数据帧被解码:

[dataFrameMACConfig, netFrame] = lrwpan.MACFrameDecoder(MPDU_data);if〜isempty(dataframemacconfig)fprintf('CRC检查传递给MAC帧。\ n');dataFrameMACConfigend
CRC检查传递给MAC帧。dataframemacconfig = macframeconfig具有属性:frameType:'data'常规mac属性:semencenumber:244确认request:1 destinationaddressing:'short地址'destinationpanidentifier:'1e16'destinationanddress:'35ea'酸菜:'短地址'sourceaddress:'0000'PaniTentionCompress:1 framepending:0 frameversion:'2003'安全性:0安全属性:无属性。信标属性:无属性。“MAC命令”属性:无属性。

Next, an acknowledgment frame is decoded:

ackFrameMACConfig = lrwpan.MACFrameDecoder(MPDU_ack)
ackFrameMACConfig = MACFrameConfig with properties: FrameType: 'Acknowledgment' General MAC properties: SequenceNumber: 165 DestinationAddressing: 'Not present' SourceAddressing: 'Not present' FramePending: 0 FrameVersion: '2003' Security: 0 Security properties: No properties. Beacon properties: No properties. "MAC Command" properties: No properties.

Generating MAC Frames

Thelrwpan.macframeGeneratorfunction can generate all MAC frame types from the IEEE 802.15.4 standard [1], i.e., 'Beacon', 'Data', 'Acknowledgment', and 'MAC Command' frame types. The MAC Command frame types can be further specified as: 'Association request', 'Association response', 'Disassociation notification', 'Data request', 'PAN ID conflict notification', 'Orphan notification', 'Beacon request', and 'GTS request'.

This code illustrates how to generate frames for all frame types:

% BeaconbeaconConfig = lrwpan.MACFrameConfig('FrameType','Beacon');beaconMACFrame = lrwpan.MACFrameGenerator(beaconConfig);% 数据dataconfig = lrwpan.macframeconfig('FrameType','数据');numOctets = 50; payload = dec2hex(randi([0 2^8-1], numOctets, 1), 2); dataMACFrame = lrwpan.MACFrameGenerator(dataConfig, payload);% AcknowledgmentackConfig = lrwpan.MACFrameConfig('FrameType','确认');ackFrame = lrwpan.MACFrameGenerator(ackConfig);% MAC CommandcommandConfig = lrwpan.MACFrameConfig('FrameType','mac命令');commandconfig.maccommmand ='Association request';麦克马克的%有效设置还包括:'关联响应',%'解剖通知','数据请求','pan ID冲突% notification', 'Orphan notification', 'Beacon request', and 'GTS request'.commandframe = lrwpan.macframegenerator(commandconfig);

进一步的探索

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

Selected Bibliography

  1. IEEE 802.15.4-2011 - 本地和大都市地区网络的IEEE标准 - 第15.4部分:低利率无线个人面积网络(LR-WPANS)