Communication Tran, Van Hoai Department of Systems & Networking Faculty of Computer Science & Engineering HCMC University of Technology Outline • Communication organized in layers • Communication models – Remote Procedure Call – Remote Method Invocation – Message Oriented Middleware – Streams 2009-2010 2 Communication is critical “A system in which hardware or software located at networked computers communicate and coordinate their actions only by message passing”. [Coulouris] 2009-2010 3 OSI model application presentation session transport application protocol 7 presentation protocol 6 session protocol 5 transport protocol 4 network protocol 3 Practicallydataimplemented link protocol 2 data link in Internet physical protocol 1 physical network Network Message in layered communication data link layer header network layer header transport layer header session layer header presentation layer header application layer header data link layer trailer Message Application Protocols • Session/Presentation Protocols – Rarely used in practice • Application Protocols – No clear distinction (in application layer) between • Application (ftp program) General-purpose protocols (in application layer) can be considered as protocol transport protocols, • Application-specific (Internet File Transfer butProtocol) are classified as MIDDLEWARE PROTOCOLS • General-purpose protocol – HTTP used for Web – HTTP used for JAVA Middleware protocols • What is it ? – more specific application – support a variety of middleware services • Examples – Authentication protocol – Authorization protocol – Multimedia broadcasting protocol They are independent to applications, but can be used in many middleware services Adapted OSI model application presentation middleware session transport network data link physical application protocol 76 presentation protocol middleware protocol session protocol 6 5 5 transport protocol 4 network protocol 3 data link protocol 2 physical protocol 1 Network • Middleware communication services provide message-passing services Remote Procedure Call (RPC) • Suggested by Birrell & Nelson (1984) • Quite simple – Calling procedures on different machines like conventional procedure calls • • • • Procedure A() calls a procedure B() A() transfers parameters, execution of A() suspended B() performed until finish Execution returns to A() How conventional call implemented? • read( fd, buf, nbytes ) Stack before Stack after Main program’s local variables stack pointer Main program’s local variables • Parameters Call-by-value Call-by-reference nbytes buf fd return address read’s local variables Principle of RPC • • • • • • • • • • Client procedure calls client stub in normal way Client stub builds message and calls local OS Client OS sends message to remote OS Remote OS gives message to server stub Server stub unpack parameters and calls server Server works and returns result to server stub Server stub packs message and calls local OS Server OS sends message to client OS Client OS gives message to client stub Client stub unpacks results and returns to client wait for result client call remote procedure server return from call request reply call local procedure and return results time RPC example on computation Client machine Server machine Server process Client process k=add(I,j) proc: “add” int: val(i) int: val(j) Implementation of add() Client Server stub stub Client OS k=add(I,j) proc: “add” int: val(i) int: val(j) ServerOS proc: “add” int: val(i) int: val(j) Network Heterogenous architectures • Large distributed systems consist of multiple machine types, difference in – data type representation • • • • IBM mainframe: EBCDIC character code Personal computer: ASCII character code Intel: little endian Sparc: big endian Passing reference parameters • Solutions – Forbid call-by-reference – Call-by-copy/restore – Eliminate copying if not necessary • Not easy to make transparent for complex data structures – graph – linked list Let applications do Parameter specification & Stub generation • Client & server must agree on representation of simple data structures – float in IEEE standard #754 – charaters in 16-bit unicode – stored in little endian Client & server uses connection-oriented protocol • Interface is define by Interface Description Language (IDL), to support stub generation Extended models of RPC • Doors: as IPC computer Server process Client process return to calling process main() { … fd=open(door_name, …); door_call( fd, … ); … Invoke registered } door at other process OS register door server_door() { … door_return(); } main() { … fd = door_create(…); fattach( fd, door_name, …); … } Asynchronous RPC (1) wait for result client call remote procedure server return from call request reply call local procedure and return results time client wait for acceptance call remote procedure server return from call request accept request call local procedure time Asynchronous RPC (2) • Deferred synchronous RPC: combining 2 asynchronous RPC wait for acceptance client call remote procedure server return from call request interrupt client return results acknowledge accept request call local procedure call client with asynchronous RPC time