Communication Chapter 2 Communication 1 Communication q Layered

  • Slides: 72
Download presentation
Communication Chapter 2 Communication 1

Communication Chapter 2 Communication 1

Communication q Layered protocols o Usual networking approach (client/server) q Remote Procedure Call (RPC)

Communication q Layered protocols o Usual networking approach (client/server) q Remote Procedure Call (RPC) o Hide message passing details (client/server) q Remote Method Invocation (RMI) o Improved RPC (client/server) Chapter 2 Communication 2

Communication q Message-Oriented Communications o Message Passing Low level, efficient o Message-Oriented Middleware (MOM)

Communication q Message-Oriented Communications o Message Passing Low level, efficient o Message-Oriented Middleware (MOM) Non client/server q Streams o Continuous flow subject to timing constraints Chapter 2 Communication 3

Layered Protocols q OSI reference model o Each layer provides service to layer above

Layered Protocols q OSI reference model o Each layer provides service to layer above o Implementation of service can change Chapter 2 Communication 4

Layer Services q Transport layer o Logical connection between hosts o Reliable communication between

Layer Services q Transport layer o Logical connection between hosts o Reliable communication between hosts q Network layer o Route packet thru network q Data link layer o Get packet over each hop q Physical layer o Put the bits on the “wire” Chapter 2 Communication 5

Layered Protocols q Layered message o Add headers when msg sent (down protocol stack)

Layered Protocols q Layered message o Add headers when msg sent (down protocol stack) o Peel the onion when msg received (up the protocol stack) Chapter 2 Communication 6

Data Link Layer q Communication at data link layer o Above, A tries to

Data Link Layer q Communication at data link layer o Above, A tries to send msgs 0 and 1 to B Chapter 2 Communication 7

Network Layer q On a LAN o Have a shared media o Put the

Network Layer q On a LAN o Have a shared media o Put the packet out, recipient picks it up q On a WAN o Have point-to-point communication o Many possible routes o Finding best route is difficult Chapter 2 Communication 8

Transport Layer q UDP for unreliable delivery o Better performance possible with UDP q

Transport Layer q UDP for unreliable delivery o Better performance possible with UDP q TCP for reliable delivery o May be easier to build app with TCP Chapter 2 Communication 9

Client-Server TCP Normal TCP Chapter 2 Communication Transactional TCP 10

Client-Server TCP Normal TCP Chapter 2 Communication Transactional TCP 10

Middleware Protocols q Reference model for middleware based distributed communication Chapter 2 Communication 11

Middleware Protocols q Reference model for middleware based distributed communication Chapter 2 Communication 11

What is Middleware? q Logically at application layer q General purpose protocols q Independent

What is Middleware? q Logically at application layer q General purpose protocols q Independent of an application q We’ll distinguish between o High level application and o Middleware Chapter 2 Communication 12

Middleware Example q Often, must authenticate users o Require users prove identity q Spse

Middleware Example q Often, must authenticate users o Require users prove identity q Spse you build authentication system q Any app can use your auth system q Your authentication “application” o Is at application layer in OSI o Is also at middleware layer in our view Chapter 2 Communication 13

Middleware q Remainder of this chapter q 4 middleware communication services o o RPC

Middleware q Remainder of this chapter q 4 middleware communication services o o RPC RMI Message oriented communication Streaming Chapter 2 Communication 14

Remote Procedure Call q Distributed systems can be built on explicit message passing o

Remote Procedure Call q Distributed systems can be built on explicit message passing o For example, send and receive q What’s wrong with this approach? o It’s not transparent to users q Why should we care? o Recall that transparency is one of primary goals in distributed systems Chapter 2 Communication 15

Remote Procedure Call q RPC is a simple idea o Make remote operation seem

Remote Procedure Call q RPC is a simple idea o Make remote operation seem like a (local) procedure call o “All the great things are simple” Winston Churchill Much better transparency compared to primitive message passing q Can we make remote operation seem local? q Chapter 2 Communication 16

