Introduction of FTP

  • FTP stands for “File Transfer Protocol”.

Definition

  • FTP is a very important protocol used for exchanging files over the Internet. 

Features

  • FTP is most commonly used to download a file from a server using the Internet or to upload a file to a server.
  • FTP allows a user to copy files to and from a remote machine. The client program also sends commands to the server program to coordinate the copying of files between the two machines on behalf of the user.
  • The working Port Number of FTP is 20(for the data port) and 21(for the control port).

Working Mechanism

  • The control connection persists over a sequence of FTP commands, as the client and the server continue their dialogue. The typical interaction starts with a command that identifies the user on the server machine followed by another command to send the user password. The arguments for these commands are gleaned from the user’s input (his account name and password). The server uses this information to verify whether the user has an authorized account on the remote machine. The next set of commands depends on the user’s request to send, receive, or view the files in a present directory.
  • The actual file (data) transfer uses a separate TCP connection established by the host sending the data. For instance, if the user wants to retrieve the file say xyz.pdf from the remote server, the server initiates the creation of the TCP data connection. In case, the user wants to put a file into the remote machine, it is the client who initiates the creation of the TCP connection. The data connection is usually established on port 20 on the server machine. In the former case (when the file is to be retrieved from the server), the server does not know the destination port for the FTP client. So before sending the command to retrieve the file, the client instructs its operating system to allocate a port number (above 1023) for such a transaction. This information is given to the server via the control connection. The data connection is created (using the usual TCP 3-way handshake mechanism), and the server writes the contents of the file and closes the connection. The client reads the bytes from its socket up to the end of the file (EOF) character. Also, unlike Telnet, FTP does not require the data transfer to 7-bit ASCII characters (NVT format); it actually permits a wide range of data types including binary files. The client requests the form of data transfer using the control connection. In practice, each data transfer requires a separate TCP connection. In contrast, the control connection can persist across multiple data transfers.

Structure

  • FTP Commands :

    • The internal operations of FTP are done with the help of several commands. These commands are different from the commands typed by the user at the interface provided by the client for certain operations.
    • The specification of FTP includes more than 30 different commands, which are transmitted over the control connection in NVT ASCII format(The Network Virtual Terminal (NVT) ASCII character set, defined in RFC 854[Request for Comments], is used for transferring files with a Representation Type (TYPE) of ASCII).
    • The commands are not case-sensitive and may have arguments.
    • Here, each command ends with a two-character sequence of a carriage return (CR) followed by a line feed (LF).
    • Transferring a single file, for instance, requires only a single user-level command (e.g., put or get), but this single command triggers the client to send a set of FTP commands to the server. The FTP server responds to each command with a three-digit reply code (for the FTP client) and an optional text message (for the user).
  • FTP differs from other applications or protocols such as Telnet i.e. FTP uses separate TCP connections for control information and data whereas in Telnet both control information and data are sent over the same TCP connection using in-band signaling. The two TCP connections in FTP are: –
    • Control Information Connection :
      • The control connection is established in the normal client-server fashion.
      • In this case, the server does a passive open (is listening) on port 21 for FTP and waits for the client connection. The client does an active open (the 2nd handshake in a TCP connection) to establish the control connection.
      • The client uses an ephemeral port number (i.e. above 1023 port no.) for the control connection. This control connection stays up for the entire time that the client communicates with this server.
      • This connection is used for commands from the client to the server and for the server’s replies. 
      • The IP type of service for the control connection should be to minimize the delay in passing these commands over the TCP connection.
    • Data Connection :
      • A data connection is created each time when a file is transferred between the client and the server.
      • The IP type of service for the data connection should be to maximize throughput since this connection is file transfer, and we want to send this entire file over a high bandwidth line.

Loading


0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.