-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
Issue description
For dish socket with UDP multicast, if it binds on INADDR_ANY (see code here), it will receive messages from other multicast IPs on the same port.
Given an example, we have 4 apps,
- R1 multicast on
udp://224.1.1.1:9000with groupevents/notification - R2 multicast on
udp://224.1.1.2:9000with groupevents/notification - D1 receives
udp://224.1.1.1:9000with groupevents/notification - D2 receives
udp://224.1.1.2:9000with groupevents/notification
Note: D1 and D2 are on the same box
We expect D1 only receives messages from R1, and D2 only from R2. But in fact, D1 will receive messages from both R1 and R2, so does D2.
This prevents us to segregate the traffic with the same port, as mentioned in issue lcm-proj/lcm#186.
Can we change the bind to the multicast IP, which prevents us from receiving messages from other multicast addresses?
Quote from UNIX Network Programming, Volume 1,
Recall that we could just bind the wildcard IP address and port 8888, but binding the multicast address prevents the socket from receiving any other datagrams that might arrive destined for port 8888.
I'm more than happy to submit a PR if you agree with this change.
Reference:
- bind()ing to the multicast group IP instead of INADDR_ANY in the udpm driver lcm-proj/lcm#186
- https://stackoverflow.com/a/10739443
- UNIX Network Programming: The sockets networking API, Volume 1, page 576
Environment
- libzmq version (commit hash if unreleased): v4.3.4
- OS: Linux
Minimal test code / Steps to reproduce the issue
N/A