Subject Name: Computer Networks & Protocols
Subject Name: BEC702
Semester : 7th
Academic Year: ODD 2025-2026
Module-5
By,
Prof. Jeevika Mary. A
Assistant Professor,
Dept., of ECE.
Hyper Text Transfer Protocol (HTTP)
The Hyper Text Transfer Protocol (HTTP) is used to define how the client-
server programs can be written to retrieve web pages from the Web.
An HTTP client sends a request; an HTTP server returns a response. The server
uses the port number 80; the client uses a temporary port number.
HTTP uses the services of TCP, which, as discussed before, is a connection-
oriented and reliable protocol.
This means that, before any transaction between the client and the server can
take place, a connection needs to be established between them.
After the transaction, the connection should be terminated. The client and
server, however, do not need to worry about errors in messages exchanged or
loss of any message, because the TCP is reliable and will take care of this matter
Nonpersistent versus Persistent Connections
The hypertext concept embedded in web page documents may require several
requests and responses.
If the web pages, objects to be retrieved, are located on different servers, we do
not have any other choice than to create a new TCP connection for retrieving
each object.
If some of the objects are located on the same server, we have two choices: to
retrieve each object using a new TCP connection or to make a TCP connection
and retrieve them all.
The first method is referred to as a nonpersistent connection, the second as a
persistent connection. HTTP, prior to version 1.1, specified nonpersistent
connections, while persistent connections are the default in version 1.1, but it
can be changed by the user.
Nonpersistent Connections
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.
In this strategy, if a file contains links to N different pictures in different files
(all located on the same server), the connection must be opened and closed N +
1 times.
The nonpersistent strategy imposes high overhead on the server because the
server needs N + 1 different buffers each time a connection is opened.
Example Figure shows an example of a nonpersistent connection. The client needs to access a file that contains one 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.
Persistent Connections
HTTP version 1.1 specifies a persistent connection by default. 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.
There are some occasions when the sender does not know the length of the data.
This is the case when a document is created dynamically or actively.
The server informs the client that the length is not known and closes the
connection after sending the data so the client knows that the end of the data has
been reached.
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. The round
trip time for connection establishment and connection termination is saved
Example Figure shows the same scenario as in previous example, but using a persistent connection.
Only one connection establishment and connection termination are used, but the request for the
image is sent separately.
FTP: File Transfer Protocol
File Transfer Protocol (FTP) is the standard protocol provided by TCP/IP for copying a file from one host to
another.
Although transferring files from one system to another seems simple and straightforward, some problems
must be dealt with first.
For example, two systems may use different file name conventions. Two systems may have different ways to
represent data. Two systems may have different directory structures.
All of these problems have been solved by FTP in a very simple and elegant approach. Although we can
transfer files using HTTP, FTP is a better choice to transfer large files or to transfer files using different
formats.
Figure shows the basic model of FTP.
The client has three components: the user interface, the client control process,
and the client data transfer process.
The server has two components: the server control process and the server data
transfer process.
The control connection is made between the control processes. The data
connection is made between the data transfer processes.
Separation of commands and data transfer makes FTP more efficient. The
control connection uses very simple rules of communication.
We need to transfer only a line of command or a line of response at a time. The
data connection, on the other hand, needs more complex rules due to the variety
of data types transferred.
Two Connections
The two connections in FTP have different lifetimes. The control connection
remains connected during the entire interactive FTP session.
The data connection is opened and then closed for each file transfer activity.
It opens each time commands that involve transferring files are used, and it
closes when the file is transferred.
When a user starts an FTP session, the control connection opens.
While the control connection is open, the data connection can be opened and
closed multiple times if several files are transferred.
FTP uses two well-known TCP ports: port 21 is used for the control
connection, and port 20 is used for the data connection.
Control Connection
For control communication, FTP uses the same approach as TELNET.
It uses the NVT(Network Virtual terminal) ASCII character set as used by
TELNET.
Communication is achieved through commands and responses.
This simple method is adequate for the control connection because we send one
command (or response) at a time.
Each line is terminated with a two-character (carriage return and line feed) end-
ofline token.
During this control connection, commands are sent from the client to the server
and responses are sent from the server to the client.
Commands, which are sent from the FTP client control process, are in the form
of ASCII uppercase, which may or may not be followed by an argument.
Some of the most common commands are shown in table.
Every FTP command generates at least one response.
A response has two parts: a three-digit number followed by text.
The numeric part defines the code; the text part defines needed parameters or further
explanations.
The first digit defines the status of the command.
The second digit defines the area in which the status applies.
The third digit provides additional information.
Table shows some common responses.
Data Connection
The data connection uses the well-known port 20 at the server site. The
creation of a data connection is different from the control connection.
The following shows the steps:
1. The client, not the server, issues a passive open using an ephemeral port. This
must be done by the client because it is the client that issues the commands for
transferring files.
2. Using the PORT command, the client sends this port number to the server.
3. The server receives the port number and issues an active open using the well
known port 20 and the received ephemeral port number.
Communication over Data Connection
• The purpose and implementation of the data connection are different from
those of the control connection.
• We want to transfer files through the data connection.
• The client must define the type of file to be transferred, the structure of the
data, and the transmission mode.
• Before sending the file through the data connection, we prepare for
transmission through the control connection.
• The heterogeneity problem is resolved by defining three attributes of
communication: file type, data structure, and transmission mode.
File Type
• FTP can transfer one of the following file types across the data connection: ASCII
file(Plain Text File Re[resented by ASCII Characters), EBCDIC file(Extended Binary
Coded Decimal Interchange Code), or image file.
Data Structure
• FTP can transfer a file across the data connection using one of the following interpretations
of the structure of the data: file structure, record structure, or page structure.
• The file structure format (used by default) has no structure. It is a continuous stream of
bytes.
• In the record structure, the file is divided into records. This can be used only with text files.
• In the page structure, the file is divided into pages, with each page having a page number
and a page header.
• The pages can be stored and accessed randomly or sequentially.
Transmission Mode
• FTP can transfer a file across the data connection using one of the following three
transmission modes: stream mode, block mode, or compressed mode.
• The stream mode is the default mode; data are delivered from FTP to TCP as a continuous
stream of bytes.
• In the block mode, data can be delivered from FTP to TCP in blocks.
• In this case, each block is preceded by a 3-byte header. The first byte is called the block
descriptor; the next two bytes define the size of the block in bytes.
File Transfer
• File transfer occurs over the data connection under the control of the commands sent over
the control connection.
• However, we should remember that file transfer in FTP means one of three things:
retrieving a file (server to client), storing a file (client to server), and directory listing (server
to client).
Thank You