File Transfer Protocol FTP

zhaozj2021-02-08  457

File Transfer Protocol (FTP) 1. Describes the goal of the FTP to improve the sharing of files, providing non-direct use of remote computers to transmit data to users transparently and efficiently. Although we can also manually use it, its main role is for the process of use. It is best to read the TCP protocol standard specification and Telnet protocol standard specification before reading this article. 2. Overview In this section, we will discuss some problems on the surface, please refer to TCP and Telnet reference. Let's introduce (1) byte size, there are two bytes in FTP: logical byte size and byte size for transmission. The latter is usually 8 bits, while the former can not necessarily be. The transmission byte does not have to be equal to the logical byte size, and it is not necessary to explain the data structure. (2) Control connection is a communication link that is built between user-pit and server-pi for exchange commands and answers. (3) Data connection is a full-duplex connection to transmit data. Transmission data can occur between the server DTP and the user DTP can also occur between the two servers DTP. (4) DTP: Data Transmission Process (DTP) Establish and Manage Data Connections, DTP can be active or passive. (5) EOR represents the recording end. (6) NTV represents a network virtual terminal, and its definition is consistent with the definition in the Telnet protocol. (7) NVFS represents a network virtual file system. (8) FTP can transmit discontinuous files, part of these files called pages. (9) PI represents the protocol interpreter. (10) The server DTP represents a transmission process, which is usually in the "active" state, which establishes a data connection with the listening port, which can also provide parameters for transmission and storage, and transmit data according to the command of the PI. Of course, DTP can also transfer "passive" state. (11) The server ftp process, which is working with the user's FTP process, which consists of PI and DTP. As for the user FTP process, it consists of PI, DTP, and user interface. The following figure is a schematic diagram of the FTP service: Note: Data connection is two-way, it does not exist for the whole time. In the above picture, the user Pi starts to control the connection, and the control connection is very similar to the Telnet protocol. At the beginning, the standard FTP command is generated by the user Pi and transmits it to the server process through the control connection. The server PI returns a standard response to the user PI. The ftp command specifies the data connection parameters and file system operations. User DTP is listened to a particular data port, and the server starts data connection and starts data transfer at the specified parameter. The data port does not have to start the FTP command, but the user or user FTP process must determine it listens on the specified data port. This data connection is a full duplex. In another case, the user may wish to transfer files between two hosts, not two local hosts. The user establishes a control connection between two hosts and planning the data connection. In this way, the control information is obtained by the user Pi, but the data is transmitted between the server DTP. Here is an example: protocol requires data transfer to turn on the control connection when processed. After the FTP service is complete, the control connection is aborted by the user, and the server is specifically operated. If the control connection is turned off when the command is not received, the server will turn off the data transfer. FTP and Telnet have a touch of contact, and FTP uses the Telnet protocol to control the connection, there are two ways to achieve the purpose: the user PI or server PI can implement the function of Telnet protocol in its own process; the second method is to use the system Telnet module. In fact, the dependence on the Telnet protocol is not much dependent, even if it is re-implemented, the amount of code is not large.

