ClientServer Model of Interaction Chapter 20 We have

  • Slides: 21
Download presentation
Client-Server Model of Interaction Chapter 20

Client-Server Model of Interaction Chapter 20

We have looked at the details of TCP/IP n n Protocols Router architecture Now

We have looked at the details of TCP/IP n n Protocols Router architecture Now want to look at application programs that use a TCP/IP internet n n n Example applications are practical & interesting But…focus instead on the patterns of interaction among the cooperating applications Primary one is client-server paradigm Forms basis of most network communications Foundation for distributed algorithms See basic model here; later chapters show use in specific applications

Client-Server Model Server n Any program that offers a service that can be reached

Client-Server Model Server n Any program that offers a service that can be reached over a network Accepts a request Performs it service Returns the result to the requester n For simple services, each request is a single IP datagram; response is another datagram

Client n An executing program that sends a request to a server and waits

Client n An executing program that sends a request to a server and waits for a response Client-server: n Extension of interprocess communication on single machine Servers can be simple or complex n n Time-of-day server: returns current time Web-server: fetches a copy of a web page

Servers are usually application programs n n n Execute on any machine supporting TCP/IP

Servers are usually application programs n n n Execute on any machine supporting TCP/IP Timesharing system or a PC Multiple servers can offer the same service Can be on same machine or on multiple machines Copies on independent machines increase reliability “Server” can be applied to a machine n When the computer’s primary purpose is to support a particular server program

Example: UDP Echo Server Simplest form of client-server interaction uses unreliable datagram delivery n

Example: UDP Echo Server Simplest form of client-server interaction uses unreliable datagram delivery n UDP echo server Echo server process gets use of UDP echo port Enters infinite loop n n n Wait for datagram Reverse source and destination addresses Return the datagram to the original sender Echo client is somewhere else n Gets unused UDP port, sends UDP msg to echo server, waits

Figure 20. 1

Figure 20. 1

Two points generally true of client-servers n 1 - Operation Server starts execution before

Two points generally true of client-servers n 1 - Operation Server starts execution before interaction begins n Accepts requests and sends responses w/o terminating Client makes request and awaits response n n Terminates after using server a finite number of times 2 - Location Server waits for requests at well-know port n Reserved for the service it offers Client allocates an arbitrary, unused, nonreserved port

Time and Date Service Time server n Used to set a computer’s time-of-day clock

Time and Date Service Time server n Used to set a computer’s time-of-day clock Hardware device that keeps current date and time n Can do manually Type in time and date when system boots n Use client-server interaction to do automatically Configure one machine manually All others contact server when they boot

Representation for the date and time n Many store time and date from an

Representation for the date and time n Many store time and date from an epoch Use count of seconds since the epoch date UNIX OS uses January 1, 1970 TCP/IP defines epoch as January 1, 1900 n n n Reports time as seconds past the epoch Time is 32 -bit integer Representation is compact Allows easy comparison Ties together date and time of day Measure time by incrementing single binary integer

Timer server interaction n Interaction with time service like echo server Server sits at

Timer server interaction n Interaction with time service like echo server Server sits at well known port Waits for UDP message Responds with UDP message containing 32 -bit current time

The Complexity of Servers Sequential servers are simple n n Process one request at

The Complexity of Servers Sequential servers are simple n n Process one request at a time Assume OS queues the requests if server busy Queue will not get too long since work is trivial n Usually more complex than that Must accommodate multiple concurrent requests Server typically has two parts n n Single master program to accept new requests Set of copies to handle individual requests

Server performs following steps: n Open port Opens the well-known port where it can

Server performs following steps: n Open port Opens the well-known port where it can be reached n n Wait for client Start copy Invoke independent, concurrent copy of itself Copy handles the one request then terminates n Continue Go to wait state while new copy handles request

Processing requests proceeds concurrently n n New copy for each request Short requests finish

Processing requests proceeds concurrently n n New copy for each request Short requests finish earlier than long requests Independent of the order in which they are started Advantage of concurrent server: n Speed Disadvantage of concurrent server: n Complexity (more difficult to construct)

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

Other forms of complexity arise as well n Must enforce authorization & protection rules Server programs execute with highest privilege Cannot blindly honor requests from other sites n Must protect themselves against errors May get malformed requests May get requests that cause them to abort

Broadcasting a Request Maybe client will not know server address n n n When

Broadcasting a Request Maybe client will not know server address n n n When booting, can use DHCP to obtain an address But does not know address of DHCP server For protocols where client does not know the address of a server, the client-server paradigm permits client to broadcast requests

Alternatives to Client-Server ARP protocol (Chap 5) n n Clients ask for information ARP

Alternatives to Client-Server ARP protocol (Chap 5) n n Clients ask for information ARP minimizes such interactions Uses cache of answers to improve later queries Improves performance when recent history of queries is a good indicator of future use Does not change essence of client-server interaction n Program executes until needs information Then becomes client to obtain the information Caching lowers the cost for all except the first process

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

How to lower cost for the first request? n In a distributed system, do precollection Background activities collect and propagate information before any program requests it n Basis for UNIX ruptime command Reports CPU load and time since system startup Background program on each machine is used n n Periodically broadcasts information Collects incoming information and stores in a file Each machine always has a copy of latest info Client never has to access the network n Reads info from secondary storage

Chief advantage of precollection is speed n Information available locally without delay Main disadvantage:

Chief advantage of precollection is speed n Information available locally without delay Main disadvantage: potential to be wasteful n n n Uses processor time and network bandwidth Even when no one cares about the data being collected Cost for reading and processing broadcasts is high Precollection is not among most popular alternatives to client-server

Summary Distributed programs need communication n Often use client-server interaction Server process awaits request;

Summary Distributed programs need communication n Often use client-server interaction Server process awaits request; then responds Client program makes request, sends, waits Client can send request directly or broadcast n n Broadcast useful on local network Machine not need to know address of server

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

Servers can use internet protocols like UDP n Accept and respond to requests across internet Can communicate with physical frames n Restricted to single physical network Precollection is an alternative to the clientserver model n Precollects information to avoid delays