GGist / ssdp-rs

Simple Service Discovery Protocol In Rust
Apache License 2.0
42 stars 13 forks source link

NotifyListener Not Receiving Multicast On Multiple Interfaces #2

Closed GGist closed 9 years ago

GGist commented 9 years ago

In NotifyListener we are spawning worker threads to listen on every local interface. However, when something like Hamachi is set as the default route in the operating system, we do not get multicast messages from our local area network.

GGist commented 9 years ago

This is most likely due to a "bug" in libstd/sys/common/net/UdpSocket::set_membership() where the ip_mreq source address is set to 0x0, or, INADDR_ANY. According to documentation on Windows and Linux (under IP_ADD_MEMBERSHIP) the wildcard address, when used in this context, selects the default network interface card set by the operating system as the address to use when forwarding multicast packets up the stack.

In my tests, when binding to an NIC that is not the default NIC and joining a multicast address, I receive no multicast packets. When binding to INADDR_ANY and joining a multicast address, I receive multicast packets from the default NIC. When binding to the default NIC and joining a multicast address, I receive multicast packets from the default NIC which happens to be the interface we bound to.