Slides for Chapter 4: Interprocess Communication

Middleware layers

Applications, services RMI and RPC

From Coulouris, Dollimore and Kindberg

Distributed Systems: Concepts and Design

Middleware layers

request-reply protocol

This chapter

marshalling and external data representation

Edition 4, © Addison-Wesley 2005

UDP and TCP

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

API for Internet Protocols (1): IPC characteristics

API for the Internet Protocols (2): Sockets and ports

 synchronous and asynchronous communication

programming abstraction for UDP/TCP originated from BSD UNIX

 blocking send: waits until the corresponding receive is issued  non-blocking send: sends and moves on  blocking receive: waits until the msg is received  non-blocking receive: if the msg is not here, moves on  synchronous: blocking send and receive  asynchronous: non-blocking send and blocking or non-blocking receive

 Message Destination  IP address + port: one receiver, many senders  Location transparency

any port

socket

⌧ name server or binder: translate service to location ⌧ OS (e.g. Mach): provides location-independent identifier mapping to lower-lever addresses

 send directly to processes (e.g. V System)  multicast to a group of processes (e.g. Chorous)

 Reliability  Ordering

client

server other ports

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

 message size: up to 216, usually restrict to 8K  blocking: non-blocking send, blocking receive  timeouts: timeout on blocking receive  receive from any: doesn't specify sender origin (possible to specify a particular host for send and receive)  failure model: omission failures: can be dropped ordering: can be out of order

 use of UDP

socket

message

Internet address = 138.37.94.248

API for Internet Protocols (3): UDP Datagram

agreed port

Internet address = 138.37.88.249

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

API for Internet Protocols (4): C and UDP datagrams

Sending a message

Receiving a message

s = socket(AF_INET, SOCK_DGRAM, 0)

s = socket(AF_INET, SOCK_DGRAM, 0)

bind(s, ClientAddress)

bind(s, ServerAddress)

sendto(s, "message", ServerAddress)

amount = recvfrom(s, buffer, from)

ServerAddress and ClientAddress are socket addresses

DNS less overhead: no state information, extra messages, latency due to start up Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

1

API for Internet Protocols (5): Java and UDP aSocket = new DatagramSocket();

aSocket = new DatagramSocket(port);





API for Internet Protocols (6): TCP stream     

InetAddress aHost = InetAddress.getByName(…); … DatagramPacket request = new DatagramPacket(msg, length, aHost, serverPort); … aSocket.send(request); … DatagramPacket reply = new DatagramPacket(buffer, length);

… aSocket.receive(reply);

DatagramPacket request = new DatagramPacket(buffer, length);



… aSocket.receive(request); …

  

DatagramPacket reply = new DatagramPacket(data, length, request.getAddress(), request.getPort()); … aSocket.send(reply);

message size: unlimited lost messages: sequence #, ack, retransmit after timeout of no ack flow control: sender can be slowed down or blocked by the receiver message duplication and ordering: sequence # message destination: establish a connection, one sender-one receiver, high overhead for short communication matching of data items: two processes need to agree on format and order (protocol) blocking: non-blocking send, blocking receive (send might be blocked due to flow control) concurrency: one receiver, multiple senders, one thread for each connection failure model  checksum to detect and reject corrupt packets  sequence # to deal with lost and out-of-order packets  connection broken if ack not received when timeout ⌧ could be traffic, could be lost ack, could be failed process.. ⌧ can't tell if previous messages were received

 use of TCP: http, ftp, telnet, smtp Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

API for Internet Protocols (7): C and TCP streams

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

API for Internet Protocols (8): Java and TCP Socket s = new Socket(host, serverPort);

Requesting a connection

Listening and accepting a connection

s = socket(AF_INET, SOCK_STREAM,0)

connect(s, ServerAddress)

s = socket(AF_INET, SOCK_STREAM,0) bind(s, ServerAddress); listen(s,5); sNew = accept(s, ClientAddress);

write(s, "message", length)

n = read(sNew, buffer, amount)

ServerSocket listenSocket = new ServerSocket(serverPort);



… Socket s = listenSocket.accept();

DataInputStream in = new DataInputStream(s.getInputStream()); DataOutputStream out = new DataOutputStream(s.getOutputStream());

