This project is to write simple UDP client and Server in C or C++. Your programs should have the following functions:
UDP Client
Your client first sends a message to the UDP server, indicating the name of an ASCII file that the client wants to send to the server.
Then the client reads the specific file line by line and sends to the server through a given UDP port.
Below is an example of a command line that could be used to run your UDP client on port 1234 and send a file specified by "myfile" to the server at address 130.127.45.7:
./client 130.127.45.7 1234 myfile
The first command line parameter (argv[1]) must be the server's IP address. The port number in the client program should be the same as the port number that the server program specifies. "myfile" is the name of the ASCII file to be sent to the server.
UDP Server
Your server creates UDP socket and waits at a specified port for the client to send data. The server first receives the filename from the client and create an ASCII file to store the data received from the client. The server will read ASCII data line by line sent by the client after it successfully creates the file. If the server is unable create a file, it must report the error to the client. The server must reverse the order of characters in each line and write it to the file opened by the server. Below is an example of a command line that could be used to run your DUP server on port 1234:
./server 1234
You must design a protocol between the client and server for synchronization and error correction. Please consult the TFTP protocol for designing your own protocol. Your programs must be able to deal with data loss in communication. For instance, the server should ask the client to resend a line if that line is not successfully received.
You must submit all the source code necessary and the Makefile for us to build and test your UDP client and server. If you don't know how to make or create a Makefile, refer to the sample TCP client and server code. Feel free to ask for help in creating a Makefile.
You must also include in your submission a file named README
that includes your name and a brief description of your submission, including
the name of each file submitted along with a one line description of what is in
the file. If your code is not complete, state in your README what works and what doesn't. If
you are submitting code that does not compile, please state it clearly in the README as well. If
any of your code was written by someone else , you are required to indicate
it in the README file (this must also be documented in the code itself). For instance, if you used a sample program from the textbook to start your assignment, please say so in your submitted files. You also need to briefly decribe
your peer-to-peer protocol in README. Finally, feel free to
include a description of any problems you had or anything else you think might be helpful to test your program.
Your project will be tested to make sure it works properly. Here is a rough breakdown of the grading:
| UDP Server | 40% |
| UDP Client | 40% |
| Error handling, Style/Code structure, etc. | 20% |
NOTE: 20% of your homework grade depends on the how well your code is written. These points include the following:
How well we can understand your code. There is no required format for your code, there is no requirement like "you must have one comment for every 5 lines of code". Feel free to provide whatever level of commenting you believe is appropriate to make sure that other competent programmers could easily understand and make changes to your code.
All files must be submitted via handin command on any Unix machine in the department as follows:
> handin.360.2 4 file1 file2 file3 ...
Please make sure you submit all your source files not the object files. You can also zip the files using the following command first:
> tar cvzf hw4.tgz file1 file2 file3 ...
and submit the single zip file hw4.tgz. Before you submit this single file, please use the following command to check make sure you have everything in this zip file:
> tar tvzf hw4.tgz
Don't send compiled code! Please ask question if you don't understand any part of this project.