Giter Site home page Giter Site logo

loraenergysim's Introduction

LoRaEnergySim

The framework consists of three main components, i.e., nodes, an air interface and a gateway. The nodes send messages to the gateway via the air interface. Collisions and weak messages are detected in the air interface component. The uncollided and strong packets are delivered to the gateway, whereafter a downlink message will be scheduled if requested by the node.

Simulation

How to cite?

@INPROCEEDINGS{8885739,  
author={G. {Callebaut} and G. {Ottoy} and L. {van der Perre}},  
booktitle={2019 IEEE Wireless Communications and Networking Conference (WCNC)},   
title={Cross-Layer Framework and Optimization for Efficient Use of the Energy Budget of IoT Nodes},   
year={2019},  
volume={},  
number={},  
pages={1-6},
}

Other publications:

G. Callebaut, G. Ottoy and L. V. d. Perre, "Optimizing Transmission of IoT Nodes in Dynamic Environments," 
2020 International Conference on Omni-layer Intelligent Systems (COINS), 2020, pp. 1-5, doi: 10.1109/COINS49042.2020.9191674.

How to use?

The source of the framework is located in the Framework folder. The Simulations folder contains some examples.

General Workflow

In order to compare different settings/configurations, it is imperative that the locations of the nodes are the same for all simulations. Therefore, a file generate_locations.py is included in the examples.

Workflow:

  • Define your the settings for a simulation environment, e.g., start spreading factor, simulation duration (real-time), in the GlobalConfig file
  • Generate your locations see here. It will use the settings defined in the GlobalConfig file.
  • Create a Simulation.py file as detailed here.

Generate Node locations

Configurable parameters:

  • number of locations, i.e., number of IoT nodes
  • cell size, the cell is here a rectangular area. The cell size will determine the length of the edges in meters
  • number of Monto-carlo simulations to run. As the simulation contains random and non-determinstic behavior and different location sets, averaging the results over multiple simulations will have a more statistical meaning.

For each simulation, a random set of locations inside the area is generated and is stored in the location_file which is a parameter defined in the GlobalConfig.py file.

Simulation

In the simulation file, you will use the building blocks in the framework to simulate a specific environment and acquire results such as the consumed energy, and the number of collided messages. See section Framework (below) for configurable parameters and output. Please see the comments in the Example>simulation.py on how to write a simulation file. In simulation.py you load the locations, specify the object to hold the results and specify what you want to simulate. In SimulationProcess, the simulation itself is run. The gateway is created, the nodes are generated with their lora parameters and energy profile. Afterwhich the simulation is run. After completion of one simulation the results are extracted from the objects and returned, to be used in the simulation.py file.

The project can now be run by first running generate_locations.py and then simulation.py.

Framework

Please read first the paper to have a more detailed understanding of the framework with respect to LoRaWAN operation and limitations.

Propagation Model

The propagation model determines how the messages are impacted by the environment. It predicts the path loss, i.e., how much the signal is attenuated between the transmitter and receiver, for a given environment. The PropagationModel.py contains (currently) two implementations:

  • log shadow model or log-distance path loss model, where the default parameters are based on the Rep. ITU-R P.2346-0 and J. Petajajarvi, K. Mikhaylov, A. Roivainen, T. Hanninen and M. Pettissalo, "On the coverage of LPWANs: range evaluation and channel attenuation model for LoRa technology," 2015 14th International Conference on ITS Telecommunications (ITST), 2015, pp. 55-59, doi: 10.1109/ITST.2015.7377400.
  • COST231, including more details about the environment, e.g., building heights

SNR Model

This model transforms the received signal strength (RSS) to a signal-to-noise ratio (SNR) by the method rss_to_snr. At this moment the noise is only affected by the thermal noise. This results in (dB):

SNR = RSS - (-174 + 10 * log10(125e3))

LoRa Parameters

All parameters specific to the lora protocol (lorawan) and measured energy consumption related to these parameters are here included.

LoRaPacket

LoRaPackets are send over the air interface from the nodes to the gateway. LoRaPacket contains a uplink and downlink message class, including relevant metadata and information concerning the state of the message, e.g., received, collided,...

Energy Profile

The energy profile class contains the sleep, processing, transmitting and received power of a node. This can be different for each node and can be defined in the simulation.py file.

Node

The Node class contains all information regarding the power consumption, number of messages send, payload send, retransmissions, ... Nodes act as real IoT nodes, joining the network, waiting, sleeping, transmittion and receiving. Their behaviour is determined in the main simulation.py file.

