Multicast sockets - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Multicast sockets

Description:

Sends data from one host to many different hosts, but not to everyone ... Used to implement various caching for the Internet which will help with the internet's growth ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 15
Provided by: v5o5jotqkg
Category:

less

Transcript and Presenter's Notes

Title: Multicast sockets


1
Multicast sockets
  • Lecture 9

2
What is Multicast Socket?
  • Sends data from one host to many different hosts,
    but not to everyone
  • Data goes only to clients who have expressed an
    interest by joining a particular multicast group.
  • People can come and go as they please, leaving
    when the discussion no longer interests them
  • Several copies of the data traverse the internet
  • Load can be minimized by carefully choosing where
    the pkts are duplicated
  • Internet routers handle the duplication process

3
Why multicasting.
  • IP also supports broadcasting, but use of
    broadcasts is strictly limited
  • Protocols require broadcast only when there is no
    alternative routers usually limit broadcast to
    the local net subnet, preventing it to reach
    the Internet.
  • Few broadcasts can bring Internet to knees
  • Broadcasting high-bandwidth data such as
    audio/video/text/imagesis out of question
  • A single email spam that goes to millions of
    addresses is bad enough!!

4
The choice
  • Technology that send data to a number of hosts
    (1000 clients) that need it
  • Data is sent 1000 times
  • Broadcast the data to every host on the internet
  • Create static connection trees (Usenet)
  • Multicasting
  • Multicasting is half-way between p2p and
    broadcasting
  • When a pkt is multicast it will not go to a
    single host (unicast) neither will it go to all
    hosts (broadcast), but sent to all host belonging
    to the group.

5
Uses of multicast
  • Audio video applications
  • Multiplayer games
  • Distributed file system
  • Massively parallel computing
  • Multi-person conferencing
  • Database replication
  • Name services directory services
  • Apples Rendezvous Suns Jini use IP
    multicasting to dynamically discover services on
    the local network

6
Uses cont..
  • Used to implement various caching for the
    Internet which will help with the internets
    growth
  • A high traffic web server can be split between a
    number of m/cs using multicast address
  • Multicasting is designed to fit seamlessly into
    the internet. Challenge remains to work in
    ubiquitous routers.

7
Multicast addresses and groups
  • Multicast addresses are IP addresses in the range
    224.0.0.0 to 239.255.255.255. All addresses in
    this range has 1110 as their first four bits.
  • They are called class D addresses
  • A multicast group is a set of internet hosts that
    share a multicast address. Any data send to the
    group is relayed to all the members of the group
  • Membership in a multicast group is open. Hosts
    can enter or leave at anytime
  • Groups can be either permanent or transparent
    (most are)
  • To create a new multicast group, pick a random
    address from 225.0.0.0 to 239.255.255.255.
    Construct an InetAddress object for that address
    and start sending it data.

8
Special purpose multicast addresses
  • allsystem.mcast.net at 224.0.0.1 is a multicast
    group to include all systems that suppory
    multicast on local net
  • Experiment.mcast.net _at_224.0.1.20 is used for
    local testing
  • All addresses beginning with 224.0.0.0 to
    224.0.0.255 are reserved for routing protocols

9
Multicast sockets
  • Makes use of Datagram sockets
  • Java.net.MulticastSocket class is a suclass of
    java.net.DatagramSocket
  • To receive data that is multicast from a remote
    site
  • create a MulticastSocket with the MulticastSocket
    () constructor.
  • Next join a multicast group using
    MulticastSockets joinGroup () method. This
    signals the routers in the path between you and
    the server to start sending data your way tells
    the local host that it should pass your IP
    packets addresses to the multicast group.
  • Security breach could take place!

10
Multicast constructors
  • Uses an unused anonymous port
  • try
  • MulticastSocket ms new MulticastSocket ()
  • //send some datagram..
  • Catch (SocketException )
  • System.err.println(se)
  • Receives datagrams on a well-known port
  • try
  • MulticastSocket ms new MulticastSocket (4000)
  • //receive incoming datagrams..
  • Catch (SocketException )
  • System.err.println(se)

11
MulticastSocket
  • You can create a MulticastSocket using
    SocketAddress object. The socket address can be
    bound to a port
  • try
  • SocketAddress address new InetSocket Address
    (4000)
  • MulticastSocket ms new MulticastSocket
    (address)
  • //receive incoming datagram..
  • Catch (SocketException )
  • System.err.println(se)
  • Socket address can be bound to a specific network
    interface on local host
  • try
  • SocketAddress address new InetSocket Address
    (192.125.22.124000)
  • MulticastSocket ms new MulticastSocket
    (address)
  • //receive incoming datagram..
  • Catch (SocketException )
  • System.err.println(se)

12
Multicast sockets..
  • You can pass null to this constructor to create
    an unbound socket which would later be connected
    with a bind () method. Useful for setting socket
    options that can only be set before the socket is
    bound.
  • try
  • MulticastSocket ms new MulticastSocket (null)
  • Ms.setReusAddress(false)
  • SocketAddress address new InetSocketAddress
    (4000)
  • Ms.bind(address)
  • //receive incoming datagram..
  • Catch (SocketException )
  • System.err.println(se)

13
Communicating with a multicast group
  • 1.Join a multicast group
  • 2.Send data to the members of the group
  • 3.Receive data from the group
  • 4.Leave the multicast group
  • MulticastSocket class has methods for 1, 2 4

14
Join the Multicast group
  • Pass an InetAddress object
  • St up datagramPacket as buffer abd pass it into
    this sockets receive method
  • try
  • MulticastSocket ms new MulticastSocket (4000)
  • InetAddress is InetAddress.getByName(224.2.2.2
    )
  • Ms.joinGroup(ia)
  • Byte buffer new byte 8192
  • While (true)
  • DatagramPacket dp new DatagramPacket(buffer,
    buffer.length)
  • Ms.receive(dp)
  • String s new String (dp.getData(), 8859_1)
  • System.out.println (s)
  • catch (SocketException )
  • System.err.println(se)
Write a Comment
User Comments (0)
About PowerShow.com