What is multicast
Unicast is used for end-to-end communication between two hosts, which is used for data communication of a host on all hosts on the local network. Unicast and broadcast are two extremes, either communicating to a single host or communicating to a host on the entire LAN. In practice, it is often necessary to communicate with a specific set of hosts, rather than all hosts on the entire LAN, which is the purpose of multicasting.
Multicast, also known as "multicast", the LAN is the same business type of host logically grouped, the data sent and received only in the same group, other hosts did not join this group can not send and receive the corresponding data.
Multicast addresses are specific and Class D addresses are used for multicast. Class D IP address is a multicast IP address, that is, the IP address between 224.0.0.0 and 239.255.255.255, and is divided into local connection multicast addresses, reserved multicast addresses and administrative rights multicast address 3 categories:
Local multicast address: Between 224.0.0.0~224.0.0.255, this is the address reserved for routing protocols and other purposes, and routers do not forward IP packets that belong to this range.
Reserved multicast addresses: Between 224.0.1.0~238.255.255.255, available on a global scale (such as the Internet) or network protocols.
Administrative rights multicast Address: Between 239.0.0.0~239.255.255.255, for use within the organization, similar to private IP address, not to the Internet, can limit multicast scope.
Addresses that belong to a permanent group:
224.0.0.1 All Multicast hosts
224.0.0.2 All multicast routers
224.0.0.4 DRMRP Router
224.0.0.5 all OSPF routers
224.0.0.6 OSPF assigned router
224.0.0.9 RPIV2 Router
224.0.0.10 EIGRP Router
224.0.0.13 PIM Router
224.0.0.22 IGMPv3
224.0.0.25 Rgmp
224.0.1.1 NTP Network Time protocol IP to Ethernet address mapping
Because Ethernet supports multiple protocols, you should take measures to allocate multicast addresses to avoid conflicts. IEEE manages Ethernet multicast address allocation. IEEE Points an Ethernet multicast address to the IANA to support IP multicasting. The address of the block begins with 01:00:5e. The 25th digit is 0, the low 23 bit is the low 23 bit of the IPV4 multicast address. The mapping relationship between the IPV4 multicast address and the MAC address is shown in the figure:
Because the highest 5bit in the multicast group number is ignored during the mapping process, the multicast group corresponding to each Ethernet multicast address is not unique. 32 different multicast group numbers are mapped to an Ethernet address. For example, a multicast address
224.128.64.32 (hexadecimal e0.80.40.20) and 224.0.64.32 (hexadecimal e0.00.40.20) are mapped to the same Ethernet address 01:00:5e:00:40:20.
Multicast Host
Multicast hosts are divided into three levels:
Level 0: Host cannot send or receive I P multicast.
Such a host should automatically discard packets it receives that have a class D destination address.
Level 1: Host can send but not receive I p multicast.
The host is not required to join this group until a datagram is sent to an I p multicast group. A multicast datagram is sent in the same way as a unicast, except that the destination address of the multicast datagram is the I p multicast group. The network drive must be able to recognize this address and multicast datagrams on the local network.
Level 2: Host can send and receive I P multicast.
In order to receive the I p multicast, the host must be able to join or leave the multicast group, and must support IGMP to Exchange group member information on at least one interface. Multi-interface host must support multicast n ET/3 on one subnet of its interface to meet level 2 host requirements, and can complete the work of multicast routers. As with unicast IP routing, we assume that the described system is a multicast router and adds a NET/3 multicast route selection program.
Linux Multicast Programming
Linux Multicast Programming steps:
1> establish a socket;
2> Set multicast parameters, such as timeout time ttl, local loop permit loop, etc.
3> Join multicast Group
4> send and receive data
5> away from multicast group
Multicast programming is implemented using the setsockopt () function and the getsockopt () function, and the multicast option is the IP layer.