… DataInputStream in = new DataInputStream(s.getInputStream()); DataOutputStream out = new DataOutputStream(s.getOutputStream());





out.write(…);

in.read(…);





in.read(…);

out.write(…);

ServerAddress and ClientAddress are socket addresses

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

External Data Representation (1):  different ways to represent int, float, char... (internally)  byte ordering for integers big-endian: most significant byte first small-endian: least significant byte first

 standard external data representation marshal before sending, unmarshal before receiving

 send in sender's format and indicates what format, receivers translate if necessary  External data representation SUN's External data representation (XDR) CORBA's Common Data Representation (CDR) Java's object serialization ASCII (XML, HTTP) Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

External Data Representation (2): CDR Primitive types (15): short, long ... support both big-endian and little-endian transmitted in sender's ordering and the ordering is specified receiver translates if needed

Constructed types Type sequence string array struct enumerated union

Representation length (unsigned long) fol lowed by elements in order l length (unsigned long) followed by characters in order (can also can have wide characters) array elements in order (no length specified because it is fixed) in the order of declaration of the components unsigned long (the values are specified by the order declared) type tag followed by the selected member Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

2

External Data Representation (3):

External Data Representation (5): Java serialization

CORBA IDL compiler generates marshalling and unmarshalling routines Struct with string, string, unsigned long

serialization and de-serialization are automatic in arguments and return values of Remote Method Interface (RMI) flattened to be transmitted or stored on the disk

index in sequence of bytes

4 bytes 5 "Smit" "h___" 6 "Lond" "on__" 1934

0–3 4–7 8–11 12–15 16–19 20-23 24–27

notes on representation

length of string ‘Smith’ length of string ‘London’ unsigned long

write class information, types and names of instance variables new classes, recursively write class information, types, names... each class has a handle, for subsequent references values are in Universal Transfer Format (UTF)

The flattened form represents a Person struct with value: {‘Smith’, ‘London’, 1934} Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

External Data Representation (6): Java serialization public class Person implements Serializable { private String name; private String place; private int year;

}

Explanation

Serialized values 8-byte version number

h0

class name, version number

3

int year

java.lang.String java.lang.String number, type and name of name: place: instance variables

1934

5 Smith

6 London

h1

External Data Representation (7) references to other objects

public Person(String aName, String aPlace, int aYear){ name = aName; place = aPlace; year = aYear; }

Person

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

values of instance variables

other objects are serialized handles are references to objects in serialized form each object is written only once second or subsequent occurrence of the object is written as a handle

 reflection ask the properties (name, types, methods) of a class help serialization and de-serialization

The true serialized form contains additional type markers; h0 and h1 are handles/references to other objects within the serialized form Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

External Data Representation (8): XML Extensible markup language (XML) User-defined tags (vs. HTML has a fixed set of tags) different applications agree on a different set of tags E.g. SOAP for web services, tags are published Tags are in plain text (not binary format)—not space efficient

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

External Data Representation (9) Person struct in XML Tag names: person, name, place, year Element: Smith Attribute: id="123456789” of person Binary data need to be converted to characters (base64) Smith London 1934

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

3

External Data Representation (10): XML namespace

External Data Representation (11): XML schema

Name clashes within an application Namespaces: a set of names for a collection of element types and attributes xmlns: xml namespace pers: name of the name space (used as a prefix)  http://www.cdk4.net/person :location of schema

Defines elements and attributes Similar to type definition xsd: namespace for xml schema definition

Smith London 1934



Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

External Data Representation (12): Remote object reference

call methods on a remote object (CORBA, Java) unique reference in the distributed system Reference = IP address + port + process creation time + local object # in a process + interface Port + process creation time -> unique process Address can be derived from the reference Objects usually don't move; is there a problem if the remote object moves?  of interface: what32interface is 32 available 32name bits 32 bits bits bits Internet address

port number

time

object number

interface of remote object

Client-server communication (1)

Client

Request

doOperation

message (wait) Reply message

getRequest select object execute method sendReply

(continuation)

Synchronous: client waits for a reply Asynchronous: client doesn’t wait for a reply

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Client-server communication (2): Request-reply message structure

