Skip to content

Simulation and Analysis of IoT LoRaWAN Networks Under ns-3

Low-power wide-area network (LPWAN).

These networks use low-power radio signals, such as those in the sub-1 GHz range, to send small amounts of data over a large area. LPWANs are used in applications such as wireless sensor networks(WSN), smart energy, smart cities, and the Internet of Things (IoT).

They are also used to connect devices in remote locations that don’t have access to reliable internet connections. LPWANs are ideal for applications that require low data rates, long battery life, and low cost.

Examples of LPWANs include Sigfox, LoRaWAN, and Weightless. LPWANs are commonly used in applications including Smart metering, smart lighting, asset monitoring and tracking, smart cities, precision agriculture, livestock monitoring, energy management, manufacturing, and industrial IoT deployments. The following article presents some introduction to some of the available LPWAN technologies:

 

Low-power wide-area networks(LPWAN) & Internet of Things(IoT)

LoRa (“long range”) is a proprietary low-power wide-area network modulation technique  based on spread-spectrum modulation techniques derived from chirp spread spectrum (CSS) technology.

It was developed by Cycleo, a company of Grenoble, France, later acquired by Semtech, which is the founding member of the LoRa Alliance.

LoRa enables long-range transmissions with low power consumption and covers the physical layer, while other technologies and protocols such as LoRaWAN (Long Range Wide Area Network) cover the upper layers[1].

LoRa

 

One of the key parameters of the LoRa modulation is the Spreading Factor (SF): this value, ranging from 7 to 12, expresses how much a packet is spread in time (i.e., how long it takes for a chirp to complete a complete scan of the available bandwidth).

Transmissions using a low SF need a lower Time on Air (ToA) (assuming the same bandwidth) than packets using SF values closer to 12. The advantage of using higher SFs is in the increased sensitivity of the receiver. Transmission using SF7 that cannot be detected by a LoRa receiver may be correctly demodulated if performed using SF12.

Another key feature of the modulation is the quasi-orthogonality between transmissions using different SF values: even if two packets overlap in time, a receiver may still be able to demodulate one of the packets, assuming that they are using different SF and that some restrictions on their reciprocal power are respected[4].

LoRaWAN

The LoRa Alliance first defined the LoRaWAN standard with the objective of creating a medium access scheme and a set of network management policies that leverage the properties of the modulation to achieve good network performance at a low price in the complexity of the devices[4].

There will be three kinds of devices in a LoRaWAN network: End Devices (EDs), Gateways (GWs) and a Network Server (NS). End Devices are basic network nodes: typically inexpensive, they are constrained by low computational capabilities and are usually powered by a battery.

Gateways are high-end, mains powered devices that are tasked with collecting the data transmitted by End Devices leveraging the LoRa modulation. After a packet is correctly received, it is forwarded to the Network Server via a link with high reliability and speed. The Network Server functions as a sink for data coming from all devices, and as a controller of the network that can leverage some MAC commands to change transmission settings in the End Devices[4].

End Devices of the most basic type are defined as Class A devices, and are currently the only kind of device supported by this module. Class A devices perform transmission in a totally asynchronous way, and open two receive windows of fixed duration after each transmission to allow the Network Server to transmit acknowledgments or MAC commands[4].

Another important characteristic of the standard is that it is defined to work on unlicensed bands in various regions, which usually subject transmitters to regulations on duty cycle. This fact will be explained in greater detail in the MAC layer model section of this document[4].

LoRaWAN ns-3 module[3]

This is an ns-3 module that can be used to perform simulations of a LoRaWAN network. This module was developed by Davide Magrin and Martina Capuzzo of the Signet Lab at University of Padova’s Department of Information Engineering, under the supervision of Lorenzo Vangelista, Marco Centenaro, Andrea Zanella and Michele Zorzi.

This module contains a series of classes and examples aimed at modeling the modulation and medium access technology of a LoRaWAN network. Thanks to a simple underlying physical layer model and to the regulations imposed on traffic in the unlicensed bands this technology operates on, this module can support simulations featuring a large number of devices that access the wireless channel infrequently.

Aside from models representing the various components of the network and helpers to set them up, the module comes with a packet tracker that monitors network performance, and with facilities that print the network topology to file for easy debugging and simulation monitoring. Various examples ranging from simple to complex network configurations are also provided[2].

Features of  LoRaWAN ns-3 module [2]

Current features include:

  • Support for Class A devices
  • Network Server Implementation
    • ADR
    • Confirmed messages
    • Multi-GW support
  • Urban propagation models
  • Realistic GW chip model
  • Energy model integration

Installing LoRaWAN ns-3 Module Under ns-3.35

 

Step 1: Install ns-3.35 using the following procedure or any other procedure of your choice.

Installing ns3.35 in Debian 10 chroot Jail Under Debian 11 Host OS or any Version of Linux Host

