Multicast Communication in Java - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Multicast Communication in Java

Description:

If process P sent messages mi and mj, in that order, then each process in the ... The four major classes in multicasting. InetAddress. DatagramPacket. DatagramSocket ... – PowerPoint PPT presentation

Number of Views:352
Avg rating:3.0/5.0
Slides: 23
Provided by: edmun2
Category:

less

Transcript and Presenter's Notes

Title: Multicast Communication in Java


1
Multicast Communication in Java
  • CMT3332
  • Lecture 7

2
Unicast vs. Multicast
3
Multicast
  • The majority of network services and network
    applications use unicast for IPC
  • Multicasting is useful for applications such as
  • groupware
  • online conferences
  • interactive distance learning, and etc.
  • It can also be used in replication of services
    for fault tolerance.

4
Mutlicast group
  • In multicasting, a set of processes form a group,
    called a multicast group.
  • Each process in a group can send and receive
    message.
  • A message sent by any process in the group can be
    received by each participating process in the
    group.
  • A process may also choose to leave a multicast
    group.
  • In an application such as online conferencing, a
    group of processes interoperate using
    multicasting to exchange audio, video, and/or
    text data.

5
Multicast API
  • There are FOUR primitive operations in
    Mutlicasting
  • Join
  • This operation allows a process to join a
    specific multicast group.
  • A process that has joined a multicast group is a
    member of the group and is entitled to receive
    all multicast addressed to the group.
  • A process can be a member of multiple multicast
    groups.