Conventional Procedure Call q a) b) Consider C function: count = read(fd, buf, bytes)

Conventional Procedure Call q a) b) Consider C function: count = read(fd, buf, bytes) Stack before call to read Stack while called procedure is active Chapter 2 Communication 17

Parameter Passing q Consider again o C function: count = read(fd, buf, bytes) q

Parameter Passing q Consider again o C function: count = read(fd, buf, bytes) q In C, parameters can be o Passed by value: bytes o Passed by reference: the array buf Usually not important whether pass by value or pass by reference is used q But it’s a big deal in RPC! q o Since procedure will execute at remote location Chapter 2 Communication 18

RPC between Client/Server q We say that this is synchronous o Since client waits

RPC between Client/Server q We say that this is synchronous o Since client waits for result Chapter 2 Communication 19

Stubs q On client side, stub marshalls parameters and send to server o Pack

Stubs q On client side, stub marshalls parameters and send to server o Pack parameters into message(s) q On server side, stub converts to local procedure call, sends back results q Stubs increase transparency Chapter 2 Communication 20

Passing Value Parameters Suppose add(i, j) returns i + j q Remote computation via

Passing Value Parameters Suppose add(i, j) returns i + j q Remote computation via RPC q Chapter 2 Communication 21

Client Stub a) b) Procedure Stub marshalls params Chapter 2 Communication 22

Client Stub a) b) Procedure Stub marshalls params Chapter 2 Communication 22

Steps in RPC 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Client

Steps in RPC 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 Chapter 2 Communication 23

Additional RPC Topics q Doors o Caller and sender on same machine q Asynchronous

Additional RPC Topics q Doors o Caller and sender on same machine q Asynchronous RPC o Client does something while server works on procedure q DCE RPC o Specific implementation of RPC Chapter 2 Communication 24

Doors q If client and server on same machine o Use interprocess communication (IPC)

Doors q If client and server on same machine o Use interprocess communication (IPC) o More efficient than network protocols Chapter 2 Communication 25

The Doors q Doors are not to be confused with “The Doors” Chapter 2

The Doors q Doors are not to be confused with “The Doors” Chapter 2 Communication 26

Asynchronous RPC a) b) Usual (synchronous) RPC Asynchronous RPC Chapter 2 Communication 27

Asynchronous RPC a) b) Usual (synchronous) RPC Asynchronous RPC Chapter 2 Communication 27

Asynchronous RPC Client and server interact via two asynchronous RPCs q More efficient, if

Asynchronous RPC Client and server interact via two asynchronous RPCs q More efficient, if applicable q Chapter 2 Communication 28

DCE RPC Distributed Computing Environment (DCE) q Read this section q A couple of

DCE RPC Distributed Computing Environment (DCE) q Read this section q A couple of interesting items… q DCE semantic options q o At-most-once no call done more than once, even if system crash o Idempotent calls can be repeated multiple times (e. g. , read) Chapter 2 Communication 29

DCE RPC q Client-to-server binding in DCE q Note directory service Chapter 2 Communication

DCE RPC q Client-to-server binding in DCE q Note directory service Chapter 2 Communication 30

RMI q Remote Method Invocation o Distributed objects q Objects hide internals o Provides

RMI q Remote Method Invocation o Distributed objects q Objects hide internals o Provides transparency o Also desirable in distributed systems q RMI can increase transparency compared to RPC q Chapter 9 has real object systems Chapter 2 Communication 31

Objects q Object encapsulates data, the state q Object encapsulates methods, operations on the

Objects q Object encapsulates data, the state q Object encapsulates methods, operations on the data q Methods are made available thru welldefined interfaces q In distributed environment o Interface can be on one machine and o Corresponding object on another machine Chapter 2 Communication 32

Distributed Objects q Interface on client q Object on server o Proxy like client

Distributed Objects q Interface on client q Object on server o Proxy like client stub in RPC o Skeleton like server stub in RPC Chapter 2 Communication 33

