Why multicast:
When the network adapter receives a 1-bit data report corresponding to the target physical address from the network, it will receive this message and upload it to the driver, this work mode of the network adapter is called broadcast mode. The default work mode of the network adapter includes direct mode and broadcast mode. With this feature, UDP (User Datagram Protocol) also provides the ability to send broadcast data packets to multiple target addresses. Broadcast data is sent from a workstation. As long as all bits corresponding to the destination physical address of the data packet are set to 1, all workstation NICs in the LAN will receive this message and upload it to the driver. This feature applies to connectionless protocols because all machines on the LAN can obtain and process broadcast messages. The disadvantage of using broadcast messages is that each machine must process the messages. For example, if a user broadcasts a message on a LAN, the NIC on each machine will receive the message and upload it to the network stack (the driver is complete). Then, stack compares the destination port number of the message with the port number specified in all network applications running on the host to see if they are equal, this determines which network application should receive the message. Generally, most machines on the LAN are not interested in the message and are discarded. However, each machine still needs to spend time processing the data packet in the driver to check whether the application is interested in it. As a result, high-broadcast communication streams make machines on the LAN in trouble because each workstation needs to check this packet.
There are some special physical addresses that cannot be used as the actual physical addresses of any network adapter, however, the NIC can be set to not filter frames received from the network that use one or more of these physical addresses as the destination physical addresses. These physical addresses are called multicast transfer addresses, and the network adapter's working mode is called multicast transfer mode.
"Multicast" is also called "multi-point transmission" (Multicast). A package sent by a host can be received by multiple other qualified hosts at the same time, this host and those qualified hosts form a group, and their communication within the group is broadcast-type. The principle of multicast is to set the NIC of some hosts on a network to multicast transmission mode, specify that it does not filter data frames with a multicast transfer address as the destination physical address. In this way, the drivers of these hosts can receive data frames with the multicast transfer address as the destination physical address at the same time, but the drivers of other hosts cannot, these Hosts form a "Multicast" group logically. This technology can effectively reduce the burden on hosts other than multicast groups on the network, because the data sent to the multicast group will not be transmitted to their drivers for processing, avoiding unnecessary waste of resources. At the beginning, the purpose of designing this technology was to make up for the lack of broadcasting communication.
Multicast can be implemented in two ways:
1. Set the NIC to the hybrid mode, and then filter all received packets through the driver, leaving the data packets of the specified multicast address.
This method is less efficient and is suitable for NICs that do not support multicast mode.
2. Set the NIC multicast mode. The NIC has a multicast filter, and the NIC can determine whether the incoming data packets belong to multicast data.
Because multicast filtering is completed by hardware, the efficiency is relatively high.
The network adapter only receives frames whose destination address is the physical address of the network adapter and multicast address (broadcast is a type of multicast. For Ethernet, the maximum bytes of the multicast address are 1 (01: 00: 00: 00: 00: 00)
For IP multicast, the IP multicast address is converted to an Ethernet multicast address. An Ethernet multicast address can correspond to multiple IP multicast addresses.
Therefore, the device driver or IP layer must filter data packets because the NIC may receive multicast data frames that the host does not want to receive. When the NIC does not provide sufficient multicast data frame Filtering functions, you must set the NIC to "hybrid mode". The driver checks whether the received data frame is required by the host.
That is to say, the two implementation modes of multicast must be filtered by the driver. However, if they are filtered by the NIC, the workload of the driver can be reduced.
A multicast address is a set of host identifiers that have been added to a multicast group. In Ethernet, the multicast address is a 48-bit identifier, naming a group of sites that should be received by an application in this network. In IPv4, it is historically called Class D address, a type of IP address, which ranges from 224.0.0.0 to 239.255.255.255. Class D addresses are used for multicast.
Broadcast address (broadcast address) is an address used to send messages to all workstations in the network at the same time. In a network that uses the TCP/IP protocol, the host ID segment is the IP address of all 1
The address is the broadcast address, and the broadcast group is sent to all computers involved in the host ID segment. For example, for the 10.1.1.0 (255.255.255.0) network segment, the broadcast address is 10.1.1.255 (255 is a binary 11111111). When a packet whose destination address is 10.1.1.255 is sent, it will be distributed to all computers on the CIDR block.