Giter Club home page Giter Club logo

lwn-simulator's Introduction

LWN Simulator

Build Status GitHub license made-with-Go GitHub go.mod Go version of a Go module GitHub release

A LoRaWAN nodes' simulator to simulate a LoRaWAN Network.

Table of Contents

General Info

LWN Simulator is a LoRaWAN nodes' simulator equipped with a web interface. It allows to communicate with a real infrastructure LoRaWAN or ad-hoc infrastructure, such as Chirpstack.

dashboard

The project consists of three main components: devices, forwarder and gateways.

The device

  • Based specification LoRaWAN v1.0.3;
  • Supports all LoRaWAN Regional Parameters v1.0.3.
  • Implements class A,C and partially even the B class;
  • Implements ADR Algorithm;
  • Sends periodically a frame that includes some configurable payload;
  • Supports MAC Command;
  • Implements FPending procedure;
  • It is possible to interact with it in real time;

The forwarder

It receives the frames from devices, creates an RXPK object including them within and forwards to gateways.

The gateway

There are two types of gateway:

  • A virtual gateway that communicates with a real gateway bridge (if it exists);
  • A real gateway to which datagrams UDP are forwarded.

Requirements

  • If you don't have a real infrastructure, you can download ChirpStack open-source LoRaWAN® Network Server, or similar software, to prove it;
  • If you have a real infrastructure, be sure that the gateways and LoRaWAN servers are reachable from the simulator.

Installation

From binary file

You can download it from the releases section the pre-compiled binary file.

Releases Page

From source code

Requirements

  • You must install Go. Version >= 1.16

Firstly, you must clone this repository:

git clone https://github.com/UniCT-ARSLab/LWN-Simulator.git

After the download, you must enter in main directory:

cd LWNSimulator

You must install all dependencies to build the simulator:

make install-dep

Now you can launch the build of the simulator:

make build

Finally, there are two modes to start the simulator:

  • from source (without building the source)
make run
  • from the built binary
make run-release

From docker

First, build the docker image:

docker-compose build

Then, run the built container:

docker-compose up

Configuration file

The simulator realises on a configuration file (config.json) which specifies some configurations for the simulator:

{
    "address":"0.0.0.0",
    "port":8000,
    "configDirname":"lwnsimulator"
}
  • address: specifies the IP mask from which the web UI is accessible.
  • port: the web server port.
  • configDirname: the directory name where all status files will be saved and will be created.

Tutorials

English

Coming Soon

Italian

Coming Soon

Arabic (thanks to IdealBit)

How to Install on Linux or WLS

How to Install on Windows

How to use LWN Simulator with ChirpStack

Publications and Citations

LWN Simulator-A LoRaWAN Network Simulator

Lightweight Root Key Management Scheme in Smart Grid IoT Network based on Blockchain Technology

lwn-simulator's People

Contributors

fedyfausto avatar jtylka avatar mjam9 avatar pippok96 avatar ttulka avatar userproblem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar

lwn-simulator's Issues

Problem on downlink

Hi,
There is a problem on downlink message.
For OTAA, no downlink accept.
For ABP, of course we can register the device. Uplink works well. But the downlink message doesn't works.

Timestamp

Time of messages is always year 1980..

Gateway bridge port

Where do I find my gateway bridge's port and IP? I assume the IP is 127.0.01 since I have it installed on the same virtual machine as my application server and my network server and I'm executing the simulator on the same machine. I tried looking into the ports that my machine are using with:
sudo lsof -i -P -n | grep LISTEN
And it was 3001. But when I try to run the simulator, it gave me this error: 2021/09/14 16:50:23 GW[gw1] [ERROR]: No connection with 127.0.0.1:3001, it may be off

Not connecting to Gateway Bridge

I'm trying to setup the Simulator and I'm running Chirpstack for the LoRaWAN network. But when I start the simulator, it doesn't connect to the Gateway Bridge's Port :// Can you help me?

image

