0% found this document useful (0 votes)
66 views

Lecture 20 - Client-Server Model

This document discusses the client-server model and concurrency in computer networks. It explains that client-server applications have client programs that request services and server programs that provide services. Servers can run concurrently to serve multiple clients simultaneously and independently. The document also describes processes, how processes are created using fork(), and how servers can use fork() to create child processes to handle client requests concurrently while the parent listens for more connections.

Uploaded by

Usama Javed
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Lecture 20 - Client-Server Model

This document discusses the client-server model and concurrency in computer networks. It explains that client-server applications have client programs that request services and server programs that provide services. Servers can run concurrently to serve multiple clients simultaneously and independently. The document also describes processes, how processes are created using fork(), and how servers can use fork() to create child processes to handle client requests concurrently while the parent listens for more connections.

Uploaded by

Usama Javed
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15

Chapter 15

Application Layer
and
Client-Server Model

 CLIENT-SERVER MODEL
 CONCURRENCY
 PROCESSES

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

2
©The McGraw-Hill Companies, Inc., 2000 2 © Adapted for use at JMU by Mohamed Aboutabl, 2003
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.

3
©The McGraw-Hill Companies, Inc., 2000 3 © Adapted for use at JMU by Mohamed Aboutabl, 2003
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.

4
©The McGraw-Hill Companies, Inc., 2000 4 © Adapted for use at JMU by Mohamed Aboutabl, 2003
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

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

6
©The McGraw-Hill Companies, Inc., 2000 6 © Adapted for use at JMU by Mohamed Aboutabl, 2003
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

7
©The McGraw-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.

 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 McGraw-Hill Companies, Inc., 2000 8 © Adapted for use at JMU by Mohamed Aboutabl, 2003
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.

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

10
©The McGraw-Hill Companies, Inc., 2000 10 © Adapted for use at JMU by Mohamed Aboutabl, 2003
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()

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

12
©The McGraw-Hill Companies, Inc., 2000 12 © Adapted for use at JMU by Mohamed Aboutabl, 2003
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.

13
©The McGraw-Hill Companies, Inc., 2000 13 © Adapted for use at JMU by Mohamed Aboutabl, 2003
A program that prints the processIDs of the parent and the
child

14
©The McGraw-Hill Companies, Inc., 2000 14 © Adapted for use at JMU by Mohamed Aboutabl, 2003
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

15
©The McGraw-Hill Companies, Inc., 2000 15 © Adapted for use at JMU by Mohamed Aboutabl, 2003

You might also like