# TFTP Server Submission by Marek Ufnal, mu222fh A Trivial File Transfer Protocol is a simple protocol which allows file transfer of files between a client and a remote host. Originally introduced in 1981, it introduced quick transmission over UDP protocol with retransmission and acknowledgements inspired by TCP. This project will demonstrate a server-side Java implementation of the protocol and discuss the relevant steps needed for a near-complete server (some errors are omitted). The implementation will include sending and retrieving of files, as well as appropriate error messages for when an issue arrises. In order to achieve the task, the java.net.DatagramSocket, as well as java.net.DatagramPacket classes will be used for the implementation of the UDP protocol and the TFTP will be built on top of the datagrams. For more details, see mu222fh_assign3.pdf ## Compilation: For your convenience the sources.txt is included in the package. In order to compile, make sure you `cd` into the directory containning `sources.txt`. Once in the directory, simply run: ``` javac @sources.txt ``` ## Configuration For your convenience, several time out related parametres can be configured in the `timeout.conf` found in the `lib` directory. ``` Sleep : 6000 ReadRcv : 200 WriteRcv : 10000 MaxRetrans : 3 ``` * Sleep is the value used by the time out thread and determines how long the server will wait before declaring the client inactive and terminating the connection. * ReadRcv is the amount of time the server will wait for the client to send ACK for each block. * WriteRcv is the ammount of time the server will wait to receive a block of data when the client tries to upload a file. * MaxRetrans is the number of retransmission attempts the client is allowed to make per block. The values are loaded on server startup and currently there is no possibility to change these values during the execution, but some provisions are made to allow this functionality in the future. In case the configuration from the file fails, default values are provided. Please note that the server currently creates a new directory in your home directory called `~/tftp` with two sub-directories `~/tftp/read/` and `~/tftp/write`. For get requests place files in the read directory, for put requests, the files will be placed in the write directory. A `access.test` file is given which has no permissions. This file can be placed in the read directory for testing. ## Running To launch the server, `cd` into the directory where you compiled the server. The server should launch using the following command: ``` java TFTPServer ``` Currently the port is hardcoded to 4970 and the directory is generated at startup as per the code template. Due to values being declared as final in the template, these are **NOT** parsed from arguments. Please feel free to change the values inside the TFTPServer.java. ## Tests The provided Python tests are attached in `python_tests`. The test had been enhanced to match the directory generated by the java server and to support both, read and write directories. Please note, __put__ tests only work using localhost due to the way they had been implemented, the rest can be tested over the network.