Docsity

Remote Procedure Call: Understanding RPC, CHAN, BLAST, and Select in Distributed Systems, Slides of Computer Networks

Partial preview of the text

Download Remote Procedure Call: Understanding RPC, CHAN, BLAST, and Select in Distributed Systems and more Slides Computer Networks in PDF only on Docsity!

2

Lecture No. 33

3

Remote Procedure CallOutlineProtocol Stack

5

RPC Timeline Client

Server BlockedComputingBlocked
Blocked

6

Remote Procedure Call (RPC)• More than just a protocol: popular mechanism forstructuring distributed systems• More complicated than local procedure calls– Complex network between calling and called process– Different architecture and data representation formats• Complete RPC mechanism has two components– Dealing with undesirable properties of network– Packaging arguments into messages and vice-versa (stubcompiler)

8

Remote Procedure Call Semanticswrite_check (CASE, 13500, “tuition payment”);• Bank’s checking service receives request from your homemachine (possibly

reassembling

UDP packets)

-^ Verifies your

identity^

(possibly via RPC to an authority)

-^ Identifies request as a write_check request•^ Unpackages

arguments, possibly converting data to

another format• Calls write_check handler function with arguments

9

Remote Procedure Call Semanticswrite_check (CASE, 13500, “tuition payment”);• At bank’s checking service,

RPC layer

receives return

value from handler function• Packages

up arguments with type write_check_reply

-^ Tags^ package (message) with your bank’s identificationand unique ID for previous request•^ Sends reply to your machine (potentially as several UDPpackets)

11

RPC Components

-^ Protocol Stack– BLAST: fragments and reassembles large messages– CHAN: synchronizes request and reply messages– SELECT: dispatches request to the correct process•^ Stubs

Caller(client)ReturnArgumentsvalueClientstubReplyRequestRPCprotocol

Callee(server)ReturnArgumentsvalueServerstubReplyRequestRPCprotocol

12

Bulk Transfer (BLAST)

-^ Unlike AAL and IP, tries to^ recover

from lost fragments

-^ Strategy–^ Selective

retransmission

  • AKA^ partial

acknowledgements

-^ Sender:– After sending all fragments, set timerDONE– If receive SRR, send missingfragments and reset DONE– If timer DONE expires, freefragments

Sender^

Receiver docsity.com

14

BLAST Header Format

-^ MID must protect against wrap around•^ TYPE = DATA or SRR•^ NumFrags indicates number of fragments•^ FragMask distinguishes among fragments– If Type=DATA, identifies this fragment– If Type=SRR, identifies missing fragments

0 16 31 ProtNumMIDLengthNumFrags^ TypeFragMask^ Data docsity.com

15

Request / Reply (CHAN)• Guarantees message delivery• Synchronizes client with server• Supports^ at-most-once

semantics

Simple case

Implicit Acks

Client^
Server^

Client^

Server …

17

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;

18

Synchronous vs Asynchronous

Protocols

-^ Asynchronous interface^ xPush(Sessn

s,^ Msg^ *msg) xPop(Sessn

s,^ Msg^ *msg,

void^ *hdr) xDemux(Protl

hlp,^ Sessn

s,^ Msg^ *msg)

-^ Synchronous interface^ xCall(Sessn

s,^ Msg^ *req,

Msg^ *rep) xCallPop(Sessn

s,^ Msg^ *req,

Msg^ *rep,

void^ *hdr)

xCallDemux(Protl

hlp,^ Sessn

s,^ Msg^ *req,

Msg^ *rep)

-^ CHAN is a

hybrid^ protocol

  • Synchronous from above:

xCall

  • Asynchronous from below:

xPop/xDemux

20

CHAN (cont)

/ attach header to msg and send it /buf = msgPush(msg, HDR_LEN);chan_hdr_store(hdr, buf, HDR_LEN);xPush(xGetDown(self, 0), msg);/ schedule first timeout event /state->retries = 1;state->event = evSchedule(retransmit, self, state->timeout);/ wait for the reply msg /semWait(&state->reply_sem);/ clean up state and*

return^ */ flush_msg(state->request);state->status = IDLE;return state->ret_val;}

21

CHAN (cont)

*retransmit(Event ev, int arg){Sessn^

s = (Sessn)arg; ChanState^

**state = (ChanState )s->state; Msg^

tmp; / see if event was*

cancelled / if ( evIsCancelled(ev) ) return;/ unblock client if we've

*retried 4 times / if (++state->retries > 4) {state->ret_val =

XK_FAILURE; semSignal(state->rep_sem);return;} / retransmit request message /msgConstructCopy(&tmp, &state->request);xPush(xGetDown(s, 0), &tmp);/ reschedule event with exponential backoff /evDetach(state->event);state->timeout^ = 2state->timeout;state->event = evSchedule(retransmit, s,state->timeout);}*