Tải bản đầy đủ (.pdf) (36 trang)

tính toán song song thoại nam distributedsystem 15 communication sinhvienzone com

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (755.08 KB, 36 trang )

om
.C

nh
Vi
en

Zo

ne

Distributed Systems
Thoai Nam

Si

Faculty of Computer Science and Engineering
HCMC University of Technology

SinhVienZone.com

/>



.C



Issues in communication
Message-oriented Communication


Remote Procedure Calls

ne



om

Chapter 2: Communication

Zo

– Transparency but poor for passing references

Remote Method Invocation

nh
Vi
en



– RMIs are essentially RPCs but specific to remote objects
– System wide references passed as parameters

Stream-oriented Communication

Si




Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

.C

ne

Zo
nh
Vi
en



Protocols are agreements/rules on communication
Protocols could be connection-oriented or
connectionless

Si



om

Communication Protocols


Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

ne

.C

A typical message as it appears on the network.

nh
Vi
en

Zo

2-2

Si



om

Layered Protocols


Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

Si

nh
Vi
en

b)

2-4 operation of TCP.
Normal
Transactional TCP.

Zo

a)

ne

.C

om

Client-Server TCP


Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

Middleware Protocols

.C

om

Middleware: layer that resides between an OS and
an application

nh
Vi
en

Zo

ne

– May implement general-purpose protocols that warrant
their own layers. Ex: distributed commit

Si




Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

Structure: group of servers offering service to
clients
Based on a request/response paradigm
Techniques:

Zo

– Socket, remote procedure calls (RPC), Remote Method
Invocation (RMI)
client
kernel

nh
Vi
en



file
server


process
server

terminal
server

kernel

kernel

kernel

Si



ne

.C



om

Client-Server Communication
Model

Khoa Công Nghệ Thông Tin
SinhVienZone.com


– Đại Học Bách Khoa Tp.HCM

/>






.C

ne

Zo



nh
Vi
en



Addressing
Blocking versus non-blocking
Buffered versus unbuffered
Reliable versus unreliable
Server architecture: concurrent versus sequential
Scalability


Si



om

Issues in Client-Server
Communication

Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>



user

nh
Vi
en

Zo

– Machine address and process
address are known a priori



user

server

Broadcast-based

Si

– Server chooses address from a
sparse address space
– Client broadcasts request
– Can cache response for future


server

.C

Question: how is the server
located?
Hard-wired address

ne



om

Addressing Issues


NS

user

Locate address via name server
Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Baùch Khoa Tp.HCM

/>
server




om

Blocking versus Non-blocking
Blocking communication (synchronous)

Zo

ne

.C

– Send blocks until message is actually sent
– Receive blocks until message is actually
received


Non-blocking communication (asynchronous)

nh
Vi
en





Si

– Send returns immediately
– Return does not block either

Examples

Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>



om

Buffering Issues

Unbuffered communication

Zo

Buffered communication

nh
Vi
en

– Client send to a mailbox
– Server receives from a mailbox
user

Si



server

ne

.C

– Server must call receive before clientuser
can call send

Khoa Công Nghệ Thông Tin
SinhVienZone.com


– Đại Học Bách Khoa Tp.HCM

/>
server


Reliability

Zo

Reliable channel

User

nh
Vi
en



– Reply acts as ACK for request
– Explicit ACK for response

ACK

Reliable communication on unreliable
channels

Si




request
reply

– Transport protocol handles lost messages
Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>
Server

ACK

Server

ACK
reply

ne

.C

– Need acknowledgements (ACKs)
– Applications handle ACKs
– ACKs for both request and reply

request

User

Unreliable channel

om




Goal: Make distributed computing look like
centralized computing
Allow remote services to be called as procedures



ne

.C



om

Remote Procedure Calls



nh
Vi
en


Zo

– Transparency with regard to location, implementation,
language

Issues

Si

– How to pass parameters
– Bindings
– Semantics in face of errors


Two classes: integrated into prog, language and
separate
Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

ne

.C

b) The stack while the called
procedure is active


