FTP/TFTP communication

FTP/TFTP communication

 FTP stands for "File Transfer Protocol" and is also known as File Transfer Protocol. It is a communication protocol for transferring files over a network, and has been the most commonly used file transfer protocol on the Internet since the early days of the Internet.

 Other file transfer protocols include NetBIOS and NFS. This realizes file transfer by virtually mounting the external file system using the OS file system.

 With FTP, you can upload files to an FTP server or download files from an FTP server after logging into the destination computer. However, since the user name and password exchanged at that time are sent in plain text without being encrypted, there is a risk of being intercepted.

 If you want to perform secure FTP communication, you need to transfer files using FTPS (FTP over SSL/TLS) or SFTP (SSH FTP).

 File transfer with FTP is command-based, but currently there are many dedicated FTP software that can be operated with a GUI in both Windows and Linux environments. With GUI tools, you can transfer files without being aware of commands.

 FTP communicates using two connections, one for control and one for data transfer. Port 21 (FTP) is used for control and port 20 (FTP-DATA) is used for data transfer.

 First, a control connection is established and user authentication is performed. After successful user authentication, a control connection is established. This is established by making a client-side request to the FTP server. The client connects to port 21 on the server using any free port.

 After establishing the control connection, establish the data connection. In this way, with FTP, by establishing a control connection separate from data transmission/reception, other commands such as a stop command can be issued even during data transfer.

 A data connection is created each time by a command passed on the control connection, and is closed when the data transfer is completed. The data connection will transfer files while repeating connection and disconnection many times during one FTP communication.

TFTP communication

 TFTP stands for "Trivial File Transfer Protocol" and is defined in RFC 1350. "Trivial" means "insignificant", and you can see from the name that it is a protocol that is not as good as FTP.

 TFTP is a protocol that simplifies the functions of FTP. Compared to FTP, the functions that can be used are limited and simple, and there is no user name and password authentication function or directory list browsing function. It also uses UDP to transfer files.

 TFTP does not have the ability to browse directories, so you must know exactly what filename you want to transfer and where it resides.

 Since TFTP is a simple protocol, it is suitable for communication with a small amount of data to be exchanged. However, in terms of reliability, it cannot be said to be highly reliable because it does not have an authentication function and uses UDP for transmission.

As a result, very few sites currently support TFTP due to security concerns.

 Currently, TFTP is used for booting an OS on a diskless computer that does not have a bootable disk, and for updating or replacing the OS and firmware of network devices such as routers and switches.

TFTP packet

 When the client accesses the TFTP server, it uses UDP port number 69. However, specifying 69 as the destination port number is only for requests from the client to the TFTP server, and for subsequent communications, the TFTP server uses a random port number for communications.

 TFTP data is sent in 512-byte fixed-length, sequence-numbered data blocks. After sending a fixed-length block of data, the server waits for an acknowledgment from the client before sending the next block of data. If the server does not receive an acknowledgment, it will resend the previous data block as a timeout process.

 If the transfer file is evenly divisible by 512 bytes, the server will send a data block with a data portion of 0 bytes at the end.