Client-Server Communication and Remote Procedure Calls

1
CMSC621: Advanced Operating Systems
Nilanjan Banerjee
Advanced Operating Systems
Associate Professor, University of Maryland
Baltimore County
nilanb@umbc.edu
Slide Credit: Dr. Ying Lu
http://www.csee.umbc.edu/~nilanb/teaching/621/
 
Assume that you are developing a client-server
application:
How to let the two processes (client and server)
located on two machines communicate with each
other?
Socket programming: using functions like connect(sd,
(struct sockaddr *)&sin, sizeof(sin)), write(sd, buf,
strlen(buf)) etc.
Client-Server Communication
Remote Procedure Calls (RPC)
Avoid explicit message exchange between
processes
Basic idea is to allow a process on a machine to
call procedures on a remote machine
Make a remote procedure possibly look like a local
one
Original paper on RPC:
A. Birrell, B Nelson, 
Implementing Remote
Procedure Calls
, ACM Symposium on Operating
System Principles, 1984
How are parameters passed in a local procedure call
E.g., 
 
#
include <
sys/types.h
>
  
#include <
unistd.h
>
  
...
  
char buf[20];
  
size_t nbytes;
  
ssize_t bytes_read;
  
int fd;
  
...
  
nbytes = sizeof(buf);
  
bytes_read = read(fd, buf, nbytes);
  
...
Conventional Procedure Call
Conventional Procedure Call
Figure 4-5. (a) Parameter passing in a local procedure call:
the stack before the call to read. (b) The stack while the
called procedure is active.
Remote Procedure Calls (RPC)
How are parameter passed in a remote
procedure call, while making it 
look like a local
procedure call?
Client and Server Stubs
Principle of RPC between a client and server
program.
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
Passing Value Parameters (1)
Steps involved in doing remote computation through RPC
2-8
Passing Value Parameters (2)
Passing Value Parameters (3)
a)
Original message on the Pentium (little-endian)
b)
The message after receipt on the SPARC (big-endian)
Note: the little numbers in boxes indicate the address of
each byte
Passing Value Parameters (3)
a)
Original message on the Pentium (little-endian)
b)
The message after receipt on the SPARC (big-endian)
c)
The message after being inverted (integer 5, 
string:
“LLIJ”
)
Note: the little numbers in boxes indicate the address of
each byte
Passing reference parameters
 
What is Call By Value and Call By Refernce?
Example: call foo(int, int * ) or read(fd, buf, nbytes)
 
 
 
 
 
 
 
Call by copy/restore
 
The dreaded 
pointer problem
Linked list
Complex graph
Marshalling
Values must match cross the network
Machine formats differ
Integer byte order
Little-endian or big-endian
Floating point format
IEEE 754 or not
Marshalling
 
 
transferring data structure used in remote
procedure call from one address space to another.
Define a “network format”, for example following XDR
(
eXternal Data Representation) standard
http://www.ietf.org/rfc/rfc1832.txt
RPC: The basic mechanism
Client 
routines
Client stub
RPC 
runtime
Network
routines
Source: R. Stevens, Unix Network Programming (IPC)
Vol 2,  1998
Server 
routines
Server 
stub
RPC 
runtime
Network 
routines
Process
kernel
Process
kernel
Client process
Server process
1.
Client calls a local procedure on the
client stub
2.
The client stub acts as a proxy and
marshalls
 the call and the args.
3.
The client stub send this to the
remote system (via TCP/UDP)
4.
The server stub 
unmarshalls
 the call
and args from the client
5.
The server stub calls the actual
procedure on the server
6.
The server stub 
marshalls
 the
reply and sends it back to the client
1
2
3
4
5
6
Binding a Client to a Server (1)
Registration of a server makes it possible for
a client to locate the server and bind to it.
Server location is done in two steps:
1.
Locate the server’s machine.
2.
Locate the server on that machine.
Binding a Client to a Server (2)
Figure 4-13. Client-to-server binding in DCE.
Asynchronous RPC (1)
a)
The interconnection between client and server in a
traditional RPC
b)
The interaction using asynchronous RPC
2-12
Asynchronous RPC (2)
A client and server interacting through two
asynchronous RPCs
2-13
LPC v.s. RPC
Global variables
Client and server fail independently
RPC: requires code to deal with server crashes
When Things Go Wrong
 
Semantics of remote procedure calls
Local procedure call: 
exactly once
How many times a remote procedure call may
be called?
A remote procedure call may be called:
0 time
: server crashed or server process died before
executing server code
1 time
: everything worked well
1 or more
: due to excess latency or lost reply from
server, client retransmitted
Exactly once may be difficult to achieve with
RPC
RPC Semantics
 
Most RPC systems will offer either:
at least once
 semantics
or 
at most once
 semantics
Understand application:
Illustrate some applications that “at least once” is suitable?
Idempotent
 functions: may be run any number of times without
harm
Illustrate some applications that “at most once” is suitable?
Slide Note
Embed
Share

