Outline • Communications in Distributed Systems – Review • Communication Primitives – Message Passing Model – Remote Procedure Calls 5/29/2016 COP5611 1 Distributed Systems • A distributed system is a collection of independent computers that appears to its users as a single coherent system – Independent computers mean that they do not share memory or clock – The computers communicate with each other by exchanging messages over a communication network 5/29/2016 COP5611 2 Distributed Systems – cont. Wide Area Networks 5/29/2016 COP5611 3 Distributed Systems – cont. Local Area Networks 5/29/2016 COP5611 4 ISO OSI Reference Model • Layers, interfaces, and protocols in the OSI model 5/29/2016 COP5611 5 Socket Programming • Review – – – – IP TCP UDP Port • Server Design Issues – Iterative vs. concurrent server – Stateless vs. stateful server – Multithreaded server 5/29/2016 COP5611 6 An Iterative Server 5/29/2016 COP5611 7 A Multithreaded Server 5/29/2016 COP5611 8 Communication Primitives • Communication primitives are the high-level constructs – Programs use the underlying network by calling these primitives – Communication primitives play a significant role in the effective usage of distributed systems • They influence a programmer’s choice of algorithms as well the performance of the programs – Message passing model and remote procedure calls are two widely models for communication primitives 5/29/2016 COP5611 9 The Message Passing Model • The message passing model provides two basic communication primitives – Send and receive – Send has two logical parameters, a message and its destination – Receive has two logical parameters, the source and a buffer for storing the message 5/29/2016 COP5611 10 Semantics of Send and Receive Primitives • There are several design issues regarding send and receive primitives – Buffered or un-buffered – Blocking vs. non-blocking primitives • With blocking primitives, the send does not return control until the message has been sent or received and the receive does not return control until a message is copied to the buffer • With non-blocking primitives, the send returns control as the message is copied and the receive signals its intention to receive a message and provide a buffer for it 5/29/2016 COP5611 11 Semantics of Send and Receive Primitives – cont. • Synchronous vs. asynchronous primitives – With synchronous primitives, a SEND primitive is blocked until a corresponding RECEIVE primitive is executed – With asynchronous primitives, a SEND primitive does not block if there is no corresponding execution of a RECEIVE primitive • The messages are buffered 5/29/2016 COP5611 12 Semantics of Send and Receive Primitives – cont. 5/29/2016 COP5611 13 Semantics of Send and Receive Primitives – cont. 5/29/2016 COP5611 14 Semantics of Send and Receive Primitives – cont. 5/29/2016 COP5611 15 Problems with Message Passing Model • While it is highly flexible, programmers must handle the details using such a model – Pairing of responses with request messages – Data representation – Naming (the address of the remote machine or the server) – Taking care of communication and system failures – The programs can be time-dependent, making it impossible to reproduce errors and debug 5/29/2016 COP5611 16 Remote Procedure Call • RPC is designed to hide all the details from programmers – Overcome the difficulties with message-passing model • It extends the conventional local procedure calls to calling procedures on remote computers 5/29/2016 COP5611 17 Conventional Procedure Call a) b) Parameter passing in a local procedure call: the stack before the call to read The stack while the called procedure is active 5/29/2016 COP5611 18 Client and Server Stubs • Principle of RPC between a client and server program. 5/29/2016 COP5611 19 Steps of a Remote Procedure Call 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 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 5/29/2016 COP5611 20 Steps of a Remote Procedure Call – cont. 5/29/2016 COP5611 21 Remote Procedure Call – cont. • Design issues – Structure • Mostly based on stub procedures – Binding • Through a binding server • The client specifies the machine and service required – Parameter and result passing • Representation issues • By value and by reference 5/29/2016 COP5611 22 Passing Value Parameters (1) • Steps involved in doing remote computation through RPC 2-8 5/29/2016 COP5611 23 Passing Value Parameters (2) a) b) c) Original message on the Pentium The message after receipt on the SPARC The message after being inverted. The little numbers in boxes indicate the address of each byte 5/29/2016 COP5611 24 Parameter Specification and Stub Generation a) b) A procedure The corresponding message. 5/29/2016 COP5611 25 Remote Procedure Call – cont. • Design issues – continued – Error handling, semantics, and correctness • • • • “At least once” semantics “Exactly once” semantics “At most once” semantics Correctness conditions – Other issues 5/29/2016 COP5611 26 Error Handling • a) b) c) A server in client-server communication Normal case Crash after execution Crash before execution 5/29/2016 COP5611 27 Asynchronous RPC (1) a) b) The interconnection between client and server in a traditional RPC The interaction using asynchronous RPC 5/29/2016 COP5611 28 Asynchronous RPC (2) • A client and server interacting through two asynchronous RPCs 5/29/2016 COP5611 29 Example: DCE RPC • Distributed Computing Environment (DCE) – By Open Software Foundation (OSF, now called Open Group) – DCE is a true middleware system • Designed as a layer of abstraction between existing operating systems and distributed applications • Provide a number of services – Distributed file service, directory service, security service, distributed time service • Support UNIX, Windows NT – A highly representative RPC system 5/29/2016 COP5611 30 Writing a Client and a Server 5/29/2016 COP5611 31 Binding a Client to a Server • Client-to-server binding in DCE. 2-15 5/29/2016 COP5611 32 Remote Object Invocation • Extend RPC principles to objects – The key feature of an object is that it encapsulates data (called state) and the operations on those data (called methods) – Methods are made available through an interface – The separation between interfaces and the objects implementing these interfaces allows us to place an interface at one machine, while the object itself resides on another machine 5/29/2016 COP5611 33 Distributed Objects • Common organization of a remote object with client-side proxy. 5/29/2016 COP5611 34 Binding a Client to an Object Distr_object* obj_ref; obj_ref = …; obj_ref-> do_something(); //Declare a systemwide object reference // Initialize the reference to a distributed object // Implicitly bind and invoke a method (a) Distr_object obj_ref; Local_object* obj_ptr; obj_ref = …; obj_ptr = bind(obj_ref); obj_ptr -> do_something(); //Declare a systemwide object reference //Declare a pointer to local objects //Initialize the reference to a distributed object //Explicitly bind and obtain a pointer to the local proxy //Invoke a method on the local proxy (b) a) b) An example with implicit binding using only global references An example with explicit binding using global and local references 5/29/2016 COP5611 35 Parameter Passing • The situation when passing an object by reference or by value. 2-18 5/29/2016 COP5611 36 Java RMI • Java distributed-object model – Aimed for high degree distribution transparency but not entirely • Java remote method invocation – There are differences between local and remote objects • Local objects are passed by value while remote objects are passed by reference 5/29/2016 COP5611 37 Next Time • We will talk about Chapter 5, “Theoretical Foundations” – Please read the chapter ahead of time as the algorithms are kind of difficult to follow 5/29/2016 COP5611 38