Fall 2016 CSE30264 Programming Assignment 1 - Simple UDP Client


Total Points: 50 points
Goal: Refresh how to compile code, gain experience with network syscalls
Write a simple UDP network client
Assigned: September 5, 2016
Due: September 14, 2016 by the beginning of class
Grouping: To be developed individually


Background

You will be writing a simple UDP client program. The program will read in a file or a string from the command line, send the file to the server, then receive an encrypted copy of the file with a time-stamp back from the server. You also need to compute the round-trip-time (RTT) of your messages.
The server code is up and running for you in order to test your code. There are two servers you need to test against. The server info is as follows:
Host1 student02.cse.nd.edu Port 41100 (UDP)
Host2 student03.cse.nd.edu Port 41100 (UDP)

Problem:

Write a simple UDP client that takes in three command line inputs:
The client needs to finish the following tasks:
  1. The client should first read the file (or string) into a temporary buffer (please set the size of the buffer to be no smaller than 4096 characters in this assignment) and send the content of the buffer to the server. (The server will in turn receive the file, append a time-stamp, encrypt the whole response message (i.e., received message + timestamp) using a simple encryption algorithm described below and send the message back to your client. The server will also send the encryption key back to the client in a separate message.)
  2. The client will receive the encrypted message and the encryption key from the server in two separate messages. The client will then use the key to decrypt the message and show the original message from the server.
  3. The client also needs to compute the round trip time (RTT) of the message (i.e., the time difference between when the client sends out the original message and when the client receives the encrypted message from the server). The RTT time should be calculated in the resolution of microsecond.
  4. Your code should display the resulting response from the server and the RTT time to the screen, and exit.
The encryption algorithm implemented at the server is simple: for each character in the sending buffer, XOR it with the appropriate character in the key. The pseudocode is as follows:

for each char resp[x] in the sending buffer resp
     resp[x] becomes the character created by XORing resp[x] with key[x modulo key length]
end for


Remember, the modulo operator (%) calculates the remainder. Note: The XORing could result in some characters being encrypted as a null character (which can be interpreted as the end of a string). Make sure you check the number of bytes of the encrypted message the client received from the server and use that to decrypt the entire message (hint: the return value of the receive function). Also note: the server use the above algorithm to encrypt everything in the sending buffer, so your client code should implement a decryption algorithm to decrypt everything in the receiving buffer to get the right message.

DO NOT output any debugging information, or other informational messages to the screen. Doing so will cost you points!

There are three test files in: /afs/nd.edu/coursefa.16/cse/cse30264.01/files/program1/
You need to run your program using these test files and a random command line string. For example:

[netid@student00 ~] $ ./udpclient student02.cse.nd.edu 41100 File1.txt
[netid@student00 ~] $ ./udpclient student03.cse.nd.edu 41100 "This is a test"

Note: The client and server should be executed on different student machines (e.g., the server is running on student 02/03, then the client should be tested on studdent 00/01).

Homework Submission

Create a README file that contains a complete listing / explanation of what files are present in the directory and the instructions to run your code (e.g., give a command line example to test your code with a sample file or random string).

Create a program1 directory in your dropbox (i.e., /afs/nd.edu/coursefa.16/cse/cse30264.01/dropbox/yournetid), and copy your .c or .cpp file, and your README file to this dropbox. Your source code file must contain your name and netid or it will not be graded.

Note that you do not need a Makefile for this code as it should be self-contained within a single file, but you are free to submit one.

Your code will be evaluated on one of the student00/01 machines based on the following evaluation rubric.

Evaluation Rubric (50 pts)

The points for the assignment are as follows:

Helpful Links

*Socket Programming in Linux : http://beej.us/guide/bgnet/ and https://www.cs.rutgers.edu/~pxk/417/notes/sockets/udp.html