3. Data transfer function data connection only transmits data, controls the connection to transfer commands and responses. Several commands are about transmitting data between hosts. The data transfer is basically independent of physical structure, but if the flow transfer is related to the file structure in the compressed transmission mode, the properties of the file are related to the indication type. 3.1. Data representation is delivered between storage settings between the host. Because the data stored mode of the two systems is different, it is necessary to convert it. There is a problem that is represented by ASCII when transmitting text. When carrying binary transmission, there will be different problems with different systems to specify different systems. The system is 7 bits, and some systems may be 32 bits, which also requires conversion. Data representation and transmission model functions are required, but FTP provides not much features in this area, and that part of the FTP provides the user to implement itself. 3.1.1. Data type data representation is the type of representation specified by the user, which may be implied, or it is user specified. Please note that the length of logical byte is different from the physical byte length. 3.1.1.1. ASCII Type This is the default type that all FTPs must be implemented, used to transfer text files, which is more convenient when transmitting EBCDIC transmission between hosts, without using ASCII types. The sender converts the internal representation into an NVT-ASCII format, and the recipient is reversed to receive data. According to the NVT standard, the sequence is to be used at the end of the line. NVT-ASCII is 8-bit. The format parameters of ASCII and EBCDIC are discussed below. 3.1.1.2. EBCDIC Type It is a data type of transmitting data between the host as another approach to ASCII. EBCDIC and ASCII are very like, there are some differences only on the type of functional description. The end of the line is very small. 3.1.1.3. Image Type The data transmitted under this type is regarded as a continuous bit, and the sender packs the data into the 8-bit transmission byte. Because the need to be fill the transfer data, the padding bytes are all 0, and the pads must be used when the file structure is used, and to be marked so that the receiver is filtered out. It is used to transmit binary data and efficiently transmit and store files, so all FTPs must also be implemented. 3.1.1.4. Local types can also specify logical bytes in decimal. If the physical byte size is different, the physical data is packaged directly into logical bytes, and no fill is not used. The recipient performs conversion based on the logical byte size and the storage characteristics of the unit. The transmission must be repeatable, that is, the same parameters as the same file must be the same. 3.1.1.5. Format Control ASCII and EBCDIC have an optional parameter, indicating that the file vertical format control, the following data indicates that the type is defined in the FTP. Character files may have three uses, print, store, or leave later. If it is used for printing, the host must know the representation of vertical format control, if stored or wait for later processing, it is also necessary to retain file format. If you are transferring back to the local host after processing over the remote host, there is no trouble when the remote host is processed. This requires the addition of new parameters in ASCII and EBCDIC format. 3.1.1.5.1. Non Print is not specified in the second parameter is that it is the default. It must be accepted for all FTPs. If the transferred file is used for printing, the default value of the boundary and interval is used. Usually it is not used for printing, and for saving files or execution files. 3.1.1.5.2. Telnet format control file includes ASCII / EBCDIC vertical format control, which makes printing normally. 3.1.1.5.3. Carriage Control (ASA) file contains ASA (Fortran) vertical format control characters. In a row formed in accordance with the ASA standard, the first character is not printed, which is used to determine the amount of paper before printing.

Here is the defined ASA character: Blank: move down 1 line; 0: Move down next to 2 lines; 1: Move to the next page; : Do not move the printer must be able to determine the end of the structure. If the file itself has a record structure, there is no problem. If not, is used to distinguish the print line, but these format tags have been used by the ASA control characters. 3.1.2. In addition to different data types, the FTP also allows different file structures. The following is three file structures: File Structure: There is no internal structure in the file, and the file is considered as a binary stream; record structure : The file is made up of a series of records; page structure: files are composed of different index sheets. If the STRU command is not used, the file structure is the default value. The structure of the file affects the transmission model, storage, and data representation. The original property is related to the host, and the different machines will save the file in their own way. The host must be recognized by each other when transmitting files between different hosts. Some of the files on the host are bytes, some are recorded, and there is a problem when transmitting. Then you have to convert internal conversions at the recipient. When converting, you need to distinguish the boundary of the record, using in ASCII, using as a separator in EBCDIC. This implementation method must be guaranteed to be reversible. 3.1.2.1. File Structure If the STRU command is not used, the file structure is the default value. There is no default value in the file structure, and the file is considered to be a continuous byte string. 3.1.2.2. Recording structure For text files, the recording structure must be that all FTP implementations must be. The recording structure file is composed of continuous records. 3.1.2.3. The page structure file is a non-continuous use of the page structure. This file is called a random access file. These files sometimes appear as a whole or part of the information. In FTP, a part of the file is called a page. To provide different page sizes and related information, each page is sent with page headers. The page is as the domain:

The length of the header includes this byte of the page length, the unit is byte, the minimum length is 4 Page Index indicates the location of this portion in the original file, it is not a logical byte number in the data length page data, The minimum value is the type of page type page. There are several types: 0 = not page, indicate the transfer structure, the header must be 4, the data length must be 0; 1 = usual page, the normal type of the usual page file without control information; 2 = Description sub page, used to transmit a description of the overall file; With one logical byte length, the logical byte length is specified by the TYPE command. If the read version is consistent with the start version number, the file access must be done with the same parameters. If the parameter is the same, the FTP implementation is the same as the content you have to ensure that the content acquired. 3.2. Establishing a data connection transmitting data mechanism includes establishing a connection to select data parameters. The user and server DTP have the default data port. The user process default data port is the same as the control connection port. Server process default data ports and control connection ports. The transmission byte size is 8-bit bytes. This byte is an actual transmission byte, but does not represent data representative in the host. The passive data transfer process receives data in the data port, and the FTP request command determines the direction of the data transmission. After receiving the request, the server connects the data connection of the port. When the connection is established, the transfer is transmitted between the DTP, and the server Pi returns the user PI. The FTP implementation runs a default data port, and the user PI can change the default port. The port command may change the port, and the user may wish to perform other operations on a third-party host, and the user PI needs to establish a connection on the two server Pi. A server is told to listen to another server request. User PI notifies another server's data port through the port command. Finally, both parties send the corresponding transfer command. Typically, the server is responsible for supporting data connections, initializing and turning off, unless the user DTP requires closing connections in transmission mode. The server closes the data connection in the case: 1. The server ends the sending data, abstains transmission via EOF; 2. The user sends an ABORT command; 3. The user changes the port; 4. Control connection is closed; 5. If you want to recover errors. 3.3. Data Connection Management Default Data Connection Port: All FTPs must support the default data connection, only the user PI can initialize the use of non-default ports. Determine non-default data port: User Pi can specify a non-default port using the port command, which requires the server to determine non-default data ports at PASV. The connection is determined by the two addresses, so changing the part of the address changed. Denual data connection: When using a streaming data transfer model, the file ends pass through the closing connection indication. If you want to transfer multiple files, you will have trouble, and the solution has two, one is to determine the non-default port, and the other is to use another transmission mode. In terms of transmission mode, the stream transmission mode is unsafe, so it is not possible to determine whether the connection is temporarily or permanently closed. Other transmission modes do not represent file structures by closing the connection, they can determine the transfer structure via the FTP command. So use these transmission modes can be transmitted in the case where the connection is kept. 3.4. The transmission mode has three transmission modes: a formatted data formats and considers the restart process; a compressed data; one is not processed (small processing) transmission. All data transfer must end with an EOF, which can be explicitly given, or by turning off the connection. For record files, all EOR is explicit, including the last record. For files transmitted in a page structure, use the "Last page" to end. From here, the byte we mentioned below refers to "Transmission bytes".

In order to conduct standardized transmission, the transmit host must convert the internal representation of the end of the line or the record to the transmission mode and the file structure designated, and the reception is reversed. The record count domain of the IBM mainframe may not be identified for other hosts, so the recording end tag is transmitted in stream mode with a double-byte control code, and transmits in the block or compression mode. The line end of ASCII or EBCDIC is or indication. Such a conversion takes time, so the same system is used in a binary or stream when transmitting a text file. The following is the transfer mode defined by FTP: 3.4.1. Stream mode data is transmitted in the form of a word stream. The type of representation is not limited, allowing the recording structure. The recording structure file EOR and EOF are represented as a double-byte control code. The first byte is all 0, and the latter byte is a escape character. When the second bit value is 1 indicates the EOR, indicating EOF at 2, if the EOR and EOF are indicated, the value is 3. Double-byte transfer must be used when all 1 bytes are transmitted as data transmission, where data is saved within the second byte. If it is a file structure, close the connection by the sender indicates EOF, and all data received is the file content. 3.4.2. Block mode file is transmitted in block, and the block has its own header. The header is included including the count domain and the descriptor subcode. The count domain describes the number of bytes of data blocks, and the descriptor is defined below: EOF, EOR restart tag or doubt error data. Doubt error data is not to perform error control, it is to transmit specific data between the site, when transmitting local errors (such as hard disk errors), but it can be pointed out that this data may be wrong. In this mode, the recording structure can be used, or the corresponding data representation can also be used. The structure of the header by is shown below: Describes that the sub-bit byte count 16 bits

The description sub-code is described by a bit tag in the sub-byte, and below is the four code already specified and its meaning:

Code Significance 128 The end of the data block is the end of the EOOR 64 data block is an EOF 32 data block has doubt error 16 data block is a resumption mark.