Join is not completed on Docker alpine 3.17

Hello. First, thank you very much for your simulator. I have been testing the simulator with the latest stable release, version 1.0.2, without compiling the code, together with ChirpStack. Running the binary directly on Linux Ubuntu 20.04.6 LTS everything works perfectly. When I run the binary in docker, alpine 3.17 image, the join is not completed. The CS receives the joinRequest, processes it and responds with the downlink that is never received by the simulator.

Below is the simulator log:

[ Oct 16 12:36:09 ] [YES]: Setup gateways OK!
[ Oct 16 12:36:09 ] [YES]: Setup devices OK!
[ Oct 16 12:36:09 ] [YES]: SETUP OK!
[ Oct 16 12:36:09 ] [YES]: START
[ Oct 16 12:36:09 ] GW[V-GATEWAY]: Turn ON
[ Oct 16 12:36:09 ] GW[V-GATEWAY]: PULL DATA send
[ Oct 16 12:36:09 ] DEV[V-DEVICE] |Activation| {A}: Turn ON
[ Oct 16 12:36:09 ] DEV[V-DEVICE] |Activation| {A}: JOIN REQUEST sent
[ Oct 16 12:36:09 ] DEV[V-DEVICE] |Activation| {A}: Open RXs
[ Oct 16 12:36:09 ] GW[V-GATEWAY]: PUSH DATA send
[ Oct 16 12:36:21 ] DEV[V-DEVICE] |Activation| {A}: No downlink received
[ Oct 16 12:36:21 ] DEV[V-DEVICE] |Activation| {A}: Unjoined

Below is the CS log:

2023-10-16T12:36:09.703739Z INFO chirpstack::gateway::backend::mqtt: Message received from gateway region_config_id="eu868" topic="eu868/gateway/9e5accc5497961e6/event/up" qos=0 json=false
2023-10-16T12:36:09.704823Z INFO chirpstack::gateway::backend::mqtt: Message received from gateway region_config_id="eu868" topic="eu868/gateway/9e5accc5497961e6/event/stats" qos=0 json=false
2023-10-16T12:36:09.707644Z INFO stats{gateway_id=9e5accc5497961e6}: chirpstack::storage::gateway: Gateway state updated gateway_id=9e5accc5497961e6
2023-10-16T12:36:09.708409Z INFO stats{gateway_id=9e5accc5497961e6}: chirpstack::storage::metrics: Metrics saved name=gw:9e5accc5497961e6 aggregation=HOUR
2023-10-16T12:36:09.709091Z INFO stats{gateway_id=9e5accc5497961e6}: chirpstack::storage::metrics: Metrics saved name=gw:9e5accc5497961e6 aggregation=DAY
2023-10-16T12:36:09.709650Z INFO stats{gateway_id=9e5accc5497961e6}: chirpstack::storage::metrics: Metrics saved name=gw:9e5accc5497961e6 aggregation=MONTH
2023-10-16T12:36:09.907349Z INFO up{deduplication_id=e23c98db-8e3d-412d-ac4f-9c71cde75566}: chirpstack::uplink: Uplink received m_type="JoinRequest"
2023-10-16T12:36:09.920307Z INFO up{deduplication_id=e23c98db-8e3d-412d-ac4f-9c71cde75566}:join_request: chirpstack::storage::device_keys: Device-nonce validated and stored dev_eui=282f5b5d8de3 27ef dev_nonce=5275
2023-10-16t12: 36: 09.921519Z info up {deduplication_id = E23C98DB-8E3D-412D-AC4F-9C71CDE75566}: join_request: chirpstack :: storage :: device_keys: device-keys updated dev 5d8de327ef
2023-10-16T12:36:09.922599Z INFO up{deduplication_id=e23c98db-8e3d-412d-ac4f-9c71cde75566}:join_request: chirpstack::storage::device_session: Device-session saved dev_eui=282f5b5d8de32 7ef dev_addr=01396f01
2023-10-16T12:36:09.923456Z INFO up{deduplication_id=e23c98db-8e3d-412d-ac4f-9c71cde75566}:join_request: chirpstack::storage::device_queue: Device queue flushed dev_eui=282f5b5d8de327ef count=0
2023-10-16T12:36:09.925010Z INFO up{deduplication_id=e23c98db-8e3d-412d-ac4f-9c71cde75566}:join_request: chirpstack::storage::device: Enabled class updated dev_eui=282f5b5d8de327ef enabled_class =A
2023-10-16T12:36:09.925260Z INFO up{deduplication_id=e23c98db-8e3d-412d-ac4f-9c71cde75566}:join_request: chirpstack::gateway::backend::mqtt: Sending downlink frame gateway_id=9e5accc5497961e6 topic=eu868/gateway /9e5accc5497961e6/command/down json=false
2023-10-16T12:36:09.926200Z INFO up{deduplication_id=e23c98db-8e3d-412d-ac4f-9c71cde75566}:join_request: chirpstack::storage::downlink_frame: Downlink-frame saved downlink_id=2178120891
2023-10-16T12:36:09.929594Z INFO chirpstack::integration::mqtt: Publishing event topic=application/17ceb164-9b65-44a1-9efd-293d99cd0ff3/device/282f5b5d8de327ef/event/join