6
Multicast API (cont'd)
  • Leave
  • This operation allows a process to stop
    participating in a multicast group.
  • A process that has left a multicast group is no
    longer a member of the group and is thereafter
    not entitled to receive any multicast addressed
    to the group.
  • Send
  • This operation allows a process to send a message
    to all processes currently participating in a
    multicast group.
  • Receive
  • This operation allows a member process to receive
    messages sent to a multicast group.

7
Reliable vs. Unreliable Multicast
  • In a multicast environment, the runtime supports
    of the multicast mechanism is responsible for
    delivering the message
  • A message may not be received by one or more of
    the processes at all, due to errors and/or
    failures in the network, the machines, or the
    runtime support.
  • Some applications, such as video conferencing,
    can tolerate an occasional miss or misordering of
    messages
  • Other applications such as database
    applications for which such anomalies are
    unacceptable.

8
Unreliable Multicast
  • Such multicast system will make a good-faith
    attempt to deliver messages to each participating
    process, but the arrival of the correct message
    at each process is not guaranteed.
  • Any message sent be received by zero or more
    processes.
  • The message may be received by some processes.
    (In the best case, all and in the worst, none)
  • Some messages may be received by some processes
    in a corrupted form

9
Reliable Multicast
  • Such multicast system guarantees that each
    message is eventually delivered to each process
    in the group.
  • Each message sent by a process can be assumed to
    be delivered in a non-corrupted form to all
    processes in the group eventually.

10
Ordered vs. Unordered Reliable Multicast
  • An unordered reliable multicast system provides
    no guarantee on the delivery order of the
    messages.
  • A FIFO (first-in-first-out) or send-order
    multicast system guarantees that the following
    delivery order of the messages
  • If process P sent messages mi and mj, in that
    order, then each process in the multicast group
    will be delivered the messages mi and mj, in that
    order.
  • Causal Order Multicast satisfies the following
    message delivery order
  • If message mj causes the occurrence of message
    mj, then mi will be delivered to each process
    prior to mj.
  • An atomic-order multicast system guarantees all
    messages to be delivered to each participant in
    the exact same order.

11
Example on FIFO
  • Suppose you have 2 processes in a multicast
    group.
  • P1 sends messages m11 then m12
  • P2 sends messages m21 then m22
  • Then a FIFO multicast system can deliver the
    messages in any of the following orders
  • m11-m12-m21-m22,
  • m11-m21-m12-m22,
  • m11-m21-m22-m12,
  • m21-m11-m12-m22
  • m21-m11-m22-m12
  • m21-m22-m11-m12.

12
Example on Casual Order
  • Suppose P1 multicasts message m1
  • to which P2 replies with a multicast message m2
  • another independent P3 replies to m1 with a
    multicast message m3
  • The three messages now share these causal
    relationships m1 -gt m2 and m1 -gt m3.
  • A causal-order multicast system can delivery
    these message in either of the following orders
  • m1- m2- m3
  • m1- m3- m2

13
Example on Atomic Order
  • P1 sends m1 then m2.
  • P1 must be delivered m1 before sending m2
  • P2 replies to m1 by sending m3.
  • P2 must receive m1 before m3
  • P3 replies to m3 by sending m4.
  • P3 must receive m3 before m4
  • Any atomic delivery order must preserve the
    order m1 m3 m4
  • An atomic multicast will result in the messages
    being delivered to each of the processes in one
    of the following orders
  • m1 m2 m3 m4
  • m1 m3 m2 m4 or
  • m1 m3 m4 m2

14
The Java Basic Multicast API
  • At the transport layer, the basic multicast
    supported by Java is an extension of UDP, which
    is connectionless and unreliable.
  • The four major classes in multicasting
  • InetAddress
  • DatagramPacket
  • DatagramSocket
  • MulticastSocket
  • The Java Reliable Multicast Service (JRM Service)
    provides the capabilities for a receiver to
    repair multicast data that are lost or damaged,
    as well as security measures to protect data
    privacy.

15
Classes for Mulitcast
  • InetAddress
  • Identify the IP of sender/receiver as well as a
    multicast group
  • DatagramPacket
  • packet of data that is sent to / received by each
    participant in a multicast group
  • DatagramSocket
  • a socket for a process to send or receive data
  • MulticastSocket
  • A MulticastSocket is a DatagramSocket, with
    additional capabilities for joining and leaving a
    multicast group.
  • An object of the multicast datagram socket class
    can be used for sending and receiving IP
    multicast packets.

16
IP Multicast Addresses
  • Instead of a single process, a multicast datagram
    is meant to be received by all the processes that
    are currently members of a specific multicast
    group.
  • Hence each multicast datagram needs to be
    addressed to a multicast group instead of an
    individual process.
  • The Java multicast API uses the Internet Protocol
    (IP) multicast addresses to identify multicast
    groups.
  • A multicast group is specified by
  • a class D IP address (224.0.0.0 (reserved) -
    239.255.255.255) and
  • a standard UDP port number.

17
IP Multicast Addresses (cont'd)
  • Some of the Class D Addresses are assigned for
    different purpose.
  • To avoid crashing, we will use 239... for our
    mulitcast exercises.
  • In the Java API, a MulticastSocket object is
    bound to a port address such as 3456

18
Joining and Leaving a Multicast Group
  • To join a multicast group
  • // join a Multicast group at IP address //
    239.1.2.3 and port 3456
  • InetAddress group
  • InetAddress.getByName("239.1.2.3")
    MulticastSocket s new MulticastSocket(3456)
    s.joinGroup(group)
  • A process may leave a multicast group by invoking
    the leaveGroup method
  • s.leaveGroup(group)

19
Message Propagation
  • Message propagation is often used to support
    Multicasting
  • A packet is propagated from a host to a
    neighboring host so that it will eventually
    deliver the message to all the participants.
  • Under some anomalous circumstances, however, it
    is possible that the algorithm which controls the
    propagation does not terminate properly,
    resulting in a packet circulating in the network
    indefinitely.
  • Indefinite message propagation causes unnecessary
    overhead on the systems and the network.

20
Time To Live
  • To avoid the infinite propagation of a packet, a
    time to live parameter is to be set with each
    multicast datagram.
  • The time-to-live (ttl) parameter limits the count
    of network links or hops that the packet will be
    forwarded on the network.
  • The recommended ttl settings are
  • 0 restricts multicast to processes on the same
    host
  • 1 restricts multicast to processes on the same
    subnet
  • 32 restricts multicast to processes on the same
    site
  • 64 restricts multicast to processes on the same
    region
  • 128 restricts multicast to processes on the same
    continent
  • 255 restricts multicast to unrestricted

21
Sending to a Multicast Group
  • String msg "This is a multicast message."
  • InetAddress group
  • InetAddress.getByName("239.1.2.3")
  • MulticastSocket s new MulticastSocket(3456)
  • s.joinGroup(group) // optional
  • DatagramPacket hi new DatagramPacket(msg.g
    etBytes( ), msg.length( ),group, 3456)
    s.send(hi)

22
Receiving Messages Sent to a Multicast Group
  • byte buf new byte1000
  • InetAddress group InetAddress.getByName("239.1
    .2.3") MulticastSocket s new
    MulticastSocket(3456) s.setTimeToLive(1)
  • s.joinGroup(group)
  • DatagramPacket recv new DatagramPacket(buf,
    buf.length)
  • s.receive(recv)
Write a Comment
User Comments (0)
About PowerShow.com