Server

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Client-server communication (3)  Failure model  UDP: could be out of order, lost...  process can fail...

messageType

int (0=Request, 1= Reply)

requestId

int

 not getting a reply

objectReference

RemoteObjectRef

 duplicate request messages on the server

methodId

int or Method

 idempotent operation: can be performed repeatedly with the same effect as performing once.

arguments

array of bytes

 timeout and retry  How does the server find out?

 idempotent examples?  non-idempotent examples?

 history of replies

Why requestID?

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

 retransmission without re-execution  how far back if we assume the client only makes one request at a time?

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

4

Client-server communication (4): RPC exchange protocols

Name

using TCP increase reliability and also cost HTTP uses TCP

Messages sent by Client

Server

R

Request

RR

Request

Reply

RRA

Request

Reply

Client-server communication (5)

Client

one connection per request-reply HTTP 1.1 uses "persistent connection" ⌧multiple request-reply ⌧closed by the server or client at any time ⌧closed by the server after timeout on idle time

Acknowledge reply

Marshal messages into ASCII text strings resources are tagged with MIME (Multipurpose Internet Mail Extensions) types: test/plain, image/gif... content-encoding specifies compression alg Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Client-server communication (6): HTTP methods GET: return the file, results of a cgi program, … HEAD: same as GET, but no data returned, modification time, size are returned POST: transmit data from client to the program at url PUT: store (replace) data at url DELETE: delete resource at url OPTIONS: server provides a list of valid methods TRACE: server sends back the request

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Client-server communication (6): HTTP request/reply format method

URL or pathname

GET

//www.dcs.qmw.ac.uk/index.html

HTTP version headers message body HTTP/ 1.1

Headers: latest modification time, acceptable content type, authorization credentials HTTP version HTTP/1.1

status code reason headers message body 200

OK

resource data

Headers: authentication challenge for the client

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

Group communication (1)

Group communication (2): IP multicast

multicast useful for:

 class D addresses, first four bits are 1110 in IPv4  UDP  Join a group via socket binding to the multicast address  messages arriving on a host deliver them to all local sockets in the group  multicast routers: route messages to out-going links that have members  multicast address allocation

fault tolerance based on replicated services ⌧requests multicast to servers, some may fail, the client will be served

discovering services ⌧multicast to find out who has the services

better performance through replicated data ⌧multicast updates

event notification ⌧new items arrived, advertising services

Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

permanent temporary: ⌧no central registry by IP (one addr might have different groups) • use (time to live) TTL to limit the # of hops, hence distance ⌧tools like sd (session directory) can help manage multicast addresses and find new ones Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

5

Group communication (3): Reliability and ordering UDP-level reliability: missing, out-of-order... Effects on fault tolerance based on replicated services ⌧ordering of the requests might be important, servers can be inconsistent with one another

discovering services ⌧not too problematic

 better performance through replicated data ⌧loss and out-of-order updates could yield inconsistent data, sometimes this may be tolerable

event notification ⌧not too problematic Instructor’s Guide for Coulouris, Dollimore and Kindberg Distributed Systems: Concepts and Design Edn. 4 © Pearson Education 2005

6

Slides for Chapter 4: Interprocess Communication

Mail Extensions) types: test/plain, image/gif... content-encoding ... better performance through replicated data multicast ... new items arrived, advertising services.

120KB Sizes 10 Downloads 205 Views

Recommend Documents

ipc interprocess communication pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. ipc interprocess ...

interprocess communication in os pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. interprocess ...

Effective Communication for SPIRE Students - Presentation Slides ...
Effective Communication for SPIRE Students - Presentation Slides.pdf. Effective Communication for SPIRE Students - Presentation Slides.pdf. Open. Extract.

Slides 4: Monty Hall game
Before opening this door, the host (who knows what is behind each door), ... Check the syntax by downloading Monty Hall.xlsx from the course webpage. 5.

Chapter 4
For example, based on historical data, an insurance company could apply ..... ios we explicitly assume that the only goal of data mining is to optimize accuracy.

