Chapter 4 -
Communication
Cosc4191 : Distributed Systems
Department of Computer Science
Semera university
Lecture by: Welday G.(Msc.)
1
Objectives of the Chapter
review of how processes communicate in a network (the
rules or the protocols) and their structures
introduce the two widely used communication models for
distributed systems:
Remote Procedure Call (RPC)
Remote Method Invocation (RMI)
2
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.
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
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
simple and elegant, but there are implementation problems
the calling and called procedures run in different address
spaces
parameters and results have to be exchanged; what if the
machines are not identical?
what happens if both machines crash?
9
Conventional Procedure Call, i.e., on a single machine
e.g. count = read (fd, buf, bytes); a C like statement, where
fd is an integer indicating a file
buf is an array of characters into which data are read
bytes is the number of bytes to be read
Stack pointer
Stack pointer
parameter passing in a local procedure the stack while the called
call: the stack before the call to read procedure is active
parameters can be call-by-value (fd and bytes) or call-by
reference (buf) or in some languages call-by-copy/restore 10
Client and Server Stubs
RPC would like to make a remote procedure call look the
same as a local one; it should be transparent, i.e., the calling
procedure should not know that the called procedure is
executing on a different machine or vice versa
principle of RPC between a client and server program
when a program is compiled, it uses different versions of
library functions called client stubs
a server stub is the server-side equivalent of a client stub
11
Steps of a Remote Procedure Call
1. Client procedure calls client stub in the normal way
2. Client stub builds a message and calls the local OS
(packing parameters into a message is called parameter
marshaling)
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
hence, for the client; remote services are accessed by making
ordinary (local) procedure calls; not by calling send and
receive
server machine vs server process; client machine vs client process
12
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
13
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 whereas IBM PCs use ASCII)
there are also differences in representing integers(1’s
complement or 2’s complement) and floating-point numbers
byte numbering may be different (from right to left in Pentium
called little endian and left to right in SPARC, big endian)
e.g.
consider a procedure with two parameters, an integer and a
four-character string; each one 32-bit word (5, “JILL”)
the sender is Intel and the receiver is SPARC
14
original message on the Pentium
(the numbers in boxes indicate the address of each byte)
the message after receipt on the SPARC; wrong integer (5*224) 83886080, but
correct string
15
one approach is to invert the bytes of each word after
receipt
the message after being inverted (correct integer but wrong string)
additional information is required to tell which is an
integer and which is a string
16
2.3 Remote Object (Method) Invocation (RMI)
resulted from object-based technology that has proven its
value in developing nondistributed applications
it is an expansion of the RPC mechanisms
it enhances distribution transparency as a consequence of
an object that hides its internal from the outside world by
means of a well-defined interface
Distributed Objects
an object encapsulates data, called the state, and the
operations on those data, called methods
methods are made available through interfaces
the state of an object can be manipulated only by invoking
methods
this allows an interface to be placed on one machine while
the object itself resides on another machine; such an
organization is referred to as a distributed object
the state of an object is not distributed, only the interfaces
are; such objects are also referred to as remote objects 17
the implementation of an object’s interface is called a proxy
(analogous to a client stub in RPC systems)
it is loaded into the client’s address space when a client
binds to a distributed object
tasks: a proxy marshals method invocation into messages
and unmarshals reply messages to return the result of the
method invocation to the client
a server stub, called a skeleton, unmarshals messages and
marshals replies
18
common organization of a remote object with client-side proxy
19
Binding a Client to an Object
a process must first bind to an object before invoking its
methods, which results in a proxy being placed in the
process’s address space
binding can be implicit (directly invoke methods using
only a reference to an object) or explicit (by calling a
special function)
an object reference could contain
network address of the machine where the object
resides
endpoint of the server
an identification of which object
the protocol used
...
20
Parameter Passing
there are two situations when invoking a method with
object reference as parameter; is the object local or
remote to the client?
remote object: copy and pass the reference of the object
as a value parameter; this means the object is passed by
reference
local object: a copy of the object is passed; this means the
object is passed by value
21
the situation when passing an object by reference or by value
22
23