FTP (File Transfer Protocol & TFTP (Trivial File Transfer Protocol), like their names suggest, are industry standard protocols for transferring files between devices over a network.

Both protocols use a client/server model. Clients can copy files to and from a server.

It’s no surprise that FTP/TFTP are frequently used for a variety of purposes across the computing world. In networking, a common use for FTP is upgrading the operating system of a network device.

File Transfer Protocol (FTP)

FTP was initially standardized in 1971, and has received many updates and revisions since. FTP provides a robust set of features for transferring files between network devices, and uses TCP, providing it with connection-oriented, reliable data transfer.

  • FTP uses TCP ports 20 (data) and 21 (control).
  • Usernames and passwords are used for authentication, however there is no encryption.
    • For greater security, FTPS (FTP over SSL/TLS) can be used.
    • SSH File Transfer Protocol (SFTP) can also be used for even greater security.
      • (note that while FTPS is an upgrade to FTP, SFTP is an entirely separate protocol)
  • FTP is more complex than TFTP, and allows not only file transfers, but clients can also navigate directories, add or remove directories, list files, etc.
  • The client sends FTP commands to the server to perform these functions

FTP uses two types of connections:

  • FTP Control connection (TCP 21) is established and used to send FTP commands and replies
  • FTP Data connections (TCP 20) are established and terminated as needed to transfer files or data

FTP Data connections are established in one of two modes:

  • Active Mode is the default, in which the server initiates the TCP connection
  • Passive Mode, in which the client initiates the data connection, is often necessary when the client id behind a firewall, which can block the incoming connection from the server.
  • In either case the FTP Control connection is maintained throughout.

Copying Files (FTP)

First, you must configure a username and password

  • (config)#ip ftp username username
  • (config)#ip ftp password password

Then use the following command to transfer files:

  • copy ftp: flash:
    • You will then be prompted for the FTP server’s IP address, the name of the file you want to copy, and the name you want that copy to have locally

Trivial File Transfer Protocol (TFTP)

First standardized in 1981, TFTP is a simplified, streamlined version of FTP. It only allows clients to copy a file to or from a server; no extra features or functions. This simplicity is convenient when only a small number of files need to be transferred. That said, TFTP is not a replacement for FTP due to its more limited functionality.

Warning

TFTP does not support authentication; servers will always respond to all TFTP requests. TFTP also does not support encryption; all data is sent in plain text.

This lack of security is the primary reason FTP is preferred to TFTP in many situations. TFTP is best used in a secure, controlled environment to transfer small, non-compromising files quickly.*

TFTP servers listen on UDP port 69. UDP is connectionless; it does not ensure that there is a device able to receive the data before it’s sent, and there’s no way to ensure the data arrived in-tact, although it operates with little overhead compared to TCP.

HOWEVER, there are some similar features built-in to TFTP itself:

TFTP Reliability

  • Every TFTP data message is acknowledged
    • If the client is transferring a file to the server, the server will send Ack messages.
    • If the server is transferring a file to the client, the client will send Ack messages.
  • Timers are used, and if an expected message isn’t received in time, the waiting device will resend its previous message.
    • This is called ‘lock-step’ communication. The client and server alternately send a message and then wait for a reply, sending retransmissions as needed.

TFTP Connections

  • TFTP file transfers have three phases:
    1. Connection: TFTP client sends a request to the server, and the server responds back, initializing the connection.
    2. Data Transfer: The client and server exchange TFTP messages. One sends data and the other sends acknowledgments.
    3. Connection Termination: After the last data message has been sent, a final acknowledgement is sent to terminate the connection.

TFTP TID

  • When the client sends the first message to the server, the destination port is UDP 69 and the source is a random ephemeral port. This random port is called a ‘Transfer Identifier (TID)’ and identifies the data transfer.
  • The server then also selects a random TID to use as the source port when it replies, not port 69.
  • When the client sends the next message, the destination port will be the server’s TID, not 69.

Note

This is probably beyond the scope of a CCNA, but it’s an interesting part of TFTP’s operation.

FTP vs TFTP

FTPTFTP
Uses TCP (20 for data, 21 for control) for connection-based communicationUses UDP (69) for connectionless communication (although a basic form of ‘connection’ is used within the protocol itself)
Clients can use FTP commands to perform various actions, not just copy filesClients can only copy files to or from the server
Authentication via Username/PasswordNo authentication
More complexSimpler