King Fahd University of Petroleum & Minerals
College of Computer Science & Engineering
Information & Computer Science Department
ICS 343
Fundamentals of Computer Networks
Standard Client-Server Protocols
WWW & HTTP
:These slides are based on
Data Communications and Networking, 5th Edition, Sec. 26.1
Outline
Introduction to World-Wide Web (WWW)
Uniform Resource Locator (URL)
Web Documents: Static, Dynamic, Active
HyperText Transfer Protocol (HTTP)
Cookies
Web Caching: Proxy Servers
HTTP Security
WORLD WIDE WEB (WWW)
The idea of the Web was first proposed in 1989 at
CERN (European Organization for Nuclear
Research)
The goal is to allow several researchers at
different locations throughout Europe to access
each others’ research.
The commercial Web started in the early 1990s.
WWW is a client-server service, in which a Web
client (Browser) access a service from a Web
server.
The service provided is called Web sites, each
Example
Assume we need to retrieve a scientific document (file A) that
contains
one reference to a large image (file B),
one reference to another text file (file C) in another site
Web Client (Browser) (Web Server) (Web Server)
Uniform Resource Locator (URL)
A web page, as a file, needs to have a unique identifier to
distinguish it from other web pages, which has three main
parts: host, port, and path
Host: the IP address of the server or the unique name given
to the server. (for the name we need DNS)
Port: a 16-bit integer, is normally predefined for the client-
server application. For example, port 80 is used in HTTP
protocol for accessing the web page.
Path: identifies the file’s location and name in the
underlying operating system. The format depends on the
operating system.
Note browsers can provide integrated access to different
services, hence an abbreviation of the protocol is
needed to tell the browser which client-server application
we want to use, e.g.
HTTP (HyperText Transfer Protocol),
FTP (File Transfer Protocol).
Uniform Resource Locator (URL)
Combining the four pieces together we get Uniform
Resource Locator (URL):
Example URL:
http://www.mhhe.com/compsci/forouzan/
The more complex format of the URL:
Web Documents
The documents in WWW can be grouped into
three broad categories:
Static documents (fixed-content documents that are
created and stored in a server) HTML & CSS
Dynamic documents (web server runs an application
program or a script that creates the dynamic
document) Needs server side programming, e.g.
using PHP, Python, ReactJS
Active documents (a program or a script to be run at
the client site) Needs client side programming, e.g.
JavaScript
HyperText Transfer Protocol (HTTP)
HTTP is used to define (the rules) how the
client-server programs can interact to retrieve
web pages from the Web.
client sends a request;
server returns a response.
server uses the port number 80;
client uses a temporary port number.
HTTP uses the services of TCP, which is a
connection-oriented and reliable protocol. (a
connection needs to be established between them)
HyperText Transfer Protocol (HTTP)
Uses TCP:
1. client initiates TCP connection to the server, port
80
2. server accepts TCP connection from client
3. HTTP (application-layer) messages exchanged
between the HTTP client and HTTP server
4. TCP connection is closed
Two connection types
Nonpersistent Connections
Persistent Connections
Nonpersistent Connection
In a nonpersistent connection, one TCP connection is
made for each request/response.
The following lists the steps in this strategy:
1. The client opens a TCP connection and sends a request.
2. The server sends the response and closes the connection.
3. The client reads the data until it encounters an end-of-file
marker; it then closes the connection.
Example 26.3: Nonpersistent
Connection
Example: Nonpersistent Connection
Example: Nonpersistent Connection
Example: Nonpersistent Connection
TCP requires at least
three handshake
messages to establish
the connection
another three
handshake messages
are needed to
terminate the
connection
Persistent Connection
In a persistent connection:
The server leaves the connection open for more requests
after sending a response.
The server can close the connection at the request of a
client or if a time-out has been reached. The sender
usually sends the length of the data with each response.
Time and resources are saved using persistent
connections.
Only one set of buffers and variables needs to be set for
the connection at each site.
Example: Persistent Connection
Example: Persistent Connection
Example: Persistent Connection
Example: Persistent Connection
Example: Persistent Connection
Formats of the request and response
messages
26.21
Methods
26.22
HTTP Status Codes
Success 2xx
Redirection 3xx
Error 4xx, 5xx
Request Header Names
Response Header Names
Example
Example
Cookies
Today the Web has other functions that need to
remember some information about the clients.
Websites are being used as electronic stores that
allow users to browse through the store, select wanted
items, put them in an electronic cart, and pay at the
end with a credit card.
Remember login details.
Visitors counter.
Some websites are just advertising agencies
For these purposes, the cookies were introduced.
Cookies
The creation and storage of cookies depend on the
implementation; however, the principle is the same.
When a server receives a request from a client, it stores
information about the client in a file or a string, such as
The domain name of the client
Registration number
A timestamp
The server includes the cookie in the response that it
sends to the client.
When the client receives the response, the browser stores
the cookie in the cookie directory, which is sorted by the
server domain name.
Example
session-id-time 954242000 amazon.com/
session-id 002-4135256-7625846
amazon.com/ x-main
eKQIfwnxuF7qtmX52x6VWAXh@Ih6Uo5H
amazon.com/ ubid-main 077-9263437-
9645324 amazon.com/
Example
Web Caching: Proxy Servers
HTTP supports proxy servers.
A proxy server is a computer that keeps copies of
responses to recent requests.
The HTTP client sends a request to the proxy server.
The proxy server checks its cache:
If the response is not stored in the cache, the proxy server
sends the request to the corresponding server.
Incoming responses are sent to the proxy server and
stored for future requests from other clients.
The proxy server reduces the load on the original
server, decreases traffic, and improves latency.
Figure: Example of a proxy server
More about Web caching
Cache acts as both client and server
Typically, the cache is installed by ISP
(university, company, residential ISP)
proxy server acts
as both server
Why Web caching? and client
1. Reduce response time for client request
2. Reduce traffic on an institution’s access link