Skip to content

Dish socket should bind on multicast group IP instead of INADDR_ANY #4582

@NoAnyLove

Description

@NoAnyLove

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:9000 with group events/notification
  • R2 multicast on udp://224.1.1.2:9000 with group events/notification
  • D1 receives udp://224.1.1.1:9000 with group events/notification
  • D2 receives udp://224.1.1.2:9000 with group events/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:

Environment

  • libzmq version (commit hash if unreleased): v4.3.4
  • OS: Linux

Minimal test code / Steps to reproduce the issue

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions