Tuesday 9 June 2015

Ping - broadcast and multicast

The range of IP addresses is divided into "classes" based on the high order bits of a 32 bits IP address:

   Bit -->  0                           31            Address Range:
           +-+----------------------------+
           |0|       Class A Address      |       0.0.0.0 - 127.255.255.255
           +-+----------------------------+
           +-+-+--------------------------+
           |1 0|     Class B Address      |     128.0.0.0 - 191.255.255.255
           +-+-+--------------------------+
           +-+-+-+------------------------+
           |1 1 0|   Class C Address      |     192.0.0.0 - 223.255.255.255
           +-+-+-+------------------------+
           +-+-+-+-+----------------------+
           |1 1 1 0|  MULTICAST Address   |     224.0.0.0 - 239.255.255.255
           +-+-+-+-+----------------------+
           +-+-+-+-+-+--------------------+
           |1 1 1 1 0|     Reserved       |     240.0.0.0 - 247.255.255.255

Every IP datagram whose destination address starts with "1110" is an IP Multicast datagram.
The remaining 28 bits identify the multicast "group" the datagram is sent to. You need to tune radio and kernel to receive packets sent to an specific multicast group. This is called joining a multicast group.

Some of the special (well known/reserved) multicast groups are:
·         224.0.0.1 is the all-hosts group. If you ping that group, all multicast capable hosts on the network should answer, as every multicast capable host must join that group at start-up on all it's multicast capable interfaces.
·         224.0.0.2 is the all-routers group. All multicast routers must join that group on all it's multicast capable interfaces.

Multicast ping: 
Get multicast address using "netstat -g" command

$ netstat -g
IPv6/IPv4 Group Memberships
Interface       RefCnt Group
--------------- ------ ---------------------
eth1            1      224.0.0.251
eth0            1      224.0.0.251

Ping to multicast address, you will get reply from multicast registered IPs.

$ ping -I eth0 224.0.0.251
PING 224.0.0.251 (224.0.0.251) from 11.191.136.143 eth0: 56(84) bytes of data.
64 bytes from 11.191.136.223: icmp_req=1 ttl=64 time=0.249 ms
64 bytes from 11.191.136.222: icmp_req=1 ttl=64 time=0.257 ms (DUP!)


Ping to all-host multicast address.
$ ping -I eth0 224.0.0.1

Broadcast ping:

$ ping -I eth0 -b 255.255.255.255

No comments:

Post a Comment