Thursday, 17 February 2011

How to calculate multicast MAC address

Hi,

It's been a while but here's a quick post on how to calculate a multicast MAC address from an IP address.

The first half of a multicast MAC address is 01-00-5E so we need to work out the second half.

To do this we need to convert the last 23 bits of the IP address in question. If you think about this we are not using the high order bit in the second octet which carries a value of 128. Therefore it must follow that a value of 6 in the second octet must be the same as 134 in the second octet as the high-order bit (i.e. a value of 128) is ignored.

So this leads to a simple method. Let us try and convert 192.168.35.1 to a multicast MAC address

1. Start with a half-filled multicast MAC address of 01-00-5E-XX-YY-ZZ

2. To calculate the value of XX take the second octet. If the value of the second octet is greater than 128 then subtract 128 from the second octet. In this example, the value of 168 is greater than 128 so we subtract 128 from 168 to give us a value of 40. Convert this value to hexadecimal. Decimal 40 = 0x28. Our multicast MAC address is now 01-00-5E-28-YY-ZZ

3. To calculate the value of YY take the third octet and convert it to hex. In this example the value is 35 which equals 0x23. Our multicast MAC address is now 01-00-5E-28-23-ZZ

4. To calculate the value of ZZ take the fourth octet and convert it to hex. In this example the value is 1 which equals 0x01. Our multicast MAC address is now 01-00-5E-28-23-01

So 192.168.35.1 has a multicast MAC address of 01-00-5E-28-23-01.

Can you spot an issue here? Hopefully you can. Basically any IP address with 40.35.1 or 168.35.1 as the last three octets carry the same multicast MAC address so you have potentially 32 addresses with the same multicast MAC address!

Back to the books for me!

Good luck with your studies.

2 comments:

  1. hi, thanks for explaining the MAC calculations.

    regarding your point about 512 possible overlaps, I think we only have to worry about the 224.0.0.0 - 239.255.255.255 range when it comes to multi-casts as it's the reserved range for this purpose.

    so the first 4 bits are always:
    1110

    only the remaining 5 bits of the 9 top bits will overlap (as the last 23 bits are used for the second half of Multi-cast MAC address)

    so it gives us:
    2^5 = 32

    32 possible overlaps in real world

    my source:
    http://routemyworld.com/2009/03/04/ip-multicast-to-mac-address-mapping/

    ReplyDelete
  2. hi, thanks for explaining the MAC calculations.

    regarding your point about 512 possible overlaps, I think we only have to worry about the 224.0.0.0 - 239.255.255.255 range when it comes to multi-casts as it's the reserved range for this purpose.

    so the first 4 bits are always:
    1110

    only the remaining 5 bits of the 9 top bits will overlap (as the last 23 bits are used for the second half of Multi-cast MAC address)

    so it gives us:
    2^5 = 32

    32 possible overlaps in real world

    my source:
    http://routemyworld.com/2009/03/04/ip-multicast-to-mac-address-mapping/

    ReplyDelete