1 / 11

IP multicasting

SWE 344 Internet Protocols & Client Server Programming. IP multicasting. What is multitasking?. IP multicasting was devised to allow an application to send a single packet to a select subset of devices both on the local subnet and across network boundaries .

gautam
Download Presentation

IP multicasting

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SWE 344 Internet Protocols & Client Server Programming IP multicasting

  2. What is multitasking? IPmulticasting was devised to allow an application to send a single packet to a select subset of devices both on the local subnet and across network boundaries. This feature allows an application to join a multicast group to participate in a wide-area conference. The IP multicasting scheme uses a particular range of IP addresses to designate different multicast groups. Each multicast group consists of a group of devices listening to the same IP address. As packets are sent out destined for the multicast group address, each device listening to the address receives them. The IP address range 224.0.0.1 through 239.255.255.255 represents multicast groups.

  3. IP Multicast Address Assignments According to Internet Request For Comments (RFC) 3171, the groups are divided as shown in Table

  4. Multicast Techniques • There are two techniques used to control multicast sessions: • A peer-to-peer technique, in which all clients can send messages to all • other clients in the group. • A central server that sends messages to group clients 1) Peer-to-Peer Technique In a peer-to-peer multicast group all of the clients in the multicast group have equal rights in the group. Any client in the group has the capability to exchange messages with any other client in the group. There are no restrictions on which clients can join a multicast group.

  5. 2) Central Server A central server (single device) on the network that controls all multicast group activity. An individual client wanting to join the multicast group must ask permission from the central server. If the central server denies the client access to that multicast group, no multicast packets will be forwarded to the requesting client.

  6. C# IP Multicast Support • The .NET network library supports IP multicasting by using Socket options. • Once a Socket object is created, it can be set to join a multicast group or to leave a multicast group that it has previously joined. • This technique is used for UdpClientobjects, as well. • The Socketclass supports IP multicasting by using the SetSocketOption() method of the socket • There are two socket options that can be used for multicasting: • Adding the socket to a multicast group • Removing the socket from a multicast group • Both of these options are defined by IP-level Socket option names, AddMembership and DropMembership.

  7. The value parameter of the SetSocketOption() method is not a normal data value. Instead, it uses the MulticastOption class. The MulticastOption class defines the multicast group that the socket will be added to or removed from. These two constructors are used for the MulticastOption class: MulticastOption(IPAddress) MulticastOption(IPAddress,IPAddress) The first constructor is to allow all interfaces on the system to be affected by the SetSocketOption() method. The second constructor wants to limit the action to an individual network interface on the system. For example, if you wanted to add a socket to the multicast group 224.100.0.1, you would use the following statement: sock.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("224.100.0.1")); This sets the socket to join the multicast group for all interfaces on the system.

  8. Receiving Multicast Packets This program sets a socket to receive multicast packets destined for the 224.100.0.1 multicast group. This program creates a UDP socket in the normal way, using the standard Socket class methods. After being added to the multicast group, the socket blocks on a ReceiveFrom() method call, waiting for data to arrive. using System; using System.Net; using System.Net.Sockets; class MultiRecv { public static void Main() { Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); Console.WriteLine("Ready to receive…"); IPEndPointiep = new IPEndPoint(IPAddress.Any, 9050); EndPointep = (EndPoint)iep; sock.Bind(iep); sock.SetSocketOption(SocketOptionLevel.IP,SocketOptionName.AddMembership, new MulticastOption(IPAddress.Parse("224.100.0.1")));

  9. byte[] data = new byte[1024]; intrecv = sock.ReceiveFrom(data, ref ep); string stringData = Encoding.ASCII.GetString(data, 0, recv); Console.WriteLine("received: {0} from: {1}", stringData, ep.ToString()); sock.Close(); } } Sending Multicast Packets For sending multicast packets you just specify the multicast group IP address as the destination address of the packet. using System; using System.Net; using System.Net.Sockets; class MultiSend { public static void Main() { Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPointiep = new IPEndPoint(IPAddress.Parse("224.100.0.1"), 9050); byte[] data = Encoding.ASCII.GetBytes("This is a test message"); server.SendTo(data, iep); server.Close(); } }

  10. Discuss: Multicast application - the chat(TCP) program sends packets to the 224.100.0.1 multicast IP address and any clients listening to that multicast group will receive the messages.

  11. END

More Related