Presentation is loading. Please wait.

Presentation is loading. Please wait.

Client-Server Model of Interaction Chapter 20. We have looked at the details of TCP/IP Protocols Protocols Router architecture Router architecture Now.

Similar presentations


Presentation on theme: "Client-Server Model of Interaction Chapter 20. We have looked at the details of TCP/IP Protocols Protocols Router architecture Router architecture Now."— Presentation transcript:

1 Client-Server Model of Interaction Chapter 20

2 We have looked at the details of TCP/IP Protocols Protocols Router architecture Router architecture Now want to look at application programs that use a TCP/IP internet Example applications are practical & interesting Example applications are practical & interesting But…focus instead on the patterns of interaction among the cooperating applications But…focus instead on the patterns of interaction among the cooperating applications Primary one is client-server paradigm 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

3 Client-Server Model Server Any program that offers a service that can be reached over a network 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 For simple services, each request is a single IP datagram; response is another datagram For simple services, each request is a single IP datagram; response is another datagram

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

5 Servers are usually application programs Execute on any machine supporting TCP/IP Execute on any machine supporting TCP/IP Timesharing system or a PC Timesharing system or a PC Multiple servers can offer the same service 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 When the computer’s primary purpose is to support a particular server program When the computer’s primary purpose is to support a particular server program

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

7 Figure 20.1

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

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

10 Representation for the date and time Many store time and date from an epoch 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 Reports time as seconds past the epoch Reports time as seconds past the epoch Time is 32-bit integer Time is 32-bit integer Representation is compact Representation is compact Allows easy comparison Ties together date and time of day Measure time by incrementing single binary integer

11 Timer server interaction Interaction with time service like echo server 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

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

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

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

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

16 Maybe client will not know server address When booting, can use DHCP to obtain an address When booting, can use DHCP to obtain an address But does not know address of DHCP server 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 For protocols where client does not know the address of a server, the client-server paradigm permits client to broadcast requests Broadcasting a Request

17 Alternatives to Client-Server ARP protocol (Chap 5) Clients ask for information Clients ask for information ARP minimizes such interactions 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 Program executes until needs information Program executes until needs information Then becomes client to obtain the information Then becomes client to obtain the information Caching lowers the cost for all except the first process Caching lowers the cost for all except the first process

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

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

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

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


Download ppt "Client-Server Model of Interaction Chapter 20. We have looked at the details of TCP/IP Protocols Protocols Router architecture Router architecture Now."

Similar presentations


Ads by Google