multicast

Introduction

With the development of computer networks and the popularization of personal computers, people can easily swim on the Internet, conduct network communications or obtain the information resources they need. In addition, people are increasingly relying on network computing. Most companies have established advanced networks to connect employees with their computers and workstations. Sometimes, important information in our work can only be obtained through the Internet. This information may be on the company’s private network or on the Internet.

The Internet is a public network that connects universities, companies, non-profit organizations, individuals, and government agencies all over the world. With the development of broadband now, emerging Internet applications such as distance learning, video conferencing, and online games have become more and more popular and sometimes become necessary. These applications involve point-to-point or multipoint-to-multipoint communication, which is very different from traditional unicast or broadcast.

In 1988, Deering proposed the concept of IP multicast. Since then, IP multicast technology has received widespread attention. Multicast is between unicast communication and broadcast communication. It can send data packets sent by the sender to a group of receivers scattered in different subnets.

The basic concept of multicast is "group". A multicast group is a group of recipients who wish to receive a specific data stream. This group has no physical or geographic boundaries: the hosts in the group can be located anywhere on the Internet or private network. Each node in the multicast group is called a multicast group member.

In many applications of multicast, unicast can be achieved, but with the increase of receivers, the number of data packets that need to be sent increases linearly. For a single receiver, the same data packet needs to be sent In this way, the traffic will increase exponentially, which will also occupy a lot of network bandwidth and sometimes cause network congestion. But the multicast communication IP data packet is sent only once. The router will automatically forward to each receiver located on a different network segment, which can be the smallest number of message copies transmitted in the network. So multicast is very necessary.

A key feature of the multicast communication model is to provide an indirectly identified multicast group, in which neither the sender nor the receiver need to know the specific situation of the other party. The sender only needs to send packets to a multicast address and the receiver only needs to tell the network that it wants to receive packets sent to this address.

To send user data from one terminal to another, the transmission route must first be determined. Different communication methods have different ways to determine the route. Nowadays, there are mainly the following communication methods in the network:

  • Unicast (unicast: pointtopoint), a point-to-point communication method;

  • Multicast (multicast: pointtOmultipoint), a point-to-multipoint communication method;

  • Concast (concast: multipointtopoint), a point-to-point communication method;

  • MultipointtOmultipoint, a multipoint-to-multipoint communication method, a promotion of multicasting;

  • Broadcast (broadcast: pointtoallpoint), point to all nodes communication mode.

Generally, services that require multicast services have high bandwidth and real-time requirements, involve more users, and take up more resources. Therefore, it is necessary to optimize multicast routing. The multicast routing algorithm is to find the optimal multicast tree. An ideal and effective routing algorithm will design a tree that only covers the members of the multicast group, and reflect the following characteristics: the tree is dynamically updated with the changes of the group members; the minimum node needs to be saved The amount of state information; avoids the concentration of traffic on links and nodes; optimizes routing according to the cost function.

Network multicast

IP multicast (also known as multicast or multicast) technology is a technology that allows one or more hosts (multicast sources) to send a single data TCP/IP network technology that packages to multiple hosts (once, at the same time). Multicast, as a point-to-multipoint communication, is one of the effective ways to save network bandwidth. In the application of network audio/video broadcasting, when the signal of one node needs to be transmitted to multiple nodes, whether it is repeated point-to-point communication or broadcast, it will seriously waste network bandwidth. Only multicast is the best s Choice. Multicast enables one or more multicast sources to only send data packets to a specific multicast group, and only hosts that join the multicast group can receive the data packets. At present, IP multicast technology is widely used in network audio/video broadcasting, AOD/VOD, network video conferencing, multimedia distance education, "push" technology (such as stock quotes, etc.) and virtual reality games.

Some applications have such a requirement: some distributed processes need to work together in a group, and the processes in the group usually send messages to all other members. That is, there is such a method that can send messages to some clearly defined groups. Although the number of members of these groups is large, it is small compared with the size of the entire network. Sending a message to such a group is called multicast, or multicast for short.

1. IP multicast address and multicast group

IP multicast communication must depend on the IP multicast address. In IPv4, it is a class D IP address ranging from 224.0.0.0 to 239.255.255.255 and is It is divided into three types: local link multicast address, reserved multicast address and management authority multicast address. Among them, the local link multicast address range is 224.0.0.0~224.0.0.255, which is reserved for routing protocols and other purposes. The router does not forward IP packets belonging to this range; the reserved multicast address is 224.0.1.0~ 238.255.255.255, which can be used on a global scale (such as the Internet) or network protocols; the management authority multicast address is 239.0.0.0~239.255.255.255, which can be used within the organization. It is similar to a private IP address and cannot be used on the Internet. It can be more restrictive. Broadcast range.

All hosts that use the same IP multicast address to receive multicast packets form a host group, also known as a multicast group. The membership of a multicast group changes at any time. A host can join or leave the multicast group at any time. The number of members of the multicast group and the geographic location are also not limited. A host can also belong to several multicast groups. . In addition, hosts that do not belong to a certain multicast group can also send data packets to the multicast group.

2. Hardware support for IP multicast technology

To realize IP multicast communication, routers, hubs, switches, and hosts between the multicast source and receiver must all support IP multicast. At present, IP multicast technology has been widely supported by hardware and software manufacturers.

(1) Host

The platforms that support IP multicast communication include WindowsCE2.1, Windows95, Windows98, WindowsNT4 and Windows2000, etc. Hosts running these operating systems can perform IP multiple Broadcast communication. In addition, almost all of the newly produced network cards also provide support for IP multicast.

(2) Hubs and switches

