Understanding LoRaWAN MAC Layer, Commands, Packet & Frame Structure

lorawan
mac layer
mac command
packet format
frame structure

The MAC (Medium Access Control) layer in LoRaWAN is crucial 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 vital for optimizing network performance and maintaining efficient operation in LPWAN networks.

In this article, 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 a LoRa gateway. The gateway functions similarly to the base station of a cellular network, and End Devices function as mobile phones.

LoRa network architecture

Like other wireless networks, transmission from a LoRa Gateway module to End devices is known as “downlink,” while transmissions from end devices to a LoRa Gateway are known as “uplink.”

LoRaWAN MAC Layer

The LoRaWAN MAC layer performs the following functions:

  • Establishes a connection between MAC layers of peers (i.e., between the LoRa Gateway and the End device).
  • Handles the transmission and reception of MAC commands and data from the application layer. All LoRaWAN MAC messages are identified based on MAC message types, as shown in Table 1.
  • Adds the MHDR (MAC header) and MIC (message integrity code) at the beginning and end of the MAC payload. The MAC header is 1 octet in size, and the MIC is 4 octets in size. As mentioned, the MAC payload carries either MAC commands or data.
  • The MAC layer data is used by the PHY layer, which incorporates the Preamble, PHY header at the beginning, and PHY header CRC and entire frame CRC at the end while constructing the PHY payload at the transmit end. The reverse process, i.e., stripping of preamble, PHY header, and CRC, is done at the receive end.

LoRaWAN MAC Commands

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

LoRaWAN MAC Commands

Table 1: Reference: LoRaWAN 1.0.3 Specification

LoRa Frame Structure

The following are different formats of the LoRa frame structure at each protocol stack.

LoRa message formats

The following table mentions MAC message types with its 3-bit “MType field.”

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

Table 2 : LoRaWAN MAC message types

  • Join Request & Join Accept: These messages are used to establish a connection between a LoRa end device and a Gateway.
  • Confirmed Data Message: This message type requires acknowledgment 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: Reserved for Future Usage.

LoRaWAN PHY Payload

Figure 2 mentions the LoRaWAN PHY payload, and Figure 3 mentions the contents of the LoRaWAN MAC payload structure. For more information, read LoRaWAN specification about each of these fields.

LoRaWAN MAC Frame Format

LoRaWAN MAC payload

MAC commands are used for network administration between the server (i.e., Gateway) and the 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 a separate frame). MAC commands are segregated based on the CID field of size 1 octet long. CID stands for Command Identifier.

These MAC commands are used by the end device, by the gateway, or by both.

For example:

  • A Value of 0x02 CID is used for the ‘LinkCheckReq’ command (by End Device for transmission to Gateway).
  • A Value of 0x02 CID is also used for ‘LinkCheckAns’ (by Gateway for transmission to End device).
  • A Value of 0x03 CID is used by the Gateway to transmit the ‘LinkADRReq’ command.
  • A Value of 0x03 CID is also used by the End device to transmit the ‘LinkADRAns’ command.

Reference: LoRaWAN™ Specification, which can be downloaded from the 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.

WiMAX MAC Protocol: An In-Depth Introduction

WiMAX MAC Protocol: An In-Depth Introduction

Explore the WiMAX MAC protocol, covering convergence, common part, and security sub-layers. Learn about frame structure, scheduling, MAC layer messages, and network entry procedures.

wimax
mac layer
protocol stack
LiFi MAC Layer Basics

LiFi MAC Layer Basics

Explore the fundamentals of the LiFi MAC layer, including frame structure, single, packed, burst and dimmed OOK modes. Understand how LiFi efficiently transmits data.

lifi
mac layer
phy layer
Understanding LoRaWAN Protocol Stack Layers

Understanding LoRaWAN Protocol Stack Layers

Explore the LoRaWAN protocol stack, covering the RF, physical, MAC, and application layers. Learn how each layer contributes to efficient and secure long-range communication in IoT networks.

lorawan
protocol stack
mac layer