• No results found

rpc-new.ppt

N/A
N/A
Protected

Academic year: 2020

Share "rpc-new.ppt"

Copied!
43
0
0

Loading.... (view fulltext now)

Full text

(1)
(2)

Client and Server Stubs

(3)

Remote procedure call

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

(4)

client server

Steps of a Remote Procedure Call

network routines network routines server functions server functions server stub (skeleton) server stub (skeleton) network routines network routines

1. Client calls stub

client functions

client functions

client stub

(5)

client server

Stub functions

server functions server functions server stub (skeleton) server stub (skeleton) network routines network routines

2. Stub marshals params to net message

(6)

client server

Stub functions

3. Network message sent to server

(7)

client server

Stub functions

4. Receive message: send to stub

(8)

client server

Stub functions

5. Unmarshal parameters, call server function

(9)

client server

Stub functions

6. Return from server function

(10)

client server

Stub functions

7. Marshal return value and send message

(11)

client server

Stub functions

8. Transfer message over network

(12)

client server

Stub functions

9. Receive message: direct to stub

(13)

client server

Stub functions

10. Unmarshal return, return to client code

(14)

Passing Value Parameters (1)

(15)

Passing Value Parameters (2)

a) Original message on the Pentium

b) The message after receipt on the SPARC

(16)

Doors

(17)

Asynchronous RPC (1)

a) The interconnection between client and server in a traditional RPC

(18)

Asynchronous RPC (2)

(19)

Sun RPC/ONC (Open Network Computing) RPC

It is designed for client-server communication over

Sun

NFS network file system.

UDP or TCP can be used. Generally, if UDP is used, the

message length is restricted to 64 KB, but 8 - 9 KB in

practice.

(20)

Sun/ONC RPC

Steps to create a Sun RPC application:

1. Create the IDL file (add.x), the client main code (add_client.c), and the server function code (add_server.c)

2. Run the RPC generator (rpcgen –a add.x) to generate client stub (add_clnt.c), server stub (add_svc.c), header file (add.h), and data coversion file (add_xdr.c).

3. Compile the client and server programs (gcc -o add_client add_client.c) and (gcc -o add_server add_server.c)

4. Start the server (./add_server)

(21)

RPC IDL File

The notation of Sun RPC IDL:

 a program number and a version number are supplied.

 The procedure number is used as a procedure definition.

 Single input parameter and output result are being passed.

RPC IDL Specification likes this:

program-def:

"program" identifier "{“ version-def:

"version" identifier "{“ procedure-def:

(22)

ONC RPC Interface Compiler

RPC Specification RPC Compiler Shared Filters and Header Files Client Stub Server Skeleton
(23)

Binding

 Sun RPC does not have a network-wide binding service. Instead it provides a local binding service called the portmapper which runs on every computer. Each instance of a portmapper records the port in use by each service running locally.

(24)
(25)
(26)

RPC Messages

Two type of message involved in the implementation

of an RPC

• Call messages

(27)

Server implementation

Server may be of two types

• Stateful

• State information are stored

• Stateless

(28)

call semantics

• Client process and the server processes possibly located on different nodes

• It is possible for either the caller or the callee node to fail independently and later to be restarted

Also failure of communication links between the caller and

callee node is also possible

• RPC may get disrupted due to one or more of following reason

 call message gets lost

 response message gets lost

 Callee node crashes and it restarted

(29)

call semantics…

• call semantics of an RPC system that determines how often the remote procedure may be executed under fault condition depends on this part of the RPC runtime code

• RPC runtime code provide the flexibility to the application programmer to select from different possible call semantics supported by an RPC system

• Type of call semantics

• Possibly or May-be call Semantics

• Last -one -call Semantics

• Last -of-many call semantics

• At-least-Once call semantics

(30)

call semantics…

Possibly or May-Be call Semantics :

 Weakest semantics

 Caller waits for predefined timeout

 No guarantee of receipt of call message

 Idle for LAN types of environment

• Last one call semantics

 Semantic retransmits the call message based on timeout

 Process repeats until caller receives the result

(31)

call semantics..

Last of Many call semantics

 It neglects orphan call by using call ID to identify each call

 Client checks messages ID, accepts response if call ID matches the recently repeated call else ignore

At- least once call semantics

 Call is executed one or more times but does not specify which result caller gets

 Nested calls having orphan calls, caller accepts the result of first response and ignore other

• Exactly Once call semantics

 Strongest call semantics

(32)

Example:

RPC IDL File (add.x)

struct intpair { int a; int b; };