Currently, most hubs and switches simply treat multicast data as broadcasts to send and receive, but some medium and high-end switches provide multiple IP addresses. Broadcast support. For example, the 802.1p or IGMP multicast filtering function can be enabled on the 3COMSuperStack3Swith3300 switch to forward multicast packets only for the ports that have detected IGMP packets.

(3) Router

Multicast communication requires that all routers between the multicast source node and the destination node must provide Internet Group Management Protocol (IGMP), multicast routing protocol ( Such as PIM, DVMRP, etc.) support.

When a host wants to join a multicast group, it will send out an IGMP message of "Host Membership Report" to notify the multicast router. When the multicast router receives the data sent to that multicast group, it will forward it to all multicast hosts. The multicast router will also periodically send out the "host member query" IGMP message to query the multicast host from the subnet. If it finds that a multicast group has no members, it will stop forwarding the multicast group's data. In addition, when a host that supports IGMPv2 (such as a Windows 98/2000 computer) exits a multicast group, it will also send a "leave group" IGMP message to the router to notify the router to stop forwarding the multicast group's data. But only when all hosts on the subnet exit a multicast group, the router will stop forwarding the multicast group's data to the subnet.

Using the multicast routing protocol, the router can establish a multicast routing table from the multicast source node to all destination nodes, so as to realize the forwarding of multicast data packets between subnets. For example, PIM (Protocol Independent Multicast) is a multicast routing protocol, which has two types: sparse-mode and dense-mode. Taking the Cisco2621 router as an example, the basic settings for enabling the IP multicast forwarding function are as follows:

c2621(config)#ipmulticast-routing enables IP multicast to make the router a multicast router

c2621(config)#intf0/0Configure Fast Ethernet port 0

c2621(config-if)#ippimdense-mode (or sparse-mode) start PIM and activate IGMP protocol at the same time

c2621(config-if)#intf0/1 Configure Fast Ethernet Port 1

c2621(config-if)#ippimdense-mode (or sparse-mode)

Programming method

In practical applications, programmers usually need to compile low-level network applications by themselves to realize the low-level communication on the Internet, such as the specific realization of the function of IP multicast communication. The programming of low-level network applications usually requires the help of network data communication programming interfaces, and the network programming interfaces provided in different operating systems are different. For example, the network programming interface in the Microsoft Windows environment is Windows Socket (WindowsSocket). , Winsock for short).

Winsock provides programming interfaces under various communication protocols including TCP/IP and IPX. Different Windows versions support different Winsock versions. Earlier versions such as Windows 95 only support programming under Winsock 1.1 (16-bit) (you can install related software packages to support Winsock 2.0), while Windows 98 and Windows NT 4.0 , Windows2000 directly supports Winsock2.0 (32-bit). Winsock 2.0 is an extension of Winsock 1.1. In addition to being compatible with Winsock 1.1 API, it also defines a set of protocol-independent APIs that can support IP multicast.

The general steps of using Winsock2.0 to realize IP multicast are as follows:

1. Initialize Winsock resources

Before using Winsock, you must call the WSAStartup() function to initialize WindowsSocketsDLL. It allows the application or DLL to specify the version required by the WindowsSocketsAPI.

2. Create a socket

Call the WSASocket() function to create a socket using the UDP protocol, which is the initial socket to join the multicast group, and later data is sent and received in this socket On the connection. For IP multicast communication, the parameter dwFlags can be set to the bit sum of WSA_FLAG_MULTIPOINT_C_LEAF, WSA_FLAG_MULTIPOINT_D_LEAF and WSA_FLAG_OVERLAPPED, indicating that IP multicast communication is "rootless" at the control level and data level, and only leaf nodes exist, and they can be added to any one of them. Multicast group, and the data sent from a leaf node will be transmitted to each leaf node (including itself); the created socket has overlapping properties.

3. Set socket options

Call the setsockopt() function to set the SO_REUSEADDR option for the socket to allow the socket to be bound to an address that is already in use.

4. Bind the socket

Call the bind() function to bind the socket, so as to associate the created socket with the local address and local port. For multicast communication, the same port is usually used for sending and receiving data.

5. Set the mode of the multicast socket

The command code SIO_MULTICAST_LOOP of the WSAIoctl() function is used to allow or prohibit whether the communication traffic sent out during multicast communication can also be received on the same socket ( That is, multicast return). It is worth noting that in Windows95/98/NT4, the default is to allow multicast return, but you cannot set prohibition, otherwise an error will occur; only in Windows2000 and above, you can set allow/prohibit multicast return.

The command code SIO_MULTICAST_SCOPE of the WSAIoctl() function is used to set the range of multicast propagation, that is, the time to live, TTL. Whenever a multicast router forwards a multicast data packet, the TTL value in the data packet will be reduced by 1. If the TTL of the data packet is reduced to 0, the router will discard the data packet. What is the value of TTL, how many multicast routers the multicast data can pass through at most. For example, if the TTL value is 0, the multicast can only be propagated among multiple sockets of the local host, but cannot be propagated to the "network cable"; if the TTL value is 1 (the default value), the multicast data encounters the first A router will be "relentlessly" discarded by it and will not be allowed to be transmitted outside the local network, that is, only multicast group members in the same network can receive multicast data.

In c#, the general proxy instance (referring to a proxy can only call one method) is defaulted to the object of the Delegate class, so the delegate keyword is usually used to define the proxy, and the new operator is used to create the proxy instance , And then use the methods and properties of the Delegate class to manage the proxy instance. The MulticastDelegate class is used to support multiple agents, and the call list can have agents with multiple methods.

Multiple agents refer to a group of agents forming a set. An object of the MuticastDelegate class manages the agent set, and uses this agent set to execute multiple methods. This function is called multicast.

Related Articles
TOP