Bi-directionnal asynchrone communication between app server and LoRaWAN-based sensor network - protocols

I am trying to build a LoRaWAN-based sensor network. These sensors communicate their data through the LoRaWAN protocol to the gateway which forwards these data to an application server through the MQTT protocol and in the other way around.
The communication has to be done from the sensors to the server and from the server to the sensors. However, things get tough at the gateway level since the message from the sensors to the server and the message from the server to the sensors can arrive at any time and my LoRaWAN module (the RN2483 from Microchip) cannot be on listening and sending mode at the same time. Hence, if I try to forward the message from the server to the sensors, the LoRaWAN packet sent by the sensors will be lost.
Do you have protocol ideas or literature suggestion for efficiently sharing the LoRaWAN module between listening and sending mode?
Thank you all and have a nice day.

I strongly recommend you to read LoRaWAN specification carefully. The LoRaWAN (not LoRa P2P model) has 3 types device, class A, B and C. RN2483 is one of class A devices, it will always have 2 receive windows (RX1, RX2) which last for 1 second long each after sending the message to gateway (uplink). You may use this feature to schedule your downlink messages. And the LoRaWAN server and LoRaWAN app server will handle the downlink issue (e.g., when to send downlink, immediately or one by one).

Related

how i can Sniff LoRaWAN packages?

I have a temperature, humidity and pressure sensor working over the LoRaWAN , I can get the read with the phone by NFC.
Also, I have some Arduino projects working with esp32 and RFM9X(Lora) boards to exchange data between the radio modules.
I want to sniff the LoraWAN packages that exchange between radio boards or between the sensor and another device
How I can do that by Wireshark??
I already have cc2531usb dongle I am using it for ZigBee packets , can i use it for Lora and how?
In order to capture LoRaWAN uplink messages, you need a LoRaWAN gateway. In order to capture downlink messages, you need an end device. The difference between UL and DL messages is that DL is sent with inverse polarization. This is why sniffing LoRaWAN messages is not so easy.
The easiest way to see what is going on between a LoRaWAN end device and a network is to use a packet logger that is usually provided by a network server.
One of the best packet logger is Actility's Wireless Logger, that you can try on the ThingPark Community portal.

Send data over network to multiple recipient parallely

Hellow, i'm working with network programing and it's been so hard to create a logic that allows to stream a video from a single server to multiple clients with no delay.
which means that i have to implement a parallel execution during the stream to all connected clients in order to display the images at the same time.
and why is that important for my project it's because i'm intending to have large number of clients (from 200 to approximately 700), now with 10 clients that delay is nothing but with 700 clients could significantly increase the delay to several minutes (not sure but possible).
for those who don't know what's the cause of the dely, it's from the for loop that i'm using which contain the send function for each frame, and that is a serial execution.
i tried threading and multiprocessing and even function schedule but every thing got messy, previously i was using socket & opencv, but for some reason it caused issues during the streaming, now i switched to Netgear & Vidgear but i'm still struggling.
Hope someone can help.
PS: multicast is just not right for the job, after i tried it i was receiving errors because of the length of the transmitted images, UDP protocol will NOT accept more then 65535 byte.
Per your comment, everything is in the same network, and we have multicast for exactly your problem. Rather than sending the same data over and over to multiple hosts, you can send a single stream of traffic to many receivers.
You set up the clients to subscribe to a multicast group, normally a group in the 239.0.0.0/8 Organization-Local scope. Your server then sends its traffic to the same multicast group to which the clients have subscribed. The single traffic stream will be received and processed by every client subscribed to the multicast group.
Because multicast sends to multiple clients, you must use a connectionless transport protocol, e.g. UDP. Connection-oriented transport protocols, e.g. TCP, create connections between two hosts, so they cannot be used with multicast, which is one-to-many.
By default, multicast only works in the same network. We do have multicast routing to send traffic to other networks, but it is very different than the usual unicast routing. Also, you cannot multicast on the public Internet because the ISPs do not have multicast routing. You can multicast to a different site across the Internet by using a tunnel that supports multicast, e.g. GRE. Both the source and destination routers need to be configured for multicast routing, as well as any routers in the path of the multicast packets (the Internet routers on see the unicast tunnel packets, not the multicast packets, so you can send the multicast across the Internet).
Hellow, i'm working with network programing and it's been so hard to create a logic that allows to stream a video from a single server to multiple clients with no delay.
Hey #zaki-lazhari I'm the creator of VidGear Video Processing Python Project. Actually, NetGear is not right API choice for multi-casting task, instead you should be using WebGear API. WebGear can acts as powerful Video Streaming Server that transfers live video-frames to any web browser on a network. So you can easily setup WebGear Server in few lines of code as follows:
# import required libraries
import uvicorn
from vidgear.gears.asyncio import WebGear
#various performance tweaks
options={"frame_size_reduction": 40, "frame_jpeg_quality": 80, "frame_jpeg_optimize": True, "frame_jpeg_progressive": False}
#initialize WebGear app
web=WebGear(source="foo.mp4", logging=True, **options)
#run this app on Uvicorn server at address http://0.0.0.0:8000/
uvicorn.run(web(), host='0.0.0.0', port=8000)
#close app safely
web.shutdown()
So every device (even a smartphone with any browser installed) on the same network can access real-time frames on there browser without any extra dependencies. More code samples can be found here: https://abhitronix.github.io/vidgear/gears/webgear/advanced/
Hope it helps. Good luck!

