IoT(Internet Of Things)
Wireless PAN (IEEE 802.15.4) - MAC
The official title of 802.15.4 is Low-Rate Wireless Personal Area Networks (LR-WPANs). As the title says, this is the specification for Small Area Network (Personal Area Network) with very low data rate and very low energy consumption. And it is basically the specification for MAC layer. It also provides the general guide lines for PHY layer but there can be many other implementation with different PHY implementation.
Overall protocol stack suggested by 802.15 and MAC and PHY frame are is as follows.

Currently (as of Jun 2015), there are two most widely used implementation that adopting this architecture. They are ZigBee and 6LoPAN and their overall structure is as follows. (I will post separate pages for ZigBee and 6LoPAN)

- Allow mesh networking and a node can forward a packet to another node
- A Node uses 64 bit address (extended address) or 16 bit address (short address)
- There can be Node Coordinator (like WiFi AP) and the coordinator assigns 16 bit address for use during the association
- Maximum Frame Size is 127 bytes : How can this small frame carry IPv6 packet (usually very big) ?
- Perform retransmission (Fully Acknowleged protocol for transfer reliability)
- Operates base on CSMA-CA or ALOHA channel access
- Support Energy Detection (ED) capability
- Support Link Quality Indicatioin (LQI)
- (Optional) I can allocate guaranteed time slot (GTS)
- (Optional) it can perform routing (Data Link layer routing)
There are four different MAC frames as listed below :
- Beacon frames : Used by a Coordinator
- MAC command frames : Used for handling all MAC peer entity control transfer
- Acknowledgement frames : Used for confirming successful frame reception
- Data frames : Used for all transfer of data
Data Frame is the frame over which IPv6 packets are being carried. Followings are the structure of each type of frames.
< 802.15.4 Figure 38—Beacon frame format >
![]()
Following is an example 802.15.4 MAC frame captured by Wireshark from Wirehshark - IEEE 802.15.4 page.
IEEE 802.15.4 Beacon, Src: 0x0000
Frame Control Field: Beacon (0x8000)
.... .... .... .000 = Frame Type: Beacon (0x0000)
.... .... .... 0... = Security Enabled: False
.... .... ...0 .... = Frame Pending: False
.... .... ..0. .... = Acknowledge Request: False
.... .... .0.. .... = Intra-PAN: False
.... 00.. .... .... = Destination Addressing Mode: None (0x0000)
..00 .... .... .... = Frame Version: 0
10.. .... .... .... = Source Addressing Mode: Short/16-bit (0x0002)
Sequence Number: 99
Source PAN: 0x01ff
Source: 0x0000
Superframe Specification
.... .... .... 1111 = Beacon Interval: 15
.... .... 1111 .... = Superframe Interval: 15
.... 1111 .... .... = Final CAP Slot: 15
...0 .... .... .... = Battery Extension: False
.1.. .... .... .... = PAN Coordinator: True
1... .... .... .... = Association Permit: True
GTS
GTS Descriptor Count: 0
GTS Permit: False
Pending Addresses: 0 Short and 0 Long
ZigBee Beacon
Protocol ID: 0
Stack Profile: Network Specific (0x00)
Protocol Version: 2
Router Capacity: True
Device Depth: 0
End Device Capacity: True
Extended PAN ID: Miniware_6f:73:6e:65:73 (00:00:72:6f:73:6e:65:73)
Tx Offset: 16777215
Update ID: 0
0000 00 80 63 ff 01 00 00 ff cf 00 00 00 20 84 73 65 ..c......... .se
0010 6e 73 6f 72 00 00 ff ff ff 00 nsor......
< 802.15.4 Figure 46—Data frame format >