nh
Vi
en

Zo

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

Si

a)

om

Conventional Procedure Call

Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>



om


Parameter Passing
Local procedure parameter passing

Remote procedure calls simulate this through:

Zo



ne

.C

– Call-by-value
– Call-by-reference: arrays, complex data structures

Related issue: global variables are not allowed in
RPCs

Si



nh
Vi
en

– Stubs – proxies
– Flattening – marshalling


Khoa Coâng Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

nh
Vi
en

Zo

ne

.C

Principle of RPC between a client and server
program.

Si



om

Client and Server Stubs

Khoa Công Nghệ Thông Tin

SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

Client makes procedure call (just like a local
procedure call) to the client stub
Server is written as a standard procedure
Stubs take care of packaging arguments and
sending messages
Packaging parameters is called marshalling
Stub compiler generates stub automatically from
specs in an Interface Definition Language (IDL)




Zo

nh
Vi
en



Si




ne

.C



om

Stubs

– Simplifies programmer task

Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Baùch Khoa Tp.HCM

/>

5.

6.
7.
8.

9.
10.

.C


ne

4.

Zo

3.

nh
Vi
en

2.

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

Si

1.

om


Steps of a Remote Procedure Call

Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

ne

Si

nh
Vi
en

Zo

2-8

.C

om

Example of an RPC

Khoa Công Nghệ Thông Tin
SinhVienZone.com


– Đại Học Baùch Khoa Tp.HCM

/>

Marshalling

om

Problem: different machines have different data
formats

.C





ne

– Intel: little endian, SPARC: big endian

Solution: use a standard representation
Problem: how do we pass pointers?

nh
Vi
en




Zo

– Example: external data representation (XDR)
– If it points to a well-defined data structure, pass a copy and the
server stub passes a pointer to the local copy

What about data structures containing pointers?

Si



– Prohibit
– Chase pointers over network


Marshalling: transform parameters/results into a byte
stream
Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>



om


Binding
Problem: how does a client locate a server?
Server

ne



.C

– Use Bindings

Client

– First RPC: send message to binder to import server
interface
– Binder: check to see if server has exported interface
» Return handle and unique identifier to client

Si



nh
Vi
en

Zo

– Export server interface during initialization

– Send name, version no, unique identifier, handle
(address) to binder

Khoa Coâng Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

.C








TCP: stream is divided into records
UDP: max packet size < 8912 bytes
UDP: timeout plus limited number of retransmissions
TCP: return error if connection is terminated by server

Multiple arguments marshaled into a single structure
At-least-once semantics if reply received, at-least-zero
semantics if no reply. With UDP tries at-most-once
Use SUN’s eXternal Data Representation (XDR)

Si




ne



Zo



One of the most widely used RPC systems
Developed for use with NFS
Built on top of UDP or TCP

nh
Vi
en



om

Case Study: SUNRPC

– Big endian order for 32 bit integers, handle arbitrarily large data
structures
Khoa Coâng Nghệ Thông Tin
SinhVienZone.com


– Đại Học Bách Khoa Tp.HCM

/>



.C

Si



nh
Vi
en

Zo



Server start-up: create port
Server stub calls
svc_register to register
prog. #, version # with local
port mapper
Port mapper stores prog #,
version #, and port
Client start-up: call
clnt_create to locate server
port

Upon return, client can call
procedures at the server

ne



om

Binder: Port Mapper



Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

Si

nh
Vi
en

Zo

ne


.C

om

Rpcgen: generating stubs




Q_xdr.c: do XDR conversion
Detailed example: later in this course
Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>

Many RPCs occur between client and server on
same machine

.C



om

Lightweight RPCs




nh
Vi
en



Server S exports interface to remote procedures
Client C on same machine imports interface
OS kernel creates data structures including an
argument stack shared between S and C

Si



Zo

ne

– Need to optimize RPCs for this special case => use a
lightweight RPC mechanism (LRPC)

Khoa Công Nghệ Thông Tin
SinhVienZone.com

– Đại Học Bách Khoa Tp.HCM

/>


×