The Trivial File Transfer Protocol (TFTP)
This section gives a “soft” introduction to TFTP compared to the one given in RFC1350. However, you have to read the document RFC1350 in order to get the information you need to accomplish the implementation. That document is designed to contain all the information you need to implement the protocol. No more, no less.
TFTP is a simple method of transferring files between two systems. It was designed to be small and easy to implement. It is much smaller than the File Transfer Protocol (FTP) and does not provide many of the features that FTP provides (directory listings, user authentification, etc.). The only services provided by TFTP is the ability to send and receive files between a client and a server.
There are five types of packets used by TFTP (write request, read request, data, acknowledgment, error) all represented by different 2-bytes opcodes (specified in RFC1350) that every packet begins with. The write and read requests are sent by the client to the server to send or receive a file. The requests specify the filename and the transfer mode. Both of these strings are of variable length. There are two different modes (netascii or octet) but you only have to implement a server that can handle the octet mode that treats all data as a stream of bytes.
A data packet contains the actual data bytes along with a block number. The length of the data in a data packet is between 0 and 512 bytes. If the length of the data is between 0 and 511 bytes, the data packet is the final one, otherwise the length is 512 and there is more data to be sent. The block number is used by the receiving end to acknowledge the most recently received valid packet of data.
The error packet is sent when an error occurs and it contains both an error code (specified in RFC1350) and an error message (suggested in RFC1350) that provides additional details on the error condition.