1 / 12

Multicasting Program

Multicasting Program. Multicasting (1). Described in RFC1112 (August 1989) Multicasting allows distribution of a datagram to a group of listeners who are not within the local network Routers between networks need to pass multicast datagrams. . but many do not!

Download Presentation

Multicasting Program

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. MulticastingProgram

  2. Multicasting (1) • Described in RFC1112 (August 1989) • Multicasting allows distribution of a datagram to a group of listeners who are not within the local network • Routers between networks need to pass multicast datagrams. . but many do not! • The MBONE is a way of tunneling datagrams across the Internet between islands of multicast activity

  3. Multicasting (2) • Multicasts are also sent to a special address (known as a “group”) • Multicast groups need to be agreed in advance. They are not derived from a specific network/host address • Multicast groups identify a subject area (or stream of content) rather than a specific computer or network. They are more like a TV channel number than a telephone number. • The IETF has set aside addresses from 224.0.0.1 to 239.255.255.255 specifically for multicasting

  4. Multicasting (3) • To send to (or receive from) a multicast group it is first necessary to register interest in the group • This results in an Internet Group Management Protocol (IGMP) message being sent to your router (RFCs 988/1112/2236) • Then a datagram is created, addressed to the group (and the chosen port) • Java has a specialised socket for multicasting: java.net.MulticastSocket

  5. Some multicast groups • 224.0.0.1 All hosts within local subnet • 224.0.1.7 Audio news multicast • 224.0.1.12 Video from IETF meetings • 224.0.1.20 Expts. within local subnet • 224.0.1.25 NBC Professional News • There are 268 million multicast addresses (in IPv4) with 65 thousand ports in each!

  6. java.net.MulticastSocket • Subclass of java.net.DatagramSocket • Constructed the same way • Adds some extra methods: • void joinGroup(InetAddress mcastGroup) • Enter the specifies group so that you can send or receive datagrams • void leaveGroup(InetAddress mcastGroup) • Leave a group that you previously joined • void setTimeToLive(int ttl) • Sets how far your datagrams will travel before routers ignore them • int getTimeToLive()

  7. sea.datagram.MulticastSender • Sending similar to the previous example. . • . . .but must register with the multicast group and decide the longevity • The steps involved are: • Create the MulticastSocket. • Join the multicast group(s) (on startup). • Create the DatagramPacket. • Send the packet through the socket. • Leave the multicast group (on exit).

  8. sea.datagram.MulticastSender InetAddress multicastGroup = InetAddress.getByName(multicastGroupAddr); MulticastSocket socket = new MulticastSocket(); socket.joinGroup(multicastGroup); socket.setTimeToLive(5); byte[] data = “This is the message”.getBytes(); DatagramPacket datagram = new DatagramPacket(data, data.length); datagram.setAddress(multicastGroup); datagram.setPort(9876); socket.send(datagram); socket.leaveGroup(multicastGroup);

  9. sea.datagram.MulticastReceiver • The steps are: • Create a multicast socket on an agreed port. • Join the multicast group (on startup). • Create an empty datagram. • Wait for datagram to be delivered on the socket. • Unpack and use the datagram. • Leave the multicast group (on exit).

  10. sea.datagram.MulticastReceiver InetAddress multicastGroup = InetAddress.getByName(multicastGroupAddr); MulticastSocket socket = new MulticastSocket(9876); socket.joinGroup(multicastGroup); byte[] data = new byte[1000]; DatagramPacket packet = new DatagramPacket(data, data.length); socket.receive(packet); String message = new String( packet.getData(), 0, packet.getLength()); socket.leaveGroup(multicastGroup);

  11. Useful sources of information • The Internet Engineering Task Force (IETF) which is at http://www.ietf.org -- you will be able to download RFCs from here • Multicasting try reading the HOWTO which is available from the URL: http://ftp.southcom.com.au/LDP/HOWTO/...Multicast-HOWTO.html

  12. Homework • Read through the code samples to convince yourself you understand what’s going on • Sample code can be downloaded from http://ciips.ee.uwa.edu.au/~gareth • If you can, run the examples

More Related