In this lesson, we discuss the process of converting a multicast IP address to a multicast MAC address. It is very important to keep in mind that network devices work with IP and MAC addresses only in binary. An IP address is 32 bits of 1 and 0s, while a MAC address is 48 bits of 1s and 0s. The decimal representation of IP addresses and the hexadecimal representation of MAC addresses are only for humans.

Multicast IP address structure

First, let's look at the binary structure of a multicast IP address. It is well-known that an IP address is made up of four octets of 8 bits - 32 bits in total. For IP multicast, the class D address range has been reserved. The first 4 bits in the first octet are always fixed to 1110, as shown in the diagram below. This is denoted by the 4 in the decimal notation 224.0.0.0/4. The /4 means that the first 4 bits are always fixed to 1110 and never change.

Multicast IP address
Figure 1, Multicast IP address

This binary structure gives us the range 224.0.0.0 - 239.255.255.255 for IP multicast. In binary, the range looks like this:

from
11100000.00000000.00000000.00000000 (224.0.0.0)
through
11101111.11111111.11111111.11111111 (239.255.255.255)

Notice that the red bits are fixed and never change.

Multicast MAC address structure

Now, let's look at the binary structure of a multicast MAC address. It is well-known that an MAC address is made up of six octets of 8 bits - 48 bits in total. For IP multicast, the MAC address prefix 0x0100.5E has been reserved. The first 25 bits in the four octets are always fixed to 00000001.00000000.01011110.0, as shown in red in the diagram below.

Multicast MAC address
Figure 2, Multicast MAC address

This binary structure gives us the range of Ethernet MAC addresses 0100.5E00.0000 to 0100.5E7F.FFFF for IP multicast. In binary, the range looks like this:

from
00000001.00000000.01011110.00000000.0000000.00000000
through
00000001.00000000.01011110.01111111.11111111.11111111

Notice that the red bits are fixed and never change.

Mapping Multicast IP to MAC

The process of mapping a multicast IP address to a MAC address is simply placing the last 23 bits of the IP address into the last 23 bits of the Ethernet multicast address, as shown in the diagram below. 

Multicast IP to MAC mapping
Figure 3, Multicast IP to MAC mapping

However, notice a few important aspects of this process:

  • A multicast IP address consists of 4 fixed bits (the multicast IP prefix in red) and 28 unique bits.
  • A multicast MAC address consists of 25 fixed bits (the multicast MAC prefix in red) and 23 unique bits.
  • Since the multicast MAC has only 23 bits that are not fixed, only 23 bits of the IP address can be mapped to the MAC address. Hence, 5 bits of the IP address (in grey) cannot be mapped.

This means that there are not enough multicast MAC addresses to map to each multicast IP address because there is no space to map all 28 unique bits of a multicast IP address into the 23 available unique bits of a multicast MAC address. In practice, this means that 25(32) IP addresses map to the same multicast MAC address. For example, 

32 multicast IP addresses map to the same MAC
Figure 4, 32 multicast IP addresses map to the same MAC

Practical Consequences

The practical consequence of this mapping inefficiency is that hosts might receive multicast frames at the Ethernet layer for different IP multicast groups that correspond to the same MAC address. 

LAN switches replicate multicast by mapping a multicast MAC address to switchports with connected interested receivers. However, since one MAC address represents 32 multicast IP addresses, hosts interested in receiving multicast on group 1 will also receive the multiple multicast streams on the other 31 IP addresses that correspond to the same MAC. That's because LAN switches only look at the layer 2 header, and a single destination MAC address is the same for 32 destination multicast IPs.

For example, suppose two sources on the same LAN stream multicast traffic, as shown in the diagram below. PC1 streams video on 239.1.1.1, while PC7 streams audio podcasts on group 224.1.1.1. PC4 wants to receive only the video stream (239.1.1.1), while PC2 only wants to receive the audio stream (224.1.1.1). Since both multicast groups map to the same multicast MAC address, from a layer 2 perspective, they are the same. Hence, SW1 cannot differentiate both streams and treat them as one stream, making the same forwarding decision.

 

Multicast MAC inefficiency
Figure 5, Multicast MAC inefficiency

In the end, both receivers (PC2 and PC4) receive both streams, even though each one only wants one of the streams. This inefficiency increases the load on the network and on the end hosts simultaneously.

How to avoid this inefficiency?

The most efficient way to avoid this problem is to ensure that applications do not use multicast IPv4 addresses corresponding to the same multicast MAC address. For example, if one application uses the 239.1.1.1 multicast address, ensure that the other 31 IPv4 addresses that correspond to MAC 0100.5E01.0101 are not used (there are enough multicast IP addresses even for the largest enterprise).

Just as a side note. Nowadays, modern switches forward multicast traffic based on destination MAC AND destination IPv4 address, even if only acting as a layer 2 Ethernet bridge. This mitigates this problem and allows the device to replicate the multicast traffic only to the interested connected receivers. However, not all platforms and vendors support this capability, so the recommended approach is to avoid using overlapping multicast IP/MAC addresses. 

Converting multicast IP to MAC address

Most likely, you will never need to manually convert a multicast IP address to a multicast MAC address. However, to simply get your head around the concept, let's see how we can manually map the address 239.5.5.5 to a multicast MAC address.

Step 1. Convert the multicast IP to bindary.
 239.5.5.5 = 11101111.00000101.00000101.00000101
 In blue are the last 23 bits.
 
Step 2. Take the last 23 bits and map it to the well-known multicast MAC prefix.
multicast MAC prefix is 00000001.00000000.01011110.0xxxxxxx.xxxxxxxx.xxxxxxxx
In red are the fixed prefix bits.

Map the last 23 IP bits (in blue) to the MAC prefix (in red)
The result is 00000001.00000000.01011110.00000101.00000101.00000101

Step 3. Convert the result to HEX:
0x0100.5E05.0505
This is the MAC address that will be used when tramisting to group 239.5.5.5.

You can try to do a few example yourself, so that it sticks to your mind. For example, convert 239.100.100.100 and 239.200.200.200 to multicast MAC addresses.

Converting multicast MAC to IP address

And the reverse operation. Let's try to convert the multicast MAC 0100.5E07.FE01 to the corresponding set of IP addresses.

Step 1. Convert the multicast MAC to bindary.
0x0100.5E07.FE01 = 00000001.00000000.01011110.00000111.11111110.00000001

Step 2. Take the last 23 bits and map to the well-known multicast IP prefix.
multicast IP prefix is 1110yyyy.yxxxxxxx.xxxxxxxx.xxxxxxxx
In red are the fixed prefix bits. In green are the 5 bits that are lost during converton. 
We set them to 0 to find the first of the 32 multicast IP addresses.

Map the last 23 IP bits (in blue) to the IP prefix (in red)
The result is 11100000.00000111.11111110.00000001

Step 3. Convert the result to decimal:
224.7.254.1
This is the first of the 32 MAC addresses that correspond to 0100.5E07.FE01.

Step 4. Find the other 31 IP addresses:
Once, we add +128 to the second octet. Then, once we add +1 to the first octet. Repeat.
2th -> 224.(7+128).254.1 = 224.135.254.1
3th -> 225.7.254.1
4th -> 225.135.254.1
5th -> 226.7.254.1
.
31th -> 239.7.254.1
32th -> 239.135.254.1

Try a few examples yourself. You can use a calculator or AI prompt for the binary, decimal, and hexadecimal conventions. It is important to understand the process.