Remote Procedure Calls-Part I: Distributed Systems CS 15-440
Remote Procedure Calls-Part I: Distributed Systems CS 15-440
CS 15-440
Mohammad Hammoud
Today…
Last Session:
Networking- Part II
Networking Principles: Encapsulation, Routing, and Congestion Control
Today’s Session:
Remote Procedure Calls- Part I
Sockets
Remote Invocations
Announcements:
Project I will be out tomorrow; it is due on October 02
PS1 is due on September 09
Communicating Entities in Distributed Systems
• Problem-oriented entities
• Objects (in object-oriented programming based approaches)
1. Same Address-Space
Global variables, Procedure calls, …
Applications, Services
Remote Invocation
Middleware
Layers
IPC Primitives (e.g., Sockets)
Transport Layer (TCP/UDP)
Data-Link Layer
Physical Layer
6
UDP Sockets
• UDP provides connectionless communication, with no acknowledgements or message
retransmissions
• Communication mechanism:
• Server opens a UDP socket SS at a known port sp,
• Socket SS waits to receive a request
• Client opens a UDP socket CS at a random port cx
• Client socket CS sends a message to ServerIP and port sp
• Server socket SS may send back data to CS
Client SS.receive(recvPacket) Server
No ACK will be
CS CS.Send(msg, ServerIP, sp) SS sent by the
receiver
cx sp
H
= Host computer H S = Socket S n = Port n
UDP– Design Considerations
• Sender must explicitly fragment a long message into smaller chunks before
transmission
• A maximum size of 548 bytes is suggested for transmission
• Receiver should allocate a buffer that is big enough to fit the sender’s message
• Otherwise the message will be truncated
TCP Sockets
• TCP provides in-order delivery, reliability, and congestion control
• Communication mechanism:
• Server opens a TCP server socket SS at a known port sp
• Server waits to receive a request (using accept call)
• Client opens a TCP socket CS at a random port cx
• CS initiates a connection initiation message to ServerIP and port sp
• Server socket SS allocates a new socket NSS on random port nsp for the client
• CS can send data to NSS
nSS = SS.accept()
Client Server
Shall I send?
SS
sp
CS
e t y o u r tra nsm ission port to n sp
OK. S CS.Send(msg)
cx
TCP fragments th nSS
e message & tra
data; receiver AC nsmits nsp
Ks receptions
Main Advantages of TCP
Applications, Services
Middleware
Layers
Remote Invocation
IPC Primitives (e.g., Sockets)
Data-Link Layer
Physical Layer
11
Remote Invocation
• Remote invocation enables an entity to call a procedure that typically executes on
an another computer without the programmer explicitly coding the details of
communication
• The underlying middleware will take care of raw-communication
• Programmer can transparently communicate with remote entity
• Data representation
• Data representation has to be uniform
• Architecture of the sender and receiver machines may differ
• Failure Independence
• Client and server might fail independently
Challenges in RPC
• Data representation
• Data representation has to be uniform
• Architecture of the sender and receiver machines may differ
• Failure Independence
• Client and server might fail independently
Parameter Passing via Marshaling
• Data representation
• Data representation has to be uniform
• Architecture of the sender and receiver machines may differ
• Failure Independence
• Client and server might fail independently
Data Representation
• The client and server have to agree on how simple data is represented in
the message
• E.g., Format and size of data-types such as integer, char and float
Challenges in RPC
• Data representation
• Data representation has to be uniform
• Architecture of the sender and receiver machines may differ
• Failure Independence
• Client and server might fail independently
Failure Independence
• In the local case, the client and server live or die together
• In the remote case, the client sees new failure types (more on this
next lecture)
• Network failure
• Server machine crash
• Server process crash
• An RPC with strict request-reply blocks the client until the server returns
• Blocking wastes resources at the client
• Asynchronous RPCs are used if the client does not need the result from server
• The server immediately sends an ACK back to the client
• The client continues the execution after an ACK from the server
wait for result client wait for acceptance
Client
return
call remote
from call return acknowledge
procedure
results
server
call local procedure time
call client with
asynchronous RPC
Remote Method Invocation (RMI)
• During any method call, the system has to resolve whether the
method is being called on a local or a remote object
• Local calls should be called on a local object
• Remote calls should be called via remote method invocation
• Remote Reference Module is responsible for translating between local and
remote object references
RMI Control Flow
Skeleton and
Proxy Request Dispatcher for
Obj A for B B’s class
Remote Remote
Remote Response Reference Obj B
Reference
Module
Module
Next class