LoRaWAN MAC Layer: Definition, Architecture, Classes, and More

By: Valerii Haidarzhy, 25 Oct 2023
5   min read
Reading Time: 5 minutes

LoRaWAN, a Media Access Control (MAC) protocol for wide-area networks, has become an interesting player in the ever-growing Internet of Things (IoT) domain. Positioned as the second layer in the Open Systems Interconnection (OSI) model, this protocol provides extensive range and low-power communication options for a myriad of IoT use cases. Let’s walk through the LoRaWAN MAC definition, its architecture and functions.

Basic terminology

LoRa, short for “Long Range,” is a modulation technique based on spread spectrum modulation and utilizes a chirp spread spectrum sub-variation. This modulation occurs in the physical layer (layer 1) of the OSI model, enabling long-range, low-power communication in the MHz frequency range.
LoRaLPWAN, or “Long Range Low Power Wide-Area Network”, is a broader term that encompasses various low-power wide-area network technologies, including LoRaWAN.
LoRaWAN, or “Long Range Wide-Area Network”, is a type of Media Access Control (MAC) protocol sublayer on top of the physical (PHY) layer. As the second layer of the OSI model, it defines communication between devices and gateways in a LoRa network.

LoRa network architecture

The LoRa network architecture comprises end devices, gateways, and a network server. End devices are sensors or actuators that transmit and receive data, while gateways serve as intermediaries, forwarding messages between end devices and the network server. The network server manages the overall network, processing messages and controlling the data flow.
In a LoRa network, devices transmit data using the LoRa modulation technique. Gateways receive the data and forward it to the network server, which then routes the information to the appropriate application server. This star-of-stars topology allows for extensive coverage and scalability.

MAC Layer Functions

The LoRaWAN MAC layer is responsible for several functions:

– Frame formatting and parsing: The MAC layer structures data into frames for transmission and interprets received frames.
– Channel management: It selects the appropriate frequency channels for communication and manages the duty cycle, ensuring compliance with regional regulations.
– Adaptive data rate: The MAC layer dynamically adjusts the data rate based on network conditions, optimizing power consumption and communication range.
– Encryption and security: It handles encryption and decryption, ensuring secure communication between devices and the network server.
– Scheduling and coordination: The MAC layer schedules transmissions and manages communication between end devices and gateways, avoiding collisions and optimizing network performance.

LoRaWAN MAC commands

These commands facilitate communication, enable efficient power usage, and ensure the compliance of the LoRaWAN MAC version with regional regulations. Here is a table outlining the most commonly used commands and their respective descriptions:

CID Command Transmitted by Description
0x02 LinkCheckReq End device Requests the network server to assess the link quality between the device and the nearest gateway
0x02 LinkCheckAns Gateway Provides the device with the link quality assessment and margin, as determined by the network server
0x03 LinkADRReq Gateway Instructs the device to change its data rate, transmission power, or channel settings
0x03 LinkADRAns End device Confirms the device’s compliance with the changes requested by the LinkADRReq command
0x04 DutyCycleReq Gateway Requests the device to adjust its duty cycle to comply with regional regulations
0x04 DutyCycleAns End device Confirms the device’s adherence to the duty cycle changes requested by the DutyCycleReq command
0x05 RXParamSetupReq Gateway Instructs the device to modify its receive window settings, such as frequency and data rate
0x05 RXParamSetupAns End device Confirms the device’s implementation of the receive window changes requested by RXParamSetupReq
0x06 DevStatusReq Gateway Requests the device to provide its current battery level and radio transmission status
0x06 DevStatusAns End device Provides the device’s current battery level and radio transmission status to the network server
0x07 NewChannelReq Gateway Requests the device to add a new frequency channel or modify an existing one
0x07 NewChannelAns End device Confirms the device’s compliance with the new or modified frequency channel requested
0x08 RXTimingSetupReq Gateway Instructs the device to modify the delay between the end of the uplink transmission and the start of the downlink receive window
0x08 RXTimingSetupAns End device Confirms the devic

e’s adherence to the updated receive window delay requested by RXTimingSetupReq

Exploring this, you may be curious about their real-world effectiveness. We’ve experienced firsthand the practical advantages of these commands in various situations. Here are just some examples:

Optimizing a device’s data rate and transmission power is very important for energy efficiency. Using the LinkADRReq command, the perfect balance between communication range and battery life can be achieved. Alternatively, sometimes connectivity challenges may arise between end devices and gateways. Utilizing the LinkCheckReq command to evaluate link quality and the LinkCheckAns response to identify issues, such as devices being too far apart, can help resolve problems and enhance connectivity. Also, while caring about a device’s battery life in applications like asset tracking, using the DevStatusReq command allows for periodic checks of battery levels and radio status, enabling proactive issue resolution and contributing to the smooth operation of the system.
By playing with these commands, you can find a way to boost device performance and network functionality within your IoT applications. Try incorporating them into your next project and witness the benefits for yourself.

LoRa MAC Layer Classes

LoRaWAN devices can operate in these three classes:

– Class A devices facilitate two-way communication, with planned uplink and downlink transmissions. Each uplink is followed by two downlink reception windows, ensuring energy-efficient functionality. These devices are perfect for applications requiring occasional, asynchronous communication.
– Class B builds upon Class A capabilities with scheduled, time-synchronized downlink transmissions. These devices receive a beacon from the gateway, allowing network synchronization and listening for downlink messages at designated times. This added feature makes Class B devices well-suited for applications needing regular, time-sensitive data transmission.
– Class C enables continuous two-way communication by keeping their reception window open, except during uplink transmissions. Although providing the quickest communication, Class C devices consume more power than their Class A and Class B counterparts. They’re ideal for applications requiring real-time communication and can accommodate increased power usage.

Enhance Your IoT solutions with Sirin Software’s expertise

We really hope that this introduction to LoRaWAN technology will help you use it to the fullest extent in your Internet of Things (IoT) applications. We at Sirin Software have an excellent track record of negotiating this technology’s complexity and making sure that IoT initiatives are successful. For instance, our team created  LoRaWAN Gateway for IoT/M2M Applications that could support numerous endpoints. With features like safe boot and secure firmware upgrades, this gateway was created using a combination of C and Python programming languages. It is flexible to a variety of deployment settings because it supports both Ethernet and cellular connectivity.
In another project, we developed a Wireless Connection Manager for IoT-Enabled Consumer Electronics. Simple device connection, safe external connections, and full lifecycle management are all made possible by this user-friendly app. It now provides a smooth experience for end users in a variety of IoT-enabled consumer electronics. We also worked on Improving Connection Standards for a New Generation of Consumer Smartwatches. Our solution significantly enhanced the user experience by lowering power consumption by 60%, improving device-server connection, and increasing GPS accuracy for precise location monitoring.

These are just a few examples of how we’ve applied our expertise to real-world challenges. We’re ready to bring this same level of dedication and technical skill to your IoT projects. If you have any questions or would like to discuss how we can help you, please don’t hesitate to contact us!


Background form

Latest articles

CoAP vs MQTT: Which Protocol is Better for IoT?

Sirin Software Recognized as a Clutch Global Leader for Spring 2024

Evaluating the Matter Protocol: First Steps