Trivial file transfer protocol

Description

  • Michal Ondrejka

  • GitHub

  • november, 2023

The aim of this project was to implement Trivial File Transfer Protocol (TFTP) with two extensions, to send desired files between client and server. Since it operates only over the local network (1st picture), no security features have to be implemented. This let me purely focus on implementing the protocol.
In this project I implemented both sides client and server. Even though it is a file transfer and we don't want to lose any packets it uses UDP. The server is concurrent, which means when process listening on main TFTP port 69 receives request message it creates a child process on another port, form which the communication continues. This ensures that the server can handle more than one client since the UDP is stateless communication.
There are multiple types of messages (2ns picture). The communication start when client sends REQUEST message to write or read a file from a server. Then the file is transfered between the client and the server. If extensions are implemented options are sent in REQUEST message as well. OACK is then sent by server to client with accepted options. This is called options negotiation. Every data packet has to be acknowledged. The end of the communication is determined by packet with less data then determined in negotiation.
The mentioned extensions are packet size and and timeout time. Packet size determines the size of of data in one packet. Without this option a default standard value would be used. Timeout time determines how long should client and server wait to decide that a timeout has occured. This happens when an expected packet didnt arrive. After the timeout a ERROR packet is sent to notify the other side to resend this lost packet.

Technology