With this coding, there may be multiple descriptive sub-coding conditions for a particular block, and the required bits must be all set. The restart tag included in the data stream, which as an 8-bit integer represents the printable byte of the language on the control connection, but is not yet. For example, to transmit 6-byte tags, the following is examples:

Descrptr code = 16 byte count = 6

Marker 8 Marker 8-bit Marker 8

MARKER 8-bit Marker 8-bit Marker 8-bit 3.4.3. Compression mode There are three information that requires transmission: General data is transmitted in byte string; compressed data, including copying and filter; control information, transmitted in two escape characters. If there is n (> 0 but less than 127) regular data transfer, plus one byte in front of the data, this byte is the highest bit of 0, and the numerical value represented by other bits is equal to N. As shown below: To compress a N-copy string of a data bit D, transfer with two bytes, as shown below, it represents a compressed byte: a string n-sharpecnote byte can be compressed into one byte, The filter bytes are different depending on the representation. If the type is ASCII or EBCDIC, the filter byte is , if it is an image or a local type, it is 0. Below is the filter byte: the escape sequence is a double byte, one full 0, and the latter is defined in block mode descriptor subcodes. Description subcodes are the same as the meaning in block mode, which acts on bytes in the backed string. Compression mode is good for increasing bandwidth (because data is compressed). 3.5. Error recovery and restart bit loss and data error are the error control of this layer is responsible by TCP. The restart is a method for the user's processing system (including operating system, network, etc.). The restart process is only available for block and compression mode, which requires the sender to add a specific tag in the data stream, and the tag is only meaningful to the transmitter, but the content is the language that controls the connection. The marker can represent any point of one bit count, record counts, or any point that can be marked with the number of data. If the recipient also supports resumption, this tag will be saved in the receiving system. After the system failure is restarted, the user can restart the data transfer according to the original tag, which is the breakpoint process of breakpoints we are familiar with. The receiver receives a segment of data and then records it. If the sender fails, it will transmit the corresponding data later. Specifically, there is not much here. 4. File Transport Features The channel from the user PI to the server is built between the user to the tag server. The User Protocol Interpreter is responsible for sending commands and interprets the received response; the server PI interpret command, send a response, and guide the DTP to establish a data connection and transmit data. If the second part of the data transmission is the user DTP, it controls it through the internal protocol of the user FTP host; if the second part is the server DTP, it is controlled by the user PI. 4.1. Ftp command 4.1.1. Access Control Command The following command Specifies the access control tag (command code in parentheses): The User Name (User) parameter is a telnet string that tag users. The user tag is a must-have, this command is usually the first command that controls the first one, and some hosts also require passwords and accounts. The server can receive a new user command at any time to change access control and / or account information. This can restart the login process, so the transmission parameter is unchanged, and the file transfer in progress is completed under the past access control parameters. The password parameter is a telnet string that tag the user password. This command is tight with the user command, where it is an indispensable step of completing access control. So the password is an important thing, so it cannot be displayed, the server side does not have a way to hide the mouth, so this task has to be completed by the user FTP process. The Account (ACCT) parameter is a telnet string that tag the user account. This command does not need to be related to user, some sites may require an account to log in, and others can limit the permissions of the account. In the latter case, this command can be sent at any time. The difference between the response can distinguish between the situation: When the login needs account information, the response to the pass command is 332.

