Detailed description of FTP Transfer Protocol Application

Source: Internet
Author: User
Tags ftp commands ftp transfer

FTP target:

1) Promote the sharing of programs and data files;

2) remote computers are encouraged;

3) the user does not have to face the differences between different file systems on different hosts;

4) efficient and reliable data transmission

Functions of FTP:

Is to let the user connect to a remote computer, check what files are available on the remote computer, and then copy the files from the remote computer mountain to the local computer, or

Files on the local computer are sent to the remote computer.

FTP terminology:

1) control connection:

The user PI and the server PI are so sad to exchange command and Response Information paths.

2) data connection:

Full two-way connection for data transmission using the specified mode and type. The transmitted data may be part of the file, the entire file, or some files. Transmission path,

It may be between server DTP and user DTP or between server DTP.

3) DTP:

Data transmission is used to establish and manage data connections. DTP can be passive or active.

4) PI:

Protocol Parser. Users and servers are used to parse the Protocol. Their specific implementations are called user PI and server PI respectively.

5) server DTP:

During the data transmission process, a data connection is usually established using the "listener" data port in the "active" status. It establishes transmission and storage parameters and

PI command to transfer data. Server-side DTP can also be used in "passive" mode, rather than actively establishing a connection on the data port.

6) server PI:

The server PI listens to the connection request of the user Protocol Parser on port L and establishes a control connection. It receives standard FTP commands from user PI, sends responses, and manages server DTP;

7) User DTP:

The data transmission process is connected to the FTP process of the "listener" server on the data port. If the two servers use it to transmit data.

8) User PI:

The user Protocol Parser uses the U port to establish control connections for the FTP process on the server and manage the user DTP during file transfer.

FTP model:

 

In the model, the control connection is initiated by the user PI. First, the user PI generates standard FTP commands to control the connection transfer to the server. Standard Response by Server

The end PI sends a data connection to the user PI and sends it to the user PI as a command response.

The FTP command specifies the data connection parameters and file system operation types. The user DTP should "listen" on the data interface, and the server initiates a data connection with the corresponding parameters and

Transmit data. The data interface host is not necessarily the same as the host that sends the FTP command, but the user or user must ensure that the specified port is under "listener" during the FTP process.

Data transmission function:

Files can only be transmitted through data connections. The control connection is used to send operation commands and corresponding command responses.

4.1 Data Type:

1) ASCII type:

The default type must be supported by all FTP implementations. It is mainly used to transmit text files, unless the EBCDIC type is considered convenient by both parties.

2) EBCDIC type:

This type is used for efficient transmission between hosts using EBCDIC encoding.

3) image items:

Data is transmitted in 8 consecutive bytes. The acceptor must describe that data is stored as a continuous bit.

Objective: To efficiently store and retrieve files and transmit binary files.

4) Local type:

Data is transmitted using the logical Byte length specified by the Byte size parameter. The byte length must be a decimal integer with no default value.

5) format control:

The ASCII and EBCDIC types also support the second optional parameter. This represents a vertical file format control.

6) non-printing

It is generally used for processing or storage.

7) TELNET format control:

8) CARRIAGECONTROL

Data structure:

Because the file types are different, FTP allows the file to have the specified structure. There are three structures:

1) file structure:

If the structure command is not used, I will love your structure by default.

There is no internal structure in the file structure, and the file is treated as a continuous byte stream.

2) record structure:

In the record structure, the price is composed of consecutive records.

3) Page Structure:

To transfer discontinuous files, FTP defines the page structure.

Create a data connection:

The data transmission process includes setting up a data connection on the specified port and selecting transmission parameters. Both the user and the server DTP have the default port number.

The default data port of the user process is the same as the control connection port (that is, port U ). The default port for server processes is adjacent to the control connection port (that is, the L-1 ).

The transmission length is 8 bytes. The length of this byte is only related to the actual data transmission, and is related to the host file system.

Is irrelevant.

