EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division...

36
EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division artment of Electrical Engineering and Computer Scie University of California, Berkeley Berkeley, CA 94720-1776
  • date post

    22-Dec-2015
  • Category

    Documents

  • view

    214
  • download

    0

Transcript of EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division...

Page 1: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

EECS122 - UCB 1

CS 194: Distributed Systems

Communication Protocols, RPC

Computer Science DivisionDepartment of Electrical Engineering and Computer Sciences

University of California, BerkeleyBerkeley, CA 94720-1776

Page 2: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

ISO OSI Reference Model for Layers

Application

Presentation

Session

Transport

Network

Datalink

Physical

Page 3: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Mapping Layers ontoRouters and Hosts

– Lower three layers are implemented everywhere– Next four layers are implemented only at hosts

Application

Presentation

Session

Transport

Network

Datalink

Physical

Application

Presentation

Session

Transport

Network

Datalink

Physical

Network

Datalink

Physical

Physical medium

Host A Host B

Router

Page 4: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Encapsulation• A layer can use only the service provided by the layer immediate

below it

• Each layer may change and add a header to data packet

– higher layer’s header is treated as payload

data

data

data

data

data

data

data

data

data

data

data

data

data

data

Page 5: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

OSI Model Concepts

• Service – says what a layer does

• Interface – says how to access the service

• Protocol – says how is the service implemented– A set of rules and formats that govern the

communication between two peers

Page 6: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Layering: Internet• Universal Internet layer:

• Internet has only IP at the Internet layer

• Many options for modules above IP

• Many options for modules below IP

Internet

Net access/Physical

Transport

Application

IP

LAN Packetradio

TCP UDP

Telnet FTP DNS

Page 7: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Internet’s Hourglass

Physical Layer

Datalink Layer

Network Layer

Application Layer

Page 8: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Physical Layer

• Service: move information between two systems connected by a physical link

• Interface: specifies how to send a bit

• Protocol: coding scheme used to represent a bit, voltage levels, duration of a bit

• Examples: coaxial cable, optical fiber links; transmitters, receivers

AdaptorAdaptor AdaptorAdaptorSignal

Network

ApplicationTransport

LinkPhysical

Page 9: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Datalink Layer

• Service: – Framing (attach frame separators) – Send data frames between peers– Medium access: arbitrate the access to common

physical media– Error detection and correction

• Interface: send a data unit (packet) to a machine connected to the same physical media

• Protocol: layer addresses, implement Medium Access Control (MAC) (e.g., CSMA/CD)…

Network

ApplicationTransport

LinkPhysical

Page 10: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Network Layer

• Service: – Deliver a packet to specified network destination– Perform segmentation/reassembly– Others

• Packet scheduling

• Buffer management

• Interface: send a packet to a specified destination

• Protocol: define global unique addresses; construct routing tables

Network

ApplicationTransport

LinkPhysical

Page 11: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Datagram (Packet) Switching

Host A

Host BHost E

Host D

Host C

router 1 router 2

router 3

router 4

router 5

router 6 router 7

Network

ApplicationTransport

LinkPhysical

Page 12: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Datagram (Packet) Switching

Host A

Host BHost E

Host D

Host C

router 1 router 2

router 3

router 4

router 5

router 6 router 7

Network

ApplicationTransport

LinkPhysical

Page 13: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Transport Layer

• Services: – Multiplex multiple transport connections to one network

connection– Provide an error-free and flow-controlled end-to-end

connection– Split one transport connection in multiple network

connections

• Interface: send a packet to specify destination

• Protocols: implement reliability and flow control

• Examples: TCP and UDP

Network

ApplicationTransport

LinkPhysical

Page 14: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

End-to-End View

• Process A sends a packet to process B

16.25.31.10 128.15.11.12

Proc. A(port 10)

Proc. B(port 7)

Internet

Page 15: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

End-to-End Layering View

16.25.31.10 128.15.11.12

Proc. A(port 10)

InternetProc. B(port 7)

Transport

Network

Datalink

Physical

Proc. A(port 10)

Proc. B(port 7)

Transport

Network

Datalink

Physical

data

16.25.31.10 128.15.11.12data 10 7

data 10 7

16.25.31.10 128.15.11.12

data

data

data

10 7

10 7

Internet16.25.31.10 128.15.11.12

Page 16: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Client-Server TCP

