One disadvantage of broadcast is that it affects all computers in the subnet, even if they are not interested in this broadcast message. Multicast can solve this problem.
Multicast adopts Promotion Technology(Browsing Web pages is a drawing technology, and also a pushing technology.EmailService). Multicast is also called multicast. If a user joins a multicast group, it can receive data sent to the group.
Multicast ApplicationDClassIPAddress (224.0.0.0-239.255.255.255), But it does not mean that the computer that receives data from each multicast group must haveDClassIPAddress. Multicast Group needsDClassIPAddress.DClassIPAddress is divided into several disconnections, some of which have special purposes.
Multicast has two application modes. One is that any user in a group sends messages, and other users can receive messages. The status of each user is equivalent. The other is that only one user sends information, and the other users only receive information.
The topology of multicast is a tree structure.
Hardware that must support multicast and MulticastTCP/IPProtocol stack, supporting multicast software. To join a multicast group, you must useSgmp(Simple Group Management Protocol) Protocol. Another message is sent to multicast.TTL (time to live)Value so that the multicast information does not pass through many subnet boundaries. The default value isTTLThe value is1That is, it is only valid for the local subnet.
C #Support for Multicast
Multicast programming needsUDP,Two classes support multicast network programming.Socket,AndUdpclient.A computer must join a group to receive information sent to a group.SocketClass to callSetsocketoptionAdd and remove functions from a group.UdpclientClass can be called by directly adding or leaving a group of member functions. To send a message to a group, there is nothing special. You only need to set the destination address of the sent data as the multicast address.
Problem:
Q:UDP ServerJoin a multicast group, bind a port, and start to receive data. what data can be received?
A: You can receive data sent to this multicast group port, broadcast data sent to this port, and unicast data sent to this port.
Q :(1) How to know the situation of multicast groups around you (DClassIPAddress occupied )? (2) Can I create a multicast group just by programming? (No information found)
A :(1. (2). Yes,SocketSend data to the port of a fixed multicast address, then a multicast group is established, and other computers can join the Group marked by this address to receive information.(Of course, hardware and software protocols are required. In addition, the value of this multicast address is also limited, and the multicast address is similar192.168.0.0The IP address that is used only for the LAN and is not routed.)