Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Systems Concepts and Design Chapter 4.

Similar presentations


Presentation on theme: "Distributed Systems Concepts and Design Chapter 4."— Presentation transcript:

1 Distributed Systems Concepts and Design Chapter 4

2 4.1. Introduction –p. 132-133

3

4 This Chapter Will Cover Characteristics of interprocess communication UDP and TCP from Programmers point of view Objects and data structures translated Design of suitable protocols

5 4.2. The API for the Internet protocols –p. 133-144 Characteristics of interprocess communication Connect Send Receive Disconnect

6 4.2. The API for the Internet protocols –p. 133-144 Characteristics of interprocess communication Synchronous and Asynchronous blocking send blocking receive non-blocking receive synchronous asynchronous Message Destination IP address & port Location transparency Send directly to processes Multicase to a group of process Reliability Ordering

7 4.2. The API for the Internet protocols –p. 133-144 Characteristics of interprocess communication Sockets – Both UDP and TCP use the socket abstraction, with provides an endpoint for communication between processes.

8 4.2. The API for the Internet protocols –p. 133-144 UDP datagram communication Message size (up to 2 16 bytes) Blocking: non-blocking send, blocking receive Timeouts Receive from any Failure Model (Omission, Ordering) Use of UDP (DNS, Less overhead)

9 4.2. The API for the Internet protocols –p. 133-144 Java API for UDP datagram UDP client sends a message to the server and gets a reply import java.net.*; import java.io.* public class UDPClient{ public static void main(String args[]){ //args give message contents and server hostname try{ DatagramSocket aSocket = new DatagramSocket(); byte[] m = args[0].getBytes(); InetAddress aHost = InetAddress.getByName(args[1]); int serverPort = 6789; DatagramPacket request = new DatagramPacket(m,args[0].length(), aHost,serverPort); aSocket.send(request); byte[] buffer = new byte[1000]; DatagramPacket reply = new DatagramPacket(buffer,buffer.length); aSocket.receive(reply); System.out.println("Reply:"+new String(reply.getData())); aSocket.close(); }catch(SocketException e) {System.out.println("Socket:"+e.getMessage()); }catch(IOException e){System.out.println("IO:"+e.getMessage();} }

10 4.2. The API for the Internet protocols –p. 133-144 Java API for UDP datagram UDP server repeatedly receives a request and sends it back to the client import java.net.* import java.io.* public class UDPServer{ public static void main(String args[]){ try{ DatagramSocket aSocket = new DatagramSocket(6789); byte[] buffer = new byte[1000]; while(true){ DatagramPacket request = new datagramPacket(buffer, buffer.length); aSocket.receive(request); DatagramPacket reply = new DatagramPacket(request.getData(), request.getLength(), request.getAddress(), request.getPort()); aSocket.send(reply); } }catch(SocketException e) {System.out.println("Socket:" + e.getMessage()); }catch(IOException e) {System.out.println("IO:" + e.getMessage());} }

11 4.2. The API for the Internet protocols –p. 133-144 TCP stream communication Characteristics Message size: Is Unlimited Lost Messages Flow Control Message duplication and order Message destination Outstanding Issues Matching of data items Blocking Treads Failure model Use of TCP: http, ftp, telnet, smtp

12 4.3. External data representation –p. 144-155 Different ways to represent int, float char... byte ordering for integer standard external data representation send in sender's format and indicates what format, receivers translate if necessary External data representation Three Approaches to External Data Representation CORBA Java’s object serialization XML

13 4.3. External data representation –p. 144-155 CORBA CDR message Primitive types Construction types CORBA IDL complier generates marshalling and unmarshalling routines Structure with string, unsigned long

14 4.3. External data representation and marshalling –p. 144-155 Java object serialization serialization and de-serialization flattened to be transmitted or stored on the disk

15 4.3. External data representation and marshalling –p. 144-155 Extensible markup language (XML) User-defined tags Different Apps agree on different set of tags. e.g. SOAP for web serves, tags are published Tags are in plain text Illustration of the use of a namespace in the person structure

16 4.4. Client-Server communication –p. 155ff Client-server communication Synchronous (client waits for a reply) Asynchronous (client doesn't wait)

17 Request/Reply Protocol p.157

18 Request/Reply Protocol pp.158-160 UDP – Failure Handling Timeout Discard of duplicates Lost replies – idempotent operations History R, RR, RRA protocols Request - Request/Reply – Request/Reply/Acknowledge Reply

19 Request/Reply Protocols pp. 160-163 TCP implementation of Request/Reply Protocols HTTP example – allows persistent connection HTTP methods – GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE HTTP Message contents Request: Method/URL/HTTP Version/Header/msg Reply: HTTP Version/status code/reason/header/msg

20 Group Communication –p. 164 Multicast Operation a single message sent from one process to all members of a group High fault tolerance Can locate servers Better performance thru replication Propagation of event notifications

21 Group Communication p. 165 IP Multicast Multicast Group Multicast Routers Multicast Address Allocation

22 Group Communications pp 166-168 IP Multicast – Failure Models Same as UDP – no guarantee of delivery Effects: Replicated services – all or none msg receipt Discovery servers – repeat requests Replicated Data –broadcast of data, not methods Event Notifications – app determines qualities

23 Unix Inter-process Communication pp. 168-169 IPC in Unix Layered on TCP and UDP protocol Socket System call – binding to an address Message destinations = socket address Msg queues at sending socket Networking protocol transmits msg Msg queues at receiving socket Receiving process makes system call to receive msg.

24 Unix Inter-process Communication pp 169-170 Datagram Communication (UDP) Sockets identified in each communication Socket call Bind call Send to call Receive from call

25 Unix Inter-process Communication pp. 170-171 Stream Communication (TCP) One server is ‘listening’ for requests Socket call for stream socket + bind + listen Accept call, create new socket Client process issues socket, connect Both use write/read Both close when communication is finished

26 Inter-process Communication Summary UDP vs. TCP Marshalling data – CORBA, Java, XML Request/Reply Protocols Multicast Messages


Download ppt "Distributed Systems Concepts and Design Chapter 4."

Similar presentations


Ads by Google