Home > Common Problem > What is the difference between ftp port numbers 20 and 21?

What is the difference between ftp port numbers 20 and 21?

醉折花枝作酒筹
Release: 2023-01-13 00:38:22
Original
39107 people have browsed it

The difference between ftp port numbers 20 and 21 is: one is the data port and the other is the control port. The control port is generally 21, but the data port is not necessarily 20. This is related to the application mode of FTP. If it is Active mode should be 20. If it is passive mode, it is determined by negotiation between the server and the client.

What is the difference between ftp port numbers 20 and 21?

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

One is the data port and the other is the control port. The control port is generally 21, while the data port is not necessarily 20. This is related to the FTP application mode. If it is active mode, it should be 20. If it is passive Mode, determined by negotiation between the server and the client

FTP Port mode and FTP Passive mode

When you troubleshoot an FTP problem, the first question you have to ask is to use Is it in port mode or passive mode. Because these two behaviors are very different, the problems caused by these two modes are also different; in the past, the client defaulted to active (port) mode; recently, due to the security issues of Port mode, many client FTP applications defaulted to Passive model.

 >>2.1 FTP Port mode

The FTP steps in Port mode are as follows:

1. The client sends a TCP SYN (TCP synchronization) packet to the server segment. FTP control port 21, the client uses the temporary port as its source port;

2. The server sends a SYN ACK (synchronization confirmation) packet to the client, the source port is 21, and the destination port is the client The temporary port used on the server;

3. The client sends an ACK (confirmation) packet; the client uses this connection to send FTP commands, and the server uses this connection to send FTP responses;

4. When the user requests a list request or initiates a request to send or receive a file, the client software uses the PORT command. This command contains a temporary port that the client hopes the server will use when opening a data connection. Temporary port; the PORT command also contains an IP address. This IP address is usually the client's own IP address, and FTP also supports third-party mode. In third-party mode, the client tells the server to open a connection with another host. Connection;

5. The server sends a SYN packet to the client's temporary port. The source port is 20. The temporary port is the temporary port number sent by the client to the server in the PORT command;

6. The client uses the source port as the temporary port and the destination port is 20 to send a SYN ACK packet;

7. The server sends an ACK packet;

8. The host sending the data uses This connection is used to send data, and the data is sent in the form of TCP segments (note: segment, PDU of layer 4) (some commands, such as STOR indicates that the client wants to send data, RETR indicates that the server segment sends data), these TCP segments require each other Perform ACK confirmation (Note: Because the TCP protocol is a connection-oriented protocol)

9. After the data transmission is completed, the host sending the data ends the data connection with a FIN command. This FIN command requires another The host confirms with ACK, and the other host also sends a FIN command. This FIN command also requires the host sending the data to confirm with ACK;

10. The client can send more commands on the control connection. This Additional data connections can be opened and closed; sometimes after the client ends, the client uses the FIN command to close a control connection, and the server uses an ACK packet to confirm the client's FIN. The server also sends its FIN, and the client uses ACK to confirm.

For more computer-related knowledge, please visit the FAQ column!

The above is the detailed content of What is the difference between ftp port numbers 20 and 21?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template