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.
TFTP requires only IP (Internet Protocol) and UDP (User Datagram Protocol). TFTP performs two operations read and write namely. In a read operation, it copies files from server SIDE yo client SIDE while in write operation it works exact oppoSIDE, it copies files from client-side to the server-side.
TFTP uses UDP services on the well-known port 69.
Types of TFTP Messages
There are five types of TFTP messages Below is the list
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 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 is that 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. Block number is a 2-byte field contains 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 be a response 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 the transmission of data. 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 error number and their 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.
To establish connections TFTP uses RRQ message, WRQ message, ACK message, an ERROR message. While to terminate 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. If 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 ACK message, if the server is able to copy file. If 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. TFTP 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.
This is a guide to TFTP, we have seen what is TFTP, different types of messages in TFTP, connections, how the TFTP connections established and termination which made it easy to understand the concepts. I hope you will find this article helpful. You may also look at the following article to learn more –