Also, if the account information is not required, the response to the pass is 230. If the account information is required in the future, the server will return 332 or 532, which is to see whether it is saved or rejects this command. Change Work Directory (CWD) This command allows users to work in different directories or data sets without changing its login or account information. Transmission parameters are also constant. The parameters are generally a directory name or a set of files related to the system. Go back to the previous point directory (CDUP) This command requires the system to implement the directory tree structure, its response and the CWD. Structural Loading (SMNT) This command enables the user to load another file system data structure without changing the login or account information. Transmission parameters are also constant. The parameter is a file directory or a set of files related to the system. Reinitialization This command terminates User, writes all I / O and account information, but not in progress. Reset all parameters, control the connection to open, you can start the user command again. Exit Login This command terminates the user. If there is no data transfer, the server shuts down the control connection; if there is data transmission, the server closes control connection after obtaining the transmission response. If the user process is transferring data to different USER, you can use Rein if you don't want to close each USER and then open it. Unexpectedly on control connection, can cause server operation abort (Abor) and quit. 4.1.2. Transfer parameters Command All data transfer parameters have default values. The server must record the default value, and after the FTP service request can be sent in any order. The following command transmits parameters: Data Port (port) parameter is the data connection port to be used, usually without command response to this. If you use this command, you want to send 32-bit IP addresses and 16-bit TCP port numbers. The above information is transmitted in 8 bits as a group, a comma-separated decimal transmission, as in the following examples: Port H1, H2, H3, H4, P1, P2 where H1 is the highest 8 bits of the IP address. Passive (PASV) This command requires server DTP to listen in the specified data port, enter the passive reception request, the parameter is the host and port address. Indicates the type (TYPE) parameter specifies the name of the representation. Some types require a second parameter, the first parameter is defined by a single telnet character, the second parameter is the decimal integer specifies byte size, and the parameters are separated by . The following is a format: The default representation is an ASCII non-printing character. If the parameter has not changed, only the first parameter is changed, and the default value is used. The file structure (STRU) parameter is a Telnet character code specified file structure. The following is the code and its meaning: F - file (non-recorded structure), it is the default value R - Recording Structure P - Page Structure Transfer Mode (MODE) Parameter is a Telnet character code specified transmission mode. The following is the code and its meaning: S - stream (default) B - block C - compression 4.1.3. FTP service command ftp service command Defines the file transfer or file system function requesting user request. The parameters of this command are usually the path name, and its syntax is consistent with the servers. The recommended default is the recent specified device directory or directory. Command order usually does not limit, only "rename from" command must be "rename to", and then restart the command must be an interrupt service command. The response of the service command is usually transmitted over a data connection. The following is a specific command: obtain the file (retr) This command enables the server DTP to transfer files in the specified path to the server or user DTP. The status and content of the file on this server are not affected. Save (Stor) This command enables the server DTP to receive data transferred on the data connection and saves the data in the server. If the file already exists, the original file will be overwritten. If the file does not exist, create a new file.

Unique Save (STOU) This command is similar to the Stor, this command requires the file name in this directory to be unique, and the response to this command must include the generated username. Additional (APPE) It is similar to the function of the Stor, but if the file already exists in the specified path, the data is attached to the end of the original file, and if there is no new file. Allocation (allo) This command is used to assign enough storage space for newly transmitted files on some hosts. The parameter is the number of logical bytes of decimal. If it is a record or page structure, a page, or a maximum size of the record, which is specified in the second parameter. The second parameter is optional, if there is it, it and the first parameter are separated by telnet character R . After this command is in the Stor or APPE command, its role is equal to NOOP for a machine that does not need to allocate storage space. Restart the parameter domain represents the server to start again, this command does not transmit files, but the data after the specified point, this command should follow other FTP commands that require files to be transferred. Renaming (RNFR) This command is the same as we used in other operating systems, but it is only to specify a new file name with "Rename TO". Rename (RNTO) This command and the above command work together to rename the file. Abandon (abor) This command notifies the service abdominal former FTP commands and related data transfer. If the previous operation has been completed, there is no action, returns 226. If you do not have, return 426, then return 226. Close the control connection, the data connection is not closed. Delete This command deletes files under the specified path. The user process is responsible for the removable prompt. Delete Directory (RMD) This command deletes the directory. Create a directory (MKD) This command creates a new directory under the specified path. The Print Work Directory (PWD) is returned to the current working directory in the response. List (list) server transmits a list to passive DTP, if the path specifies a directory or a lot of files, returns a list of files under the specified path. If the path name specifies a file, the server returns the current information of the file, the parameter is empty, indicating the current working directory or default directory of the user. Data transfer is performed in ASCII or EBCDIC, and the user must confirm this. Because the file information is different due to the system, it is impossible to be automatically utilized by the program, but human users need. Name List (NLST) Server Directory Table Name Name, the path name should specify the file group descriptor specified by the directory or other system; empty parameters refer to the current directory. The server returns the file name data stream, transmitted in ASCII or EBCDIC, and separated by or . The information returned here is sometimes available for further processing. The site parameter (Site) server is used to provide server system information, and the information is different due to the system, and the format is given in the Help Site Command Answer. The system (SYST) is used to determine the operating system running on the server. Status (STAT) This command returns to the control connection status, which can be sent during the file transfer, and the server returns the state of the operation. You can also send between file transfer. At this time, the command has a parameter, the parameter is the path name, and the function of this command is similar to the list of lists in the control connection. If the part path is specified, the server returns in the file name or the attribute associated with the description; if there is no parameters, the server returns status information of the server FTP process, including the current value of the transmission parameter and the connection state. Help (HELP) This command does not differ from the help in the usual system, and the response type is 211 or 214. It is recommended to use this command before using the USER command. Waiting (Noop) This command does not generate what actual action, which only returns the server to OK. FTP uses Telnet communication on the control connection, so there is a chance to see the relevant protocol description. The understanding of the following will be very beneficial. The following will be explained to the command response and details about the command.