Compile-time vs Runtime q Compile-time objects o Objects analogous to those in Java, C++

Compile-time vs Runtime q Compile-time objects o Objects analogous to those in Java, C++ o Pluses: easy to implement o Minuses: depends on specific language q Runtime objects o Implementation is open, use adapter (wrapper) to hide implementation o Plus and minus opposite of those above Chapter 2 Communication 34

RMI and Parameter Passing q Makes sense to treat local and remote objects differently

RMI and Parameter Passing q Makes sense to treat local and remote objects differently o Lots of overhead to remote objects o Pass by reference gets complicated Chapter 2 Communication 35

Java RMI q Distributed objects are an integral part of Java o Aims for

Java RMI q Distributed objects are an integral part of Java o Aims for high degree of transparency o For example client proxy has same interface as remote object q There are subtle differences between local and remote objects… Chapter 2 Communication 36

Java RMI q Cloning o o q Cloning a local object results in exact

Java RMI q Cloning o o q Cloning a local object results in exact copy Only server can clone remote object In Java, proxies not cloned So must bind (again) to cloned object Can declare method to be synchronized o Ensures access to data is serialized q Blocking o Clients blocked Chapter 2 Communication 37

Java RMI Read the details q A preview of Chapter 5… q Spse multiple

Java RMI Read the details q A preview of Chapter 5… q Spse multiple clients want to access a method on server (method is synchronized) q o Block all but one client lots of overhead o Block at the server what if client crashes? q Java restricts blocking to proxies o Simplifies things o But then can’t prevent simultaneous access of remote objects simply by synchronized Chapter 2 Communication 38

Message-Oriented Comm. q RPC and RMI enhance transparency q But RPC and RMI are

Message-Oriented Comm. q RPC and RMI enhance transparency q But RPC and RMI are “inherently synchronous” q Consider an email system where o Messages stored on email servers when in transit and before read o Stored locally after read q Example of persistent communication Chapter 2 Communication 39

Message-Oriented Comm. q In email example o Sender need not continue executing after sending

Message-Oriented Comm. q In email example o Sender need not continue executing after sending msg o Receiver need not be executing when msg sent (to dest server) q Comparable to the Pony Express! q The more things change, the more they stay the same… Chapter 2 Communication 40

Pony Express q Persistent comm. and the Pony Express Chapter 2 Communication 41

Pony Express q Persistent comm. and the Pony Express Chapter 2 Communication 41

Transient and Asynchronous q Transient o Msg is stored only as long as sender

Transient and Asynchronous q Transient o Msg is stored only as long as sender and receiver are alive o If msg can’t be delivered, discard it q Asynchronous o Sender does not wait for response before continuing q Recall persistent and synchronous q Four possible combinations… Chapter 2 Communication 42

Examples q Transient asynchronous q Transient synchronous o UDP o Synchronous RPC q Persistent

Examples q Transient asynchronous q Transient synchronous o UDP o Synchronous RPC q Persistent asynchronous q Persistent synchronous o email o Msg can only be stored at receiving host Chapter 2 Communication 43

Persistence and Synchronicity a) b) Persistent asynchronous communication Persistent synchronous communication Chapter 2 Communication

Persistence and Synchronicity a) b) Persistent asynchronous communication Persistent synchronous communication Chapter 2 Communication 44

Persistence and Synchronicity c) d) Transient asynchronous communication Receipt-based transient synchronous communication Chapter 2

Persistence and Synchronicity c) d) Transient asynchronous communication Receipt-based transient synchronous communication Chapter 2 Communication 45

Persistence and Synchronicity e) f) Delivery-based transient synchronous communication at message delivery Response-based transient

Persistence and Synchronicity e) f) Delivery-based transient synchronous communication at message delivery Response-based transient synchronous communication Chapter 2 Communication 46

Message-Oriented Comm. q Message-oriented systems take transient asynchronous as baseline o Like UDP q

