[riot-notifications] [RIOT-OS/RIOT] UDP packets get lost between udp socket and gnrc_netapi (#15704)

Nicolas notifications at github.com
Mon Jan 4 14:46:08 CET 2021


### Description

Lately I have been experimenting with the UDP sockets in RIOT. Everything worked pretty well until my system increased in complexity. 

**Context:**

I have 4 devices connected to the same network, lets call them, device A, B, C and Root. A B C are perfectly synchronized in time, and all send data to Root at regular intervals. I use Particle Xenons for this (so NRF52840 MCUs). 

**My software implementation:**

One thread "listens" to the UDP socket continuously, stores any received data into a buffer (which will be later read by another thread but that's irrelevant to the problem in this issue) then send an ACK to the sender. 
One thread "writes" to the UDP socket asynchronously, then, will later check for an ACK, if no ACK received, resend message once.

Both threads access the same UDP socket, but that should not be a problem, right ?
 
**My issue:**

I seem to be missing a lot of UDP packets. Which doesn't surprise me really, but, what is a bit weird is that it seems the lost packets are lost in the gnrc_netapi layer, about 95% of the time, the rest seems to get lost before they are decoded as UDP packets (which is fine and not the issue here). I have turned on the debug traces in both in gnrc_udp and gnrc_netapi and I get odd stuff:

`2021-01-04 13:51:02,966 # udp: GNRC_NETAPI_MSG_TYPE_RCV
2021-01-04 13:51:02,967 # udp: GNRC_NETAPI_MSG_TYPE_SND
2021-01-04 13:51:02,967 # NODE: - Received UDP data INRIA_NODE_A (13:50:04) Vbat < 3.636446 > Temp/Hydro <> 
2021-01-04 13:51:02,968 # udp: GNRC_NETAPI_MSG_TYPE_RCV
2021-01-04 13:51:02,968 # udp: GNRC_NETAPI_MSG_TYPE_SND
2021-01-04 13:51:02,969 # NODE: - Received UDP data INRIA_NODE_B (13:50:04) Vbat < 3.903948 > Temp/Hydro <> 
2021-01-04 13:51:03,022 # udp: GNRC_NETAPI_MSG_TYPE_RCV
2021-01-04 13:51:03,023 # udp: unable to forward packet as no one is interested in it
2021-01-04 13:51:03,023 # udp: GNRC_NETAPI_MSG_TYPE_RCV
2021-01-04 13:51:03,023 # udp: unable to forward packet as no one is interested in it
`

As you can see, both A and B UDP messages are received perfectly. But there is two UDP messages received (without a doubt the ones from the C device) that are never passed to my app. 

I've looked a bit into this and printed the return value of gnrc_netreg_num  in the gnrc_netapi_dispatch function and got this: 

`2021-01-04 13:59:02,915 # udp: GNRC_NETAPI_MSG_TYPE_RCV
2021-01-04 13:59:02,915 # number of subs : 0
2021-01-04 13:59:02,916 # udp: unable to forward packet as no one is interested in it
`

The return value is 0 which is odd (I think). When a UDP message is successfully  passed to my app I get a more "normal" return value of 1 registered thread. I have no idea where to look from there. Anyone can help ? It seems to me that, the more I add new devices, and the more they send simultaneously, the more I encounter this problem. 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/issues/15704
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210104/ff927e8a/attachment.htm>


More information about the notifications mailing list