The ftp command can be divided into access control tags, data transfer parameters, or FTP service requests, and specific commands (such as Abor, STAT) can be transmitted over the control connection during data transfer. Some servers cannot monitor data and control links at the same time, so they have to take additional measures. Please note the following suggestions: 1. User system Insert Telnet's "Interrupt Process" information into the Telnet stream; 2. User system sends a "SYNCH" signal for Telnet; 3. User system will insert commands (such as Abor) Telnet stream; 4. After receiving IP, the server PI looks for only one FTP command in the Telnet stream. 4.2. The response of the FTP response FTP command is to synchronize the data transfer request and the process, but also to let the user understand the status of the server. Each command must have a minimum of one response, if it is multiple, they have to distinguish. Some commands are sequential, so the failure of any of the commands can cause the beginning of the head. The FTP response consists of three numbers, followed by some text. Number with enough information Naming User PI Don't check the text know what happened. Text information is related to the server, and the user may get different text information. Text and numbers are at the end of the Telnet line end in . The text may be more than one line. At this time, the text must be in parentheses, and there must be information in the first line to indicate more than one line, and the last line must be marked. If you are multi-line, you can add "-" after the digital code, the last line starts with the number, and the end is , plus the telnet's row end character. Here is an example: 123-The first line of the second line 234 has a certain meaning of each line of the first line of 123, and the first one determines whether the response is good, bad or not complete, pass Check the first place, the user process usually knows what actions are about to take. If the user program wishes to understand what the problem, you can check the second bit, the third bit indicates other information. The first one has five values: 1YZ determines the operation of the prepared response request is being initialized; waiting for an additional response before entering the next command. This type of sound application is accepted, how to synchronize monitoring in the implementation, and the user process can now pay attention to the data connection. The server FTP process returns to 1YZ response to the first command. 2YZ determines that the operation of completing the response requirement has been completed, and a new command can be executed. 3yz determines that the intermediate response command is accepted, but the required operation is stopped and the information is stopped. 4YZ temporarily refused to complete the response uncharged command, the required operation did not execute, but the error was temporary, and the message can be sent again after a while. The user should return the beginning of the command sequence. This temporary is not well determined, this order means that the user process will try again again. 5yz always refuses to complete the response It is the difference between the temporary refusal to complete the response is that the error condition will not disappear for a while. Let's take a look at the meaning of the second representative: X0z format error; X1z This type of response is to request information; X2Z This type of response is about control and data connection; X3Z regarding authentication and account login process; X4z is not used X5z This type of response is about the file system; the third number is further refined to the answer on the basis of the second number. In general, there is a text message after digital code. When implementing, try to use existing code, not just add new code. Some commands such as Type or ALLO, their success does not provide task new information for the user process, so there will be no 200 response returns.

If some commands are not supported for the server, but also returns to determine completion answers, so that the user process is likely to make the following command. If the required command is not an optional implementation, this command does not implement, then return to code 502. Below we list all responses and its meaning: 110 Restart the tag response. In this case, the text is determined, it must be: Mark YYYY = MMMM, where YYY is the user process data stream tag, and the mmmm is a server tag. 120 service is ready for NNN minutes 125

Data connection has been opened, ready to transfer

150

Good file status, open data connection

200

Command success

202

Command is not implemented

211

System status or system help response

212

Directory status

213

File status

214

Help information, information is only useful to human users

215

Name system type

220

Prepare for new user services

221