After running the simulation, you can extract the following iniformation:

  • energy_per_bit. This is the amount of energy consumed to send one bit of data
  • transmit_related_energy_per_bit. This only contains the energy spend in transmit mode.
  • transmit_related_energy_per_unique_bit. This only contains the energy spend in transmit mode and tx'ed retransmissions are not count against the transmitted bits
  • total_energy_consumed
  • get_simulation_data:
series = {
            'WaitTimeDC': self.total_wait_time_because_dc / 1000,  # [s] instead of [ms]
            'NoDLReceived': self.num_no_downlink,
            'UniquePackets': self.num_unique_packets_sent,
            'TotalPackets': self.packets_sent,
            'CollidedPackets': self.num_collided,
            'RetransmittedPackets': self.num_retransmission,
            'TotalBytes': self.bytes_sent,
            'TotalEnergy': self.total_energy_consumed(),
            'TxRxEnergy': self.transmit_related_energy_consumed(),
            'EnergyValuePackets': self.energy_value
        }

Air interface

The air interface detects collisions and alters the LoRaPacket object so the node and gateway know what happened during the transmission of the message. It employs the used propagation model and snr model to determine if the transfer was successful or not.

Gateway

At the gateway, the received SNR is checked and messages below the required threshold are marked as weak and is not rx'ed. The gateway also handles DL messages if requested by the node.

Configurable Properties

  • energy_profile: EnergyProfile,
  • lora_parameters,
  • sleep_time,
  • process_time,
  • adr,
  • location,
  • payload_size,
  • confirmed_messages=True

What is currently tracked

  • 'WaitTimeDC': total_wait_time_because_dc
  • 'NoDLReceived': num_no_downlink,
  • 'UniquePackets': num_unique_packets_sent,
  • 'TotalPackets': packets_sent,
  • 'CollidedPackets': num_collided,
  • 'RetransmittedPackets': num_retransmission,
  • 'TotalBytes': bytes_sent,
  • 'TotalEnergy': total_energy_consumed(),
  • 'TxRxEnergy': transmit_related_energy_consumed(),

Common Erros

Q: Can't find Globaconfig, Locations, ....
A: Ensure that the folders Framework and Simulations are marked as Source Root. For Pycharm right click on the folder > Mark directory as > Source Root

Q: no output in IPython/Spyder
A: The code is run in parralel by default and the std output is not handled well in that case. You can run the code sequently, see the comments in Example/simulation.py regarding the pool.map function at the bottom.

Academic work using our simulator

Cited in.

