Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

LoRa communication simulator in Python with adaptive data rate and noise modeling.

Notifications You must be signed in to change notification settings

dragonGR/lora-sim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

πŸ“‘ LoRa Communication Simulator

A realistic simulation of LoRa (Long Range) wireless communication between two nodes. This tool demonstrates key concepts in wireless networking, packet transmission, error detection, adaptive data rate (ADR), and channel interference modeling.

This simulator can be used for:

  • Learning how LoRa works
  • Testing network behavior under noise and distance
  • Demonstrating understanding of wireless protocols
  • Visualizing performance trends using graphs

🧠 Features

βœ… Packet Generation with CRC32 Checksums

Each packet includes a CRC32 checksum to validate integrity upon reception.

βœ… Wireless Signal Loss Based on Distance

Signal strength degrades realistically as the distance increases.

βœ… Channel Noise / Interference Modeling

Simulates external interference by introducing random corruption.

βœ… Adaptive Data Rate (ADR) Simulation

Automatically adjusts spreading factor based on link quality to optimize throughput or reliability.

βœ… Retransmission Logic

Packets are retransmitted up to 3 times if not received correctly.

βœ… CLI Interface

Run simulations directly from the terminal with customizable parameters.

βœ… Delivery vs Distance Plotting

Visualize how delivery rate changes over distance using matplotlib.


πŸ“¦ Requirements

Make sure you have the following installed:

pip install numpy matplotlib

πŸ’‘ Note: Python 3.8+ is recommended.


πŸš€ How to Run

πŸ”Ή Basic Usage

Runs a default simulation at 3000 meters with 10 packets and SF=10.

python simulator.py

πŸ”Ή Custom Simulation

Example with custom settings:

python simulator.py --distance 5000 --packets 15 --sf 9 --noise 0.2

πŸ”Ή Run Distance Sweep and Plot Results

Generates a graph showing how delivery rate decreases with increasing distance.

python simulator.py --plot --noise 0.1

πŸ“‹ Output Example

[Summary]
Packets Sent: 10
Packets Received: 8
Packets Corrupted: 1
Packets Lost: 1
Delivery Rate: 80.00%

🚩 Command-Line Flags

Flag Full Name Description Example
-h --help Show help message and exit python simulator.py --help
--distance Distance in meters Simulated distance between sender and receiver --distance 5000
--sf Spreading Factor Initial spreading factor (7–12) --sf 9
--packets Number of Packets Total number of packets to send --packets 20
--noise Channel Noise Level Simulated channel noise [0.0 to 1.0] --noise 0.3
--quiet Quiet Mode Suppress per-packet output --quiet
--plot Run Distance Sweep Run simulations at multiple distances --plot

βœ… Example Usage Commands

# Basic simulation with default settings
python simulator.py
# Custom simulation: 5000m, 15 packets, SF=9, moderate noise
python simulator.py --distance 5000 --packets 15 --sf 9 --noise 0.2
# Plot delivery rate across multiple distances
python simulator.py --plot --noise 0.1

About

LoRa communication simulator in Python with adaptive data rate and noise modeling.

Resources

Stars

Watchers

Forks

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /