Summary: Multicast socket blocks other UDP sockets
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: dapaulid
Submitted on: Tue 27 Aug 2019 10:43:16 AM CEST
Severity: 3 - Normal
Item Group: Faulty Behaviour
Assigned to: None
Discussion Lock: Any
Planned Release: None
lwIP version: git head
We came across an issue where an UDP socket that joined a multicast group led
to blocking recv() calls on other sockets, given that some datagrams were sent
to the multicast socket but not yet received by the application.
In our case, the effect was that the whole UDP communication to our embedded
device was down, because a single thread was blocked so that it could not
consume the multicast datagrams.
The setup is as follows:
LWIP application (server):
- socket1 bound to 5000
- socket2 bound to 5001 and joined multicast group 18.104.22.168
- while (1):
- receive datagram on socket1 and send it back (echo)
- do nothing with socket2 (do not receive multicast data)
PC application (client):
- while (1):
- send multicast to 5001
- send and receive datagram from 5000 (echo)
=> will timeout in the second iteration because no echo received.
See attached code to reproduce the issue.
- It seems that all UDP sockets are affected, but not TCP sockets.
- When the client uses the unicast IP instead of 22.214.171.124 to send data to
5001, the problem does not occur.