Understanding LoRaWAN MAC Layer, MAC Commands, Packet Format and LoRa Frame Structure

The MAC (Medium Access Control) layer in LoRaWAN is responsible for managing communication between devices and the network. It handles tasks such as frame format definition, scheduling, and ensuring the reliability of data transfer. Understanding the LoRaWAN MAC layer is crucial for optimizing network performance and maintaining efficient operation in LPWAN networks. In this page, we will explore MAC Commands, Packet Format and LoRa Frame Structure.

As shown in the figure, like other wireless networks, LoRaWAN consists of End Devices and LoRa gateway. The gateway functions similar to base station of cellular network and End Devices function as mobile phones.

LoRa network architecture

Like other wireless network, transmission from LoRa Gateway module to End devices is known as "downlink" while transmissions from end devices to LoRa Gateway is known as "uplink".

LoRaWAN MAC Layer

The LoRaWAN MAC layer performs following functions.
• Establishes connection between MAC layer of peers (i.e. between LoRa Gateway and End device).
• The MAC layer handles transmission and reception of MAC commands and data from application layer. All the LoRaWAN MAC messages are identified based on MAC message types. This is shown in the table-1.
• MAC layer adds MHDR (MAC header) and MIC (message integrity code) at the beginning and end of MAC payload. MAC header is 1 octet in size and MIC is 4 octet in size. As mentioned MAC payload carries either MAC commands or data.
• The MAC layer data is used by PHY layer which incorporates Preamble, PHY header at the beginning and PHY header CRC and entire frame CRC at the end while constructing PHY payload at the transmit end. The reverse process i.e. stripping of preamble, PHY header and CRC is done at receive end.
Refer PHY vs MAC for functions of PHY layer and MAC layer in general.

LoRaWAN MAC commands

Following table mentions list of LoRaWAN MAC commands with CID, transmitted by end device or gateway and their functions.

LoRaWAN MAC Commands
Table-1: Reference: LoRaWAN 1.0.3 Specification

LoRa frame structure

Following are different formats of LoRa frame structure at each protocol stack.

LoRa message formats

Following table mentions MAC message types with its 3 bit "MType field".


MAC message type Description
000 Join Request
001 Join Accept
010 Unconfirmed Data Up
011 Unconfirmed Data Down
100 Confirmed Data Up
101 Confirmed Data Down
110 RFU
111 Proprietary

Table-2 : LoRaWAN MAC message types

Join Request & Join Accept: These messages are used to establish connection between LoRa end device and Gateway.
Confirmed Data Message: This message type requires to be acknowledged by its receiver.
Unconfirmed Data Message: This message type does not require any acknowledgment.
Proprietary : This message type is used to incorporate non standard message format functionalities.
RFU : It means Reserved for Future Usage.

LoRaWAN PHY Payload

The figure-2 mentions LoRaWAN PHY payload and figure-3 mentioned contents of LoRaWAN MAC payload structure. For more information refer LoRaWAN specification about each of these fields.

LoRaWAN MAC frame format

LoRaWAN MAC payload

MAC commands are used for network administration between server (i.e. Gateway) and end device. These commands are non visible to applications running in the LoRa server and end devices. A single data frame consists of one or multiple MAC commands(either piggybacked or transmitted as separate frame). MAC commands are segregated based on CID field of size 1 octet long. CID stands for Command IDentifier. These mac commands are used by end device or by gateway or by both.

For example,
Value of 0x02 CID is used for 'LinkCheckReq' command (by End Device for transmission to Gateway)
Value of 0x02 CID is also used for 'LinkCheckAns' (by Gateway for transmission to End device)
Value of 0x03 CID is used by Gateway to transmit 'LinkADRReq' command.
Value of 0x03 CID is also used by End device to transmit 'LinkADRAns' command.

Reference:
LoRaWAN™ Specification, which can be downloaded from following link.
https://www.lora-alliance.org/

Conclusion

The LoRaWAN MAC layer plays a pivotal role in maintaining order and efficiency within the network. By managing data exchanges and coordinating access to the shared medium, the MAC layer helps ensure reliable communication and optimal use of resources. A solid grasp of the MAC layer functions enables network designers to build more resilient and adaptable LoRaWAN networks.

Similar posts on LoRaWAN technology

MAC layers of other wireless standards

Other IoT Wireless Technologies

WLAN    THREAD    EnOcean    LoRa    SIGFOX    WHDI    Zigbee   6LoWPAN   Zigbee RF4CE   Z-Wave   NFC   RFID   Lonworks   CEBus   UPB