Data transmission in the network is a complex process. A simple data transmission has actually passed through many protocols. Now let's introduce the FTP protocol, the remote file transfer protocol.
1. What is the FTP protocol?
FTP Protocol File Transfer Protocol) is a remote File Transfer Protocol used to simplify File Transfer between systems on the IP network. FTP is a specific application of TCP/IP, it works on the layer 4 of the OSI model and the layer 4 of the TCP model, that is, the application layer. It uses TCP transmission instead of UDP, and FTP establishes a reliable connection. Using the FTP protocol, Internet users can efficiently download large amounts of data files from online FTP servers, and copy files on remote hosts to their computers. To share resources and transmit information. As FTP is used, a large number of download servers are available to users on the Internet. Internet has become a giant software repository.
2. How FTP works
FTP has two processes: control connections and data transmission. The FTP protocol does not need a port as the default connection. The HTTP port is 80, and the FTP port is 21 ). The FTP protocol requires two ports. One port serves as the control connection port, namely port 21 of FTP, which is used to send commands to the server and wait for the server to respond. The other port is used for the data transmission port, PORT Number is 20 only in PORT mode), is used to establish a data transmission channel, the main function is to send a file from the customer to the server, from the server to send a file to the customer, the slave server sends a file or directory list to the client.
3. FTP transmission mode
An FTP task transfers files from one computer to another, regardless of the location, connection method, or even whether the two computers use the same operating system. Assume that the two computers communicate over the ftp protocol and can access the Internet. You can use ftp commands to transmit files. There are some nuances in the use of each operating system, but the basic command structure of each protocol is the same.
There are two FTP transmission modes: ASCII transmission mode and binary data transmission mode.
The ASCII transmission mode assumes that the file being copied contains simple ASCII code text. If the file running on a remote machine is not UNIX, during file transfer, ftp usually automatically adjusts the content of the file so that the file can be interpreted as another computer that stores the text file format. However, in this case, the files being transmitted by the user are not text files. They may be programs, databases, word processing files, or compressed files. Although most of the word processing files contain text files, it also contains non-printable characters indicating the page size and font information ). Before copying any non-text files, use the binary command to tell ftp to copy them verbatim. Do not process these files. This is also the binary transfer to be discussed below.
In binary transmission, the file order is saved so that the original and copied files are one-to-one. Even if the destination machine contains files with bit sequences, it makes no sense. For example, if a macintosh transfers an executable file to a Windows system in binary mode, the file cannot be executed on the other system. If you transfer a binary file in ASCII mode, the translation will still be translated even if you do not need it. This slows down the transmission, damages the data, and makes the file unusable. On most computers, the ASCII mode generally assumes that the first valid bit of each character is meaningless, because it is not used for the combination of ASCII characters. If you transmit binary files, all bits are important .) If you know that the two machines are the same, the binary method is effective for text files and data files.