The passive data transmission process (which may be user DTP or another server DTP) should "listen" on the data port before sending the FTP request command.

The FTP request command determines the data transmission direction. After receiving the transmission request, the server establishes a connection to the specified port. After the connection is established,

Data is transmitted between DTP at both ends, and the server PI sends a confirmation reply to the user PI.

Each FTP implementation must support the use of the default data port. Only the user PI can use the changed non-default port.

You may use the PORT command to specify another data PORT. The user may want to download the object to the TAC line.

Or download from a third-party host. In the latter case, the user PI establishes a control connection to the two server PI at the same time.

One server (using FTP commands) waits for a connection and the other server establishes a connection. The user PI sends a PORT command to the server PI to indicate the data PORT of the other server.

Finally, send appropriate transmission commands to both ends.

Transmission Mode:

1) stream mode:

Data is transmitted in byte streams. There is no limit on the expression type;

2) Fast Mode

Files are transmitted using continuous data blocks with data headers. The data header contains a counting field and description code. The counting field indicates the entire length of the data block, so you can calculate the next

The starting position of the data block. The description code defines the last part of the file, record the last part, and re-mark or suspect data.

3) compression mode

In this mode, there are three types of information to be sent: regular data, sent in byte strings; compressed data, including copies or fills; control information, transmitted in two bytes of transferred characters.

File Transfer Function:

The transmission channel from user PI to server PI is established through a TCP connection from user to standard server port

. The user PI is responsible for sending the FTP command and parsing the received response. The server PI parses the command and sends the response

And control DTP to establish a data connection and transmit data. If the other end of data transmission (passive transmission) is user DTP,

The user's DTP is controlled by the internal protocol of the user's FTP host. If the other end is another server's DTP, the server

DTP is controlled by the user PI by sending commands.

FTP command:

1) access control command:

USER name: USER

Password: PASS

Account: ACCT

Change working directory: CWD

Back to the upper Directory: CDUP

Structural equipment: SMNT

Reinitialization: REIN

Logout: QUIT

2) transmission parameter command:

Data PORT: PORT

Passive: PASV

TYPE

File structure: STRU

F-File

R-record Structure

P-Page Structure

Transmission MODE: MODE

S-stream

B-block

C-compression

3) FTP service command:

Obtain: RETR

Save: STOR

Unique storage: STOU

Append: APPE

Allocation: ALLO

Restart: REST

Rename start: RNFR

Rename: RNTO

Abandon: ABOR

Delete: DELE

Delete Directory: RMD

Create directory: MKD

Print the working directory: PWD

LIST: LIST

Name List: NLST

SITE parameters: SITE

System: SYST

Status: STAT

HELP

Null operation: NOOP

FTP Response:

The FTP Response consists of three digits (transmitted with three digits) followed by some text. Each digit of a three-digit number has a specific meaning. Allows user processes to simplify complex responses.

The first digit indicates that the response is good, bad, or incomplete.

1) The first number of the response may have the following five values:

1yz, preparation status

2yz, completion status

3yz, intermediate status

4yz, temporarily rejected

5yz, permanently rejected

2) The following is a second digit function:

X0z syntax-this response indicates a syntax error. The given command does not exist, is not implemented, or is redundant.

X1z information-response to request information, such as a request to the status or help.

X2z connection-response to control connections and data connections.

X3z authentication and account-response to the login process and account processing.

X4z is not used yet.

X5z file system-the status of the Server File System or other file system actions when a request is sent.

3) the third digit provides more detailed meaning for the status specified by the second digit.

Minimum implementation:

In order for FTP to work properly, the server must have the following minimum implementation:

Type-ASCII non-printing

Mode-stream mode

Structure-file structure, record Structure

Command-USER, QUIT, PORT, TYPE, MODE, STRU, default value, RETR, STOR, NOOP.

The default value of the transmission parameter is:

Type-ASCII non-printing

Mode-stream mode

Structure-file structure

All Hosts must accept the above standard default values.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.