37
1 Chapter 26-27 Client-Server Interaction

1 Chapter 26-27 Client-Server Interaction. 2 Functionality Transport layer and layers below Basic communication Reliability Application layer

Embed Size (px)

Citation preview

Page 1: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

1

Chapter 26-27

Client-Server Interaction

Page 2: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

2

FunctionalityFunctionality

Transport layer and layers belowBasic communicationReliability

Application layerAbstractions

FilesServicesDatabases

Names

Page 3: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

3

Dichotomy of DutiesDichotomy of Duties

NetworkTransfers bitsOperates at application’s request

Applications determineWhat to sendWhen to sendWhere to sendMeaning of bits

Page 4: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

4

Important PointImportant Point

Although an internet system provides a basic communication service, the protocol software cannot initiate contact with, or accept contact from, a remote computer. Instead, two application programs must participate in any communication: one application initiates communication and the other accepts it.

Page 5: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

5

How Two Application Programs Make Contact

How Two Application Programs Make Contact

One applicationBegins execution firstWaits passively at prearranged location

Another applicationBegins execution laterActively contacts first program

Called client-server interaction

Page 6: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

6

Client-Server ParadigmClient-Server Paradigm

Used by all network applicationsPassive program called a serverActive program called a client

Page 7: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

7

Internet CommunicationInternet Communication

All network applications use a form of communication known as the client-server paradigm. A server application waits passively for contact, while a client application initiates communication actively.

If both parties are equal, you may have a peer-to-peer solution

Page 8: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

8

Characteristics of a ClientCharacteristics of a Client

Arbitrary application programBecomes client temporarilyCan also perform other computationsInvoked directly by userRuns locally on user’s computerActively initiates contact with a serverContacts one server at a time

Page 9: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

9

Characteristics of a ServerCharacteristics of a Server

Special-purpose, privileged programDedicated to providing one serviceCan handle multiple remote clients simultaneouslyInvoked automatically when system bootsExecutes foreverNeeds powerful computer and operating systemWaits passively for client contactAccepts requests from arbitrary clients

Page 10: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

10

TerminologyTerminology

ServerAn executing program that accepts contact over

the networkServer-class computer

Hardware sufficient to execute a serverInformally

Term server often applied to computer

Page 11: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

11

Direction of Data FlowDirection of Data Flow

Data can flowFrom client to server onlyFrom server to client onlyIn both directions

Application protocol determines flowTypical scenario

Client sends request(s)Sever sends response(s)

Page 12: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

12

Key IdeaKey Idea

Although the client initiates contact, information can flow in either or both directions between a client and server. Many services arrange for the client to send one or more requests and the server to return one response for each request.

Page 13: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

13

Clients, Servers, and Other Protocols

Clients, Servers, and Other Protocols

Clients and servers are application programs

Page 14: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

14

Server CPU UseServer CPU Use

FactsServer operates like other applications

Uses CPU to execute instructionsPerforms I/O operations

Waiting for data to arrive over a network does not require CPU time

ConsequenceServer program only uses CPU when servicing a

request

Page 15: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

15

Multiple ServicesMultiple Services

Can have multiple servers on single computer

Servers only use processor when handling a request

Powerful hardware required to handle many services simultaneously

Page 16: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

16

Illustration of Multiple Servers

Illustration of Multiple Servers

Each server offers one serviceOne server can handle multiple clients

Page 17: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

17

Identifying a ServiceIdentifying a Service

Protocol port number usedEach service given unique port number, PServer

Informs OS it is using port PWaits for requests to arrive

ClientForms requestSend request to port P on server computer

Page 18: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

18

The Point About PortsThe Point About Ports

Transport protocols assign each service a unique port identifier. A server must specify the identifier when it begins execution. A client must specify the identifier when it requests transport protocol software to contact a server. Protocol software on the server computer uses the identifier to direct an incoming request to the correct server.

Page 19: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

19

In TheoryIn Theory

Port numbers are merely integersAny server could use any port number

Page 20: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

20

In PracticeIn PracticeProtocol port numbers used as service identifiersNeed uniform numbering

To allow arbitrary client to contact server on arbitrary machine

To avoid inventing “directory assistance” mechanismPort numbers

