LoRaWAN MAC layer message formats | LoRaWAN MAC commands
This page describes function of LoRaWAN MAC layer. It mentions LoRaWAN MAC messages and their meanings in the LoRaWAN network.
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.
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.
Table-1: Reference: LoRaWAN 1.0.3 Specification
LoRaWAN MAC message formats
Following are the LoRaWAN MAC message formats at each protocol stack.
Following table mentions MAC message types with its 3 bit "MType field".
|MAC message type||Description|
|010||Unconfirmed Data Up|
|011||Unconfirmed Data Down|
|100||Confirmed Data Up|
|101||Confirmed Data Down|
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.
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.
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.
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.
LoRaWAN™ Specification, which can be downloaded from following link.