Chapter 4 - GitHub
The mathematics: A kernel is any function K such that for any u, K(u) ≥ 0, ∫ duK(u)=1 and ∫ uK(u)du = 0. • The idea: a kernel is a nice way to take weighted averages. The kernel function gives the .... The “big-Oh” notation means we have

Chapter 4 Rational Numbers
students a solid foundation, one that prepares them for college and careers in the 21st century. Send all inquiries to: McGraw-Hill Education. 8787 Orion Place.

Chapter 4 Notepacket Key
s XTA-ex -\ ic O. Writing Equations from Roots: esser 2. C-X A- \\ (K A- \\ - O. A root of an equation is a value that makes the equation true. 0. 7 O X A-\ s O X A \ rt O. Use the Zero Product Property to write a quadratic equation with each pair of

Chapter 4 Notepacket Key
sa. Does the parabola open up or down? Graph the quadratic functions. Is the y-coord. of the vertex a max or min? Find the vertex and AOS if possible ... sés. CN. Date Notes 4.2: Dvocacy d. Ysales. A >do & soul Yurc-v- s-. Standard Form of a Quadrat

Chapter 4
In this chapter we will show that data mining and classifier induction can lead to ..... Such background knowledge may encourage an analyst to apply dis-.

Slides
int var1 = 5; //declares an integer with value 5 var1++;. //increments var1 printf(“%d”, var1); //prints out 6. Page 17. Be Careful!! 42 = int var;. Page 18. Types. Some types in C: int: 4 bytes goes from -231 -> 231 - 1 float: 4 bytes (7-digit p

Chapter 4 - Heuristics_6JobShopSchedulingProblem.pdf ...
Solve the problem to achieve each of the objective above using heuristic technique that is based on. Earliest due date, Shortest processing time, and Longest ...

Chapter 4, Section 4 Notes.pdf
Pearson Education, Inc., publishing as Pearson Prentice Hall. All rights reserved. Section Reading Support HOW 69. Ancient India, Section 4. • Born poor; was a slave at. one time. • Believed in absolute power. and complete control over. the peopl

Chapter 4 exer.pdf
Page 1 of 20. SECTION 4.1 Polynomial Functions and Models 187. EXAMPLE 11 A Cubic Function of Best Fit. The data in Table 5 represent the weekly cost C (in thousands of dollars) of print- ing x thousand textbooks. (a) Draw a scatter diagram of the da

Chapter 4.pdf
Air, which is a gas, also flows. Both gases and liquids are fluids. Fluids flow because some sort of force is ... How do deposits. on artery walls affect the flow of blood? How is an airplane affected by. different kinds of airflow? ... Flow tests ar

Chapter 4 Review.notebook
October 27, 2016. Oct 262:45 PM. 1. There were 920 people who attended a Winter Carnival. Festival on a Saturday. The number of children (c) was triple the number of adults. (a). Given a ... A video game store sold 96 games. The store sold 3 times mo

CHAPTER 4.pdf
Page 1 of 11. sarojpandey.com.np Page 1 of 11. CHAPTER 4. 4. HTTP and the Web Services 8 Hrs. 4.1 HTTP, Web Servers and Web Access. [Self Study]. 4.2 Universal naming with URLs. [Self Study]. 4.3 WWW Technology: HTML, DHTML, WML, XML. HTML. [Self Stu

CHAPTER 4.pdf
a common-law rule barring recovery of damages that a tort victim "could have avoided by ... EXCLUSIVE OR A CLOSED LIST. .... Displaying CHAPTER 4.pdf.

Chapter 4.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Chapter 4.pdf.

chapter 4 - Demography.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. chapter 4 ...

chapter 4.pdf
ENG-207: Electrical Engineering, Academic year 2/2555. Computer Engineering Program, Faculty of Engineering, Thai-Nichi Institute of Technology. Objectives.

Chapter 4 merged.pdf
fifty-nine thousand people, was the most populous colony. ... Crude woodcuts like this one were used to identify various “brands” of ... Chapter 4 merged.pdf.

Animal Farm: Chapter 4 - edl.io
Page 1. Animal Farm. © COPYRIGHT, The Center for Learning. Used with permission. Not for resale. Name: Animal Farm: Chapter 4. Directions: Use the ...