0% found this document useful (0 votes)
21 views28 pages

FTP - 100549

Uploaded by

athulkav2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views28 pages

FTP - 100549

Uploaded by

athulkav2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

APPLICATION LAYER

File Transfer Protocol(FTP)


Introduction
• It is the standard mechanism provided by TCP/IP for copying a file from one host to another.
• The following problems have to be dealt with while transferring files :
 Two systems may use different file name conventions.
 Two systems may have different ways to represent text and data.
 Two systems may have different directory structures.
• It establishes two connections between the hosts:
 One connection is used for data transfer, the other for control information (commands and
responses).
• The control connection uses very simple rules of communication.
• Only a line of command or a line of response need to be transmitted at a time.
• The data connection, on the other hand, needs more complex rules due to the variety of data
types transferred.
• FTP uses two well-known TCP ports:
 Port 21 : Used for the control connection
 Port 20 : Used for the data connection.
• Figure shows the basic model of FTP

• The client has three components:


1. User interface
2. client control process
3. The client data transfer process.
• The server has two components:
1. The server control process
2. The server data transfer process.
• The control connection is made between the control processes.

• The data connection is made between the data transfer processes.

• The control connection remains connected during the entire interactive FTP session.

• The data connection is opened and then closed for each file 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.
Connections
• The two FTP connections : control and data, use different strategies and different port
numbers.
Control Connection
• There are two steps:
1. The server issues a passive open on the well-known port 21 and waits for a client.
2. The client uses an temporary port and issues an active open.
• The connection remains open during the entire process.
• The service type, used by the IP protocol, is minimize delay because this is an interactive
connection between a user (human) and a server.
• The user types commands and expects to receive responses without significant delay.
Data Connection
• The data connection uses the well-known port 20 at the server site.
• The following steps shows how FTP creates a data connection:
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. The client sends this port number to the server using the PORT command.
3. The server receives the port number and issues an active open using the wellknown port 20
and the received ephemeral port number.
• The steps for creating the initial data connection are shown in figure.
Communication
• FTP has two different approaches, one for the control connection and one for the data
connection.
Communication over Control Connection
• It uses the 7 bit NVT ASCII character set.

• 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 command or response is only one short line so we need not worry about file format
or file structure.
• Each line is terminated with a two-character end-of-line token.
Communication over Data Connection
• Files are transferred through the data connection.
• The client must define the following and thus resolve the heterogeneity problem:
1. The type of file to be transferred
2. The structure of the data
3. The transmission mode.
• Before sending the file through the data connection, transmission through the control
connection is prepared.
File Type

• FTP can transfer one of the following file types across the data connection:
 ASCII file. This is the default format for transferring text files. Each character is encoded
using NVT ASCII. The sender transforms the file from its own representation into NVT
ASCII characters and the receiver transforms the NVT ASCII characters to its own
representation.
 EBCDIC file. If one or both ends of the connection use EBCDIC encoding, the file can be
transferred using EBCDIC encoding.
 Image file. This is the default format for transferring binary files. The file is sent as
continuous streams of bits without any interpretation or encoding. This is mostly used to
transfer binary files such as compiled programs.
Data Structure

• FTP can transfer a file across the data connection using one of the following
interpretations about the structure of the data:
 File structure (default). The file has no structure. It is a continuous stream of bytes.

 Record structure. The file is divided into records. This can be used only with text files.

 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.

• This is the default mode.

• Data are delivered from FTP to TCP as a continuous stream of bytes. TCP is responsible for
chopping data into segments of appropriate size.
• If the data is in file structure, no end-of-file is needed. End-of-file in this case is the closing
of the data connection by the sender.
• If the data is in record structure, each record will have a 1-byte end-of-record (EOR)
character and the end of the file will have a 1-byte end-of-file (EOF) character.
 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.
 Compressed mode.

• If the file is big, the data can be compressed.

• The compression method normally used is run-length encoding.

• In this method, consecutive appearances of a data unit are replaced by one occurrence and the
number of repetitions.
• In a text file, this is usually spaces (blanks).

• In a binary file, null characters are usually compressed.


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
• A file is to be copied from the server to the client (download). This is called retrieving a
file. It is done under the supervision of the RETR command.
• A file is to be copied from the client to the server (upload). This is called storing a file. It
is done under the supervision of the STOR command.
• A list of directory or file names is to be sent from the server to the client. This is done
under the supervision of the LIST command.
• An example of using FTP for retrieving a list of items in a directory.
1. After the control connection to port 21 is created, the FTP server sends the 220 (service
ready) response on the control connection.

2. The client sends the USER command.

3. The server responds with 331 (user name is OK, password is required).

4. The client sends the PASS command.

5. The server responds with 230 (user login is OK).

6. The client issues a passive open on an ephemeral port for the data connection and sends
the PORT command (over the control connection) to give this port number to the server.

7. The server does not open the connection at this time, but it prepares itself for issuing an
active open on the data connection between port 20 (server side) and the ephemeral port
received from the client. It sends response 150 (data connection will open shortly).
8. The client sends the LIST message.

9. Now the server responds with 125 and opens the data connection.

10. The server then sends the list of the files or directories (as a file) on the data connection.
When the whole list (file) is sent, the server responds with 226 (closing data
connection) over the control connection.

11. The client now has two choices. It can use the QUIT command to request the closing of
the control connection or it can send another command to start another activity (and
eventually open another data connection). In our example, the client sends a QUIT
command.

12. After receiving the QUIT command, the server responds with 221 (service closing) and
then closes the control connection.
Command Processing
• FTP uses the control connection to establish a communication between the client control
process and the server control process. During this communication, the commands are
sent from the client to the server and the responses are sent from the server to the client
Commands
• Access commands. These commands let the user access the remote system.
• File management commands. These commands let the user access the file system on the
remote computer. They allow the user to navigate through the directory structure, create
new directories, delete files, and so on.
• Data formatting commands. These commands let the user define the data structure, file
type, and transmission mode.
• Port defining commands. These commands define the port number for the data
connection on the client site.
 There are two methods to do this.
1. First method - using the PORT command : the client can choose an ephemeral port
number and send it to the server using a passive open. The server uses that port
number and creates an active open.
2. Second method - using the PASV command : the client just asks the server to first
choose a port number. The server does a passive open on that port and sends the
port number in the response
• File transfer commands. These commands actually let the user transfer files.
• Miscellaneous commands. These commands deliver information to the FTP user at the
client site.
Responses
• 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 extra explanations.
• The three digits are represented as xyz.
• The meaning of each digit is described below.
• First Digit The first digit defines the status of the command. One of five digits can be used
in this position:
1. 1yz (positive preliminary reply). The action has started. The server will send another
reply before accepting another command.
2. 2yz (positive completion reply). The action has been completed. The server will
accept another command.
3. 3yz (positive intermediate reply). The command has been accepted, but further
information is needed.

4. 4yz (transient negative completion reply). The action did not take place, but the
error is temporary. The same command can be sent later.

5. 5yz (permanent negative completion reply). The command was not accepted and
should not be retried again.
• Second Digit The second digit also defines the status of the command. One of six digits can be
used in this position:

1. x0z (syntax).

2. x1z (information).

3. x2z (connections).

4. x3z (authentication and accounting).

5. x4z (unspecified).

6. x5z (file system).

• Third Digit The third digit provides additional information.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy