What is FTp

04/20/11

 Home

 

 

 

File Transfer Protocol

 

            The file transfer protocol (FTP) is used to make sharing files easy and convenient, to make the details of different types of storage seem non-existent to the user, and to make sure data is transferred with reliability and efficiency. From a users view FTP is simple: connect to the remote host, transfer the file or files, and close the session. From a programmers point of view the details go much deeper. This paper will attempt to describe some of the details and mechanisms of the FTP process in the order they are used in.

 

            The user makes the connection to a remote server. The connection that is made is the first of two, it is called the control connection, and it is a full duplex connection. The control connection is used to pass commands to the server and replies to the user.

 

This connection is referred to in FTP as the user-protocol interpreter (user-PI), and on the server side it is called the sever-PI. After the initial connection the server-PI replies saying it is there. A variety of FTP commands are passed, to the server-PI, such as the user name, password, and account. These commands verify the user authorization to access the server. This information is sent along the control connection, which uses the standard Telnet protocol and is secured by using TCP. Once the server-PI replies with the verification of the account the user-PI sends the parameters for the data. The user can specify all parameters.

            The data port parameter is used to tell the server which port the user data transfer process (user-DTP) is listening on. The second connection, which the data will be transferred on called the data connection Although, only unless this port is different than the default port will this command be sent.

 

            Another parameter is needed to inform the server of which mode the data will be transmitted in. There are three modes: the Stream mode where the data is transmitted as a stream of bytes, and has one downfall. It is the unreliable mode of the bunch. This is due to the fact that at the end of each file transfer the closing of the connection represents the end of file. Therefore, it is impossible to know if the connection closed before it was supposed to, plus this makes transferring multiple files inefficient (more on closing the connections later). The Block mode, which uses at least one header byte for each block of data, and the Compressed mode which uses replicated bytes or filler strings.

 

            Yet another parameter is needed by the server to ensure it understands how to interpret the data. This is known as the Type. There are four different types: the ASCII type, which is mainly used for text file transmission. When a user has a file stored locally and wants to transfer it to a server there will need to be a transformation. The process is needed due to the fact that the internal representation of the data may be different from that of the server's internal representation. Therefore the data is converted to standard 8-bit NVT-ASCII. Once the server receives the data, the server will convert it to its own internal representation. A second type is called EBCDIC, which is efficient when both hosts use EBCDIC as their internal character representation. The data is transferred as 8 bit EBCDIC. The code used to identify characters is the only difference between ASCII and EBCDIC. Another type is the Image type. The Image type is stored and retrieved efficiently and also used to transfer binary data. The Image type may be padded, because it is transmitted as contiguous bits, which the receiving host will store as contiguous bits adding zeros for padding, which are easily removed, and added to the end of the file or record. The last type is the Local type which uses a second parameter called Byte size. The Local type is transferred in logical byte sizes defined by the Byte size, which is a decimal integer specified by the user (it has no default value). If the Byte size is different than the transfer byte size (8 bits), then the logical bytes are packed contiguously, and stored contiguously by the receiving host who will use padding if necessary. 

 

            Before the request for a data connection can be sent, still another parameter for the structure is needed. There are three possible structures. The first is called the File structure. It is default when the structure command is not used, and is interpreted as contiguous data bytes. The seconds is the Record structure, the records are sequential and except text files. The last is Page structure. This is used when files are not continuous. Each is called a page. Each page contains a page header which includes the following fields: header length, page index, data length, page type, and optional fields.

 

            Once these parameter commands have been relayed to the server-PI, the user-PI will listen on its' data connection port (the users' data connection port and its' command connection port are the same) then it will make a FTP service request. The server-PI will receive the request and establish the data connection to the users port. At this point the transmission may begin and the server-PI will send the user-PI a confirmation reply. For every command sent by the user-PI the server-PI must send at least one reply. The reply is a three digit number, where each digit position and value have a meaning. Text is sent along with the reply, but this is only useful to the user. The digits are always followed by a space. The codes for the first digit have the following meaning: 1xx = a positive preliminary reply. Meaning more replies are coming so hang on. 2xx = a positive completion reply. Meaning the requested action was completed. 3xx = a positive intermediate reply. Meaning another command is needed. 4xx = a transient negative completion reply. Meaning you can try again, but the last one failed. 5xx = permanent negative completion reply. Meaning this wont work. Try something else first and maybe it will then. For the second digit the meanings are as follows; x0x = syntax error, x1x = the user requested some kind of information, x2x = has to do with control or data connections, x3x = has to do with a login or an accounting procedure, x4x= Not specified, x5x = has to do with the servers file system. The third digit is specific to the second digit.

 

            TCP is used as the error control mechanism for FTP to insure the data is received correctly. In the case of a failure, there is the restart procedure. This can only be used if Block or Compressed modes are used. The user must foresee the need for a possible restart. To use the restart procedure a marker must be inserted into the data somewhere. As the data is being transferred the receiver sends the last know markers to the sender as it receives them. If a failure occurs, the user-PI sends the server-PI a list of the markers it has received. From there the user-PI decides where to begin the retransmission.

 

            All commands are transferred via Telnet. Up to this point only transfers between a user and a server have been discussed. There is another method of transferring data via FTP. This method is when the user (not local to any) sets up control connections between two servers and connects two server-DTP's to each other. The user can send commands to the receiving server-PI and receive the replies from the other server-PI. In the case prior to this, between the user and the server, the user is using the existing Telnet module, but the user can also directly enter the rules of the Telnet protocol increasing efficiency and independence.

 

            The server is responsible for initiating and maintaining the data connection. It is also the servers' responsibility to close the data connection. There are five reasons the server will close this connection. One the transfer mode requires the connection to be closed to show it is the end of the file. Two the user tells the server to abort. Three the user changed ports. Four the session is over and the user requested to end the session. Five an irrecoverable error occurred. If the file transfer is complete and the user requests to logout the control connection is closed. If the file transfer is not complete and the user requests to logout the server will complete the transfer and only then close the control connection.

 

            The file transfer protocol has many options. This protocol uses two connections simultaneously. One is the control connection, which handles commands sent to the server-PI from the user-PI. The user-PI receives the replies from the server-PI that are sent after each command on this connection. The data connection is established, after all the parameters are passed to the server, by the server. The parameters include the data port, the transfer mode, the representation type, and the structure. If the correct procedures are taken before a transfer and a failure occurs the restart procedure can be used to begin transfer at some marked place in the data. A user can connect two remote servers passing data between them. The server opens, maintains, and closes the data connection. While the user establishes the control connection and the server closes it.

 

 

Home | Family | Brad Rebecca & Jordan |Tie Dye | Friends | The Deck | The Yard | Drums |

Off Road Adventures | Guinea Pig Place | Cat Nip Corner

 

Tie Dye Main Page

1 | 2 | 3 | 4 | 5

 

www.Phatdyes.com

Phat Dyes Custom Tie-Dye T-shirts & Tapestries

 

 

This site was last updated 04/20/11