Outdated Go version recommended in README

While running $ make build I encountered the following problems:

# github.com/prometheus/common/model
note: module requires Go 1.20
# golang.org/x/net/http2
note: module requires Go 1.18
# github.com/gin-gonic/gin/render
note: module requires Go 1.20
# github.com/gin-gonic/gin/binding
note: module requires Go 1.20

The current README says Go Version >= 1.16 is sufficient but I tried with 1.17.4 and it failed.

Upgrading to the latest version solved the issue but the README should recommend at least 1.20 based on the errors I received.

Feature request: Ability to vary RSSI and SNR

Enabling the adjustment of SNR and RSSI, and thereby the transmission strength of simulated devices to real gateways, would enhance the realism of test scenarios. This is particularly essential for evaluating ADR algorithms, which respond directly to changes in SNR. The option to set these parameters either statically or dynamically over time would greatly enhance the value of such testing.

Unable to view JoinRequest on LoRaWAN Frames

I have set up a testing environment with ChirpStack and the LWN Simulator on a Linux (Ubuntu) virtual machine. In this environment, I created a virtual gateway using the LWN Simulator, and the simulator's logs indicate that it is sending join request frames.
WhatsApp Image 2023-09-15 at 10 26 18 AM
Problem:
The issue I'm facing is that I cannot see these join request frames in the ChirpStack UI's LoRaWAN frames section. Despite the simulator sending the join requests, there is no visibility or record of them within the ChirpStack application.
WhatsApp Image 2023-09-15 at 10 20 32 AM

My current Setup:
Installed ChirpStack (v4) according to the "Getting Started with Debian/Ubuntu" guide.
Configured and launched the LWN Simulator.
Created a virtual gateway within the LWN Simulator.
Initiated join requests from the LWN Simulator.

Environment:
ChirpStack Version: v4
Operating System: Ubuntu 22.04
ChirpStack Gateway Bridge Configuration Details:
WhatsApp Image 2023-09-14 at 4 37 53 PM
WhatsApp Image 2023-09-14 at 4 50 22 PM

This issue is a crucial step toward achieving my ultimate goal of data transfer from ChirpStack to Azure IoT Hub.

Send new payload to a device from CMD

Is it possible to call a function or run a command to change the payload of a specific sensor?
I want to simulate the change of temperature and humidity during the day

Devices configuration file.

Which file are the devices configuration saved in ?
I need to add hundreds of devices and it would be easier and faster to just add them directly to the file instead of using the GUI, the only thing that changes is the EUI.

Use a binary payload

Is it possible to set up a virtual device with a binary payload?

