Add support for source filtering for multicast

As inter-domain any-source multicast has been deprecated by the IETF in 2020, the current std::net implementation for multicast is only useful for intra-domain use cases. Support for source filtering would be needed to enable SSM. This can be done by executing operations of the type IP_ADD_SOURCE_MEMBERSHIP (for joining) and IP_DROP_SOURCE_MEMBERSHIP (for leaving).

1 Like

Sorry for my lack of background. What is this about?

It's about a different mode of connection compared to the standard unicast (one-to-one). In multicast, receivers join a multicast group for data they wish to receive. A sender then only sends the data packet once and network components, i.e. routers, duplicate it so that all the receivers get it. This is useful in cases where many users want to receive the same content at the same time (think livestreams or downloads for newly released games) as it reduces load on servers and parts of the network.

There are two types ASM (any-source multicast, you just specify the group and receive the packets from anyone that sends to that group) and SSM (source-specific multicast, you specify both the group and a list of sources you want to receive traffic from, you will only receive traffic from those sources). ASM for inter-domain use has many flaws, which is why it was depreciated. Having SSM support in Rust would be really useful and the socket operation for it is already there.

1 Like

+1, modern network receive libraries (at least those that accept unencrypted UDP, and perhaps others) should have support for SSM multicast, IMO. Rust seems like a pretty cool language, but this is an important gap for some applications if the feature is not supported.

A few useful references:

See also a prior report:

HTH :slight_smile:

1 Like

How is the support of source specific multicast across various OSes? Which OSes support is and which don't? For those which support it when did they get support for it? If the support is not (near) universal it will likely have to be added as platform specific extensions. Note also that you can directly call the respective libc functions if you want or write a wrapper crate for it. The socket2 crate may be a good location to add it to. It offers a more extensive interface around sockets than libstd.

It's mostly supported (to some extent) in all the widely used operating systems, but it's got some cross-platform specific needs unfortunately. There's actually a few different APIs with slightly different amounts of support.

MCAST_JOIN_SOURCE_GROUP & MCAST_LEAVE_SOURCE_GROUP can be used for both IPv4 and IPv6 and should be used by preference, but don't work in practice on macos.

IP_ADD_SOURCE_MEMBERSHIP & IP_DROP_SOURCE_MEMBERSHIP are IPv4-only, but do work on Mac (in a slightly flaky way, but that should be fixed eventually and can do some things successfully today).

VLC has an implementation that uses this and checks which APIs exist by platform, with a compile time fallback to EAFNOSUPPORT when something is unavailable:

I also have a project that tries to put a cross-platform layer on this. It doesn't yet have windows support, but that's in progress. That code is here:

Windows claims to have the feature. I haven't checked it yet, but VLC does work for IPv4, and from the VLC code I think that means it's using the IP-family-agnostic API:

I'm not sure when they got support for this in windows, mac, or ios. Linux reportedly added it in kernel 2.6.31 sometime around 2012:

As a follow up, IPv4 SSM joins/leaves are now included in socket2.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.