Remote Procedure Call Concept
(RPC)
Internetworking TCP/IP vol III
Comer and Stevens
Jan 2009 Aman Jatain, Asst Prof., SE & IT 1
Deptt., ITM
Overview
• Introduction
• RPC Model
• Paradigm for Distributed Programs
• Conventional Procedure Call Model
• Client/Server and RPC
• Sun Microsystems’ RPC Definition
• Remote Programs and Procedures
• Management for RPC’s
• Communication Semantics
• RPC Mapping
• RPC Data Marshaling
• Summary
Jan 2009 2
Introduction
• Remote Procedure Call (RPC) is a protocol that one program can use
to request a service from a program located in another computer.
• RPC uses the client/server model.
– The requesting program is a client and the service-providing program is
the server.
– Similar to a local procedure call, an RPC is a synchronous operation
requiring the requesting program to be suspended until the results of the
remote procedure are returned.
– Threads or lightweight processes that share the same address space allow
multiple RPC’s to be performed concurrently.
• The RPC concept simplifies the design of client/server software
– Makes the programs easier to understand
Jan 2009 3
Remote Procedure Call Model
• A conceptual framework for building
distributed programs
– Remote Procedure Call model or RPC model
– Uses familiar concepts from conventional
programs as the basis for the design of
distributed applications
Jan 2009 4
Distributed Programs Paradigms
• Communication-Oriented Design
– Begin with the communication protocol
– Design a message format and syntax
– Design the client/server by specifying how each reacts to incoming/outgoing
messages
– A communication-oriented design may lead to problems
• Protocol may not provide all the needed functionality
• Inexperience with protocol design could lead to inefficient protocols
• Difficult to understand or modify
• Application-Oriented Design
– Begin with the application
– Design a conventional application program
– Build and test a working version as a conventional program
– Divide the program into several pieces to execute on separate computers
– The remote procedure call paradigm focuses on the application
• Emphasizes the problem to be solved instead of the communication mechanism
• Does not require major code changes when splitting procedures between
local/remote machines
• RPC separates the solution of a problem from the task of making the solution
operate in a distributed environment
• Because RPC divides programs at procedure boundaries, the split into local and
remote parts can be made without major modification to the program structure.
Jan 2009 5
Conceptual Model for
Conventional Procedure Calls
main
proc1 proc2 proc3 proc4
proc5 proc6 proc7 proc8
Jan 2009 6
Extension of the Procedural
Model
computer1 computer2
main
proc1 proc2 proc3 proc4
proc5 proc6 proc7 proc8
Jan 2009 7
Conventional Procedure Call Execution
• Single thread of control through all procedures
• Execution begins in main and continues until it encounters a
procedure call
• Execution branches to the code in the procedure
• Execution continues in the procedure until it encounters a return
statement
Code for Main Code for Code for
Program Procedure A Procedure B
main
Call A
Call B
exit return return
Jan 2009 8
Distributed Procedural Model
• Single thread of execution executes in a distributed environment
• Client/Server corresponds to a procedure call and return
• Client request corresponds to a procedure call
• Server response corresponds to the return function
Main Program Procedure A Procedure B
machine 1 machine 2 machine 3
(client) (server) (server)
main
call remote call remote
proc A proc A
respond to respond to
exit caller
caller
Jan 2009 9
Analogy between RPC and client
server
• We know that conventional procedure remains completely
inactive until the flow of control passes to it(i.e until it is
called).
• In contrast ,a server must exist in the remote system and be
waiting to compute a response the first request from a
client.
• Further differences arises in the way data flows to a remote
procedure. Conventional procedures usually accept a few
arguments and return only a few results.
• However , a server can accept or return arbitrary amounts
of data.
Distributed Computation
• Paradigm helps programmers design
distributed programs easily
– Distributed program invokes a procedure to
access a remote service
– Remote procedures are accessed the same as
local procedures
– Distributed are as easy to construct as
conventional programs
11
Sun Microsystems' RPC
Definition
• Sun Microsystems developed a specific form of RPC (Sun
RPC, Open Network Computing (ONC) RPC or simply
RPC)
• Received wide acceptance including NFS
• ONC RPC defines the format of messages
• Allows the calling program to use UDP or TCP
• Uses XDR to represent procedure arguments as well as
data items in an RPC message header
• ONC RPC includes a compiler system to aid in building
distributed applications
12
Remote Programs and
•
Procedures
RPC defines a remote program as the basic unit of software that
executes on a remote machine
• Each remote program corresponds to a server and contains a set of
one or more procedures plus global data
• The procedures inside a remote program all share access to its global
data
A single remote program
proc1 proc2 proc3
shared global data
13
Identifying Remote Programs
and Procedures
• The ONC RPC standard specifies that each remote program be
assigned a unique 32-bit integer to identify it
• ONC RPC assigns an integer to each remote procedure inside a given
remote program
• The procedures are numbered: 1, 2, … N
• ONC RPC divided the set of program numbers into 8 groups of 32-bit
numbers
• Each remote program is assigned a unique number
• ONC RPC includes an integer version number for each remote
program
– The RPC specification permits a computer to run multiple versions of a
remote program
14
Mutual Exclusion for Procedures in
a Remote Program
• The ONC RPC mechanism specifies that at most
one remote procedure can execute in a remote
program at one time
• RPC provides automatic mutual exclusion among
procedures within a given remote program
• Important for remote programs that maintain a
shared data area
15
Communication Semantics
• ONC RPC does not enforce reliable semantics
• Can use TCP or UDP as a transport protocol
– When using UDP as the transport protocol the application must be
able to tolerate zero-or-more execution semantics
– Each remote procedure call needs to be idem potent
• The standard does not specify additional protocols or
mechanisms for reliable delivery
• RPC semantics are defined as a function of the underlying
transport protocol
16
RPC Retransmission
• ONC RPC includes a simple timeout and
retransmission strategy
– Does not guarantee reliability
– Default timeout mechanism implements a fixed
timeout with a fixed number of retries
17
Map a Remote Program to a
Protocol Port
• TCP/UDP use 16-bit protocol numbers
• RPC uses 32-bit numbers to identify remote
programs
– RPC programs can outnumber protocol ports
– Unable to map RPC program to protocol ports directly
– Each RPC program can obtain a protocol port number
if port assignments are temporary
18
Dynamic Port Mapping
• ONC RPC mechanism includes a dynamic mapping
service to solve the identification problem
• Each machine that supports RPC provides a mechanism
that allows a mapping of RPC program numbers to
protocol ports
RPC program
RPC register RPC port
program mapper
(server) (server)
RPC program socket socket for well-
used by RPC known port
19
RPC Port Mapper Algorithm
1. Create a passive socket bound to the well-
known port assigned to the ONC RPC
port mapper service (111)
2. Repeatedly accept request to register an
RPC program number or to look up a
protocol port given an RPC program
number
20
ONC RPC Message Format
• ONC RPC does not use a fixed format for
messages
– The standard defines the general format of RPC
messages
– The XDR language defines the data items
– The XDR language defines how to assemble a
message
21
Data Marshaling Arguments
• RPC must represent all arguments in an
external form for transfer
• Complex data structures must be encoded
into a compact representation
– marshal, linearize or serialize
• Client side marshals the arguments into the
message and the server side un-marshals
them
22
Authentication
• RPC uses several forms of authentication
– Simple scheme that relies on UNIX
– Complex scheme that uses the Data Encryption
Standard (DES)
• RPC leaves the format and interpretation up
to the authentication subsystem
23
Example RPC Message
MESSAGE ID
MESSAGE TYPE (0 or CALL)
RPC VERSION NUMBER (2)
REMOTE PROGRAM (0x186a3 for NFS)
REMOTE PROGRAM VERSION (2)
REMOTE PROCEDURE (1 for GETATTR)
UNIX Authentication
ARGUMENTS FOR REMOTE PROCEDURE
24
Summary
• The remote procedure model helps make distributed programs easy to
design and understand
• The RPC model views each server as implementing one or more
procedures
• A message from a client corresponds to a call and a response from the
server corresponds to a return
• Remote procedures accept arguments and return one or more results
• Sun Microsystems developed the de-facto standard form of remote
procedure call (ONC RPC)
• ONC RPC use a dynamic binding mechanism called the RPC Port
Mapper
March 2010 Aman Jatain, Asstt. Prof., SE & IT 25
Deptt., ITM