I would like to simulate a LoRaWAN payload of bytes that cannot be represented by a simple ASCII string, but there does not seem to be a way to configure that in the UI.

Device not registered on ChirpStack

I created 1 virtual GW and 1 virtual device on LWM, and redirected gateway bridge to my NAS executing ChirpStack. All on the same local network.

I can see the virtual gateway active on ChirpStack Dashboard (with localization ok).

Under the device detail on CS dashboard I can see activation data and LoRaWAN frames, but only JOIN_REQUEST/JOIN_ACCEPT ... no downlink/uplink messagge .

I reported the simulator console output. I can't understand if the problem is the simulator or the server. Seems the JOIN_accepted message is not received, but I'm not sure.

Same executing lwm simulator with make run or docker

2023/09/28 16:15:46 LWN Simulator is online...
2023/09/28 16:15:46 Autostart not enabled
2023/09/28 16:15:46 [WS]: Listen [ 192.168.10.52:8000 ]
2023/09/28 16:16:24 [WS]: Socket connected
2023/09/28 16:16:27 [SIM]: SETUP OK!
2023/09/28 16:16:27 [SIM]: START
2023/09/28 16:16:27 GW[vg1]: Setup OK!
2023/09/28 16:16:27 GW[vg1]: UDP connection with 192.168.10.250:1700
2023/09/28 16:16:27 GW[vg1]: Turn ON
2023/09/28 16:16:27 GW[vg1]: PULL DATA send
2023/09/28 16:16:27 DEV[vd1] |Activation| {A}: Setup OK!
2023/09/28 16:16:27 DEV[vd1] |Activation| {A}: Turn ON
2023/09/28 16:16:27 DEV[vd1] |Activation| {A}: JOIN REQUEST sent
2023/09/28 16:16:27 DEV[vd1] |Activation| {A}: Open RXs for 0 and 869525000
2023/09/28 16:16:27 GW[vg1]: PUSH DATA send
2023/09/28 16:16:28 GW[vg1]: PULL ACK received
2023/09/28 16:16:29 GW[vg1]: PUSH ACK received
2023/09/28 16:16:30 GW[vg1]: PULL RESP received
2023/09/28 16:16:30 GW[vg1]: TX ACK sent
2023/09/28 16:16:39 DEV[vd1] |Activation| {A}: None downlink received
2023/09/28 16:16:39 DEV[vd1] |Activation| {A}: Unjoined
2023/09/28 16:16:39 DEV[vd1] |Activation| {A}: JOIN REQUEST sent
2023/09/28 16:16:39 GW[vg1]: PUSH DATA send
2023/09/28 16:16:39 DEV[vd1] |Activation| {A}: Open RXs for 0 and 869525000
2023/09/28 16:16:40 GW[vg1]: PUSH ACK received
2023/09/28 16:16:42 GW[vg1]: PULL RESP received
2023/09/28 16:16:42 GW[vg1]: TX ACK sent

Statik is an unmentioned requirement

While running $ make build I encountered the following problem:

Building the LWN Simulator
Building the User Interface
/bin/sh: line 1: statik: command not found
make: *** [Makefile:8: build] Error 127

It's interesting because I ran $ make install-dep and I've even tried to just run go install github.com/rakyll/statik by itself but it did not give me a globally available command.

I've resolved the problem on two systems via two different solutions:

  • Fedora 39: sudo dnf install golang-github-rakyll-statik
  • Debian 11: sudo apt update && sudo apt install golang-statik

I think the most sensible solution would be to list the tool as a requirement (or export the one installed by make install-dep to PATH)

Add a missing command on the README file

I've noticed that, in some specific executions (e.g., macOS), it is required to run the following command before the make build one:

PATH=$HOME/go/bin:$PATH

I suggest to add it on the README.md file.

Proposal for Makefile with GNU Make 4.4.1 Built for Windows

Install Make in Windows with chocolatey

>choco install make
--Rename folder LWN-Simulator with LWNSimulator
SUFFIX := ".exe"
clean:
	@rmdir /s /q bin

