You are on page 1of 30

Chapter 2 - Communication 

Introduction
 interprocess communication is at the heart of all distributed
systems
 communication in distributed systems is based on message
passing as offered by the underlying network as opposed to
using shared memory
 modern distributed systems consist of thousands of
processes scattered across an unreliable network such as
the Internet
 unless the primitive communication facilities of the network
are replaced by more advanced ones, development of large
scale Distributed Systems becomes extremely difficult

2
Objectives of the Chapter
 review of how processes communicate in a network (the
rules or the protocols) and their structures
 introduce the four widely used communication models for
distributed systems:
 Remote Procedure Call (RPC)
 Remote Method Invocation (RMI)
 Message-Oriented Middleware (MOM)
 Streams

3
2.1 Layered Protocols
 two computers, possibly from different manufacturers, must
be able to talk to each other
 for such a communication, there has to be a standard
 The ISO OSI (Open Systems Interconnection) Reference
Model is one of such standards - 7 layers
 TCP/IP protocol suite is the other; has 4 or 5 layers
 OSI
 Open – to connect open systems or systems that are open
for communication with other open systems using standard
rules that govern the format, contents, and meaning of the
messages sent and received
 these rules are called protocols
 two types of protocols: connection-oriented and
connectionless

4
layers, interfaces, and protocols in the OSI model
5
Media (lower) Layers
 Physical: Physical characteristics of the media
 Data Link: Reliable data delivery across the link
 Network: Managing connections across the network
or routing
 Transport: End-to-end connection and reliability
(handles
lost packets); TCP (connection-oriented),
UDP (connectionless), etc.
 Session: Managing sessions between applications
(dialog control and synchronization); rarely
supported
 Presentation: Data presentation to applications; concerned
with the syntax and semantics of the
information transmitted
 Application: Network services to applications; contains
protocols that are commonly needed by
users;
Host (upper) FTP, HTTP, SMTP, ...
Layers
6
a typical message as it appears on the network

7
 a conversation occurs between a sender and a receiver at
each layer
 e.g., at the data link layer

discussion between a receiver and a sender in the data link layer 8


 Transport Protocols: Client-Server TCP

assuming no messages are lost,


 the client initiates a setup
connection using a three-way
handshake (1-3)
 the client sends its request (4)
 it then sends a message to
close the connection (5)
 the server acknowledges
receipt and informs the client
that the connection will be
closed down (6)
 then sends the answer (7)
followed by a request to close
the connection (8)
 the client responds with an ack
normal operation of TCP to finish conversation (9)
9
 much of the overhead in TCP is for managing the connection
 combine connection setup with
request and closing connection
with answer
 Such protocol is called TCP for
Transactions (T/TCP)
 the client sends a single
message consisting of a setup
request, service request, and
information to the server that
the connection will be closed
down immediately after
receiving the answer (1)
 the server sends acceptance of
connection request, the
answer, and a connection
release (2)
 the client acknowledges tear
down of the connection (3) transactional TCP 10
2.2 Remote Procedure Call
 The first distributed systems were based on explicit message
exchange between processes through the use of explicit send
and receive procedures; but do not allow access transparency
 In 1984, Birrel and Nelson introduced a different way of
handling communication: RPC
 It allows a program to call a procedure located on another
machine

 In RPCA process on machine A can call a procedure on


machine B.

 The RPC protocol enables users to work with remote procedures

 RPC implements a logical client-to-server communications


 For carrying the message data between communicating programs
11
2.2 Remote Procedure Call….

 Goal:
 Provide process-to-process communication that
enables a process on one system to invoke a
function, or service, on a another system
 Each network service is a collection of remote programs

 A remote program implements remote procedures

 A client directly calls a procedure located in a remote


server program
2.2 Remote Procedure Call…

What is procedure?
 A procedure is a method for completing something
with steps and instructions for each aspect of the
task
 A procedure is a set of coded instructions that tell a
computer how to run a program or calculation.
 We can define a procedure with no parameters, one
parameter, or more than one. 
 A parameter represents a value that the procedure
