21
Client-Server Model Client-Server Model of Interaction of Interaction Chapter 20 Chapter 20

Client-Server Model of Interaction

  • Upload
    jaunie

  • View
    35

  • Download
    0

Embed Size (px)

DESCRIPTION

Client-Server Model of Interaction. Chapter 20. We have looked at the details of TCP/IP Protocols Router architecture Now want to look at application programs that use a TCP/IP internet Example applications are practical & interesting - PowerPoint PPT Presentation

Citation preview

Page 1: Client-Server Model of Interaction

Client-Server Model of Client-Server Model of InteractionInteraction

Chapter 20Chapter 20

Page 2: Client-Server Model of Interaction

We have looked at the details of TCP/IPWe have looked at the details of TCP/IP ProtocolsProtocols Router architectureRouter architecture

Now want to look at application programs Now want to look at application programs that use a TCP/IP internetthat use a TCP/IP internet Example applications are practical & interestingExample applications are practical & interesting But…focus instead on the patterns of interaction But…focus instead on the patterns of interaction

among the cooperating applicationsamong the cooperating applications Primary one is Primary one is client-serverclient-server paradigm paradigm

Forms basis of most network communicationsForms basis of most network communicationsFoundation for distributed algorithmsFoundation for distributed algorithmsSee basic model here; later chapters show use in See basic model here; later chapters show use in specific applicationsspecific applications

Page 3: Client-Server Model of Interaction

Client-Server ModelClient-Server Model

ServerServer Any Any programprogram that offers a service that can be that offers a service that can be

reached over a networkreached over a networkAccepts a requestAccepts a request

Performs it servicePerforms it service

Returns the result to the requesterReturns the result to the requester For simple services, each request is a single For simple services, each request is a single

IP datagram; response is another datagramIP datagram; response is another datagram

Page 4: Client-Server Model of Interaction

ClientClient An executing program that sends a request to a An executing program that sends a request to a

server and waits for a responseserver and waits for a response

Client-server:Client-server: Extension of interprocess communication on Extension of interprocess communication on

single machinesingle machine

Servers can be simple or complexServers can be simple or complex Time-of-day server:Time-of-day server: returns current time returns current time Web-server:Web-server: fetches a copy of a web page fetches a copy of a web page

Page 5: Client-Server Model of Interaction

Servers are usually application programsServers are usually application programs Execute on any machine supporting TCP/IPExecute on any machine supporting TCP/IP Timesharing system or a PCTimesharing system or a PC Multiple servers can offer the same serviceMultiple servers can offer the same service

Can be on same machine or on multiple machinesCan be on same machine or on multiple machines

Copies on independent machines increase reliabilityCopies on independent machines increase reliability

““Server” can be applied to a machineServer” can be applied to a machine When the computer’s primary purpose is to When the computer’s primary purpose is to

support a particular server programsupport a particular server program

Page 6: Client-Server Model of Interaction

Example: UDP Echo ServerExample: UDP Echo Server

Simplest form of client-server interaction Simplest form of client-server interaction uses unreliable datagram deliveryuses unreliable datagram delivery UDP echo serverUDP echo server

Echo server process gets use of UDP echo portEcho server process gets use of UDP echo portEnters infinite loopEnters infinite loop

Wait for datagramWait for datagram Reverse source and destination addressesReverse source and destination addresses Return the datagram to the original senderReturn the datagram to the original sender

Echo client is somewhere elseEcho client is somewhere else Gets unused UDP port, sends UDP msg to echo server, waitsGets unused UDP port, sends UDP msg to echo server, waits

Page 7: Client-Server Model of Interaction

Figure 20.1Figure 20.1

Page 8: Client-Server Model of Interaction

Two points generally true of client-serversTwo points generally true of client-servers 1 - Operation1 - Operation

Server starts execution before interaction beginsServer starts execution before interaction begins Accepts requests and sends responses w/o terminatingAccepts requests and sends responses w/o terminating

Client makes request and awaits responseClient makes request and awaits response Terminates after using server a finite number of timesTerminates after using server a finite number of times

2 - Location2 - LocationServer waits for requests at well-know portServer waits for requests at well-know port

Reserved for the service it offersReserved for the service it offers

Client allocates an arbitrary, unused, nonreserved portClient allocates an arbitrary, unused, nonreserved port

Page 9: Client-Server Model of Interaction

Time and Date ServiceTime and Date Service

Time serverTime server Used to set a computer’s time-of-day clockUsed to set a computer’s time-of-day clock

Hardware device that keeps current date and timeHardware device that keeps current date and time Can do manuallyCan do manually

Type in time and date when system bootsType in time and date when system boots Use client-server interaction to do automaticallyUse client-server interaction to do automatically

Configure one machine manuallyConfigure one machine manually

All others contact server when they bootAll others contact server when they boot

Page 10: Client-Server Model of Interaction

Representation for the date and timeRepresentation for the date and time Many store time and date from an epochMany store time and date from an epoch

Use count of seconds since the epoch dateUse count of seconds since the epoch date

UNIX OS uses January 1, 1970UNIX OS uses January 1, 1970

TCP/IP defines epoch as January 1, 1900TCP/IP defines epoch as January 1, 1900 Reports time as seconds past the epochReports time as seconds past the epoch Time is 32-bit integerTime is 32-bit integer

Representation is compactRepresentation is compactAllows easy comparisonAllows easy comparison

Ties together date and time of dayTies together date and time of day

Measure time by incrementing single binary integerMeasure time by incrementing single binary integer

Page 11: Client-Server Model of Interaction

