Subnet Masks – Do Subnet Masks Hinder the Ability to Listen to a UDP Multicast?

ipipv4multicastsubnetudp

I have a device connected to an ethernet switch, and my PCs NIC is connected to that switch as well. The device is sending multicast messages to 239.255.255.251 to which I am able to listen. My computer's IP address is 192.168.1.50, and the netmask is 255.0.0.0.

Shouldn't this not work?

Best Answer

No, this should not not work, it should work.

Anyone in the layer 2 broadcast domain will be able to receive any multicast message sent in that domain. Unless you use vlans, anything attached to the switch can listen for all multicast groups. Routers do not forward multicast traffic, unless specifically configured to do so.

Subnet masks only tell your computer which IP addresses are in its local subnet, and which addresses are not. They have no role to play in multicast.

On the ethernet layer, the multicast group is mapped to a multicast MAC address. Switches will send traffic destined to a multicast MAC address to all ports (unless specifically configured no to do so).

To find the multicast MAC for your multicast group, first convert the IP address to binary:

239.255.255.251 = 11101111.11111111.11111111.11111011

The first 25 bits of a multicast MAC are always 00000001:00000000:01011110:0. This means they range from 01:00:5E:00:00:00 to 01:00:5E:7F:FF:FF.

To construct the multicast MAC, append the last 23 bits of the IP to the fixed first 25 bits of all multicast MACs. In this case, we get:

00000001:00000000:01011110:01111111:11111111:11111011

which is

01:00:5E:7F:FF:FB.

You may have noticed it is not possible to do the reverse mapping. All multicast IPs start with the 4 bits 1110, leaving 28 bits for 2^28 different multicast addresses. Since there is only room for 23 bits in the multicast MAC address, such a MAC corresponds to a group of 32 multicast IP addresses.