program ADD_PROG {

version ADD_VERS {

int ADD(intpair) = 1; } = 1;

(33)

Example (Sun RPC)

Program-number is usually assigned as follows:

 0x00000000 - 0x1fffffff defined by SUN

 0x20000000 - 0x3fffffff defined by user

 0x40000000 - 0x5fffffff transient

(34)

RPC Client Code (1) [add_client.c]

#include "add.h" #include <stdio.h> void

add_prog_1( char* host, int a, int b ) {

CLIENT *clnt; int *result_1; intpair add_1_arg;

clnt = clnt_create(host, ADD_PROG, ADD_VERS, "udp");

if (clnt == NULL) {

clnt_pcreateerror(host); exit(1);

}

add_1_arg.a = a; add_1_arg.b = b;

result_1 = add_1(&add_1_arg, clnt); if (result_1 == NULL) {

clnt_perror(clnt, "call failed:"); }

else

print("return is %d\n", *result_1); clnt_destroy( clnt );

(35)

RPC Client Code (2) [add_client.c]

int

main(int argc, char *argv[]) {

char *host; int a, b;

if (argc != 4) {

printf ("usage: %s server_host num1 num2\n", argv[0]); exit(1);

}

host = argv[1];

if ((a = atoi(argv[2])) == 0 && *argv[2] != '0') { fprintf(stderr, "invalid value: %s\n", argv[2]); exit(1);

}

if ((b = atoi(argv[3])) == 0 && *argv[3] != '0') { fprintf(stderr, "invalid value: %s\n", argv[3]); exit(1);

}

(36)

RPC Server Code (add_server.c)

/* * RPC server code for the remote add function */

#include "add.h" int *

add_1_svc(intpair *argp, struct svc_req *rqstp) {

static int result;

result = argp->a + argp->b;

printf("add(%d, %d) = %d\n", argp->a, argp->b, result); return &result;

(37)

Compilation Linking

 rpcgen –a add.x

 gcc -c add_client.c -o add_client.o

 gcc -c add_clnt.c -o add_clnt.o

 gcc -c add_xdr.c -o add_xdr.o

gcc -o client add_client.o add_clnt.o add_xdr.ogcc -c add_server.c -o add_server.o

gcc -c add_svc.c -o add_svc.o

(38)

Internal Details of ONC RPC

Initialization

Server runs: register RPC with port mapper on server host (rpcinfo –p)

Client runs: clnt_create contacts server's port mapper and establishes TCP/UDP connection with server

Client

 Client calls local procedure (client stub: add_prog_1), that is generated by rpcgen. Client stub packages arguments, puts them in standard format (XDR), and prepares network messages (marshaling).

 Network messages are sent to remote system by the client stub.

(39)

Internal Details of ONC RPC

Server

 Server stub (generated by rpcgen) unmarshals arguments from network messages. Server stub executes local procedure (add_1_svc) passing arguments received from network messages.

 When server procedure is finished, it returns to server stub with return values.

 Server stub converts return values (XDR), marshals them into network messages, and sends them back to client

Back to Client

 Client stub reads network messages from kernel

(40)

RPC in Practice - DCE RPC

• The Distributed Computing Environment (DCE) RPC is developed by the Open Software Foundation (OSF)/Open Group.

• DCE is a middleware executing as an abstraction layer between (network) operating systems and distributed applications.

• Microsoft derived its version of RPC from DCE RPC (e.g., MIDL compiler, etc.)

DCE includes a number of services:

– Distributed file service

– Directory service

– Security service

(41)

Writing a Client and a Server

The steps in writing a client and a server in DCE RPC.

(42)

Client-to-Server Binding (DCE RPC)

Issues:

Client must locate server machine and

locate the server.

Execution of Client and Server

The server registers its procedures with the portmapper.Client must locate server machine: The client contacts

the portmapper to determine which port the server is listening to.

The client communicates with the server on the assigned

port.

DCE uses a separate daemon for each server

(43)

Binding a Client to a Server

References

Related documents

After reviewingclassical theoriesand the universal methods of enterprise evaluation, this paperuses the Discounted Free Cash Flow Method to study this merger

3 - 5 Status Bar Info Center Maximize, Minimize, and Close Buttons Styles Toolbar Layers Toolbar Standard Toolbar Quick Access Toolbar Menu Browser Button Smooth Mesh

Discussion Topic(s): “Website/mobile device security” – Computer security, also known as cybersecurity or IT security, is the protection of information systems from theft or

If you are a small business owner that is thinking about upgrading your current phone system because it’s outdated, you’re moving offices or because you just want to see if you

As a consequence, a fuzzy image segmentation using suppressed fuzzy c-means clustering (FSSC) algorithm was proposed that merged the initially segmented regions produced by a

If you’re one of the many lawyers who have decided to take advantage of the cloud for cost savings, mobility, security, flexibility and disaster preparedness, it’s important that

In addition, all Residents and Guests shall use the Recreation Facilities at their own risk, on the expressed understanding that the condominium, the Board of Directors and the