Chapter 15 Application Layer and ClientServer Model CLIENTSERVER

  • Slides: 15
Download presentation
Chapter 15 Application Layer and Client-Server Model Ø CLIENT-SERVER MODEL Ø CONCURRENCY Ø PROCESSES

Chapter 15 Application Layer and Client-Server Model Ø CLIENT-SERVER MODEL Ø CONCURRENCY Ø PROCESSES 1 ©The Mc. Graw-Hill Companies, Inc. , 2000 1 © Adapted for use at JMU by Mohamed Aboutabl, 2003

Comparison between OSI and TCP/IP 2 ©The Mc. Graw-Hill Companies, Inc. , 2000 2

Comparison between OSI and TCP/IP 2 ©The Mc. Graw-Hill Companies, Inc. , 2000 2 © Adapted for use at JMU by Mohamed Aboutabl, 2003

15. 1 Client-server model n n To make any use of the Internet, application

15. 1 Client-server model n n To make any use of the Internet, application programs should run on the two endpoints of a network connection. The applications are the entities that communicate with each other to exchange services “Client” applications request service “Server” applications provide service. 3 ©The Mc. Graw-Hill Companies, Inc. , 2000 3 © Adapted for use at JMU by Mohamed Aboutabl, 2003

Client-Server Relationship: Many-to-One n Servers q q n Run all the time (i. e.

Client-Server Relationship: Many-to-One n Servers q q n Run all the time (i. e. infinite) Provide service to any client Typically specialize in providing a certain type of service, e. g. Mail. Listen to a well-known port and passively open connection. Clients q q Run when needed, then terminate (i. e. finite) Actively Open TCP or UDP connection with Server’s socket. 4 ©The Mc. Graw-Hill Companies, Inc. , 2000 4 © Adapted for use at JMU by Mohamed Aboutabl, 2003

15. 1 Concurrency n n Operation mode could be either iterative or concurrent. In

15. 1 Concurrency n n Operation mode could be either iterative or concurrent. In clients: q Iterative mode: One client at-a-time in serial q Concurrent mode: Several clients run at the same time In servers: q Iterative mode: serve one client at-a-time (clients wait in a queue) q Concurrent mode: serve multiple clients concurrently and independently. In addition, servers could chose the Transport layer protocol: q UDP, i. e. connectionless q TCP, i. e. connection-oriented 5 ©The Mc. Graw-Hill Companies, Inc. , 2000 5 © Adapted for use at JMU by Mohamed Aboutabl, 2003

Server types Transport Protocol Operation Mode 6 ©The Mc. Graw-Hill Companies, Inc. , 2000

Server types Transport Protocol Operation Mode 6 ©The Mc. Graw-Hill Companies, Inc. , 2000 6 © Adapted for use at JMU by Mohamed Aboutabl, 2003

Connectionless iterative server n n Clients’ request arrive inside UDP datagrams and wait in

Connectionless iterative server n n Clients’ request arrive inside UDP datagrams and wait in a queue for the server Server processes one datagram at-a-time, send response back to client inside a UDP datagram Clients use ephemeral UDP ports Server uses one well-known UDP port at which all clients’ requests arrive 7 ©The Mc. Graw-Hill Companies, Inc. , 2000 7 © Adapted for use at JMU by Mohamed Aboutabl, 2003

Connection-Oriented Concurrent Server Requests and responses are streams of data spanning several segments. n

Connection-Oriented Concurrent Server Requests and responses are streams of data spanning several segments. n n n Parent Server passively opens the well-know port to listen for incoming connection requests Once opened, connections now use ephemeral ports between one client and one Child Server. 8 ©The Mc. Graw-Hill Companies, Inc. , 2000 8 © Adapted for use at JMU by Mohamed Aboutabl, 2003

15. 3 Programs and Processes n n Program: code on disk Process: a running

15. 3 Programs and Processes n n Program: code on disk Process: a running instance of a program. Process Control Block: q Process. ID, User. ID, Program Name. q Where is the data q Which line will execute next Figure shows two processes of the same program. 9 ©The Mc. Graw-Hill Companies, Inc. , 2000 9 © Adapted for use at JMU by Mohamed Aboutabl, 2003

The Process ID & getpid() 10 ©The Mc. Graw-Hill Companies, Inc. , 2000 10

The Process ID & getpid() 10 ©The Mc. Graw-Hill Companies, Inc. , 2000 10 © Adapted for use at JMU by Mohamed Aboutabl, 2003

Process Creation & fork() n n n By Replication One-Parent needed After the fork(),

Process Creation & fork() n n n By Replication One-Parent needed After the fork(), both parent and child processes execute the same line, the one after the fork() 11 ©The Mc. Graw-Hill Companies, Inc. , 2000 11 © Adapted for use at JMU by Mohamed Aboutabl, 2003

A program with two fork functions 12 ©The Mc. Graw-Hill Companies, Inc. , 2000

A program with two fork functions 12 ©The Mc. Graw-Hill Companies, Inc. , 2000 12 © Adapted for use at JMU by Mohamed Aboutabl, 2003

Return Value of fork() n n n In the parent process, fork() returns the

Return Value of fork() n n n In the parent process, fork() returns the process. ID of the just created child In the child process, fork() simply returns a 0 (which is not a valid process. ID) This way, each of the two identical replica can detect whether it is indeed the original parent, or it is the newly created process. 13 ©The Mc. Graw-Hill Companies, Inc. , 2000 13 © Adapted for use at JMU by Mohamed Aboutabl, 2003

A program that prints the process. IDs of the parent and the child 14

A program that prints the process. IDs of the parent and the child 14 ©The Mc. Graw-Hill Companies, Inc. , 2000 14 © Adapted for use at JMU by Mohamed Aboutabl, 2003

Example of a server program with parent and child processes n n n Parent

Example of a server program with parent and child processes n n n Parent Server listens indefinitely (to the well-know port) for connection requests from clients Once a client requests a connection, a child server process is created to serve this client (on an ephemeral port) The parent server continues to listen for more clients 15 ©The Mc. Graw-Hill Companies, Inc. , 2000 15 © Adapted for use at JMU by Mohamed Aboutabl, 2003