Simulator used in:

  • Park, G., Lee, W., & Joe, I. (2020). Network resource optimization with reinforcement learning for low power wide area networks. EURASIP Journal on Wireless Communications and Networking, 2020(1), 1-20.
  • L. Beltramelli, A. Mahmood, P. Österberg, M. Gidlund, P. Ferrari and E. Sisinni, "Energy Efficiency of Slotted LoRaWAN Communication With Out-of-Band Synchronization," in IEEE Transactions on Instrumentation and Measurement, vol. 70, pp. 1-11, 2021, Art no. 5501211, doi: 10.1109/TIM.2021.3051238.
  • Thoen B, Callebaut G, Leenders G, Wielandt S. A Deployable LPWAN Platform for Low-Cost and Energy-Constrained IoT Applications. Sensors. 2019; 19(3):585. https://doi.org/10.3390/s19030585
  • T. Fedullo, A. Morato, F. Tramarin, P. Bellagente, P. Ferrari and E. Sisinni, "Adaptive LoRaWAN Transmission exploiting Reinforcement Learning: the Industrial Case," 2021 IEEE International Workshop on Metrology for Industry 4.0 & IoT (MetroInd4.0&IoT), Rome, Italy, 2021, pp. 671-676, doi: 10.1109/MetroInd4.0IoT51437.2021.9488498.
  • Leenders G, Callebaut G, Ottoy G, Van der Perre L, De Strycker L. An Energy-Efficient LoRa Multi-Hop Protocol through Preamble Sampling for Remote Sensing. Sensors. 2023; 23(11):4994. https://doi.org/10.3390/s23114994
  • Acosta-Garcia, L., Aznar-Poveda, J., Garcia-Sanchez, A. J., Garcia-Haro, J., & Fahringer, T. (2023). Dynamic transmission policy for enhancing LoRa network performance: A deep reinforcement learning approach. Internet of Things, 24, 100974.
  • G. Leenders, G. Ottoy, G. Callebaut, L. Van der Perre and L. De Strycker, "An Energy-Efficient LoRa Multi-Hop Protocol through Preamble Sampling," 2023 IEEE Wireless Communications and Networking Conference (WCNC), Glasgow, United Kingdom, 2023, pp. 1-6, doi: 10.1109/WCNC55385.2023.10118770.
  • E. Sisinni et al., "A new LoRaWAN adaptive strategy for smart metering applications," 2020 IEEE International Workshop on Metrology for Industry 4.0 & IoT, Roma, Italy, 2020, pp. 690-695, doi: 10.1109/MetroInd4.0IoT48571.2020.9138226.
  • T. Fedullo, A. Mahmood, F. Tramarin, A. Morato, M. Gidlund and L. Rovati, "Exploiting Hybrid Medium Access Control and Relaying Strategies to Overcome Duty-Cycle Limitations in LoRa-Based Sensor Networks," 2023 IEEE International Instrumentation and Measurement Technology Conference (I2MTC), Kuala Lumpur, Malaysia, 2023, pp. 01-06, doi: 10.1109/I2MTC53148.2023.10176039.
  • F. De Rango, A. Lipari, D. Stumpo and A. Iera, "Dynamic Switching in LoRaWAN under multiple Gateways and Heavy Traffic Load," 2021 IEEE Global Communications Conference (GLOBECOM), Madrid, Spain, 2021, pp. 1-6, doi: 10.1109/GLOBECOM46510.2021.9685009.
  • D. Stumpo, F. De Rango, F. Buffone and M. Tropea, "Performance of Extended LoRaEnergySim Simulator in supporting Multi-Gateway scenarios and Interference Management," 2022 IEEE/ACM 26th International Symposium on Distributed Simulation and Real Time Applications (DS-RT), Alès, France, 2022, pp. 135-142, doi: 10.1109/DS-RT55542.2022.9932063.
  • G. Callebaut, G. Ottoy and L. V. d. Perre, "Optimizing Transmission of IoT Nodes in Dynamic Environments," 2020 International Conference on Omni-layer Intelligent Systems (COINS), Barcelona, Spain, 2020, pp. 1-5, doi: 10.1109/COINS49042.2020.9191674.
  • Križanović, V.; Grgić, K.; Spišić, J.; Žagar, D. An Advanced Energy-Efficient Environmental Monitoring in Precision Agriculture Using LoRa-Based Wireless Sensor Networks. Sensors 2023, 23, 6332.
  • Zhang, Jiayue. "Design Guidelines of A Low Power Communication Protocol for Zero Energy Devices." (2023).
  • Stumpo, Daniele, Floriano De Rango, and Francesco Buffone. "Extending LoRaEnergySim Simulator to Support Interference Management under Multi-Gateway IoT Scenarios." (2022).
  • T. Fedullo, A. Morato, F. Tramarin, P. Ferrari and E. Sisinni, "Smart Measurement Systems Exploiting Adaptive LoRaWAN Under Power Consumption Constraints: a RL Approach," 2022 IEEE International Workshop on Metrology for Industry 4.0 & IoT (MetroInd4.0&IoT), Trento, Italy, 2022, pp. 354-359, doi: 10.1109/MetroInd4.0IoT54413.2022.9831487.

loraenergysim's People

Contributors

gillesc avatar sukanya-j avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

loraenergysim's Issues

Results of the LoRaEnergySim simulation

Dear All,

I completed the simulation with the same parameters as in the Global Config file. When I go to the results, I find that they are not clear. How can I read these results.

Duality of Variables Definition 2