Service shut down control connection, you can exit login

225

Data connection is open, no transmission is being performed

226

Turn off the data connection, the requested file operation is successful

227

Enter passive mode

230

User login

250

Request file operation

257

Create "pathname"

331

The user name is correct, you need a password

332

Account information needs to be logged in

350

Request file operation requires further command

421

Can't provide service, close control connection

425

Can't open data connection

426

Close connection, abort transmission

450

The requested file operation is not executed

451

Operation of the procedure: Have a local error

452

Operation of unforgettable request: System storage space is insufficient

500

Format error, command is not recognized

501

Parameter syntax error

502

Command is not implemented

503

Command order error

504

Command function under this parameter is not implemented

530

Not logged in

532

Store files require account information

550

Operation of the request

551

Request operation stop: Page type unknown

552

Request file operation abort, storage allocation overflow

553

Operation of the request: the file name is not legal

5. Description 5.1. Minimal implementation below is the minimum implementation of the FTP server: Type - Ascii Non-Print Mode - Stream Structure - File, Record Command - User, Quit, Port, Type, Mode, STRU, RETR, STOR, NOOP. Transmission The default parameter is: Type - ASCII Non-Print Mode - Stream Structure - File All hosts will be used as default. 5.2. The connection server protocol interpreter will initialize the full-duplex control connection in the port L, the user, or the user protocol interpreter, the server, and user processes should follow the Telnet protocol. The server does not provide the editing function of the command line should be responsible for all by the user. After all transfer and response, the server closes the control connection at the user's request. User DTP must listen on the specified data port, which can be the default port U or the port specified by the port command. The default data port of the server is L-1. The transfer direction and port can be determined by the ftp command. Only the user PI can change the default port. When data is transmitted between servers A and B, the user PI, C, establishes a control connection between the two server PIs. One of the servers A, receive the PASV command initialization connection when receiving the transmission service command, when the user PI receives the confirmation of the PASV command (confirmed the host ID and port), send the port to B with the port command to B. After receiving an acknowledgment, the user Pi can send the corresponding command to A and B, B initial connection and transmission process, command response sequences as shown below, please pay attention to time according to position: At any time, servers and users as long as one Close the connection, the other party will read the data in the buffer, and then turn off the connection. 5.3. Commands this section mainly discusses the command format. Command is not sensitive to case. Commands typically consist of command code and corresponding parameters. The middle is separated by one or several spaces. The parameter domain is ended by , and the server will not take any action when the end of the line is not received. The format described below is to use NVT-ASCII as accurate, square brackets represent an optional parameter domain, and the default value is used if the optional parameter domain is not selected.

5.3.1. The ftp command is the ftp command, where username represents the username, Password representative password, PathName represents the path name, Host-Port represents the host port, Account-Information represents account information, Typecode represents type code, Decimal-Integer delegate decimal Integer, MARKER representative tag, String representative string: user pass acct CWD CDUP SMNT Quit Rein Port PASV Type STRU Mode RETR stor stou APPE Allo [ r ] REST RNFR RNTO Abor Dele RMD MKD PWD List [ ] NLST [ ] Site SYST Stat [ ] CRLF> Help [ ] NOOP < CRLF> 5.3.2. Ftp command parameter The following is the parameter format represented by BNF paradigm: :: = :: = :: =

:: = | :: = All ASCII characters except and :: = :: = | :: = Print ASCII character, from 33 to 126 :: = :: = , :: = , , , :: = , :: = from 1 to 255 Decimal Integer :: = n | T | c :: = a [ ] | E [ ] | i | l :: = f | r | P :: = s | b | c :: = :: = Any decimal integer 5.4. Command and response sequence server and user communication are the process of dialogue, the user sends an FTP command, then wait for one of the server (or Multiple) responding, send a new command according to the response. The response when the connection carries a lot of information, usually, the server will return 220 response, wait for input, the user sends a new command after receiving this response, if the server does not receive the input immediately, returns 120 after 220. Some information If the server will stop working after 15 minutes is to send to the user, but the server cannot direct the user directly, the process buffer is to return the message and return to the user in the next response. The answer to the command is listed below, the first is the preparation response, the second is determined, the third is refusing to complete, and finally the intermediate response. These responses are the basis of the constituent state diagram, and the status map will be given in the next section: establish a connection

