Distributed Computing
Second Edition
      © Oxford University Press 2013. All rights reserved.
         Chapter 3
 Interprocess
Communication
 © Oxford University Press 2013. All rights reserved.
                         OUTLINE
• Message passing
• Group communication
• API for Internet protocol
         © Oxford University Press 2013. All rights reserved.
Message Passing vs Shared Memory
      © Oxford University Press 2013. All rights reserved.
     Desirable Features of Message
            Passing Systems
•   Hardware approach
•   Functionality
•   Performance
•   Uniform semantics
•   Efficiency
•   Reliability
•   Correctness
•   Flexibility
•   Portability
•   Security
             © Oxford University Press 2013. All rights reserved.
Message Passing Process
   © Oxford University Press 2013. All rights reserved.
IPC Message Format
 © Oxford University Press 2013. All rights reserved.
      IPC Message
© Oxford University Press 2013. All rights reserved.
         IPC Synchronization
• Ensure message is received in the buffer:
   – Polling
   – Interrupt
• Message communication techniques
  – Synchronous communication
  – Asynchronous communication
             © Oxford University Press 2013. All rights reserved.
IPC: Synchronous Communication
      © Oxford University Press 2013. All rights reserved.
IPC: Asynchronous Communication
      © Oxford University Press 2013. All rights reserved.
    IPC Primitives
© Oxford University Press 2013. All rights reserved.
Message Buffering Strategies
      © Oxford University Press 2013. All rights reserved.
    Null Buffering
© Oxford University Press 2013. All rights reserved.
Null Buffering with Blocked Receiver
            Null buffering with blocking
                    mechanism
       © Oxford University Press 2013. All rights reserved.
Null Buffering with Non-blocked Receiver
        Null buffering with non-blocking mechanism
         © Oxford University Press 2013. All rights reserved.
Message Buffering: Single Buffer
                  Single-message buffering
      © Oxford University Press 2013. All rights reserved.
     Message Buffering: Multiple
          Message Buffer
• Receiver overflow handled using
   – Unsuccessful communication indication
   – Flow control mechanism
              © Oxford University Press 2013. All rights reserved.
     Multidatagram Messaging
•   Concept of MTU
•   Message sequencing and reassembly
•   Message contents
•   Message representation: tagged, untagged
               © Oxford University Press 2013. All rights reserved.
Message Data Transmission
    © Oxford University Press 2013. All rights reserved.
Process Addressing Techniques
• Explicit addressing :send (process_id, message) and receive
  (process_id, message)
• Implicit addressing:send_any (service_id, message) and
  receive_any (service_id, message)
   – Two level addressing : machine_id@local_id (receiver
     machine name)
   – Three level addressing:
     machine_id@local_id@machine_id (node where the
     process was created @ generated by the first machine@
     last known location of the machine)
            © Oxford University Press 2013. All rights reserved.
Link-based Process Addressing
      © Oxford University Press 2013. All rights reserved.
Failure Handling Mechanism
     © Oxford University Press 2013. All rights reserved.
                 IPC Protocols
• 4-message reliable IPC protocol
• 3-message reliable IPC protocol
• 2-message reliable IPC protocol
            © Oxford University Press 2013. All rights reserved.
IPC 4 Message Protocol
   © Oxford University Press 2013. All rights reserved.
IPC 3 Message Protocol
   © Oxford University Press 2013. All rights reserved.
IPC 2 Message Protocol
   © Oxford University Press 2013. All rights reserved.
          IPC Failure
© Oxford University Press 2013. All rights reserved.
     Group Communication
• Unicast –one to one communication
• Many-to-one group communication
• One-to-many or multicast group communication
           © Oxford University Press 2013. All rights reserved.
Unicast Group Communication
     © Oxford University Press 2013. All rights reserved.
Many-to-One Communication
    © Oxford University Press 2013. All rights reserved.
Multicast Communication
Broadcast Communication
    © Oxford University Press 2013. All rights reserved.
               Types of Groups
• Closed group
• Open group
• Peer group
• Hierarchical group
            © Oxford University Press 2013. All rights reserved.
          Group Management
• Centralized approach
• Distributed approach
              © Oxford University Press 2013. All rights reserved.
Group Addressing                     Message Delivery
• High level naming   • Send to all semantics
• For large LANs/     • Bulletin board
  MANs: send message    semantics
  to individual group
  members
         © Oxford University Press 2013. All rights reserved.
      Reliability Mechanism
• Classified based on number of receivers from which sender
  expects a response
            © Oxford University Press 2013. All rights reserved.
Message Ordering
© Oxford University Press 2013. All rights reserved.
Message Ordering: Absolute Ordering
       © Oxford University Press 2013. All rights reserved.
Message Ordering: Consistent Ordering
        © Oxford University Press 2013. All rights reserved.
Message Ordering: Causal Ordering
       © Oxford University Press 2013. All rights reserved.
  https://www.geeksforgeeks.org/difference-between-synchronous-and-
  asynchronous-transmission/
    API for Internet Protocol
• Synchronous Communication
Both the sending and receiving processes synchronize at every
  message so that both send and receive primitives are blocking
  operations. When a send is issued, the sending process is blocked
  until the receive command is issued, and the other process is
  blocked until the message is received.
• Asynchronous Communication
The send is a non-blocking command. The issuing process is allowed to
  continue when the message is stored in a local buffer and then both
  the transmission of the message and the sender process continues
  simultaneously. The receive operation works both in blocking and
  non-blocking modes.
              © Oxford University Press 2013. All rights reserved.
 https://www.geeksforgeeks.org/differences-between-tcp-and-udp/
UDP Datagram Communication
• A datagram is transmitted from the client process and sent to
  the server process, which receives it.
• To communicate messages to and fro, a process must first
  create a process and bind it to a local port and to an Internet
  address of the local host.
• The receive method includes the Internet address and the
  port number so that the receiver can send a reply.
• UDP protocol may be used for some services where
  sometimes the messages may be dropped.
• The main advantage lies in the fact that datagrams do not
  require overheads for correct delivery.
              © Oxford University Press 2013. All rights reserved.
TCP Datagram Communication
 • TCP is a connection-oriented protocol
 • Sequencing: A data stream is divided into a sequence of data
   segments with a sequence number attached to each and
   transmitted as IP packets. It gives the byte number within the
   stream for the first byte of the segment.
 • Flow control: When a segment is received, its sequence number is
   noted and periodically, the receiver sends the highest number of
   received segments and also the window size to the sender. This is
   sent in a special acknowledgement segment.
 • Retransmission and buffering: The sender keeps track of the
   sequence number of sent segments and retransmits them in case
   any segment does not receive acknowledgement from the receiver.
   The incoming buffer at the receiver’s site stores the incoming data
   packets.
               © Oxford University Press 2013. All rights reserved.
Services Using TCP Protocol
• HTTP Hypertext transfer protocol is used to communicate
  between Web browsers and Web server.
• FTP File transfer protocol allows files to be transferred
  between the remote computer and the host computer. It also
  allows directories from a remote computer to be accessed.
• Telnet It allows a user to log on to the remote computer
  system and start a terminal session.
• SMTP Simple mail transfer protocol is used to send mail from
  one computer to another.
             © Oxford University Press 2013. All rights reserved.