©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
1
1
Chapter 15
Application Layer
and
Client-Server Model
 CLIENT-SERVER MODEL
 CONCURRENCY
 PROCESSES
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
2
2
Comparison between OSI and TCP/IP
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
3
3
15.1 Client-server model
 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.
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
4
4
Client-Server Relationship: Many-to-One
 Servers
 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
 Run when needed, then
terminate (i.e. finite)
 Actively Open TCP or UDP
connection with Server’s socket.
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
5
5
15.1 Concurrency
 Operation mode could be either iterative or concurrent.
 In clients:
 Iterative mode: One client at-a-time in serial
 Concurrent mode: Several clients run at the same time
 In servers:
 Iterative mode: serve one client at-a-time (clients wait in a queue)
 Concurrent mode: serve multiple clients concurrently and
independently.
 In addition, servers could chose the Transport layer protocol:
 UDP, i.e. connectionless
 TCP, i.e. connection-oriented
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
6
6
Server types
Transport Protocol  Operation Mode
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
7
7
Connectionless iterative server
 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
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
8
8
Connection-Oriented Concurrent Server
 Requests and responses are streams of data
spanning several segments.
 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.
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
9
9
15.3 Programs and Processes
 Program: code on disk
 Process: a running instance of a
program.
 Process Control Block:
 ProcessID, UserID, Program
Name.
 Where is the data
 Which line will execute next
 Figure shows two processes of
the same program.
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
10
10
The Process ID & getpid()
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
11
11
Process Creation & fork()
 By Replication
 One-Parent
needed
 After the fork(),
both parent and
child processes
execute the same
line, the one after
the fork()
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
12
12
A program with two fork functions
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
13
13
Return Value of fork()
 In the parent process, fork() returns the processID of the just created
child
 In the child process, fork() simply returns a 0 (which is not a valid
processID)
 This way, each of the two identical replica can detect whether it is
indeed the original parent, or it is the newly created process.
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
14
14
A program that prints the processIDs of the parent and the
child
©The McGraw-Hill Companies, Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003
15
15
Example of a server program with parent and child processes
 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

Lecture 20- Client-Server Model.ppt

  • 1.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 1 1 Chapter 15 Application Layer and Client-Server Model  CLIENT-SERVER MODEL  CONCURRENCY  PROCESSES
  • 2.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 2 2 Comparison between OSI and TCP/IP
  • 3.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 3 3 15.1 Client-server model  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.
  • 4.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 4 4 Client-Server Relationship: Many-to-One  Servers  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  Run when needed, then terminate (i.e. finite)  Actively Open TCP or UDP connection with Server’s socket.
  • 5.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 5 5 15.1 Concurrency  Operation mode could be either iterative or concurrent.  In clients:  Iterative mode: One client at-a-time in serial  Concurrent mode: Several clients run at the same time  In servers:  Iterative mode: serve one client at-a-time (clients wait in a queue)  Concurrent mode: serve multiple clients concurrently and independently.  In addition, servers could chose the Transport layer protocol:  UDP, i.e. connectionless  TCP, i.e. connection-oriented
  • 6.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 6 6 Server types Transport Protocol  Operation Mode
  • 7.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 7 7 Connectionless iterative server  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
  • 8.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 8 8 Connection-Oriented Concurrent Server  Requests and responses are streams of data spanning several segments.  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.
  • 9.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 9 9 15.3 Programs and Processes  Program: code on disk  Process: a running instance of a program.  Process Control Block:  ProcessID, UserID, Program Name.  Where is the data  Which line will execute next  Figure shows two processes of the same program.
  • 10.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 10 10 The Process ID & getpid()
  • 11.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 11 11 Process Creation & fork()  By Replication  One-Parent needed  After the fork(), both parent and child processes execute the same line, the one after the fork()
  • 12.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 12 12 A program with two fork functions
  • 13.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 13 13 Return Value of fork()  In the parent process, fork() returns the processID of the just created child  In the child process, fork() simply returns a 0 (which is not a valid processID)  This way, each of the two identical replica can detect whether it is indeed the original parent, or it is the newly created process.
  • 14.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 14 14 A program that prints the processIDs of the parent and the child
  • 15.
    ©The McGraw-Hill Companies,Inc., 2000 © Adapted for use at JMU by Mohamed Aboutabl, 2003 15 15 Example of a server program with parent and child processes  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