740 likes | 881 Vues
3. Communication in distributed system. Name,. Communication middleware. IP address port,. 3.1 Introduction. Interprocess communication is at the heart of distributed systems. Distributed Application. Low-level message passing underlying network. P69. Middleware Protocols.
E N D
Name, ... Communication middleware IP address port, ... 3.1 Introduction Interprocess communication is at the heart of distributed systems Distributed Application Low-level message passing underlying network
P69 Middleware Protocols An adapted reference model for networked communication. 2-5
Distributed Middleware • Communication middleware: RPC, RMI, MPI • name DCE, CORBA • message-oriented • various communication forms • Authentication, authorization protocols • Distributed commit protocols
Client-Server TCP P65 Normal operation of TCP. Transactional TCP. 2-4
S T Q P Two issues for communication mechanism: • How indicate destination? • How many methods (forms)?
S T Q P 1. Addressing Indicate sending and receiving processes 1) <IP address, port no.> ex, <202.119.32.6, 80> 2) Unique name ex, www.nju.edu.cn; procedure name( )
Domain name IP address Type www.nju.edu.cn 202.119.32.6 A cs.nju.edu.cn 202.119.36.5 A …… …... …... www.nju.edu.cn DNS 80 21 ftp://nju.edu.cn <202.119.32.6, 21> <202.119.32.6, 80> web server FTPd 202.119.32.6
sender sender receiver receiver mailbox 3) Mailbox (queue, indirect) multi-in, multi-out 2. Methods 1) Synchronous/asynchronous
waiting waiting Synchronous: sender will be blocked if receiver is not ready P1 P2 send receive receive send send( ), recv( ); RPC
UDP, Asynchronous RPC Asynchronous P1 P2 send receive receive send Internet?
Comparison Defects merits Synchronous wait, no broadcast safe, simple Asynchronous buffer full,not safe parallelism, broadcast 2) Transient/persistent • Persistent communication: A message is stored by communication system as long as it takes to deliver it. Neither the sender nor the receiver need to be up. Ex, email P100-1
send, recv; RPC UDP; asyn RPC email • Transient communication: A message is stored by communication system as long as the sending and receiving applications are executing Ex, send, recv in Socket Question: difference (relation) between 1) and 2) transient synchronous persistent asynchronous As to: 1) sender/receiver; 2) message
3) Stream-oriented communication Two successive messages have a temporal relationship. Ex, movie, audio stream
P68 3.2 RPC P1 P2 Proc G(u,v) Call P2.G(x,y) node 1 node 2 ……….. 2003.7 Worm.msBlast
i buf j sp 1. Conventional procedure call Node 1 process Procedure Q(u,box,v) { … { … Q(i,buf,j) … … } } return addr. result stack
proc Q int i return addr.1 ? buf return addr 2 int j i result i buf sp buf j j sp return 2. How does RPC work? node 1node 2 process Procedure Q(u,box,v) { … { … Q(i,buf,j) … … } } result result ? stack stack
Original procedure call: Now push return addr.1 push i Q(i,buf,j) push buf push j goto Q goto c_stub take result
Q( ) { } • S_stub • receive message • unpack message • push return addr. • goto Q( ) • take & pack result • send it to C_stub • C_stub • pack parameters & name • send them to S_stub • receive result • unpack result • return transform
P72 Steps of a Remote Procedure Call • Client procedure calls client stub in normal way • Client stub builds message, calls local OS • Client's OS sends message to remote OS • Remote OS gives message to server stub • Server stub unpacks parameters, calls server • Server does work, returns result to the stub • Server stub packs it in message, calls local OS • Server's OS sends message to client's OS • Client's OS gives message to client stub • Stub unpacks result, returns to client
P74 Passing Value Parameters Steps involved in doing remote computation through RPC 2-8
Issues to be handled • Machine may be not identical • Execute in different spaces • Machine may crash 3. Parameter passing Implementation should consider: • Different types of computers • Pointer or call by reference
P75 1) Deal with different types of computers 5 Jill (a) Original message on the Pentium (b) The message after receipt on the SPARC (c) The message after being inverted. The little numbers in boxes indicate the address of each byte
proc Q int i char buf int j How represent parameters? • In intermediate form • Indicating in type i typeitypej Message should include parameters and their type 2) Deal with call by reference
B 5200 Node1Node2 Main( ) { int B[100] proc write(name,buf,len) … { int len, buf[ ]; write(f1,B,100)… … } proc read(name, buf, len) { int len, buf[ ]; read(f2,B,100) … } 5200
write read
proc write(in char name, in int buf[], in int len); proc read(in char name, out int buf[], in int len); • Input parameter deliver the array • Output parameter needn’t 4. Where stubs come from? • Write server specification (interfaces) including: Server name, version, list of procs • Stub compiler generates c_stub & s_stub
Specification of file server Specification of file_server, version 3.1: long read(in char name[MAX_PATH], out char buf[BUF_SIZE], in long bytes, in long position); long write(in char name[MAX_PATH], in char buf[BUF_SIZE], in long bytes, in long position); int create(in char name[MAX_PATH], in int mode); int delete(in char name[MAX_PATH]); end; return IDL
C_stub specification Stub compiler S_stub 5. Steps for using RPC • write specification • compile • write server code and link with s_stub • write client code and link with c_stub
P82 The steps in writing a client and a server in DCE RPC.
{…… } {…… }
binder 2 1 3 client server 4 6. Dynamic binding --- How client find server 1) Register: name, version, handle(IP,port), unique id 2) Look up: name, version (first time) 3) Reply: handle, unique id 4) Request: unique id, parameters 5) Deregister: name, version, unique id
Advantage: flexible • Server move won’t affect client • Binder can even load if multiple servers support the same interface • Disadvantage • Overhead at running time • Binder is bottleneck
NFS FTP Telnet XDR RPC Socket/TLI TCP|UDP ICMP IP ARP Driver Addressing Method Addressing: name Method: synchronous, transient
100 A B 7. Extended RPC --- asynchronous RPC P79 (a) The interconnection between client and server in a traditional RPC (b) The interaction using asynchronous RPC
A client wants to prefetch network addresses of a set of hosts A client and server interacting through two asynchronous RPCs 2-13 P80
P86 3.3 RMI (or Remote Object Invocation) Common organization of a remote object with client-side proxy.
1. Distributed object RMI Compares to RPC: • Same: • the steps of call is similar • separating interface from implementation • Difference • procedure is a segment of program. • object is a variable of a data type, method is in object.
distributed obj local object remote Object reference compare to pointer. System provides 2. Object references Object references are similar to pointer, but not the same. point object object reference
advertise salesman cost() {… } bonus() {… } employee Object servers promote() {…} dismiss() {… } 2. personnel.hire( ) Corp server 3. personnel ? hire() {… } … P152 Sale server 1. IP address
Information object reference contains P89 • network address of the machine • server id or endpoint (i.e.port number) • object id
2 1 3 4 • May use location server location server client server Server can move
3. Implementation of object references • Server id instead of server’s endpoint. A daemon listens to a well-known endpoint and knows every server. daemon server1 keep a table server2
How introduce object? 4. Several remote object invocation chapter 9 1) CORBA Open, heterogeneous environment 2) DCOM Microsoft world C++ Java C func P( ) Object Object
3) Java RMI • Java environment • Distributed objects have been integrated into the language Summary Addressing: name Method: synchronous, transient
P99 3.4 Message-oriented communication 1. Message-oriented transient communication 1) RPC and RMI advantages: hide communication; message-oriented disadvantage: synchronous; both need to be up 2) Recall socket P105 addressing: IP address, port forms: synchronous/asynchronous, transient shortage: low-level, byte-oriented/TCP-IP
3) MPI P107 designed for parallel applications; offer efficient communication primitives; for high-speed nets. World Jupiter Process0 Process1 Process2 Process0 Process1 Process3 Process2 Process5 Process4 communicator
100 • Addressing (groupID, processID) • Forms support most transient communication forms ? A B; email Need for various communication forms • Synchronous/asynchronous • Transient/persistent
100 Various combinations: P103 Why list so many forms? Where to use? For efficiency. (a) email (c) A B (e) send recv (f) RPC (persistent, asynchronous) (transient, asynchronous) (transient, synchronous) (transient, synchronous/asyn)