LMAC: Efficient CSMA for LoRa

LoRa testbed

Why CSMA? | CAD as CSMA | Instructions | Hardware | Cite this work

Importance of CSMA? ^

The absent ability to perform carrier-sense on off-the-shelf LoRa end devices has impeded studies and implementations of the suitable Carrier-Sense Multiple Access (CSMA) schemes for LoRa. Currently, the LoRa networks, including those organized in an ad-hoc manner or by following the LoRaWAN specification, adopt an ALOHA media access control (MAC) mechanism to access communication mediums defined by radio frequency and the spreading factor (SF) of the chirp spread spectrum (CCS) modulation. Although ALOHA allows a simple network implementation, it is not competent with keeping up with the increasing demand of IoT devices added to the ISM band. For this reason, even though devices may conform to channel usage limitations (e.g., 0.1% or 1% duty cycle in Europe), the ALOHA-based LoRa networks will have degraded network performance due to massive collisions when the numbers of end devices grow sharply in this era of IoT.

Channel Sensing by CAD ^

The Channel Activity Detection (CAD) feature available within the whole family of LoRa radios sheds light on a possible mechanism to enable CSMA for LoRa networks. LoRa promotes CAD as a means to energy-efficiently detect an incoming frame without resorting to power-hungry continuous receiving mode. Prior to performing a CAD, the LoRa radio is set on the desired CH/SF. The radio then switches to the CAD mode and performs a CAD operation on the set CH/SF. A CAD operation lasts [Tsym + (32/BW)] milliseconds, during which the radio performs a receive operation correlation on the received samples. Tsym is the duration that is the airtime of a single LoRa chirp which depends on the Spreading Factor (SF). BW is the bandwidth of the LoRa channel, typically 125KHz.

The CAD mode which is available on all of LoRa radios (e.g., SX126x and SX127x) is primarily designed for energy-efficient preamble detection. Preamble detection is not full-fledged carrier sense. However, our extensive measurement study shows that CAD can also detect payload chirps with satisfactory performance. Specifically, it achieves more than 95% accuracy in detecting the occupancy of an on-going transmission. CAD is also a power efficient. To show how power efficient a it is, we present below a measured current trail of a CAD opeartion comparing it with idle and transmission power trails under SF7.

Current Trail of a Single CAD operation
Current draw of SX1276 during idle, CAD, & transmitting states in SF7

The interested reader may refer to Insights to LoRa CAD for a detailed explanation about principles of CAD operation.

RSS-based Channel Sensing and CSMA ^

RSS is an indicator of signal strength within a channel at a specified time. When a LoRa radio computes RSS, the result may arrise not just due to on-going LoRa transmissions but also due to other physical layer technologies within the ISM band. LoRa bears considerable immunity towards such transmissions. Thus, in order to achieve efficient channel sensing among LoRa nodes, the unique features of LoRa radios need to be considered. For instance, LoRa frames can traverse below the noise floor. I.e., a LoRa receiver's sensitivity is ~105 times higher compared to that of a Wi-Fi radio. Therefore, an on-going LoRa transmission may not even be detected by RSS measures.
In addition, LoRaWAN encourages concurrent transmissions (by means of different SFs) within a single channel. The use of concurrent SFs in the same channel render traditional Received Signal Strength (RSS) based CSMA ineffective. Therefore, LoRa begs for a clean-slate CSMA design that addresses the unique features of LoRa modulation.

Instructions to the user ^

arduino-lmic-csma [https://github.com/NTU-WANDS/arduino-lmic-csma] is an extension of the widely used state-of-the-art LoRaWAN arduino-lmic library with the addition of CSMA functionality. In addition to all features of the original library, this library enables CSMA for LoRaWAN by exploiting of CAD mode of the LoRa radio. Currently, this library is tested to work with the SX127x series of LoRa radios. arduino-lmic-csma largly borrows from the work that is proposed in LMAC which discusses efficient CSMA mechanisms for LoRa networks. The library offers four modes of CSMA configured within the config.h file through the compiler directive LMIC_CSMA_LEVEL. Note: the set spreading factor is never altered under any CSMA configurations. The functionality of each mode is breifly explained below. However, the interested reader may also refer a much detaled discription of CSMA options made available here.


Disables CSMA and reverts to ALOHA. No extra codespace is used for unused CSMA functionality.


Enables basic channel sensing. A node continues sensing the CH/SF the radio is configured to. Once the the set CH/SF is ensured free ("free" within a DIFS window), the frame is transmitted.


Enables random channel hoping. Under this setting, a node hops randomly to one of the 8 channels defined within the user space. If the newly hopped channel is sensed free, the frame is transmitted. Otherwise, a new random channel is selected until a free channel is ensured.


Enables channel profiling. Maintains a matrix of previous interactions and switches to the least busy channel once the current CH/SF is busy. If the newly selected channel is ensured free, the frame is transmitted. Else, the next best channel is selected.

Hardware ^

This library has been compiled and tested for the ubiquitous Atmega328 microcontroller with the SX127X LoRa radio family. This project may also work for different microcontrollers supported under the Arduino platform but have not been tested. This project requires no hardware changes to enable channel sensing. Following is a list of hardware that has been tested to work with this library. If you test this project with new hardware, we would be glad to include it in the following table with an acknowledgement.

MicrocontrollerRadio IDE
Atmega 328SX1276Arduino IDE
MSP430G2553(under test)SX1276TI Energia Platform
STM32-L476RG(under test)SX1276Arduino IDE

Cite this work ^

Bibtex Integration:

The addition of CSMA to LoRaWAN through this library is a direct extension of the following forthcoming research work "LMAC: Efficient Carrier-Sense Multiple Access for LoRa", completed by Amalinda Gamage, Jansen Christian Liando, Chaojie Gu under the support and guidance of Prof. Mo Li and Prof. Rui Tan of Nanyang Technological University.

You may also take a look at our previous work that dives deep into LoRa's physical layer & network performance.

Credits & Maintenance ^

The library is provided by the Wireless And Networked Distributed Sensing (WANDS) group of Nanyang Technological University of Singapore.
The CSMA enabled LoRaWAN library was developed by Amalinda Gamage, Jansen Christian Liando under the guidance of Prof. Mo Li of Nanyang Technological University.
This library is fork of Matthijs Kooijman's arduino-lmic library who is an author of the original IBM LMiC LoRaWAN implementation.
For qestions regarding this library, you may contact: amalinda {at} ntu dot edu dot sg.

Frequently Asked Questions ^

Would this library be updated as LoRaWAN stack is updated?
Yes, we will keep upto date with the latest LoRaWAN stack on https://github.com/matthijskooijman/arduino-lmic .

Does this library change the format of a LoRaWAN frame?
No, this library by no means affects the LoRaWAN packet structure. The sole purpose of this library is to ensure a higher chance of packet delivary.

Can I have two versions of this library (original & CSMA enabled) installed under the same Arduino IDE?
Sorry, not at the moment.