How it works...

There are two modes of FTP: active and passive. In active mode, the server opens another connection to the client, while in passive mode, it is the client that opens the second connection to the server. Let's see how it works.

In passive mode, the operations are as shown in the following diagram:

Figure 12.4: FTP passive mode steps

These are described here:

  1. The client opens a control connection from a random port P (1024 in the example) to server port 21
  2. The server answers back from port 21 to the client port 1024
  3. Now, the client opens a data connection from the port P+1 (1025 in the example) to a data port that the server has opened and notified the client about (port 2000 in the example)
  4. The server answers from the data port (2000 in the example) to the client port that initiated the connection, that is, the data port P+1 (1025 in the example)

In active mode, the operation is slightly different:

  1. The client opens a control connection from a random port P (1024 in the example) to server port 21
  2. The server answers from port 21 to client port 1024
  3. The server opens the data connection from port 20 to the client port P+1 (1025 in the example)
  4. The client answers from the data port P+1 (1025 in the example) to server port 20
Figure 12.5: FTP active mode steps
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.205.123