Communication between REST and UDP server

I have a REST server to handle communication between my database server and Android/iOS devices, the REST server is also able to send push messages via Firebase. My second server is a UDP server, that receive and send messages to a IOT device, both server are written in Node.js and running on different EC2 instances.
Then my UDP server receive a message from the IOT device, lets say some GPS data. Is there a good way to call some methods from my REST server via the UDP server? Or send the data to it ? Are there any ways that the two server can communicate with each other ?
You could implement a separate API on your REST server that would be called from your UDP server.
Interprocess communication is a wide topic, there are plenty of ways to do it, it all depends on your needs.
via http
via tcp/ip or udp
via a database (or even a file)
using named sockets (on unix/linux)
using a pub-sub library
using a message queue library
by piping standard input/output

MQTT broker for Windows IOT Core?

I have a Raspberry Pi running Windows IOT Core and it is running my home automation application. Now I need to set up communication between the RB pie and ESP8266.
I've been considering the MQTT protocol but I don't want to have an external server running the MQTT broker and I can't find a broker for the Win IOT. Does a MQTT broker exist for Windows IOT Core? If not, what communication protocol would you recommend for this purpose?
Antonio there are a few options available for you on Windows IoT Core
If you're building an application using Node.js there's Mosca (http://www.mosca.io)
If you're building an application using Python, you can check out hbmqtt (https://github.com/beerfactory/hbmqtt)
Of course for .NET applications you can search Nuget. GnattMQ (www.nuget.org/packages/GnatMQ) seems to be pretty popular .NET library
The is the GnatMQTT which is written in C# so I guess should build on Window IoT
Possibly there exist some MQTT lib or another protocol. But I assume the following situation and going to suggest a solution:
Assumptions:
Rpi is at the core of the system.
ESP is working like satellite, sensor etc.
So ESP is reporting data to the Rpi
They (Rpi and ESPs) all are in the same subnet.
Solution:
On the Rpi side implement a simple UDP bcast listener and listen to some specific port on BROADCAST ip. (ex: 8889)
On the ESP side implement a UDP Client to send data to BROADCAST ip and to specific port. (ex: 8889)
Implement a message format and make ESP to send it and Rpi to parse it.
Example Message Format:
The message can be a string (ASCII encoded).
ABBBEEECCCDDDD.....DDD
A: Start Header
BBB: Sender ID
EEE: Receiver ID
CCC: Payload Byte Count
D..: Payload
OR
A|BBB|EEE|DDDDD..DDDDDD|F
A: Start Header
|: Seperator
BBB: Sender ID
EEE: Receiver ID
D..: DATA payload
F: End Header.
This config will allow you to use DHCP, not to record any IP address of the clients and it is cheap to implement (according to resources ram,cpu etc).
Note: I don't know how MQTT uses resources.
There are a ton of MQTT brokers available. ActiveMQ is built with Java and can be installed on any platform that supports Java. Mosquitto and RabbitMQ have installers for Windows.
However, if you want something even more lightweight than MQTT you might also want to look into CoAP.

What excectly is Cirrus server role in flash P2P connection

According to the article quoted below, if we want to use Cirrus for RTMFP connection it should stay connected for the whole communication period.
Cirrus service
Flash Player instances must connect to the Cirrus service (using rtmfp://p2p.rtmfp.net) in order to communicate with one another. Cirrus is a hosted rendezvous service that helps Flash Player instances contact one another even if they are located behind NATs. Although connecting to Cirrus service is very similar to connecting to Flash Media Server, Cirrus does not provide any of the typical Flash Media Server features (media relay, shared objects, remoting, etc.). Flash Player endpoints must stay connected to Cirrus during the entire time of communication . In order to access Cirrus, you will need a developer key that is generated when you create your Adobe Developer ID.
http://www.adobe.com/devnet/flashplayer/articles/rtmfp_cirrus_app.html
And I wonder why do we need to keep the server communication after the first NAT traversing hand shake?
What part does it take when a P2P connection between the clients is done?
Imagine you have various clients in a NetGroup and then one client suddenly disconnects. Due to the stateless nature of UDP, the other clients don't recognize the disconnect. This event is being handled and dispatched to the other clients by Cirrus.
Furthermore, Cirrus handles the translation of peer IDs to network addresses. This must be done in the period in which clients are connected.

Resources