Minggu, 22 Maret 2009

IP Multicast to MAC Address Mapping

Map Multicast MAC address to IP Multicast Addresses

In the course of reading through the BSCI authorize self-study guide, I’ve come across a multicast example where the author talks about the concepts behind the multicast IP to MAC address mapping.

  • In order to achieve the translation between a Layer 3 IP multicast address and Layer 2 multicast MAC address, the low-order 23 bits of the IP address (Layer 3) is mapped into the low-order 23 bits of the MAC address (Layer 2).
  • The high order 4 bits of the Layer 3 IP address is fixed to 1110 to indicate the Class D address space between 224.0.0.0 through 239.255.255.255
    • Ethernet MAC addresses start with 01:00:5E, allowing for a range from 01:00:5E:00:00:00 through 01:00:5E:7F:FF:FF.
  • With 32 total bits present in an IP address and 4 high order bits of it set at 1110, we are left with 28 bits of unique IP addresses we can use (32 - 4 = 28).
  • But remember, 23 low-order bits out of the 28 available bits are mapped to the MAC address, giving us 5 remaining bits of overlap.
  • With the 5 bits of extra overlap, there are 32 (25 = 32) IP multicast address that map to one MAC multicast address.

The problem is, the book does not explain or show how it solved the mapping. So I went about researching how it was done. If you happened to be studying for BSCI, I am referring to the section of the BSCI: Authorized Self-Study Guide, by Teare and Paquet, that starts on page 598 - 600.

The following is an example of how we arrive with those 32 IP addresses that map to a single MAC address:

For reference, use the following conversion chart for converting hex to binary and vice versa
hexconverttable

Let’s start by using the example MAC address given in the book :