Uniform throughout InternetSet by standards bodies (IANA – Internet Assigned

Numers Authority)

Page 21: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

21

Assigned port numbersAssigned port numbersThe port numbers are divided into three ranges:

The Well Known Ports, 0 - 1023. The Registered Ports, 1024 - 49151 The Dynamic and/or Private Ports, 49152 – 65535

Numbers primarily assigned for TCP. UDP for most part uses the same numbers

http://www.iana.org/assignments/port-numbers

Page 22: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

22

TerminologyTerminology

Sequential programTypical of most programsSingle thread of control

Concurrent programMultiple threads of controlExecution proceeds “in parallel”More difficult to create

Page 23: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

23

Servers and ConcurrencyServers and Concurrency

Sequential serverAlso called iterativeHandles one request at a time

Concurrent serverCan handle multiple requests at a timeNo waiting

Page 24: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

24

Delay in ServersDelay in Servers

Concurrent serverServer creates new thread of control to handle each

requestClient only waits for its request to be processed

Sequential serverClient waits for all previous requests to be processed as

well as for its request to be processedUnacceptable to user if long request blocks short

requests

Page 25: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

25

Concurrency in ServersConcurrency in Servers

Concurrent execution is fundamental to servers because concurrency permits multiple clients to obtain a given service without having to wait for the server to finish previous requests. In a concurrent server, the main server thread creates a new service thread to handle each client.

Page 26: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

26

Protocol Ports and Concurrent ServersProtocol Ports and Concurrent Servers

Apparent problemOne port number assigned to each serviceConcurrent server has multiple copies (threads)

runningClient and server may interactMessages sent to server’s port must be delivered

to correct copy

Page 27: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

27

Protocol Ports and Concurrent Servers

(continued)

Protocol Ports and Concurrent Servers

(continued)Solution to problem: use information about

client as well as server to deliver incoming packets

TCP uses four items to identify connectionServer’s IP addressServer’s protocol port numberClient’s IP addressClient’s protocol port number

Page 28: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

28

Demultiplexing in a Concurrent ServerDemultiplexing in a Concurrent Server

Transport protocols assign an identifier to each client as well as to each service. Protocol software on the server’s machine uses the combination of client and server identifiers to choose the correct copy of a concurrent server.

Page 29: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

29

Variations on a ThemeVariations on a Theme

A server can useConnectionless transport (UDP)Connection-oriented transport (TCP)Both for a single service

A single server can offer multiple servicesOften used for “trivial” servicesServer uses multiple port numbers

simultaneously

Page 30: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

30

Variations on a Theme (cont)

Variations on a Theme (cont)

A server canMaintain interaction with a client for days or

hoursSend a short response and terminate interactionPerform I/O on the local computerBecome a client for another service (potential

cycle problem)

Page 31: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

31

Example of CircularityExample of Circularity

Time serverReturns time of day

File serverAllows client to read or write a fileCalls time server when generating time stamp for

fileSuppose programmer modifies time server to

log requests to a file

Page 32: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

32

Interacting with Protocol Software

Interacting with Protocol Software

Client or server uses transport protocolsProtocol software inside OSApplications outside OSMechanism needed to bridge the two

Called Application Program Interface (API)

Page 33: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

33

Application Program Interface

Application Program Interface

Part of operating systemPermits application to use protocolsDefines

Operations allowedArguments for each operation

Page 34: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

34

Socket APISocket API

Originally designedFor BSD UNIXTo use with TCP/IP protocols

NowIndustry standardAvailable on many operating systems

Page 35: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

35

Sockets and Socket Libraries

Sockets and Socket Libraries

A socket library can provide applications with a socket API on a computer system that does not provide native sockets. When an application calls one of the socket procedures, control passes to a library routine that makes one or more calls to the underlying operating system to implement the socket function.

Page 36: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

36

SocketSocket

OS abstraction (not hardware)Created dynamicallyPersists only while application runsReferenced by a descriptor

Page 37: 1 Chapter 26-27 Client-Server Interaction. 2 Functionality  Transport layer and layers below  Basic communication  Reliability  Application layer

37

DescriptorDescriptor

Small integerOne per active socketUsed in all operations on socketGenerated by OS when socket createdOnly meaningful to application that owns

socketIn UNIX, integrated with file descriptors