install-dep:
	@go install github.com/rakyll/statik
	@go get -u -d ./...

build:
	@echo "Building LWN Simulator"
	@echo "Building User Web Interface"
	@cd webserver && statik -src=public -f 1>NUL	
	@mkdir bin
	@copy config.json bin\config.json
	@echo "Building from the source.."
	@go build -o bin/lwnsimulator${SUFFIX} cmd/main.go
	@echo "Build Complete."

build-platform:
	@echo "Building LWN Simulator"
	@echo "Building User Web Interface"
	@cd webserver && statik -src=public -f 1>NUL	
	@mkdir bin
	@copy config.json bin\config.json
	@echo "Building from the source.."
	@go build -o bin/lwnsimulator${SUFFIX} cmd/main.go
	@echo "Build Complete."

build-x64:	
	@make build-platform GOOS=windows GOARCH=amd64 SUFFIX="_x64.exe"

build-x86:
	@make build-platform GOOS=windows GOARCH=386 SUFFIX="_x86.exe"	

run:
	@go run cmd/main.go

Parameters to be set in the config.json file

Hello,

I am having Ubuntu 18.04 running as VM on windows host. In the same VM I have installed all the Chirpstack components namely Gateway-Bridge, network Server and Application server. I have installed the LWN-Simulator too in the same VM but while executing the 'make run' command I am getting the error as :

2sudip@sudip_ubuntu:~/LWN-Simulator$ make run
2021/11/09 14:37:10 LWN Simulator is online...
2021/11/09 14:37:10 [WS]: Listen [ 192.168.1.5:8000 ]
2021/11/09 14:37:10 [WS] [ERROR]: listen tcp 192.168.1.5:8000: bind: address already in use

192.168.1.5- is my VM ip address.

The same 8000 port I have used while adding network server in the application server web interface.
'localhost:8000'.

What shall I do to get the websocket of the simulator to get connected?

Please help!!

sending hex str in device chirpstack

Hi
I tried sending "51282412059f23190000000000000000000000000000000000000000000000000000000000000000" in device payload and i am getting base64 encoded data on chirpstack as
NTEyODI0MTIwNTlmMjMxOTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDA=

whereas expected encoded data is
USgkEgWfIxkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==

i tried finding the issue and in order to get this data correctly i need to do a hex decode , but i am not sure where to do it

i am addding the sample sudo code here

package main

import (
"encoding/base64"
"encoding/hex"
"fmt"
)

func main() {
fmt.Printf("expected: \n USgkEgWfIxkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==")
payload := "51282412059f23190000000000000000000000000000000000000000000000000000000000000000"

current_output := base64.StdEncoding.EncodeToString([]byte(payload))
db := decodeHex([]byte(payload))
expected_output := base64.StdEncoding.EncodeToString(db)

fmt.Printf("\noriginal encoding \n %s\n", current_output)
fmt.Printf("new encoding \n %s\n", expected_output)

}

func decodeHex(input []byte) []byte {
db := make([]byte, hex.DecodedLen(len(input)))
hex.Decode(db, input)
return db
}

kindly suggest where this decodeHex needs to be put

Issue with timestamp on real gateway.

Hello,
I´m using the simulator with a real gateway (Raspberry Pi based with SEMTECH packet forwarder) and I´m getting the error below during JOIN procedure (response from gateway):

JSON down: {"txpk":{"powe":14,"imme":false,"tmst":1720347887,"codr":"4/5","datr":"SF12BW125","freq":434.665,"modu":"LORA","rfch":0,"ipol":true,"size":17,"data":"IOQR2FI5nM79GpmgfqD6BWk="}}
src/jitqueue.c:251:jit_enqueue(): ERROR: Packet REJECTED, timestamp seems wrong, too much in advance (current=491697203, packet=1720347887, type=0)
ERROR: Packet REJECTED (jit error=2)

And the node never joins. The clocks are correct. I´m out of ideas.

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.