HyperText Transfer Protocol (HTTP)

 

HyperText Transfer Protocol (HTTP)

Introduction

HyperText Transfer Protocol (HTTP) is the application-layer protocol used for transferring web pages and other web resources on the World Wide Web (WWW).

It defines how a web browser (client) communicates with a web server to request and receive web pages.

HTTP follows the client–server paradigm, where:

  • The client sends an HTTP request.
  • The server processes the request and sends an HTTP response.

HTTP uses the services of the TCP protocol, which provides reliable and connection-oriented communication.


Definition

HTTP (HyperText Transfer Protocol) is an application-layer protocol that defines how web browsers and web servers communicate to retrieve and transfer web pages over the Internet.


Features of HTTP

  • Application-layer protocol
  • Uses the client–server model
  • Uses TCP for reliable communication
  • Default server port number: 80
  • Client uses a temporary (ephemeral) port number
  • Supports request–response communication

Working of HTTP

The communication between a client and a server follows these steps:

  1. The client (browser) establishes a TCP connection with the server.
  2. The client sends an HTTP request.
  3. The server processes the request.
  4. The server sends an HTTP response containing the requested web page or resource.
  5. The TCP connection is closed or kept open depending on the connection type.

HTTP Communication

Web Browser (Client)
        |
   HTTP Request
        |
        v
Web Server
        |
   HTTP Response
        |
        v
Web Browser

HTTP Uses TCP

HTTP relies on Transmission Control Protocol (TCP) because TCP provides:

  • Reliable communication
  • Connection-oriented service
  • Error control
  • Ordered delivery of data

Before any HTTP communication:

  • A TCP connection must be established.

After communication:

  • The TCP connection is terminated or kept alive.

HTTP Connections

HTTP supports two types of TCP connections:

  1. Nonpersistent Connection
  2. Persistent Connection

1. Nonpersistent Connection

Definition

In a nonpersistent connection, a separate TCP connection is established for each HTTP request and response.

This was the default behavior in HTTP/1.0.


Working

For every requested object:

  1. Open TCP connection
  2. Send HTTP request
  3. Receive HTTP response
  4. Close TCP connection

The same process is repeated for every object.


Example

Suppose a web page contains:

  • One HTML file
  • One image

The browser requires:

  • One TCP connection for the HTML page
  • Another TCP connection for the image

Total:
2 TCP connections

Example 

Figure shows an example of a nonpersistent connection. The client needs to access a file that containsone link to an image. The text file and image are located on the same server. Here we need two connections. For each connection, TCP requires at least three handshake messages to establish the connection, but the request can be sent with the third one. After the connection is established, the object can be transferred. After receiving an object, another three handshake messages are needed to terminate the connection. This means that the client and server are involved in two connection establishments and two connection terminations.If the transaction involves retrieving 10 or 20 objects, the round trip times spent for these handshakes add up to a big overhead. This is another burden on both sites, but especially on the server site.


Advantages

  • Simple implementation
  • Each request is independent

Disadvantages

  • High communication overhead
  • Repeated connection establishment and termination
  • More memory and buffer usage
  • Increased response time

2. Persistent Connection

Definition

In a persistent connection, one TCP connection is used for multiple HTTP requests and responses.

This is the default behavior in HTTP/1.1.


Working

  1. Establish one TCP connection.
  2. Send multiple HTTP requests.
  3. Receive multiple HTTP responses.
  4. Close the connection only after all objects are transferred or when a timeout occurs.

Example

Suppose a web page contains:

  • One HTML file
  • One image

Only one TCP connection is established.

The browser requests:

  • HTML page
  • Image

using the same connection.

Example 

Figure shows the same scenario as in Example of non persistent connection, but using a persistent connection.Only one connection establishment and connection termination is used, but the request for the image is sent separately.



Advantages

  • Reduced overhead
  • Faster communication
  • Saves bandwidth
  • Lower memory usage
  • Better server performance

Disadvantages

  • Connection remains open for a longer time.
  • Requires timeout management.

Comparison of Nonpersistent and Persistent Connections

Feature    Nonpersistent ConnectionPersistent Connection
TCP Connection    One per request    One for multiple requests
HTTP Version    Default in HTTP/1.0    Default in HTTP/1.1
Overhead    High    Low
Speed    Slower    Faster
Resource Usage    More    Less
Suitable For    Small transfers    Multiple web objects

Why Persistent Connections are Preferred

Persistent connections:

  • Reduce the number of TCP handshakes.
  • Save transmission time.
  • Reduce server workload.
  • Improve web browsing performance.

Therefore, HTTP/1.1 uses persistent connections by default.

HTTP Security

HTTP per se does not provide security. However, as we show in Chapter 10, HTTP can be run over the Secure Socket Layer (SSL). In this case, HTTP is referred to as HTTPS.HTTPS provides confidentiality, client and server authentication, and data integrity.


Summary

HTTP (HyperText Transfer Protocol) is the application-layer protocol used to transfer web pages between a web browser and a web server. It follows the client–server model and uses TCP for reliable communication. HTTP supports two types of connections: nonpersistent connections, where a new TCP connection is created for every request, and persistent connections, where multiple requests are served using a single TCP connection. Persistent connections reduce overhead and improve communication efficiency, making them the default in HTTP/1.1.

Comments

Popular posts from this blog

Computer Networks PCCST501 Semester 5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Computer Networks

Introduction to Local Area Network (LAN)