120

220

220

421

log in

User 230 530 500, 501, 421 331 332 PASS 230 202 530 500, 501, 503, 421 332 ACCT 230 202 530 500, 501, 503, 421 CWD 250, 501, 502, 421, 530, 550 CDUP 200 500 , 501, 502, 421, 530, 550 SMNT

202, 250

500, 501, 502, 421, 530, 550

sign out

Rein 120 220 220 421 500, 502 quit

221

500

Transmission parameters

Port 200 500, 501, 421, 530 Pasv 227 500, 501, 502, 421, 530 Mode 200 500, 501, 504, 421, 530 Type 200 500, 501, 504, 421, 530 STRU200

500, 501, 504, 421, 530

File operation command

Allo 200 202 500, 501, 504, 421, 530 REST 500, 501, 502, 421, 530 350 STOR 125, 150

(110)

226, 250 425, 426, 451, 551, 552 532, 450, 452, 530 STOU 125, 150 (110) 226, 250 425, 426, 451, 551, 552 532, 450, 452 553 500, 501, 421, 530 RETR 125, 150 (110) 226, 250 425, 426, 501, 421, 530 List 125, 150 226, 250 425, 426, 451 450 500, 501 , 502, 421, 530 NLST 125, 150 226, 250 425, 426, 451 450 500, 501, 502, 421, 530 APPE 125, 150 (110) 226, 250 425, 426, 451, 551, 552 532, 450 550, 502, 421, 530 RNFR 450, 550 500, 501, 502, 421, 530 350 RNTO 250 532, 553 500, 501, 502, 503, 421, 530 Dele 250 450, 550 500, 501, 502, 421, 530 RMD 250 500, 501, 502, 421, 530, 550 MKD 257 530, 501, 502, 421, 530, 550 PWD 257 500, 501, 502, 421, 550 Abor

225, 226

500, 501, 502, 421

Get information command

SYST 215 500, 501, 502, 421 Stat 211, 212, 213 450 500, 501, 502, 421, 530 HELP

211, 214

500, 501, 502, 421

Other orders

Site 200 202 500, 501, 530 NOOP

200

500 421

6. Status Figure Next is a simple implementation of the FTP state diagram, only the first bit of the response code. There are three possibilities for all commands or command sequences: Success (S), Failure (F) or Error (E). In the state diagram B represents the beginning, W represents waiting for a response. Here we give a general chart, the general chart can include commands: Abor, Allo, Dele, CWD, CDUP, SmNT, Help, Mode, NOOP, PASV, Quit, Site, Port, Syst, Stat, RMD, MKD, PWD, STRU, and TYPE The commands that can be included in the following figure include: APPE, LIST, NLST, Rein, Retr, Stor, and STOU. The first picture and the second figure difference are not large. If a 100 series response occurs in the first picture, it will not be in the second picture. Below is a renaming process: The following is a reboot command, where CMD represents APPE, Stor or Retr. The following picture represents the login process: 7. Typical FTP process assumes that the user is located on the U-U-S-S (lower) file, usually the user needs to use the user FTP process and server communication, the following is an example: the local command issued by the user

Explanation

FTP (Host) Multics

Port L connected to S, establish control connection

<---- 220 Service Ready .

User name doe nesed password . User doe ----> <- 331 User Name Correct Password

Pass Password ---->

<---- 230 User logged in .

RETRIEVE (LOCAL TYPE) ASCII (Local Pathname) TEST 1 (for. Pathname) Test.pl1

User-ftp opens local file in ascii. Retr Test.pl1 ----> <---- 150 file status is normal, open data connection

Server is located in port U set up a data connection

File transfer

<---- 226 Close data connection, file transfer correct

TYPE Image

TYPE I ---->

<---- 200 Command OK

Store (Local Type) Image (log.pathname)> UDD> CN> FD

User-ftp Opens Local File in Image. Stor> UDD> CN> FD ---->

<---- 550 Access refusing

Suspend

Quit ---->

Server Turn off all Connections FTP Connections Established by User Process Port U and Server Port L, the default L = 21 here.

转载请注明原文地址:https://www.9cbs.com/read-839.html

New Post(0)