Caption script:
Overview: FTP Basics
Goal. Visualize FTP basic operations: Setup control and data connections, transfer data, closoe connections. Topology. A client H1 is connected to a FTP server S1 via Internet Steps: 1) H1 requests for a control connection with S1. 2) S1 requests for a data connection with H1. 3) S1 transfers data to H1. 4) When data transfer is done, S1 requests to close data connection and control connection.
H1: Control connection request
At H1, user types: ftp 1.1.2.1. It triggers H1 sending a Control Connection Request packet to S1. When S1 receives this request, it sends an Ack back to H1. Upon receiving Ack, H1 prints "20 FTP Server ready" to indicate that controol connection is up.
H1: Get foo, PORT
- User types "get foo" at H1 to ask S1 to send a file foo. - Then H1 sends a PORT command. Click PORT to see H1's port information: (IP: 1.1.1.1, port: 54705). Note: In this tutorial, FTP runs in active mode. It is server that initiates data connection. But server needs to know client's port number first. This is why H1 sends an unsolicited PORT command to S1.
S1: Data coonection rqeuest
- Upon receiving PORT, S1 sends data_Conn to H1 (source port 20, destination port 54705) - H1 responds with an Ack_data_Conn. Now data connection is up. - S1 receives the Ack and sends a message to H1 (not shown in animation) - H1 receives the message and prints "150 Opening BINARY...." to indicate that data transfre is starting. Note: In order to focus the key FTP packet transaction, we do not show non-critical packets in this tutorial.
S1 trsnafers foo to H1
- With data connection estbalished, S1 starts to transmit foo data one packet (ftp_Data) at a time. - When H1 receives a data packet, it responds an Ack_Data. - When S1 receives Ack, it sends the next data packet. Note: In this animation, we show only one ftp_Data.Ack_Data transaction.
S1: close data connection
- After S1 has transmitted all data packets, it sends a message to H1 (noy shown in animation) - When H1 receives this message, it pritns "226 Transfer complete" to indicate the file transfer is done. - S1 close the data connection adn sends Close_Data request to H1. - H1 receives this reqest and sends an Ack to grant it. This closes FTP data connection.
S1: close control connection
- User has no other FTP tasks to do and types "quit." It triggers a message to S1 (not shown in animation) - When S1 receives the quit message, it sends a goodbyte message to H1 (not shown in animation) - H1 receives this message and prints "221 Goodbye" to tell user that FTP is exited. - S1 sends Close_Ctrl to close control connection with H1. - H1 receives the request and sends Ack_Close to confirm. Now FTP control connection is closed..
FAQ
1) What is FTP? FTP stands for File Transfer Protocol. It is a TCP application that is used for file transfer. 2) What does FTP do? FTP allows FTP clients to connect to FTP server, then download or upload files from/to a FTP server. 3) Why FTP uses control connection and data connection? FTP uses control connection to transfer user commands. Server uses port 21 for this connection/ FTP uses data connection to transfer data. Server uses port 20 for this connection. Using two connections separates control and data tasks. Changes in one area do not have side effects on the other one. 4) How to setup/close down FTP connections? FTP uses TCP's 3-way handshaking to setup connections: SYN, SYNACK, and ACK. To close connections, FTP uses TCP's connection tear down packets: FIN, ACK, FIN, and ACK. See more details in FTP connection basic animation. 5) How to initiate data connection? FTP data connection is established in two ways: active, passive. - In active mode, the client sends the server the IP address and port number (PORT command) that the client will listen. Then the server initiates the TCP data connection. - If the client is behind a firewall, it cannot accept incoming TCP connections, passive mode is used. The client sends a PASV command to the server and receives an IP address and port number from the server. The client then uses these to open the data connection. 6) What are FTP commands? FTP client send FTP commands to server to start a task. For example, CDUP: Change to Parent Directory. DELE: Delete file. PORT: Specifies an address and port to which the server should connect. STOR: Accept the data and to store it as a file. USER: Authentication username. 7) How does server respond to client commands? FTP server responds to FTP commands by sending a numbered message to client. For example, - 200 PORT command successful (Server has received PORT) - 220 FTP Server ready (To indicate that server has established control connection) - 226 Transfer complete (Server has sent data completely) See RFC959 for detail commands. See FTP error code at http://www.theegglestongroup.com/writing/ftp_error_codes.php 8). What does PORT command do? In Active mode, the server makes data connection request to the (IP, port) that the client is listening at. But the server does not know. Therefore, the client sends the PORT command to server to inform its intended IP address and port number. A client may send several PORT commands to the same server to have concurrent data connections. 9) What are the common errors of making FTP connections? For active mode, client side firewall may block server's connection request. For passive mode, server side firewall may block client's connection request. To get it work, network admin needs to configure firewall to allow FTP connections. 10) How to setup FTP servers for servers in a subnet? Configure the gateway router to map FTP connection to the server.

| Single step forward | |
| Play animation | |
| Backup one step |
| Read the next page | |
| Read the last page |
| Don’t show me this message next time. |