Installing ns3.35 in Debian 10 chroot Jail Under Debian 11 Host OS or any Version of Linux Host

Step 2: Cloning the LoRaWAN ns-3 Module from GitHub

#change to the src folder of your ns-3 installation
$ cd ./ns-allinone-3.35/ns-3.35/src

#Clone the project from GitHub
$ git clone https://github.com/signetlabdei/lorawan ./lorawan

The above command will create a folder “lorawan” under the “src” directory and clone the LoRaWAN project in it.
The following screenshot shows the successful cloning:

Step 3: Configuring waf make system

#change to the ns-3.35 folder
$ cd ./ns-allinone-3.35/ns-3.35/

#Configure Waf
$ ./waf  configure –enable-examples

The above command will configure the make system and produce output like the below one on success.

Step 4: Compiling ns-3

#compile ns-3
$ ./waf

The above command will compile ns-3 with the newly added LoRaWAN Module and produce output like the below one on success.

Testing the LoRaWAN ns-3 Module

Testing the installation by running simple-network-example.cc example.
$ ./waf –run simple-network-example
The following screenshot shows the successful run of the simulation and hence proves the good working of the newly installed LoRaWAN ns-3 module.

 

Hidden Section! Contact Charles  

The key/passphrase will be given once you have been approved for getting paid research support/assistance from Charles. To get paid support, you may start a 'free' research discussion.  

WhatsApp chatDiscuss Through WhatsApp
 

The LoRaWAN IoT Network Simulation with NetAnim Output.

I have modified the adr-example.cc and tried to simulate a small LoRaWAN IoT network to visualize it under NetAnim.
The following is the NamOuput of that simulation. For better visualization, I reduced the number of EDs.  In the following output, it seems that the GW nodes are not correctly getting rendered.

If you try to create NetAnim output similar to the above, then you will find it very difficult. To understand the way of generating the following NetAnim output of that example scenario, one should clearly understand the following:

Hidden Section! Contact Charles  

The key/passphrase will be given once you have been approved for getting paid research support/assistance from Charles. To get paid support, you may start a 'free' research discussion.  

WhatsApp chatDiscuss Through WhatsApp
 

So, after understanding the above facts, you can create a NetAnim output  like the below one (a 7 GW node scenario) :

 

 

One may think that creating and using  NetAnim output is not at all needed for research-level work. But while experimenting with several topologies, I didn’t get the correct PDR for one particular topology.  After a lot of effort only, I found the “logical error” that I made in that particular topology. It was related to the automated placing of the WS nodes and their locations- I was able to find that mistake only while visualizing the scenario under NetAnim.

The Animation of the Above Network

The following is the gif animated video of the same example scenario. In the following output also the GW nodes are not correctly getting rendered.  We have to use a suitable image to represent the GW node.


Simulation of a simple LoRaWan Network with Static IoT-EDs

The following is the output of the same example script (with a little bit of modification). In this, we use only one GW node and now the GW node is getting rendered correctly with a suitable image.

 

Simulation of a simple LoRaWan Network with Mobile IoT-EDs

The following is the output of the same example script (with a little further modification). In this, we make the LoT-EDs to move – so that making it as a Mobile LoRaWAN network.

 

Energy Consumption  in LoRaWan Network with 50 IoT-EDs

The following screenshot shows the Energy Consumed by the 50 IoT EDs at the end of the 1200 second simulation.

 

The following Gnuplot Shows the Energy Consumption over time by ED(0).

The following Gnuplot Shows the Comparison  of Energy Consumption over time in ED(0) and ED(1).

Doing Scholarly Research on LoRaWAN

The above outputs are elementary ones. In fact, it is possible to do an excellent research work on LoRaWAN since it has lot of scope for new innovations in WSN and IoT.

It is possible to do a research quality evaluation and new innovations on this area and attain results such as the one shown in the  following article.

Generating Genuine, Quality Tables & Graphs for Publication.

 

It is possible to do the WSN/IoT based research works under ns-3 using ns3-sigfox moudule also. The following article explains the way of installing ns3-sigfox module under ns-3:

Installing ns3-sigfox on higher versions of ns-3 using CMake

 

Further, it is possible to do the WSN/IoT based research works under ns-3 using NB-IoT moudule also. The following article explains the way of installing NB-IoT module under ns-3:

Simulating WSN/IoT Systems under ns-3 using NB-IoT Module.

 

References:

  1. https://en.wikipedia.org/wiki/LoRa
  2. https://apps.nsnam.org/app/lorawan/
  3. https://github.com/signetlabdei/lorawan
  4. https://signetlabdei.github.io/lorawan-docs/models/build/html/lorawan.html
  5. Network level performances of a LoRa system (Master thesis).
  6. D. Magrin, M. Capuzzo and A. Zanella, “A Thorough Study of LoRaWAN Performance Under Different Parameter Settings,” in IEEE Internet of Things Journal. 2019.
WhatsApp Discuss Through WhatsApp