Monday, November 12, 2012

Multicast Vs. Broadcast.

In networking multicast is always confusing and most often ignored and replaced by its ally broadcast but there are few distinctions between the two.We discuss the differences layer wise MAC and IP layers.

MAC Layer:


First of all lets take a look at the addresses

Broadcast: FF:FF:FF:FF:FF:FF
Multicast: 01:00:5e:XX:XX:XX (Where XX is directly mapped from the IPV4 address*) 

Cc957928.INAF01(en-us,TechNet.10).gif
For example, the multicast address 224.192.16.1 becomes 01-00-5E-40-10-01.

As for layer 2 is considered, there's really no difference between the broadcast and multicast packets. Multicast's packets will filtered only based on the L3 information (IGMP snooping) because only IP layer knows which Applications have registered for that specific multicast group.
  
IP Layer:
The below para says that the packets will dropped at IP layer if no APP is registered  for that packet. (setsockopt will add the IP Membership for a socket)
            A host MUST silently discard an incoming datagram that is
            not destined for the host.  An incoming datagram is destined
            for the host if the datagram's destination address field is:

            (1)  (one of) the host's IP address(es); or

            (2)  an IP broadcast address valid for the connected
                 network; or

            (3)  the address for a multicast group of which the host is
                 a member on the incoming physical interface.

            For most purposes, a datagram addressed to a broadcast or
            multicast destination is processed as if it had been
            addressed to one of the host's IP addresses; we use the term
            "specific-destination address" for

This is an important rule w.r.t broadcast and Multicasts. So we cannot send a packet with unicast IP address 
and a group based mac addressed. 

        When a host sends a datagram to a link-layer broadcast address,
         the IP destination address MUST be a legal IP broadcast or IP
         multicast address.

         A host SHOULD silently discard a datagram that is received via
         a link-layer broadcast (see Section 2.4) but does not specify
         an IP multicast or broadcast destination address. 

We need to use the protocol like IGMP to join and become a member of the group so that we will receive packets. 

ARP

For Broadcast IP addresses the destination address will be FF:FF:FF:FF:FF:FF so there is no need for ARP. 
For Multicast Addresses the destination MAC Address can be reconstructed from destination IP Address with direct mapping 
 as explained above.  

Routes

For Broadcast the stack can identify the address and uses the any subnet broadcast as the destination address ("255.255.255.255") 
(or) some stacks use the specific subnet broadcast address.

As most of the PC's do not support multicast routing we need to add "device" routes for all multicast addresses 
For Eg:

route add 224.0.0.0 netmask 240.0.0.0  dev wlan0.

240.0.0.0 mask covers all the multicast addresses ranging from 224.0.0.0-239.255.255.255.
 
 
* The mapping of IP Class D addresses to local addresses is
         currently specified for the following types of networks:

         o    Ethernet/IEEE 802.3, as defined in [IP:4].

         o    Any network that supports broadcast but not multicast,
              addressing: all IP Class D addresses map to the local
              broadcast address.

         o    Any type of point-to-point link (e.g., SLIP or HDLC
              links): no mapping required.  All IP multicast datagrams
              are sent as-is, inside the local framing.

         Mappings for other types of networks will be specified in the
         future.
 
 All quoted Text from RFC1122.