Introduction: Currently, multipoint broadcast applications are very broad. As the network's bandwidth is increasing and the utilization of multimedia flows, broadcasting will become a widely utilized approach in the near future. What is IP multiple broadcast? IP multiplexing is a broadband storage technology that can be used to solve the information crowd on the network, send a single information flow by simultaneously transmitting thousands of recipients. His feature is that it is inexlable and there is no reverse signal. This point of view can be considered to be similar to the broadcast between satellites and television. A single satellite sends information to many recipients on the ground, transmitting information along the router and host passing through the transmission path, while these routers and hosts can copy the data stream, and send them to other routers and hosts.
IP multiplexing needs: All routers passing through data throughout the IP multiplex broadcast must be available. For Internet broadcasts, all transmission devices must be MBONE (a multimedia skeleton structure, which can be transferred on a global transmission image). However, as more and more manufacturers have developed routers that support IP broadcasts, Mbone will gradually withdraw from the historical stage. System needs: 1. Support for IP multiplexed operating systems, such as Windows2000, XP. Berkeley Sockets, Windows Sockets 2 and Apple Macintosh Open Transport support IP multiplexing.
2..NET Framework API. Microsoft.NET Framework provides a hierarchical, scalable and jurisded web service for the application, and its namespace system.net and system.net.sockets include rich classes to develop A variety of web applications. The hierarchical structure adopted by the .NET class allows the application to access the network at different levels, developers can choose to make different levels of programming as needed, almost all incorporated all needs - from Socket sockets Ordinary request / response, more importantly, this hierarchy can be extended and can adapt to the need for Internet's continuous expansion.
Here, I will provide an example to implement IP multiplexing through C # 1. Send data to a broadcast group because it is unidirectional transmission, so there is no need to shake hands, here we use UDP protocols. // Create a socket
Socket S = New Socket (addressFamily.Internetwork, _ sockettype.dgram, _ protocoltype.ud);
//AddressFamily.InterneTWork IP version 4 address.
//Sockettype.dgram supports the data textbook, that is, the maximum length (usually small) is unconnected, unreliable message. The message may // will be lost or repeated and may not be arranged in sequence when arriving. The DGRAM type Socket does not need to // before sending and receiving data, and can communicate with multiple other hosts.
// SocketType Implicit indicates which protocoltype will be used in AddressFamily. For example, when sockettype // is DGRAM, ProtocolType is always UDP. When SocketType is stream, ProtocolType is always // TCP.
// The effective IP address of the multiple broadcast packet is between 224.0.0.0 to 239.255.255.255.
Ipaddress ip = ipaddress.parse ("224.5.6.7");
S.setSocketoption (socketoptionlevel.ip, _ socketoptionname.addmembership, _ new_multicastoption (ip)); // socketoptionlevel parameter explanation: // IP socket option is applied to IP socket. // Socket socket option is applied to the socket itself. // TCP socket option is applied to the TCP socket. // UDP socket option is applied to the UDP socket. //Socketoptionname.addmembership // Addmembership Add an IP group member. S.SetSocketoption (socketoptionlevel.ip, socketoptionname.multicastTIMETOLIVE, 2); //socketoptionname.multicastTIMETOLIVE IP multiplexed survival time. IpendPoint Ipep = New IpendPoint (IP, 4567); S.Connect (IPEP);
// Create a transmitted data abcdefghij byte [] b = new byte [10]; for (int x = 0; x // Send data S.send (B, B.Length, SocketFlags.none); // Close Socket S.Close (); 2. A multi-channel receiving data program: We have sent letters Abcdefghij to broadcast group 224.5.6.7 through port 4567. All listening programs will receive this set of data Socket S = New Socket (AddressFamily.Internetwork, sockettype.dgram, protocoltype.ud); // Create a Socket with a similar method similar to the sender IpendPoint Ipep = New IpendPoint (iPaddress.Any, 4567); S.Bind (IPEP); / / Any IP of any listening port is 4567 will receive data Ipaddress ip = ipaddress.parse ("224.5.6.7"); S.SetSocketoption (socketoptionledLevel.ip, _ socketoptionname.addmembership, _ new multicastoption (ip, ipaddress.any)); // Add Socket to the broadcast group 224.5.6.7. Byte [] b = new byte [1024]; s.Receive (b); string str = system.text.Encoding.ascii.getstring (b, 0, b.length); console.writeline (Str.Trim ()) ; / / So we can receive any data issued by this broadcast group.