Timer server interactionTimer server interaction Interaction with time service like echo serverInteraction with time service like echo server

Server sits at well known portServer sits at well known port

Waits for UDP messageWaits for UDP message

Responds with UDP message containing 32-bit Responds with UDP message containing 32-bit current timecurrent time

Page 12: Client-Server Model of Interaction

The Complexity of ServersThe Complexity of Servers

Sequential servers are simpleSequential servers are simple Process one request at a timeProcess one request at a time Assume OS queues the requests if server busyAssume OS queues the requests if server busy

Queue will not get too long since work is trivialQueue will not get too long since work is trivial Usually more complex than thatUsually more complex than that

Must accommodate multiple concurrent requestsMust accommodate multiple concurrent requests

Server typically has two partsServer typically has two parts Single master program to accept new requestsSingle master program to accept new requests Set of copies to handle individual requestsSet of copies to handle individual requests

Page 13: Client-Server Model of Interaction

Server performs following steps:Server performs following steps: Open portOpen port

Opens the well-known port where it can be reachedOpens the well-known port where it can be reached Wait for clientWait for client Start copyStart copy

Invoke independent, concurrent copy of itselfInvoke independent, concurrent copy of itselfCopy handles the one request then terminatesCopy handles the one request then terminates

ContinueContinueGo to wait state while new copy handles requestGo to wait state while new copy handles request

Page 14: Client-Server Model of Interaction

Processing requests proceeds concurrentlyProcessing requests proceeds concurrently New copy for each requestNew copy for each request Short requests finish earlier than long requestsShort requests finish earlier than long requests

Independent of the order in which they are startedIndependent of the order in which they are started

Advantage of concurrent server:Advantage of concurrent server: SpeedSpeed

Disadvantage of concurrent server:Disadvantage of concurrent server: Complexity (more difficult to construct)Complexity (more difficult to construct)

Page 15: Client-Server Model of Interaction

Other forms of complexity arise as wellOther forms of complexity arise as well Must enforce authorization & protection rulesMust enforce authorization & protection rules

Server programs execute with highest privilegeServer programs execute with highest privilege

Cannot blindly honor requests from other sitesCannot blindly honor requests from other sites Must protect themselves against errorsMust protect themselves against errors

May get malformed requestsMay get malformed requests

May get requests that cause them to abortMay get requests that cause them to abort

Page 16: Client-Server Model of Interaction

Maybe client will not know server addressMaybe client will not know server address When booting, can use DHCP to obtain an When booting, can use DHCP to obtain an

addressaddress But does not know address of DHCP serverBut does not know address of DHCP server For protocols where client does not know the For protocols where client does not know the

address of a server, the client-server paradigm address of a server, the client-server paradigm permits client to broadcast requestspermits client to broadcast requests

Broadcasting a RequestBroadcasting a Request

Page 17: Client-Server Model of Interaction

Alternatives to Client-ServerAlternatives to Client-Server

ARP protocol (Chap 5)ARP protocol (Chap 5) Clients ask for informationClients ask for information ARP minimizes such interactionsARP minimizes such interactions

Uses cache of answers to improve later queriesUses cache of answers to improve later queries

Improves performance when recent history of queries is Improves performance when recent history of queries is a good indicator of future usea good indicator of future use

Does not change essence of client-server interactionDoes not change essence of client-server interaction Program executes until needs informationProgram executes until needs information Then becomes client to obtain the informationThen becomes client to obtain the information Caching lowers the cost for all except the first processCaching lowers the cost for all except the first process

Page 18: Client-Server Model of Interaction

How to lower cost for the first request?How to lower cost for the first request? In a distributed system, do In a distributed system, do precollectionprecollection

Background activities collect and propagate Background activities collect and propagate information before any program requests itinformation before any program requests it

Basis for UNIX Basis for UNIX ruptimeruptime command commandReports CPU load and time since system startupReports CPU load and time since system startup

Background program on each machine is usedBackground program on each machine is used Periodically broadcasts informationPeriodically broadcasts information Collects incoming information and stores in a fileCollects incoming information and stores in a file

Each machine always has a copy of latest infoEach machine always has a copy of latest info

Client never has to access the networkClient never has to access the network Reads info from secondary storageReads info from secondary storage

Page 19: Client-Server Model of Interaction

Chief advantage of precollection is speedChief advantage of precollection is speed Information available locally without delayInformation available locally without delay

Main disadvantage: potential to be wastefulMain disadvantage: potential to be wasteful Uses processor time and network bandwidthUses processor time and network bandwidth Even when no one cares about the data being Even when no one cares about the data being

collectedcollected Cost for reading and processing broadcasts is Cost for reading and processing broadcasts is

highhigh

Precollection is not among most popular Precollection is not among most popular alternatives to client-serveralternatives to client-server

Page 20: Client-Server Model of Interaction

SummarySummary

Distributed programs need communicationDistributed programs need communication Often use client-server interactionOften use client-server interaction

Server process awaits request; then respondsServer process awaits request; then responds

Client program makes request, sends, waitsClient program makes request, sends, waits

Client can send request directly or Client can send request directly or broadcastbroadcast Broadcast useful on local networkBroadcast useful on local network Machine not need to know address of serverMachine not need to know address of server

Page 21: Client-Server Model of Interaction

Servers can use internet protocols like UDPServers can use internet protocols like UDP Accept and respond to requests across internetAccept and respond to requests across internet

Can communicate with physical framesCan communicate with physical frames Restricted to single physical networkRestricted to single physical network

Precollection is an alternative to the client-Precollection is an alternative to the client-server modelserver model Precollects information to avoid delaysPrecollects information to avoid delays