0% found this document useful (0 votes)
34 views23 pages

Remote Procedure Call: Outline

The document describes remote procedure call (RPC) protocols. It outlines the RPC protocol stack including presentation formatting, BLAST for message fragmentation, CHAN for request-reply synchronization, and SELECT for dispatching calls to server procedures. It then provides details on the operation and header formats of each component.

Uploaded by

Henri Yates
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views23 pages

Remote Procedure Call: Outline

The document describes remote procedure call (RPC) protocols. It outlines the RPC protocol stack including presentation formatting, BLAST for message fragmentation, CHAN for request-reply synchronization, and SELECT for dispatching calls to server procedures. It then provides details on the operation and header formats of each component.

Uploaded by

Henri Yates
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Remote Procedure Call

Outline
Protocol Stack
Presentation Formatting

Spring 2002 CS 461 1


RPC Timeline

Client Server

Blocked

Blocked Computing

Blocked

Spring 2002 CS 461 2


RCP Components
• Protocol Stack
– BLAST: fragments and reassembles large messages
– CHAN: synchronizes request and reply messages
– SELECT: dispatches request to the correct process
• Stubs
Caller Callee
(client) (server)
Return Return
Arguments Arguments
value value
Client Server
stub stub

Request Reply Request Reply

RPC RPC
protocol protocol

Spring 2002 CS 461 3


Bulk Transfer (BLAST)
Sender Receiver

• Unlike AAL and IP,


tries to recover from
lost fragments

• Strategy
– selective retransmission
– aka partial
acknowledgements

Spring 2002 CS 461 4


BLAST Details
• Sender:
– after sending all fragments, set timer DONE
– if receive SRR, send missing fragments and reset DONE
– if timer DONE expires, free fragments

Spring 2002 CS 461 5


BLAST Details (cont)
• Receiver:
– when first fragments arrives, set timer LAST_FRAG
– when all fragments present, reassemble and pass up
– four exceptional conditions:
• if last fragment arrives but message not complete
– send SRR and set timer RETRY
• if timer LAST_FRAG expires
– send SRR and set timer RETRY
• if timer RETRY expires for first or second time
– send SRR and set timer RETRY
• if timer RETRY expires a third time
– give up and free partial message

Spring 2002 CS 461 6


BLAST Header Format
0 16 31

• MID must protect against wrap around ProtNum

MID
• TYPE = DATA or SRR
Length
• NumFrags indicates number of fragments NumFrags Type
• FragMask distinguishes among fragments FragMask

– if Type=DATA, identifies this fragment Data

– if Type=SRR, identifies missing fragments

Spring 2002 CS 461 7


Request/Reply (CHAN)
• Guarantees message delivery
• Synchronizes client with server
• Supports at-most-once semantics
Simple case Implicit Acks
Client Server Client Server


Spring 2002 CS 461 8
CHAN Details
• Lost message (request, reply, or ACK)
– set RETRANSMIT timer
– use message id (MID) field to distinguish
• Slow (long running) server
– client periodically sends “are you alive” probe, or
– server periodically sends “I’m alive” notice
• Want to support multiple outstanding calls
– use channel id (CID) field to distinguish
• Machines crash and reboot
– use boot id (BID) field to distinguish
Spring 2002 CS 461 9
CHAN Header Format
typedef struct {
u_short Type; /* REQ, REP, ACK, PROBE */
u_short CID; /* unique channel id */
int MID; /* unique message id */
int BID; /* unique boot id */
int Length; /* length of message */
int ProtNum; /* high-level protocol */
} ChanHdr;

typedef struct {
u_char type; /* CLIENT or SERVER */
u_char status; /* BUSY or IDLE */
int retries; /* number of retries */
int timeout; /* timeout value */
XkReturn ret_val; /* return value */
Msg *request; /* request message */
Msg *reply; /* reply message */
Semaphore reply_sem; /* client semaphore */
int mid; /* message id */
int bid; /* boot id */
} ChanState;

Spring 2002 CS 461 10


Synchronous vs Asynchronous
Protocols
• Asynchronous interface
send(Protocol llp, Msg *message)
deliver(Protocol llp, Msg *message)

• Synchronous interface
call(Protocol llp, Msg *request, Msg *reply)
upcall(Protocol hlp, Msg *request, Msg *reply)

• CHAN is a hybrid protocol


– synchronous from above: call
– asynchronous from below: deliver

Spring 2002 CS 461 11


Dispatcher (SELECT)
• Dispatch to appropriate Caller
Client
Callee
Server

