Communication - London South Bank University

Download Report

Transcript Communication - London South Bank University

Outcomes
• What is RPC?
• The difference between conventional procedure
call and RPC?
• Understand the function of client and server
stubs
• How many steps could happen for a RPC?
• How RPC deals with the parameter passing?
• How to write a client and server using DCE
RPC?
1
RPC - Conventional Procedure Call
a)
b)
Parameter passing in a local procedure call: the stack before the
call to read (fd, buf, nbytes)
2
The stack while the called procedure is active
Definition of Remote Procedure Call
Principle of RPC between a client and server program.
• When a process on machine A calls a procedure on machine B,
the calling process on A is suspended, and execution of the called
procedure takes place on B. Information can be transported from
the caller to the callee in the parameters and can come back in the
procedure result. No message passing at all is visible to the
programmer. This method is known as Remote Procedure Call. 3
Client and Server Stubs
2-8
Steps involved in doing remote computation through RPC
• The function of stub is that, instead of asking operating to give it
data, it packs the parameters into message and requests the
message to be sent to the server. After client stub calls send, it calls
receive, block itself until the reply comes back.
4
Steps of a Remote Procedure Call
1. Client procedure calls client stub in normal way
2. Client stub builds message, calls local OS
3. Client's OS sends message to remote OS
4. Remote OS gives message to server stub
5. Server stub unpacks parameters, calls server
6. Server does work, returns result to the stub
7. Server stub packs it in message, calls local OS
8. Server's OS sends message to client's OS
9. Client's OS gives message to client stub
10. Stub unpacks result, returns to client
5
Passing Reference Parameters
• Passing the reference parameter is very difficult:
– read(fd, buf, nbytes) example
• One solution is to forbid pointers and reference
parameters in general.
• Strategy : In read example, the client stub knows the buf
points to an array and the array length.
– Client stub copies the array into message and send it to the
server
– Server stub call the server with a pointer to this array
– When server (procedure) finishes, the original message can be
sent back to the client stub
– Client stub copies buf back to the client (procedure).
6
Parameter Specification and Stub Generation
•Hiding a RPC requires C-S agree on the format of the
messages they exchange
•In this example, both S stub and C stub should knows the
format of foobar
•RPC protocols should contains all agreements such as
transfer protocols and message format, etc.
•Different procedure has different interface to the
applications. It should be defined by IDL (interface define
Language.
a)
b)
A procedure
The corresponding message.
7
Writing a Client and a Server
2-14
The steps in writing a client and a server in DCE RPC.
8
Binding a Client to a Server
2-15
Client-to-server binding in DCE.
• To allow a client to call a server, the server must be registered first
• The steps to locate the server and bind to it:
– Locate the server’s machine
– Locate the server (i.e. the correct process) on that machine
9