expects
2.2.1 Client and Server Stubs
 RPC is accomplished by generating stub functions:
 Client stub  also known as proxy
 Its Job is to,
 Take the parameters, 
 Marshal  the parameters into a network message,
 Send them to the server,
 Received results from the server  
 Unmarshal the results and return them to the caller.
 Server stub  also known a skeleton
 Its Job is to,
 Unmarshals the message in the request,
 Calls the local procedure and does the work
 Marshals the results into a network message that is sent back to
the recipient/client
2.2.1 Client and Server Stubs…

principle of RPC between a client and server program


 Steps of a Remote Procedure Call
1. Client OS calls client stub in the normal way
2. Client stub packs a message and calls the local OS
3. Client's OS sends the message to the remote OS

4. Remote OS gives the message to the server stub


5. Server stub unpacks the parameters and calls the server
6. Server does the work and returns the result to the stub
7. Server stub packs it in a message and calls the local OS
8. Server's OS sends the message to the client's OS

9. Client's OS gives the message to the client stub


10. Stub unpacks the result and returns to client

16
 Summary of a Remote Procedure Call
Steps
 In the RPC model,
 Step-1: The client makes a procedure call to send a
data packet to the server.
 Step-2: When the packet arrives, the server uses the
local procedure and performs whatever service is
requested
 Step-4: Sends a reply back to the client (i.e. result)
2.2.2 Parameter Passing
1. Passing Value Parameters
 e.g., consider a remote procedure add(i, j), where i and j are
integer parameters

steps involved in doing remote computation through RPC


18
2.2.2 Parameter Passing….
 The above discussion applies if the server and the client
machines are identical
 But that is not the case in large distributed systems
 The machines may differ in data representation ,e.g.,
 IBM mainframes use EBCDIC
 IBM PCs use ASCII
 There are also differences in representing integers
 1’s complement
 2’s complement and
 Floating-point numbers
 Byte numbering may be different
 From right to left in Pentium little endian
 Left to right in SPARC big endian

19
2.2.2 Parameter Passing….
 e.g.,
 Consider a procedure with two parameters, an integer and a four-
character string; each one 32-bit word (5, “JILL”)

Original message on the Pentium


(the numbers in boxes indicate the address of each byte)

the message after receipt on the SPARC; wrong integer, but correct string
20
2.2.3 Extended RPC Models

 Original RPC assume remote communication  shortcomings

 To solve some of the shortcomings of the original model


 No need of network communication
 When both server and client are on the same machine

A. Doors
 Called door is used for colocated client-server process
communication

21
2.2.3 Extended RPC Models…..
1. The server process registers a door before it can be called
(door_create) and a name is attached to it
2. A client calls a door by a system call (door_call) including
all parameters
3. Results are returned by the system call door_return

22
the principle of using doors as RPC mechanism
2.2.3 Extended RPC Models…..

 Benefit: it allows the use of procedure calls on a single


mechanism
 Disadv: application developers have to be aware of where a
procedure is located; is it
 Local within the current process (a single process)
 Local to a different process on the same machine

23
B. Asynchronous RPC
 If there is no need to block the client until it gets a reply
 One cases:
1. If there is no result to be returned
 e.g., adding entries in a database, ...

a) the interconnection between client and server in a traditional RPC


b) the interaction using asynchronous RPC
24
2.3 Remote Object (Method) Invocation (RMI)
 Expansion of idea of RPC to RMI (or It is an expansion of the RPC
mechanism)
 This desire if fueled by the concept of the object and interface
 Distribution aspects can be hidden behind the object interfaces.
 Goal:
 Implement process-to-process communication over distributed
objects
 It enhances distribution transparency
 RMI uses object and interface

25
w1
2.3 Remote Object (Method) Invocation (RMI)...

 Object = data + methods


 accessed by means of references, which is used to
find it
 Interaction via interfaces
 Interface: the only means to access data
 An object reference could contain
 Network address of the machine where
the object be located in
 Endpoint of the server
 An identification of which object
 The protocol used
Working of RMI

The communication between client and server is handled by


using two intermediate objects:
 Stub object (on client side) and
 Skeleton object (on server-side)
 Steps of a Remote Method Invocation
Thank you !
Quiz-1

List the seven (7) layers of OSI


model

You might also like