- FTP is a network protocol used to transfer computer files between a client and server on a computer network.
- FTP is built on a client-server model architecture and uses separate control and data connections between client and server.
- FTP may run in active or passive mode, which determines how the data connection is established.
- In both the cases, the client creates a TCP control connection from a random, usually an unprivileged, port N to FTP server command port 21.
- In active mode, the client starts listening for Incoming data connections from the server on Port M.
- It sends the FTP command port M to inform the server on which port it is listening. The server then initiates a data channel to the client from its port 20, the FTP server data port.
- In situations where the client is behind a firewall and unable to accept incoming TCP connections, passive mode may be used.
- In this mode, the client uses the control connection to send a PASV command to the server and then receives a server IP address and server Port number from the server.
- Which the client then uses to open a data connection from an arbitrary client port to the server IP address and server port number received.
- While transferring data over the network, four data representations can be used. ASCII : This mode is used for text.
Communication and data transfer
Binary mode: The sending machine sends each file byte for byte, and the recipient store the byte stream as it receives it.
EBCDIC mode: Used for plain text between hosts using the EBCDIC character set.
Local mode: Allows two computers with identical setups to send data in a proprietary format without the need to convert it to ASCII.
Data transfer can be done in any of three modes
Stream mode: Data is sent as a continuos stream, relieving FTP from doing any processing.
Block mode: FTP breaks the data into several blocks and then passes it on to TCP.
Compressed mode: Data is compressed using a simple algorithm.