Message-Oriented Comm. q Message-oriented systems take transient asynchronous as baseline o Like UDP q But persistence sometimes needed o Especially if geographically distributed o Network or process failures likely q Message passing like transport layer Chapter 2 Communication 47

Message-Oriented Comm. q Transient o Berkeley sockets o Message Passing Interface (MPI) q Persistent

Message-Oriented Comm. q Transient o Berkeley sockets o Message Passing Interface (MPI) q Persistent o Message queuing model, MOM o Message brokers Chapter 2 Communication 48

Berkeley Sockets q Primitive Meaning Socket Create a new communication endpoint Bind Attach a

Berkeley Sockets q Primitive Meaning Socket Create a new communication endpoint Bind Attach a local address to a socket Listen Announce willingness to accept connections Accept Block caller until a connection request arrives Connect Actively attempt to establish a connection Send some data over the connection Receive some data over the connection Close Release the connection Socket primitives for TCP/IP Chapter 2 Communication 49

Berkeley Sockets Connection-oriented communication pattern using sockets q Note “synchronization point” q Chapter 2

Berkeley Sockets Connection-oriented communication pattern using sockets q Note “synchronization point” q Chapter 2 Communication 50

Message-Passing Interface (MPI) Primitive Meaning MPI_bsend Append outgoing message to a local send buffer

Message-Passing Interface (MPI) Primitive Meaning MPI_bsend Append outgoing message to a local send buffer MPI_send Send a message and wait until copied to local or remote buffer MPI_ssend Send a message and wait until receipt starts MPI_sendrecv Send a message and wait for reply MPI_isend Pass reference to outgoing message, and continue MPI_issend Pass reference to outgoing message, and wait until receipt starts MPI_recv Receive a message; block if there are none MPI_irecv Check if there is an incoming message, but do not block q q q A few (of the many) MPI primitives Emphasis here is on efficiency Big parallel machines use MPI Chapter 2 Communication 51

Message-Passing Interface (MPI) Primitive Meaning MPI_bsend Append outgoing message to a local send buffer

Message-Passing Interface (MPI) Primitive Meaning MPI_bsend Append outgoing message to a local send buffer MPI_send Send a message and wait until copied to local or remote buffer MPI_ssend Send a message and wait until receipt starts MPI_sendrecv Send a message and wait for reply MPI_isend Pass reference to outgoing message, and continue MPI_issend Pass reference to outgoing message, and wait until receipt starts MPI_recv Receive a message; block if there are none MPI_irecv Check if there is an incoming message, but do not block q q Transient asynchronous: MPI_bsend Transient synchronous: MPI_ssend “Stronger” form of synchronous: MPI_sendrecv Many more possibilities (read the book…) Chapter 2 Communication 52

Message Queuing q Persistent o Message-Queuing Systems or MOM q Insert msgs into queues

Message Queuing q Persistent o Message-Queuing Systems or MOM q Insert msgs into queues o o q Delivered via a series of servers Can be delivered even if server down No guarantee msg will be delivered No assurance msg will be read, etc. For systems where communications takes minutes instead of milliseconds Chapter 2 Communication 53

Message-Queuing Model q Loosely-coupled communications using queues Chapter 2 Communication 54

Message-Queuing Model q Loosely-coupled communications using queues Chapter 2 Communication 54

Message-Queuing Model Primitive Meaning Put Append a message to a specified queue Get Block

Message-Queuing Model Primitive Meaning Put Append a message to a specified queue Get Block until the specified queue is nonempty, and remove the first message Poll Check a specified queue for messages, and remove the first. Never block. Notify Install a handler to be called when a message is put into the specified queue. q Simple interface to message-queuing system o Put is non-blocking o Get blocks only if queue is empty o Poll is non-blocking form of Get Chapter 2 Communication 55

Message-Queuing System q Addressing in message-queuing system Chapter 2 Communication 56

Message-Queuing System q Addressing in message-queuing system Chapter 2 Communication 56

