1. FTP protocol Overview
FTP is the abbreviation for File Transfer Protocol (Transfer Protocol). FTP is a specific application of TCP/IP, it works on the seventh layer of the OSI model, on the fourth layer of the TCP model, the application layer, using TCP transmission instead of UDP,FTP connection is reliable, and it is connection-oriented, which provides a reliable guarantee for data transmission.
The FTP operating mode is similar to the client/server model. Unlike most other TCP applications, FTP uses two TCP connections between the client and the server--control the connection and the data connection, the control connection exists in the whole process of the client interacting with the server, and the data connection is created only when there is a file or directory transmission, and is closed after use. The control connection is used to send instructions to the server and wait for the server to respond, and the data connection is used to establish the data transfer channel.
Two connection modes of 2.FTP ―――port mode and passive mode
FTP uses a different TCP port number, depending on whether you are using port mode or passive mode.
2.1 FTP Port Mode
The FTP steps for Port mode are as follows:
1, the client sends a TCP SYN (TCP synchronization) packet to the server segment well-known FTP control port 21, the client uses the temporary port as its source port;
2, the server sends the SYN ACK (synchronous confirmation) package to the client, the source port is 21, the destination port is the temporary port which uses on the client end;
3, the client sends an ACK (confirm) package, the client uses this connection to send the FTP command, the server side uses this connection to send the FTP reply;
4. When the user requests a list request or initiates a request to send or accept a file, the client software uses the Port command, which contains a temporary port, and the client expects the server to use this temporary port when opening a data connection; The port command also contains an IP address, this IP address is usually the client's own IP address, and FTP also supports the third party (third-party) mode, the third party mode is the client told the server side to open the connection with another host;