What is Remote Procedure Call (RPC) ? – Network Communication

Remote Procedure Call (RPC)

Remote Procedure call is a high-level model for the client server communication.
A remote procedure call makes a call to a remote service look like a local call

  • RPC makes transparent whether server is local or remote.
  • RPC allows applications to become distributed transparently.
  • RPC makes architecture of remote machine transparent.

Remote Procedure Call
Remote Procedure Call

 


RPC Mechanism

The client transfer call request (the procedure name) and the arguments to the server via client stub function.

  • stub function marshals arguments and places them into a message together with the remote procedure identifier.
  • Sends message to server and waits for call return
  • Server receives the call request and passes to an appropriate server stub function.server stub function unmarshals the arguments, call the corresponding (local) service procedure.
  • On  return, the server stub marshals the output arguments into a call return message and sends back to the client.
  • Client stub receives call reply, unmarshals value, returns to client code.

Open Network Computing (ONC RPC)

There are a number of popular RPC specifications.

  • Sun RPC (ONC RPC) is widely used.
  • NFS (Network File System) is RPC based.
  • Rich set of support tools.

Procedure Arguments:
To reduce the complexity of the interface specification,  Sun RPC includes support for a single argument to a remote procedure.
Typically the single argument is a structure that contains a number of values.
Procedure Identification:
Each procedure is identified by:

  • Hostname (IP Address)‏
  • Program identifier (32 bit integer)‏
  • Procedure identifier (32 bit integer)‏
  • Program Version identifier : for testing and migration.

Program Identifiers:
Each remote program has a unique ID.
Sun divided up the IDs:
0x00000000 – 0x1fffffff   Sun
0x20000000 – 0x3fffffff   SysAdmin
0x40000000 – 0x5fffffff   Transient
0x60000000 – 0xffffffff     Reserved
Procedure Identifier and Program Version numbers:

  • Procedure Identifiers usually start at 1 and are numbered sequentially.
  • Version Numbers typically start at 1 and are numbered sequentially.

 


RPC: Port Mapper

The port mapper (rpc.portmap or just portmap) is a service that runs on nodes on the Internet for the purpose of mapping an ONC RPC program number to the network address of the server that listens for the program number.

  • Portmap is server software running under Unix-like systems that converts RPC program numbers into DARPA protocol port numbers. Its design objective was to minimize the number of ports in use, but this never happened as it never had wide adoption. It must be running in order to make RPC calls.
  • When an RPC server is started, it will tell portmap what port number it is listening to, and what RPC program numbers it is prepared to serve. When a client wishes to make an RPC call to a given program number, it will first contact portmap on the server machine to determine the port number where RPC packets should be sent.
  • Portmap must be started before any RPC servers are invoked.

What is Rpcgen ?

RPCGEN is an interface generator pre-compiler for Sun Microsystems RPC. It uses an interface definition file to create client and server stubs in C.
RPCGEN creates stubs based on information contained within an IDL(interface description language) file. This file is written in a language called RPCL – remote procedure call language. This language closely mimics C in style, and is designed purely for defining specification to be used for ONC RPC.
An RPC specification contains a number of definitions. These definitions are used by RPCGEN to create a header file for use by both the client and server, and client and server stubs.
     RCPL Definitions
Constant
Enumeration
Struct
Union(Note – this is not like a C union- it behaves more like a
discriminated record)
Typedef
Program
 

rpcinfo

rpcinfo is a shell command that reports current RPC registration information known to rpcbind (and can be used, by administrators, to delete registrations).
rpcinfo can be used to find all the RPC services registered on a specified host and to report their universal addresses and the transports for which they are registered.
It can also be used to call (ping) a specific version of a specific program on a specific host using a TCP or UDP transport, and to report whether a response is received.
Syntax
List all programs registered with the port mapper:
rpcinfo -p [host]
rpcinfo [-n portnum] -u host program [version]
rpcinfo [-n portnum] -t host program [version]
rpcinfo -b program version
rpcinfo -d program version




 
 

RPC Library

RPC Service Library Routines:

RPC Library
RPC Library