Following is an example 802.15.4 MAC frame captured by Wireshark from Wirehshark - IEEE 802.15.4 page.
IEEE 802.15.4 Data, Dst: Broadcast, Src: 0x2c4d
Frame Control Field: Data (0x8841)
.... .... .... .001 = Frame Type: Data (0x0001)
.... .... .... 0... = Security Enabled: False
.... .... ...0 .... = Frame Pending: False
.... .... ..0. .... = Acknowledge Request: False
.... .... .1.. .... = Intra-PAN: True
.... 10.. .... .... = Destination Addressing Mode: Short/16-bit (0x0002)
..00 .... .... .... = Frame Version: 0
10.. .... .... .... = Source Addressing Mode: Short/16-bit (0x0002)
Sequence Number: 14
Destination PAN: 0x01ff
Destination: 0xffff
Source: 0x2c4d
[Extended Source: ExeginTe_ff:ff:00:20:07 (00:1c:da:ff:ff:00:20:07)]
[Origin: 23]
ZigBee Network Layer Data, Dst: Broadcast, Src: 0x2c4d
Frame Control Field: Data (0x0248)
.... .... .... ..00 = Frame Type: Data (0x0000)
.... .... ..00 10.. = Protocol Version: 2
.... .... 01.. .... = Discover Route: Enable (0x0001)
.... ...0 .... .... = Multicast: False
.... ..1. .... .... = Security: True
.... .0.. .... .... = Source Route: False
.... 0... .... .... = Destination: False
...0 .... .... .... = Extended Source: False
Destination: 0xfffd
Source: 0x2c4d
Radius: 30
Sequence Number: 123
[Extended Source: ExeginTe_ff:ff:00:20:07 (00:1c:da:ff:ff:00:20:07)]
[Origin: 19]
ZigBee Security Header
Security Control Field
...0 1... = Key Id: Network Key (0x01)
..1. .... = Extended Nonce: True
Frame Counter: 0
Extended Source: ExeginTe_ff:ff:00:20:07 (00:1c:da:ff:ff:00:20:07)
Key Sequence Number: 0
Message Integrity Code: 9376f9f8
[Expert Info (Warn/Undecoded): Encrypted Payload]
[Message: Encrypted Payload]
[Severity level: Warn]
[Group: Undecoded]
Data (20 bytes)
Data: 31316d646805adc32b8eafa8e32b726e3bb5a52e
[Length: 20]
0000 41 88 0e ff 01 ff ff 4d 2c 48 02 fd ff 4d 2c 1e A......M,H...M,.
0010 7b 28 00 00 00 00 07 20 00 ff ff da 1c 00 00 31 {(..... .......1
0020 31 6d 64 68 05 ad c3 2b 8e af a8 e3 2b 72 6e 3b 1mdh...+....+rn;
0030 b5 a5 2e 93 76 f9 f8 ....v..
< 802.15.4 Figure 48—MAC command frame format>


Following is an example 802.15.4 MAC frame captured by Wireshark from Wirehshark - IEEE 802.15.4 page.
IEEE 802.15.4 Command, Dst: 0x0000, Src: ExeginTe_ff:ff:00:20:07
Frame Control Field: Command (0xc823)
.... .... .... .011 = Frame Type: Command (0x0003)
.... .... .... 0... = Security Enabled: False
.... .... ...0 .... = Frame Pending: False
.... .... ..1. .... = Acknowledge Request: True
.... .... .0.. .... = Intra-PAN: False
.... 10.. .... .... = Destination Addressing Mode: Short/16-bit (0x0002)
..00 .... .... .... = Frame Version: 0
11.. .... .... .... = Source Addressing Mode: Long/64-bit (0x0003)
Sequence Number: 12
Destination PAN: 0x01ff
Destination: 0x0000
Source PAN: 0xffff
Extended Source: ExeginTe_ff:ff:00:20:07 (00:1c:da:ff:ff:00:20:07)
Command Identifier: Association Request (0x01)
Association Request
.... ...0 = Alternate PAN Coordinator: False
.... ..1. = Device Type: True (FFD)
.... .1.. = Power Source: True (AC/Mains Power)
.... 1... = Receive On When Idle: True
.1.. .... = Security Capability: True
1... .... = Allocate Address: True
0000 23 c8 0c ff 01 00 00 ff ff 07 20 00 ff ff da 1c #......... .....
0010 00 01 ce ...
< 802.15.4 Figure 47—Acknowledgment frame format >

Following is an example 802.15.4 MAC frame captured by Wireshark from Wirehshark - IEEE 802.15.4 page.
IEEE 802.15.4 Ack, Sequence Number: 12
Frame Control Field: Ack (0x0002)
.... .... .... .010 = Frame Type: Ack (0x0002)
.... .... .... 0... = Security Enabled: False
.... .... ...0 .... = Frame Pending: False
.... .... ..0. .... = Acknowledge Request: False
.... .... .0.. .... = Intra-PAN: False
.... 00.. .... .... = Destination Addressing Mode: None (0x0000)
..00 .... .... .... = Frame Version: 0
00.. .... .... .... = Source Addressing Mode: None (0x0000)
Sequence Number: 12
0000 02 00 0c