01:00:5e:0a:00:01

  1. Convert the hexadecimal MAC address 01:00:5e:0a:00:01 to binary
    • 0000 0001 : 0000 0000 : 0101 1110 : 0000 1010 : 0000 0000 : 0000 001
    • Here’s a breakdown of the conversion bit by bit:
      hex-bin
  2. Isolate the 23 low-order binary bits from the converted MAC address:
    • 0000 0001 : 0000 0000 : 0101 1110 : 0000 1010 : 0000 0000 : 0000 0001
  3. Take the low order 23 bits from step 2 and plug it into the low-order 23 bits of the IP address (do this in binary):
    • 1110 xxxx : x000 1010 : 0000 0000 : 0000 0000
      • 1110 - First 4 high-order bits of the IP address for the multicast address space (224.x.x.x).
      • xxxx x - 5 remaining bits after the 23bits of the IP address is mapped to the MAC address plus the 4 high order bits 1110. This is equal to 32 total IP addresses.
  4. Convert the binary equivalent of the IP addresses to decimal, replacing the x variables with all the values to get all 32 possible IP addresses:
    • 1110 0000 : 0000 1010 : 0000 0000 : 0000 0001 = 224.10.0.1
    • 1110 0001 : 0000 1010 : 0000 0000 : 0000 0001 = 225.10.0.1
    • 1110 0010 : 0000 1010 : 0000 0000 : 0000 0001 = 226.10.0.1
    • 1110 0011 : 0000 1010 : 0000 0000 : 0000 0001 = 227.10.0.1
    • 1110 0100 : 0000 1010 : 0000 0000 : 0000 0001 = 228.10.0.1
    • 1110 0101 : 0000 1010 : 0000 0000 : 0000 0001 = 229.10.0.1
    • 1110 0110 : 0000 1010 : 0000 0000 : 0000 0001 = 230.10.0.1
    • 1110 0111 : 0000 1010 : 0000 0000 : 0000 0001 = 231.10.0.1
    • 1110 1000 : 0000 1010 : 0000 0000 : 0000 0001 = 232.10.0.1
    • 1110 1001 : 0000 1010 : 0000 0000 : 0000 0001 = 233.10.0.1
    • 1110 1010 : 0000 1010 : 0000 0000 : 0000 0001 = 234.10.0.1
    • 1110 1011 : 0000 1010 : 0000 0000 : 0000 0001 = 235.10.0.1
    • 1110 1100 : 0000 1010 : 0000 0000 : 0000 0001 = 236.10.0.1
    • 1110 1101 : 0000 1010 : 0000 0000 : 0000 0001 = 237.10.0.1
    • 1110 1110 : 0000 1010 : 0000 0000 : 0000 0001 = 238.10.0.1
    • 1110 1111 : 0000 1010 : 0000 0000 : 0000 0001 = 239.10.0.1
    • 1110 0000 : 1000 1010 : 0000 0000 : 0000 0001 = 224.10.0.1
    • 1110 0001 : 1000 1010 : 0000 0000 : 0000 0001 = 225.138.0.1
    • 1110 0010 : 1000 1010 : 0000 0000 : 0000 0001 = 226.138.0.1
    • 1110 0011 : 1000 1010 : 0000 0000 : 0000 0001 = 227.138.0.1
    • 1110 0100 : 1000 1010 : 0000 0000 : 0000 0001 = 228.138.0.1
    • 1110 0101 : 1000 1010 : 0000 0000 : 0000 0001 = 229.138.0.1
    • 1110 0110 : 1000 1010 : 0000 0000 : 0000 0001 = 230.138.0.1
    • 1110 0111 : 1000 1010 : 0000 0000 : 0000 0001 = 231.138.0.1
    • 1110 1000 : 1000 1010 : 0000 0000 : 0000 0001 = 232.138.0.1
    • 1110 1001 : 1000 1010 : 0000 0000 : 0000 0001 = 233.138.0.1
    • 1110 1010 : 1000 1010 : 0000 0000 : 0000 0001 = 234.138.0.1
    • 1110 1011 : 1000 1010 : 0000 0000 : 0000 0001 = 235.138.0.1
    • 1110 1100 : 1000 1010 : 0000 0000 : 0000 0001 = 236.138.0.1
    • 1110 1101 : 1000 1010 : 0000 0000 : 0000 0001 = 237.138.0.1
    • 1110 1110 : 1000 1010 : 0000 0000 : 0000 0001 = 238.138.0.1
    • 1110 1111 : 1000 1010 : 0000 0000 : 0000 0001 = 239.138.0.1
  5. All the 32 IP addresses on step 4 map to MAC address 01:00:5e:0a:00:01

Convert IP Multicast Address to Multicast MAC Address

Conversely, a multicast IP address can be converted to its equivalent MAC address. Once you’ve figured out how to convert from Layer 2 MAC to Layer 3 IP, doing the reverse is easy.

To start, we can pick any address from the 32 IP addresses we converted above. Let’s pick a random one like 227.138.0.1

  1. First convert the address 227.138.0.1 to binary:
    • 11100011 : 10001010 : 00000000 : 00000001
    • We’re only concerned with the red colored portion which represents the low-order 23bits of the IP address.
    • Notice that we are dropping the high order bit of the second octet.
  2. Convert those 23 bits to hexadecimal:
    • 0A:00:01
  3. We already know that the first 3-bytes (24 bits) of the MAC address is 01:00:5E. This was established earlier in the article. Simply append the result on step 2 to the first 3-bytes and you have your MAC address:
    • 01:00:5E:0A:00:01
    • *You can pick any of the 32 Ip addresses we have on the list above and you will always get 01:00:5E:0A:00:01 as your MAC address following the steps just mentioned.

To summarize:

  • 1st octet - Notice that the first octet is left alone.
  • 2nd octet - You only need to convert the last 7 bits to hex. The second octet in decimal is 138. But if you drop the highest order bit, it becomes a decimal 10 or hex 0A.
  • 3rd octet - Convert it directly to hex.
  • 4th octet - Convert it directly to hex.
taken from : http://routemyworld.com/2009/03/04/ip-multicast-to-mac-address-mapping/

1 komentar:

Unknown mengatakan...

What is the benefit's to multicast MAC Address?

Thanks
Silvester Norman

Change Mac Address

Posting Komentar