Rpc

28
Remote Procedure Calls By P.SAHITHI CHAITANYA (1551210075) A.RAMPRAKASH REDDY(1551210077) G.V.R.SHASHANK(1551210080)

Transcript of Rpc

Page 1: Rpc

Remote Procedure

Calls

ByP.SAHITHI CHAITANYA (1551210075)

A.RAMPRAKASH REDDY(1551210077)G.V.R.SHASHANK(1551210080)

Page 2: Rpc

Introduction Inter-process communication (IPC). Another virtual address space.

Another process on the same machine. Another process on different machine.

Hides remote interaction. Network programming standard 1980s Builds on named pipes or Winsock. Remote Method Invocation (RMI)

Page 3: Rpc

How RPC Operates

Page 4: Rpc

Cont…. When client code calls a remote

procedure, the client stub code Retrieves the required parameters from the

client address space. Marshals1 the parameters as needed into a

standard NDR2 format for transmission over the network.

Calls functions in the RPC client run-time library to send the request and its parameters to the server.

1 Marshalling (similar to serialization) is the process of transforming the memory representation of an object to a data format suitable for storage or transmission2 Network Data Representation (NDR) is an implementation of the presentation layer in the OSI model.

Page 5: Rpc

Cont… The server performs the following steps to

call the remote procedure: The server RPC run-time library functions accept

the request and call the server stub procedure. The server stub retrieves the parameters from

the network buffer and converts (i.e. unmarshals) them from the network transmission format to the format the server needs.

The server stub calls the actual procedure on the server.

Page 6: Rpc

Stubs Client stub

Packs parameter into message. Calls : Send & Receive.

Server Stub Calls : Receive & Send. Unpacks parameter from the message.

Details of message passing are hidden – two libraries.

Page 7: Rpc

Cont…

Page 8: Rpc

Steps1. The client procedure calls the client stub in the normal way. 2. The client stub builds a message and traps to the kernel.3. The kernel sends the message to the remote kernel.4. The remote kernel gives the message to the server stub.5. The server stub unpacks the parameters and calls the server.6. The server does the work and returns the result to the stub.7. The server stub packs it in a message and traps to the kernel.8. The remote kernel sends the message to the clients kernel.9. The client’s kernel gives the message to the client stub.10. The stub unpacks the result and returns to the client.

Page 9: Rpc

Parameter Passing

Parameter Marshaling. Ex: Remote procedure “sum( i, j)”.

Identical machines.

Page 10: Rpc

Problems - Parameter Passing Different Machine Types

Ex: IBM mainframes (EBCDIC) & IBM PCs(ASCII).

Different representation of Integers (1s compliment & 2s Compliment), Floating point numbers.

Numbering of bytes Right to Left (Ex: Intel 486) – Little Endian. Left to Right (Ex: Sun SPARC) – Big Endian.

Page 11: Rpc

Example - 1

Page 12: Rpc

Example - 2

Page 13: Rpc

Representation of Information Canonical Form

Convert internal representation while marshaling.

Ex: 2’s compliment for integers. 0 for ASCII. 1 for Boolean. IEEE format for floating point no.

Page 14: Rpc

Pointer Passing One way is to forbid the pointers & reference parameters in

general. – Highly undesirable One strategy is copying the whole array/structure (simple)

into message. Call by reference is replaced by copy/restore. Optimization – Buffer knows if stub is an input / output

parameter. (Twice as efficient). Pointer is followed (dereferenced) by putting it in the

register. – Highly Inefficient.

Page 15: Rpc

Dynamic Binding

Hardwiring network add. of server into client – Extremely Inflexible

To avoid problems like Replication of server Relocation Migration Interface Change

Page 16: Rpc

Terms Exports Interface Imports Interface Binder Registering

Unique Id – Typically 32 bit long Handle

System Dependent IP Add. , Ethernet Add. , etc.

Page 17: Rpc

Disadvantages

Overhead Exporting & Importing Costs Time Many short lived client process may have to start over

again. Binder may act as bottleneck in distributed system. Registering / Deregistering of interfaces creates more

overhead.

Page 18: Rpc

RPC semantics-presence of failures Unable to locate the server Lost request message Lost reply message Server crashes Client crashes

Page 19: Rpc

Unable to locate the server When server is down it intimate the value -

1 Client is unable to locate the server

Page 20: Rpc

Lost request message Message send from client to server is lost

Page 21: Rpc

Lost reply message Reply message from server to client is lost

Page 22: Rpc

Server crashes Server crashes after receiving a request Solutions

Atleast one semantic Atmost one semantic Exactly one semantic

Page 23: Rpc

Client crashes Client crashes after sending a request Solution is extermination

Page 24: Rpc

Protocols for RPCs1. Request protocol2. Request / Reply protocol3. Request /Reply /Acknowledge-Reply

protocol

Page 25: Rpc

Request (R) protocolClient Server

First RPC

NextRPC

Request message

Request message Procedureexecution

Procedureexecution

Page 26: Rpc

Request / Reply (RR) protocol

Client Server

First RPC

NextRPC

Request message

Request message

Procedureexecution

Procedureexecution

Reply message

Reply message

Also serves as acknowledgement for the request message

Also serves as acknowledgement for the request message

Also serves as acknowledgement for the reply of the previous RPC

Page 27: Rpc

Request / Reply / Ack. (RRA) protocol

Client Server

First RPC

NextRPC

Request message

Request message

Procedureexecution

Procedureexecution

Reply message

Reply message

Reply acknowledgement message

Reply acknowledgement message

Page 28: Rpc