a) Normal operation of TCP.b) Transactional TCP.

2-4

Page 17: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Conventional Procedure Call

a) Parameter passing in a local procedure call: the stack before the call to read

b) The stack while the called procedure is active

Page 18: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Example: Local Procedure Call

.

.

.

n = sum(4, 7);...

sum(i, j)int i, j;{ return (i+j);}

Machine

Process

Page 19: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Example: Remote Procedure Call

.

.

.

n = sum(4, 7);...

sum(i, j)int i, j;{ return (i+j);}

Client

Process

sum47

message

OS

Server

Process

sum47

message

OS

Stubs

Page 20: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Client and Server Stubs

• Principle of RPC between a client and server program.

Page 21: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Steps of a Remote Procedure Call1. Client procedure calls client stub in normal way2. Client stub builds message, calls local OS3. Client's OS sends message to remote OS4. Remote OS gives message to server stub5. Server stub unpacks parameters, calls server6. Server does work, returns result to the stub7. Server stub packs it in message, calls local OS8. Server's OS sends message to client's OS9. Client's OS gives message to client stub10. Stub unpacks result, returns to client

Page 22: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Parameter Passing

• Server and client may encode parameters differently– E.g., big endian vs. little endian

• How to send parameters “call-by-reference”?– Basically do “call-by-copy/restore”– Woks when there is an array of fixed size– How about arbitrary data structures?

Page 23: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Different Encodings

a) Original message on the Pentiumb) The message after receipt on the SPARCc) The message after being inverted. The little numbers in

boxes indicate the address of each byte

Page 24: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Parameter Specification and Stub Generation

a) A procedureb) The corresponding message.

Page 25: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Binding a Client to a Server• Client-to-server binding in DCE.

2-15

Page 26: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Doors• The principle of using doors as IPC mechanism.

Page 27: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

RPC Semantics in the Presence of Failures

• The client is unable to locate the server

• The request message from the client to server is lost

• The reply message from the client is lost

• The server crashes after sending a request

• The client crashes after sending a request

Page 28: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Client is Unable to Locate Server

• Causes: server down, different version of server binary, …

• Fixes– Return -1 to indicate failure (in Unix use errno to

indicate failure type)• What if -1 is a legal return value?

– Use exceptions• Transparency is lost

Page 29: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Lost Request Message

• Easiest to deal with

• Just retransmit the message!

• If multiple message are lost then– “client is unable to locate server” error

Page 30: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Lost Reply Message

• Far more difficult to deal with: client doesn’t know what happened at server– Did server execute the procedure or not?

• Possible fixes– Retransmit the request

• Only works if operation is idempontent: it’s fine to execute it twice

– What if operation not idempotent?• Assign unique sequence numbers to every request

Page 31: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Server Crashes

• Two cases– Crash after execution– Crash before execution

• Three possible semantics– At least once semantics

• Client keeps trying until it gets a reply

– At most once semantics• Client gives up on failure

– Exactly once semantics• Can this be correctly implemented?

Page 32: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Client Crashes

• Let’s the server computation orphan

• Orphans can– Waste CPU cycles– Lock files – Client reboots and it gets the old reply immediately

Page 33: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Client Crashes: Possible Solutions

• Extermination: – Client keeps a log, reads it when reboots, and kills the orphan– Disadvantage: high overhead to maintain the log

• Reincarnation: – Divide times in epochs– Client broadcasts epoch when reboots – Upon hearing a new epoch servers kills the orphans– Disadvantage: doesn’t solve problem when network partitioned

• Expiration:– Each RPC is given a lease T to finish computation– If it does not, it needs to ask for another lease– If client reboots after T sec all orphans are gone – Problem: what is a good value of T?

Page 34: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

RPC Semantics: Discussion

• The original goal: provide the same semantics as a local call

• Impossible to achieve in a distributed system– Dealing with remote failures fundamentally affects

transparency

• Ideal interface: balance the easy of use with making visible the errors to users

Page 35: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Asynchronous RPC (1)

a) The interconnection between client and server in a traditional RPCb) The interaction using asynchronous RPC

2-12

Page 36: EECS122 - UCB 1 CS 194: Distributed Systems Communication Protocols, RPC Computer Science Division Department of Electrical Engineering and Computer Sciences.

Asynchronous RPC (2)

• A client and server interacting through two asynchronous RPCs