Updated March 16, 2023
What is TFTP?
TFTP stands for Trivial File Transfer Protocol. This protocol is used when users need to copy their files. In other words, it allows the user to store and access their files from the remote host. It is mainly used for the booting system. To understand this concept, let us take a simple example, Suppose you have a booted diskless system or router; for that, you need to download bootstrap files and configurations files. In that situation, you need a protocol to copy those files at a faster speed. Here the TFTP comes into the picture. It is designed to copy these types of files.
It requires only IP (Internet Protocol) and UDP (User Datagram Protocol). It performs two operations, read and write, namely. In a read operation, it copies files from server SIDE yo client SIDE, while in a write operation, it works exact oppoSIDE; it copies files from client-side to the server-side.
It uses UDP services on the well-known port 69.
Types of TFTP Messages
There are five types of TFTP message listed below:
- RRQ
- WRQ
- DATA
- ACK
- ERROR
1) RRQ message
RRQ stands for the read request message. The client uses this to create a connection For reading data from the server SIDE. RRQ message has three fields OpCode, Filename and Mode. An OpCode is a 2 byte in size; It contains 1 to show the RRQ message. Filename defines the name of the file. Modes define the transmission mode. Transmission mode can be netascii for ASCII file or octet for binary files. The message format of RRQ is given as follows.
2) WRQ message
WRQ stands for the write request message. The client uses this to create a connection for writing data from the server SIDE. WRQ message has the same fields as RRQ, only difference because OpCode contains 2 to show the WRQ message. Here we can see the WRQ message format.
3) DATA message
Both client and server use data messages to send data blocks. Data contains three fields – OpCode, Block number, and Data. OpCode contains 3 to show data messages. A Block number is a 2-byte field that contains a block number. All blocks are sequentially numbered from 1. The client and server use this field to send data sequentially so that the receiver will combine the whole message using this block number. Data is of 512 bytes. Data can be transferred in the form of netascii (ASCII file) or octet (Binary file). The DATA message format is given as follows.
4) ACK message
ACK stands for Acknowledge message. Both client and server use this ACK to acknowledge the receipt of the data block. This message is of 4 bytes. It contains two fields – OpCode and Block number. OpCode contains 4 to show the ACK message. Block number is of a 2-byte field that contains the number of data blocks received. ACK message can also respond to the WRQ message, which is sent by a server to the client for indicating that the server is ready to receive data from the client. ACK message format is given as follows.
5) ERROR message
Client and server use ERROR message when a connection between client and server cannot be established or when some error has occurred during data transmission. It sends a negative response to the RRQ message or WRQ message. This message contains three fields – Oe, Error number and Error data. OpCode contains 5 to show the ERROR message. The error number is of 2 byte that contains the error number and its meaning. The ERROR message format is given as follows.
Below is the list of error number with their meaning
0 – Not defined
1 – File not found
2 – Access violation
3 – Disk full or quota exceeded
4 – Illegal operation
5 – Unknown port number
6 – File already exists
7 – No such user
The error data field contains error data in text format. It is a 1-byte field and terminated by 0s.
TFTP Connections
It uses an RRQ message, WRQ message, ACK message, and ERROR message to establish connections. While terminating connections, TFTP uses the DATA message.
1) Connection Establishment
The process of connection establishment for reading files is different from writing files.
- Reading: The client sends the RRQ message to establish a connection for reading. This message contains the name of the file and the transmission mode of the file. Once the connection is established, the server sends a positive response with the DATA message if the server is able to transfer the file. Suppose it does not then send a negative response with an ERROR message.
- Writing: The client sends WRQ messages to establish a connection for writing. This message contains the name of the file and the transmission mode of the file. Once the connection is established, the server sends a positive response with an ACK message if the server is able to copy the file. Suppose it does not then send a negative response with an ERROR message.
Here is the representation of reading and writing operation
2) Connection Termination
After the transmission of the file, the connection must be terminated. It does not use a special message to terminate the connection. Termination is done by sending the last data block, which is less than 512 bytes.
Recommended Articles
This is a guide to TFTP. Here we have discussed an overview of different types of TFTP messages, how the TFTP connections established, and termination that made it easy to understand the concepts. You may also look at the following article to learn more –