Message-Queuing System q Routing in message-queuing system Chapter 2 Communication 57

Message-Queuing System q Routing in message-queuing system Chapter 2 Communication 57

Message Brokers Message broker in message-queuing system q Translates between msg formats q Chapter

Message Brokers Message broker in message-queuing system q Translates between msg formats q Chapter 2 Communication 58

Example: IBM MQSeries q Read it Chapter 2 Communication 59

Example: IBM MQSeries q Read it Chapter 2 Communication 59

Streams q Other methods based on more-or-less independent units of data o Timing does

Streams q Other methods based on more-or-less independent units of data o Timing does not affect correctness q In multimedia, timing is critical o Audio and video o Can tolerate loss, but not “jitter” q Temporal relationship is important Chapter 2 Communication 60

Stream Transmission Modes q Asynchronous transmission mode o Data sent one after another o

Stream Transmission Modes q Asynchronous transmission mode o Data sent one after another o No other timing constraints q Synchronous transmission mode o Max end-to-end delay for each unit q Isochronous transmission mode o Max and min end-to-end delay Chapter 2 Communication 61

Stream q q Stream from process to process Stream can be viewed as a

Stream q q Stream from process to process Stream can be viewed as a virtual connection between source and sink Chapter 2 Communication 62

Stream q Stream sent directly between two devices Chapter 2 Communication 63

Stream q Stream sent directly between two devices Chapter 2 Communication 63

Stream Multicasting a stream q Different requirements for receivers? q Chapter 2 Communication 64

Stream Multicasting a stream q Different requirements for receivers? q Chapter 2 Communication 64

Specifying Qo. S q Characteristics of the Input Service Required Maximum data unit size

Specifying Qo. S q Characteristics of the Input Service Required Maximum data unit size (bytes) Token bucket rate (bytes/sec) Toke bucket size (bytes) Maximum transmission rate (bytes/sec) Loss sensitivity (bytes) Loss interval ( sec) Burst loss sensitivity (data units) Minimum delay noticed ( sec) Maximum delay variation ( sec) Quality of guarantee A flow specification Chapter 2 Communication 65

Specifying Qo. S A token bucket algorithm q Don’t want bucket to be empty

Specifying Qo. S A token bucket algorithm q Don’t want bucket to be empty of overflowing q Then can feed out at precise time intervals q Chapter 2 Communication 66

Setting Up a Stream q q q RSVP for resource reservation Purpose is to

Setting Up a Stream q q q RSVP for resource reservation Purpose is to try to insure Qo. S Highly dependent on data link layer Chapter 2 Communication 67

Synchronization q q q Explicit synchronization for data units Read and write incoming stream

Synchronization q q q Explicit synchronization for data units Read and write incoming stream units App is responsible for sync. , only low-level utilities Chapter 2 Communication 68

Synchronization q q Synchronization supported by high-level interfaces A middleware approach Chapter 2 Communication

Synchronization q q Synchronization supported by high-level interfaces A middleware approach Chapter 2 Communication 69

Summary q Communication is a fundamental issue in distributed systems q Networking overview q

Summary q Communication is a fundamental issue in distributed systems q Networking overview q RPC o Goal is transparency q RMI o Transparency and objects q RPC and RMI are synchronous Chapter 2 Communication 70

Summary q Recall o Synchronous block until msg delivered (or until response received) o

Summary q Recall o Synchronous block until msg delivered (or until response received) o Asynchronous sender continues immediately after sending o Persistent msg stored until delivered o Transient msg delivered now or never Chapter 2 Communication 71

Summary q Message-Oriented Communication o Message passing § For transient asynchronous (MPI) § Good

Summary q Message-Oriented Communication o Message passing § For transient asynchronous (MPI) § Good for big parallel machines o Message queuing or message-oriented middleware (MOM) § Designed for persistent asynchronous q Streams o Primarily for video and audio o Temporal relationship is critical Chapter 2 Communication 72