procedure call upcall

• Synchronous SELECT SELECT

counterpart to UDP call upcall

• Implement concurrency CHAN CHAN

(open multiple CHANs) send deliver send deliver

• Address Space for Procedures


– flat: unique id for each possible procedure
– hierarchical: program + procedure number

Spring 2002 CS 461 12


Simple RPC Stack
SELECT

CHAN

BLAST

IP

ETH

Spring 2002 CS 461 13


SunRPC
• IP implements BLAST-equivalent SunRPC

– except no selective retransmit


UDP

• SunRPC implements CHAN-equivalent


– except not at-most-once IP

ETH

• UDP + SunRPC implement SELECT-equivalent


– UDP dispatches to program (ports bound to programs)
– SunRPC dispatches to procedure within program

Spring 2002 CS 461 14


SunRPC Header Format
• XID (transaction id) is 0
XID
31 0
XID
31

similar to CHAN’s MID MsgType = CALL MsgType = REPLY

• Server does not remember RPCVersion = 2 Status = ACCEPTED

last XID it serviced Program Data

• Problem if client Version

retransmits request while Procedure

reply is in transit Credentials (variable)

Verifier (variable)

Data

Spring 2002 CS 461 15


Presentation Formatting
• Marshalling (encoding)
application data into Application Application
messages data data

• Unmarshalling
(decoding) messages Presentation
encoding
Presentation
decoding
into application data

Message Message Message

• Data types we consider • Types of data we do not consider


– integers – images
– floats – video
– strings
– multimedia documents
– arrays
– structs

Spring 2002 CS 461 16


Difficulties
• Representation of base types
– floating point: IEEE 754 versus non-standard
– integer: big-endian versus little-endian (e.g., 34,677,374)
(2) (17) (34) (126)
Big-endian 00000010 00010001 00100010 01111110

(126) (34) (17) (2)


Little-endian 01111110 00100010 00010001 00000010

High Low
address address
• Compiler layout of structures

Spring 2002 CS 461 17


Taxonomy
• Data types
– base types (e.g., ints, floats); must convert
– flat types (e.g., structures, arrays); must pack
– complex types (e.g., pointers); must linearize
Application data structure

Marshaller

• Conversion Strategy
– canonical intermediate form
– receiver-makes-right (an N x N solution)
Spring 2002 CS 461 18
Taxonomy (cont)
• Tagged versus untagged data
type = len = 4 value = 417892
INT

• Stubs Interface
descriptor for
– compiled Call P Procedure P P
– interpreted
Arguments Specification Arguments

Client Code Stub Code Server


stub compiler stub
Marshalled Marshalled
arguments arguments

RPC RPC

Message

Spring 2002 CS 461 19


eXternal Data Representation
(XDR)
• Defined by Sun for use with SunRPC
• C type system (without function pointers)
• Canonical intermediate form
• Untagged (except array length)
• Compiled stubs

Spring 2002 CS 461 20


#define MAXNAME 256;
#define MAXLIST 100;

struct item {
int count;
char name[MAXNAME];
int list[MAXLIST];
};

bool_t
xdr_item(XDR *xdrs, struct item *ptr)
{
return(xdr_int(xdrs, &ptr->count) &&
xdr_string(xdrs, &ptr->name, MAXNAME) &&
xdr_array(xdrs, &ptr->list, &ptr->count,
MAXLIST, sizeof(int), xdr_int));
}

Count Name
3 7 J O H N S O N

List
3 4 97 8 321 2 65

Spring 2002 CS 461 21


Abstract Syntax Notation One
(ASN-1)
• An ISO standard
• Essentially the C type system
• Canonical intermediate form
• Tagged
• Compiled or interpretted stubs
• BER: Basic Encoding Rules
(tag, length, value)

type length type length value type length value


value

INT 4 4-byte integer

Spring 2002 CS 461 22


Network Data Representation
(NDR)
• Defined by DCE – IntegerRep
• 0 = big-endian
• Essentially the C type system • 1 = little-endian
• Receiver-makes-right – CharRep
(architecture tag) • 0 = ASCII
• 1 = EBCDIC
• Individual data items untagged – FloatRep
• Compiled stubs from IDL • 0 = IEEE 754
• 1 = VAX
• 4-byte architecture tag • 2 = Cray
• 3 = IBM

0 4 8 16 24 31
IntegrRep CharRep FloatRep Extension 1 Extension 2

Spring 2002 CS 461 23

You might also like