In a sentence, passive mode reverses the setup direction of the FTP data channel.
After completing the initial setup, such as the FTP feature and login exchanges,
the client will want to perform some kind of file transfer.
In FTP active mode,
the client issued the port command to prescribe a TCP port to the server in
preparation to accept a new FTP data transport session.
In passive mode, the client sends the PASV message with no arguments.
The command requests that the server specify a port to the client.
Because the client connects to the server in passive mode,
the server is responsible for allocating a port.
It replies with an acknowledgement of passive mode,
which, like the port command, contains an ephemeral TCP port.
In our example, port 40515 was returned.
Keep this in mind as we advance to the next slide.
Now that the client knows on what port the server is listening,
it can download files.
Just like with active mode,
the client uses the RETR command to grab a copy of the R1.cfg file.
This message is transferred in the FTP signaling channel on port 21.
With active mode, the server would have initiated a session to the client,
but in passive mode, the client initiates a second session to the server.
It uses the destination port it learned from the server after
sending the PASV command on the previous slide,
which was 40515.
I'm showing the TCP SYN here just for flow visualization,
although we know there is additional TCP chatter needed to form the session.
Once the session is fully established,
the server sends the file down to the client using the
PASV port as the TCP source port,
which is expected given the basic rules of TCP communication.
The FTP data has a source port of 40515 because this is the port the
server selected for this specific file transfer.
The upload operation works similarly with the main difference
being the reversal of the file transfer.
I'm not showing the PASV chatter again to avoid excessive repetition.
The client sends the STOR command within the FTP control
channel on port 21 towards the server.
This notifies the server that an upload is about to occur,
and the server acknowledges that it is ready to receive the file.
In this example, the PASV exchange yielded port 28034,
allocated by the server to signal on which port it is
expecting an FTP data session to be established.
The client sends a TCP SYN to start setting up the data session.
Once the session is up,
the client uploads the file with traffic destined to port 28034.
After the file is transferred, the standard FTP teardown process occurs, much like active mode.