I am referring to the issue (Variables being Defined Twice #18)

My question was

I found that some of the variables are being defined more that once, for example, Number of Simulations is being defined both in the Global Config File and the locations file, number of locations is the same.

Can you explain to me the reason for that?

The answer was:

The generate_locations.py is not part of the framework, but part of your own simulation. The user of the framework thus can choose what he/she will adopt from the GlobalConfig file. BUT, THE GENERATE_LOCATIONS.PY FILE STILL NEEDS TO BE RUN BEFORE RUNNING THE SIMULATION.PY FILE, THIS MEANS THAT THE VARIABLES IN THERE HAVE EFFECT, MOREOVER, THOSE VARIABLES ARE NOT CHANGED BASED ON THE AMENDMENT OF THE VARIABLES IN THE GLOBALCONFIG.PY FILE, WHICH MEANS THAT THERE WILL BE PROBLEM IN THE PARAMETRIC STUDIES.

In my example I only used the definition of the file path from the GlobalConfig from GlobalConfig import locations_file.

That the parameters/variables have the same number (GlobalConfig vs generate_locations.py) are coincidence. YOU DID NOT GET MY POINT, I WANTED TO SAY THAT SIMILAR TO THE DUALITY OF THE DEFINITION OF THE NUMBER OF SIMULATIONS VARIALBE, THE num_locations = 3
cell_size = 100
num_of_simulations = 1

ARE ALSO DOUBLE DEFINED IN BOTH OF THE GENERATE LOCATION FILE AS WELL AS THE GLOBAL CONFIG FILE.
WHAT IS THE RELATION BETWEEN BOTH OF THEM? MOREOVER, THE NUM_LOCATIONS VRIABLE DEFINED IN THE GENERATE_LOCATIONS.PY FILE REFERS TO WHAT?

Can you please find my COMMENT above and provide me with your precious response.

Best Regards,
Kawther

Variables being Defined Twice

I found that some of the variables are being defined more that once, for example, Number of Simulations is being defined both in the Global Config File and the locations file, number of locations is the same.

Can you explain to me the reason for that?

Best Regards,
Kawther

Error in Append

When running the simulator (LoRaEnergySim), and after number of simulation progressions, an error kept showing up like below

Traceback (most recent call last):

File "/home/kawtherhamad/Downloads/LoRaEnergySim-master/Simulations/Example/./simulation.py", line 110, in <module>

r_list = [SimulationProcess.run_helper(a) for a in args]

File "/home/kawtherhamad/Downloads/LoRaEnergySim-master/Simulations/Example/./simulation.py", line 110, in <listcomp>

r_list = [SimulationProcess.run_helper(a) for a in args]

File "/home/kawtherhamad/Downloads/LoRaEnergySim-master/Simulations/Example/SimulationProcess.py", line 21, in run_helper

return run(*args)

File "/home/kawtherhamad/Downloads/LoRaEnergySim-master/Simulations/Example/SimulationProcess.py", line 56, in run

data_mean_nodes = Node.get_mean_simulation_data_frame(nodes, name=sigma) / (

File "/home/kawtherhamad/Downloads/LoRaEnergySim-master/Framework/Node.py", line 561, in get_mean_simulation_data_frame

data = Node.get_simulation_data_frame(nodes).sum(axis=0)

File "/home/kawtherhamad/Downloads/LoRaEnergySim-master/Framework/Node.py", line 557, in get_simulation_data_frame

return pdf.append(list_of_series)

File "/home/kawtherhamad/.local/lib/python3.10/site-packages/pandas/core/generic.py", line 5989, in __getattr__

return object.__getattribute__(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'. Did you mean: '_append'?

Any clue here is much appreciated.

Best regards,
Kawther

Found Bugs

Hi Gilles,

Thank you for your contributions. I found some minor bugs in your simulator as follows:

  1. In timing_collision method of Framework/AirInterface.py, other should be returned if other_time_collided is True
  2. In tp_to_rss method of Framework/PropagationModel.py, the gain of the return statement should be plus (i.e., tp_dB, + self.GL - Lpl)

May I also ask about the source of LoRa Gateway's SENSITIVITY values? I observed that yours are different from Semtech specification where SENSITIVITY = {6: -118, 7: -123, 8: -126, 9: -129, 10: -132, 11: -133, 12: -136}

Warmest wishes,
Sukanya

MonteCarlo Simulation and the number of simulations parameter

Hi,

I have the below inquiries:

  1. Why is the number of simulations in the global config file not used in the generate locations file, moreover, the locations file is not used in the generate locations.
  2. Where is the monte carlo simulation in the simulator?
  3. When I changed the parameter number of simulations in the generate locations file, at the same time, changed the number of simulation variable in the global config file and increased the number of the payload sizes, the simulation went into non ending.

Spikes in the Results.

Hello

I need your support here,, I ran the simulator, when I drew charts from the CSV converted file, I got some spikes; specifically at the payload size of 45. The curve goes smoothly at all values, but suddenly at pyload size of 45, it jumps up and then goes back to its normal behavior.

This behavior was obtained for the TxRxEnergy at the default Global Config Parameters and when changing the path loss variance into 7.8 or 5, and when turning on the ADR.

TxRXEnergy

also, when turning the ADR mechanism off with payload size 7.8, spikes show up in the below results:
TxRXEnergy
Retransmitted packets
std energy

Thank you for support.
Kawther

ADR

Hi,

I would like to ask if the ADR algorithm has been added to the Framework.

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.