1 / 58

ITEC801 Distributed Systems

ITEC801 Distributed Systems. Inter-process Communication Coulouris Sections 4.1-3, 4.6 Liu Chapter 2. Important Things. All distributed systems depend on some form of IPC Basic form of IPC is messaging Understanding of IPC concepts

shayla
Download Presentation

ITEC801 Distributed Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ITEC801Distributed Systems Inter-process Communication Coulouris Sections 4.1-3, 4.6 Liu Chapter 2

  2. Important Things • All distributed systems depend on some form of IPC • Basic form of IPC is messaging • Understanding of IPC concepts • Protocols, connection-oriented, connectionless, synchronous, asynchronous, data representation (encoding), data marshalling Inter-process Communication

  3. Inter-process Communications • Inter-process communications (IPC) facilities for single systems include • message queues • semaphores • shared memory • Distributed computing systems make use of these facilities to provide application programming interface which allows IPC to be programmed at a higher level of abstraction. • Distributed computing requires information to be exchanged among independent processes. Inter-process Communication

  4. IPC – unicast and multicast • When communication is from one process to a single other process, the IPC is said to be a unicast • When communication is from one process to a group of processes, the IPC is said to be a multicast Inter-process Communication

  5. IPC paradigms and implementations Paradigms of IPC of different levels of abstraction have evolved, with corresponding implementations. Inter-process Communication

  6. IPC API • An abstraction of details and intricacies of system level facilities • For programmer to concentrate on application logic. Inter-process Communication

  7. Protocols • two or more processes engage in IPC in a protocol agreed upon by the processes • A process may be a sender at some points during a protocol, a receiver at other points. Inter-process Communication

  8. Protocol • In a distributed application, two processes perform IPC in a mutually agreed upon protocol. • The specification of a protocol should include • the sequence of data exchange, which can be described using a time event diagram. • the specification of the format of the data exchanged at each step. Inter-process Communication

  9. HTTP: A sample protocol • The Hypertext Transfer Protocol is a protocol for a process (the browser) to obtain a document from a web server process. • Data form • It is a request/response protocol: a browser sends a request to a web server process, which replies with a response. • Stateless Inter-process Communication

  10. Event diagram Distributed Computing, M. L. Liu

  11. Event Diagram for a HTTP session Distributed Computing, M. L. Liu

  12. Sequence Diagram Distributed Computing, M. L. Liu

  13. sequence diagram for a HTTP session Distributed Computing, M. L. Liu

  14. A sample HTTP session Inter-process Communication

  15. IPC in Distributed Computing P1 P2 data sender receiver Inter-process Communication

  16. Unicast vs. Multicast … P2 P2 P2 P2 m m m m P1 P1 unicast multicast Inter-process Communication

  17. Archetypal IPC API • Send ( [receiver], message) • Receive ( [sender], message storage object) • Connect (sender address, receiver address) • for connection-oriented communication. • Disconnect (connection identifier) • for connection-oriented communication. Inter-process Communication

  18. IPC in basic HTTP Web Browser Web Server C1 S1 C2 S2 C3 S3 C4 S4 C1: make connection C2: send request C3: receive response C4: disconnect S1: accept connection S2: receive request S3: send response S4: disconnect Inter-process Communication

  19. Connection-oriented Protocols • Sender and receiver establish a connection • Possibly negotiate protocols and/or communication parameters • Then exchange data • When done connections is released Inter-process Communication

  20. Connectionless Protocols • No setup required • Sender transmits data • No information about connection retained Inter-process Communication

  21. Event Synchronisation • IPC requires that the two processes synchronise their operations: • one side sends • the other receives • until all data has been sent and received. • Ideally, the send operation starts before the receive operation commences. • In practice, the synchronisation requires system support. Inter-process Communication

  22. Synchronous vs. Asynchronous • Easy way to synchronise is to use blocking operations • When a process issues a blocking operation the process blocks • When the operation completes the process unblocks Inter-process Communication

  23. Synchronous vs. Asynchronous • IPC operations may be asynchronous or nonblocking • An asynchronous operation issued by a process will not block further processing of the process • the process is free to proceed with its processing • may optionally be notified by the system when the operation is fulfilled. Inter-process Communication

  24. Synchronous Send & Receive A sends message and then waits for response A Request is received Response B B is not running Process request B blocks waiting for next request time Inter-process Communication

  25. Asynchronous send & receive A sends message and continues A Request is received Response B B is running Process request B continues time Inter-process Communication

  26. Synchronous send and Async. Receive - Distributed Computing, M. L. Liu

  27. Synchronous send and Async. Receive - Distributed Computing, M. L. Liu

  28. Synchronous send and Async. Receive - Distributed Computing, M. L. Liu

  29. Asynchronous send and Asynchronous receive Distributed Computing, M. L. Liu

  30. Event diagram Distributed Computing, M. L. Liu

  31. Deadlock and Timeouts • Blocking operations issued in the wrong sequence can cause deadlocks • Deadlocks should be avoided • Alternatively, timeout can be used to detect deadlocks Inter-process Communication

  32. Deadlock and Timeouts Receive from Process B issued Process A blocked pending data from process B A B Receive from Process A issued Process B blocked pending data from process A time Inter-process Communication

  33. Using threads for asynchronous IPC • When using an IPC programming interface, it is important to note whether the operations are synchronous or asynchronous. • If only blocking operation is provided for send and/or receive, then it is the programmer’s responsibility to using child processes or threads if asynchronous operations are desired. • We may have time to discuss threads in more detail Inter-process Communication

  34. Using threads for asynchronous IPC A spawns thread to send message A thread Thread blocks awaiting response Request is received Response B B is running Process request B continues time Inter-process Communication

  35. Data Representation • Data transmitted on the network is a binary stream. • An IPC system may provide the capability to allow data representation to be imposed on the raw data • We have already seen this with RPC/RMI Inter-process Communication

  36. Data Representation • Because different computers may have different internal storage format for the same data type, an external representation of data may be necessary. • Data marshalling is the process of • flattening a data structure • converting the data to an external representation Inter-process Communication

  37. Data Representation • Some well known external data representation schemes are: • Sun XDR • ASN.1 (Abstract Syntax Notation) • XML (Extensible Markup Language) Inter-process Communication

  38. Data Encoding Protocols Inter-process Communication

  39. Tag-Length-Value (TLV) Encoding • The data encoding structure has three values • Tag/Type (T) • Length (L) • Value (V) • Known as TLV. • Basic Encoding Rules (BER) defines order and structure • Guarantees that both ends interpret communication channels consistently.

  40. TLV Encoding Length Value Tag Format (1 bit) Number 5 bits Class 2 Bits

  41. TLV Encoding TAG : • Comes first, alerts destination of structure that follows. • Defines the type of data • Composed of three subfields: • Class (two bits). • Format (one bit). • Number (Five bits). • Class: defines scope of data. Four classes defined: • Universal (00) • Application-wide (01). • Context-Specific (10). • Private (11).

  42. TLV Encoding Class • Universal: data types taken from ASN.1. • Include • Integer • String • ObjectIdentifier. • Application-wide: Include • IPAddress/Counter • Gauge/TimeTicks.

  43. TLV Encoding • Format (P/C: Primitive/Constructed) : Indicates if data is Primitive [simple (0)] or constructed [structured (1).] • Primitive encoding means contents octets represent the value directly. • Constructor encoding means that contents octets encode one or more additional data values such as SEQUENCE.

  44. TLV Encoding • Number: Divides simple or structured data into subgroups. • Example: In Universal class, with simple format, Integer has a value 2. Inter-process Communication

  45. TLV Encoding Length • Follows Type field. • Determines the number of octets value field will contain. • Either short definite or long definite form. • Another form indefinite is not used. • Definite: length of encoding known before transmission. • Indefinite indicate otherwise. • Short Definite: 0 to 127 octets in the value field. • Long definite: 128 or more. • Uses multiple octets to represent total length.

  46. TLV Encoding 0 0 0 0 0 0 1 0 A. Shaded part defines the length 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 0 0 B. Shaded two bytes define the length of the length (2 bytes); the colored bytes define the length (260 bytes)

  47. TLV Encoding Length (Contd.) • Single octet representation: Most significant byte zero, other seven bytes define length of data. • Multiple octet representation: Most significant bit of first byte 1, other seven bits define no. of bytes to define length. • Following octets take up rest of length. Value • Codes the value of data according to BER.

  48. Encoding Examples 00000010 00000100 00000000 00000000 00000000 00001110 Tag Length Value Integer 14 00000100 00000010 01001000 01001001 IP address: 131.21.14.8

  49. Data Marshalling Inter-process Communication

  50. XML • http://java.sun.com/xml/docs/tutorial/overview/1_xml.html#intro • XML is a text-based markup language that is fast becoming the standard for data interchange on the Web. • XML has a syntax analogous to HTML. • Unlike HTML, XML tags tell you what the data means, rather than how to display it. Inter-process Communication

More Related