Developing client-server applications involves using socket programming for communication between processes on different machines. Remote Procedure Calls (RPC) enable calling procedures on remote machines as if they were local. Explore how parameters are passed in local and remote procedure calls, along with the step-by-step process of RPC between client and server programs.

  • Client-Server Communication
  • Socket Programming
  • Remote Procedure Calls
  • RPC
  • Operating Systems

Uploaded on Dec 06, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. CMSC621: Advanced Operating Systems Nilanjan Banerjee Associate Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/621/ Slide Credit: Dr. Ying Lu Advanced Operating Systems 1

  2. Client-Server Communication Assume that you are developing a client-server application: How to let the two processes (client and server) located on two machines communicate with each other? Socket programming: using functions like connect(sd, (struct sockaddr *)&sin, sizeof(sin)), write(sd, buf, strlen(buf)) etc.

  3. Remote Procedure Calls (RPC) Avoid explicit message exchange between processes Basic idea is to allow a process on a machine to call procedures on a remote machine Make a remote procedure possibly look like a local one Original paper on RPC: A. Birrell, B Nelson, Implementing Remote Procedure Calls , ACM Symposium on Operating System Principles, 1984

  4. Conventional Procedure Call How are parameters passed in a local procedure call #include <sys/types.h> #include <unistd.h> ... char buf[20]; size_t nbytes; ssize_t bytes_read; int fd; ... nbytes = sizeof(buf); bytes_read = read(fd, buf, nbytes); ... E.g.,

  5. Conventional Procedure Call Figure 4-5. (a) Parameter passing in a local procedure call: the stack before the call to read. (b) The stack while the called procedure is active.

  6. Remote Procedure Calls (RPC) How are parameter passed in a remote procedure call, while making it look like a local procedure call?

  7. Client and Server Stubs Principle of RPC between a client and server program.

  8. 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

  9. Passing Value Parameters (1) 2-8 Steps involved in doing remote computation through RPC

  10. Passing Value Parameters (2)

  11. Passing Value Parameters (3) a) b) Note: the little numbers in boxes indicate the address of each byte Original message on the Pentium (little-endian) The message after receipt on the SPARC (big-endian)

  12. Passing Value Parameters (3) a) b) c) Original message on the Pentium (little-endian) The message after receipt on the SPARC (big-endian) The message after being inverted (integer 5, string: LLIJ ) Note: the little numbers in boxes indicate the address of each byte

  13. Passing reference parameters What is Call By Value and Call By Refernce? Example: call foo(int, int * ) or read(fd, buf, nbytes) Machine B Machine A Copy value a and contents of loc b a b a b into a and loc b ReturnCopy contents of loc b into b Call foo(a, &b ) foo(a, &b ) Call by copy/restore The dreaded pointer problem Linked list Complex graph

  14. Marshalling Values must match cross the network Machine formats differ Integer byte order Little-endian or big-endian Floating point format IEEE 754 or not Marshalling transferring data structure used in remote procedure call from one address space to another. Define a network format , for example following XDR (eXternal Data Representation) standard http://www.ietf.org/rfc/rfc1832.txt

  15. RPC: The basic mechanism 1. Client calls a local procedure on the client stub Server process Client process Client routines Server routines 2. The client stub acts as a proxy and marshalls the call and the args. 1 5 3. The client stub send this to the remote system (via TCP/UDP) Server stub Client stub 2 4 RPC runtime RPC runtime 4. The server stub unmarshalls the call and args from the client Process kernel Process kernel 5. The server stub calls the actual procedure on the server 3 6 6. The server stub marshalls the reply and sends it back to the client Network routines Network routines Source: R. Stevens, Unix Network Programming (IPC) Vol 2, 1998

  16. Binding a Client to a Server (1) Registration of a server makes it possible for a client to locate the server and bind to it. Server location is done in two steps: 1.Locate the server s machine. 2.Locate the server on that machine.

  17. Binding a Client to a Server (2) Figure 4-13. Client-to-server binding in DCE.

  18. Asynchronous RPC (1) 2-12 a) The interconnection between client and server in a traditional RPC The interaction using asynchronous RPC b)

  19. Asynchronous RPC (2) A client and server interacting through two asynchronous RPCs 2-13

  20. LPC v.s. RPC Global variables Client and server fail independently RPC: requires code to deal with server crashes

  21. When Things Go Wrong Semantics of remote procedure calls Local procedure call: exactly once How many times a remote procedure call may be called? A remote procedure call may be called: 0 time: server crashed or server process died before executing server code 1 time: everything worked well 1 or more: due to excess latency or lost reply from server, client retransmitted Exactly once may be difficult to achieve with RPC

  22. RPC Semantics Most RPC systems will offer either: at least once semantics or at most once semantics Understand application: Illustrate some applications that at least once is suitable? Idempotent functions: may be run any number of times without harm Illustrate some applications that at most once is suitable?

Related


More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#