Monday, March 31, 2014

What is IP Multicasting

P multicast is a technique for one-to-many and many-to-many real-time communication over an IP infrastructure in a network. It scales to a larger receiver population by requiring neither prior knowledge of a receiver's identity nor prior knowledge of the number of receivers. Multicast uses network infrastructure efficiently by requiring the source to send a packet only once, even if it needs to be delivered to a large number of receivers. The nodes in the network (typically network switches and routers) take care of replicating the packet to reach multiple receivers such that messages are sent over each link of the network only once. The most common low-level protocol to use multicast addressing is User Datagram Protocol (UDP). By its nature, UDP is not reliable—messages may be lost or delivered out of order. Reliable multicast protocols such as Pragmatic General Multicast (PGM) have been developed to add loss detection and retransmission on top of IP multicast.
IP multi-casting is a communication mechanism in which data is communicated from server to a set of clients who are interested in receiving that data. Any client can dynamically enter or leave the communication.
IP multicast is a method of sending Internet Protocol (IP) datagrams to a group of interested receivers in a single transmission. It is often employed for streaming media applications on theInternet and private networks. The method is the IP-specific version of the general concept of multicast networking. It uses specially reserved multicast address blocks in IPv4 and IPv6. In IPv6, IP multicast addressing replaces broadcast addressing as implemented in IPv4.
Though the overall concept seems very simple but the way it is implemented requires  good understanding. So, in this tutorial we will cover the basics of IP multi-casting and how it is achieved.

Multicast IP address

To understand how multi-casting works, one needs to understand the structure of multicast IP address. Multicast IP address form the basis of multicast communication. In terms of classes, it’s the Class D IP addresses that are used as multicast IP addresses.
Here is the structure of Class D IP addresses :
So, it can be easily said that multicast IPs range from 224.0.0.0 to 239.255.255.255. As with the case of ports (where we have well known ports ie 0-1024), there are some reserved multicast IP addresses or well known IP addresses.
For example :
  • 224.0.0.1 signifies every system on a subnet
  • 224.0.0.2 signifies every router on a subnet
  • and so on
In case of multicast communication, the server sends data on a particular multicast IP address and clients who intend to receive that data need to listen on the same multicast address. These clients can be various different networks. A group of clients listening to same multicast address is known as host group.

On one hand, clients can leave and join a multicast group dynamically while on the other side the server does not need to know that identity of clients (joining or leaving). The clients useIGMP protocol for joining a multicast group.

Mapping multicast IP address with ethernet address

There is a specific mapping of IP multicast addresses with the ethernet mac addresses in order for multicast communication to work.
Before understanding the mapping, lets discuss multicast mac addresses :
  • An ethernet mac address is of 6 bytes or 48 bits.
  • A range of ethernet addresses ie from 00:00:5e:00:00:00 to 00:00:5e:ff:ff:ff is owned by IANA.
  • Now, a half of these addresses are reserved for multicast addresses but with one condition that the first byte of a multicast ethernet address should be 01.
  • This means that the ethernet addresses 01:00:5e:00:00:00 to 01:00:5e:7f:ff:ff are reserved as multicast ethernet addresses.
Now, here is how this mapping works :
  • The lower order 23 bits of a multicast mac address should correspond to IP multicast group ID (see figure above).
  • More precisely, this means that lower order 23 bits of multicast IP address should be same as lower order 23 bits of ethernet address.
This leads to another conclusion :
  • A multicast group ID is of 28 bits, but only lower 23 bits of a multicast group ID are mapped. This means that the higher order 5 bits of a multicast group ID can be variable.
  • This means that 32 (2 ^ 5) different IP multicast group IDs can map to one ethernet address.
  • Now, if a process on a system is interested in data packets destined for specific multicast group ID then the IP module or the device driver has to do perform some filtering operation as the interface card with a multicast ethernet address may receive packets of 32 different multicast group IDs.

Multicasting on single network

On a single network, the concept of multitasking works as follows :
  • The server sends data packet to specific destination IP address or a multicast IP address.
  • Through the mapping described above, the multicast IP address is converted into ethernet address and sent on the network.
  • A process on a client that is willing to receive multicast traffic need to specify the same multicast IP address while communicating with the systems IP layer which further configures lower layers to look out for such multicast packets.
  • When a multicast packet is received on the system, it is filtered in order to discard unwanted packets as 32 multicast group IDs can correspond to one ethernet address (explained above)
  • Please note that there can be multiple processes on single client that want to receive packets with same multicast ID. In this case, the kernel makes sure that each process gets a copy of the packet.

Multicasting across the networks

Things get a bit complex when multicast IP packets have to traverse across networks because of that fact that multiple routers come into the scenario. Each router that comes in path should support multi-casting and should contain forwarding entries for multicast packets. Whenever a client joins a multicast group, a distribution tree is created for it which specifies the path for the multicast traffic corresponding to this multicast connection. Talking about routers, it is helpful to get yourself comfortable with the route command examples.
Multiple routers can be part of a distribution tree and one router can be part of multiple distributions trees. It means that if a router is a part of X distribution trees then it must contain X number of forwarding entries where each entry would correspond to a distribution tree.

Multicasting Vs Broadcasting

Multicasting can be a good alternative to broadcasting in some scenarios like when a client needs a bootstrap server to boot-up. Generally it is done by sending broadcast packets but this results in packet processing by those hosts also that do not provide this service. While if the same is done through multicast messages then the requests would get received by only those hosts that provide this service.

No comments:

Post a Comment