Top Banner
Distributed Systems Concepts and Design Chapter 4
26
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Distributed Systems Concepts and Design Chapter 4.

Distributed SystemsConcepts and Design

Chapter 4

Page 2: Distributed Systems Concepts and Design Chapter 4.

4.1. Introduction –p. 132-133

Page 3: Distributed Systems Concepts and Design Chapter 4.

4.1. Introduction –p. 132-133

Page 4: Distributed Systems Concepts and Design Chapter 4.

4.1. Introduction –p. 132-133

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

Page 5: Distributed Systems Concepts and Design Chapter 4.

4.2. The API for the Internet protocols –p. 133-144

Characteristics of interprocess communication

Connect Send Receive Disconnect

Page 6: Distributed Systems Concepts and Design Chapter 4.

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

Page 7: Distributed Systems Concepts and Design Chapter 4.

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.

Page 8: Distributed Systems Concepts and Design Chapter 4.

4.2. The API for the Internet protocols –p. 133-144

UDP datagram communication

•Message size (up to 216 bytes)

•Blocking: non-blocking send, blocking receive

•Timeouts

•Receive from any

•Failure Model (Omission, Ordering)

•Use of UDP (DNS, Less overhead)

Page 9: Distributed Systems Concepts and Design Chapter 4.

4.2. The API for the Internet protocols –p. 133-144

Java API for UDP datagramUDP 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();} } }

Page 10: Distributed Systems Concepts and Design Chapter 4.

4.2. The API for the Internet protocols –p. 133-144

Java API for UDP datagramUDP 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());} } }

Page 11: Distributed Systems Concepts and Design Chapter 4.

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

Page 12: Distributed Systems Concepts and Design Chapter 4.

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

Page 13: Distributed Systems Concepts and Design Chapter 4.

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

Page 14: Distributed Systems Concepts and Design Chapter 4.

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

Page 15: Distributed Systems Concepts and Design Chapter 4.

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

Page 16: Distributed Systems Concepts and Design Chapter 4.

4.4. Client-Server communication –p. 155ff

Client-server communication

•Synchronous (client waits for a reply)•Asynchronous (client doesn't wait)

Page 17: Distributed Systems Concepts and Design Chapter 4.

Request/Reply Protocol p.157

Page 18: Distributed Systems Concepts and Design Chapter 4.

Request/Reply Protocol pp.158-160

UDP – Failure Handling Timeout Discard of duplicates Lost replies – idempotent operations History

R, RR, RRA protocolsRequest - Request/Reply –

Request/Reply/Acknowledge Reply

Page 19: Distributed Systems Concepts and Design Chapter 4.

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 contentsRequest:Method/URL/HTTP Version/Header/msgReply:HTTP Version/status code/reason/header/msg

Page 20: Distributed Systems Concepts and Design Chapter 4.

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

Page 21: Distributed Systems Concepts and Design Chapter 4.

Group Communication p. 165

IP Multicast

Multicast Group Multicast Routers Multicast Address Allocation

Page 22: Distributed Systems Concepts and Design Chapter 4.

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

Page 23: Distributed Systems Concepts and Design Chapter 4.

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.

Page 24: Distributed Systems Concepts and Design Chapter 4.

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

Page 25: Distributed Systems Concepts and Design Chapter 4.

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

Page 26: Distributed Systems Concepts and Design Chapter 4.

Inter-process Communication

Summary UDP vs. TCP Marshalling data – CORBA, Java, XML Request/Reply Protocols Multicast Messages