Fall 2016 CSE30264 Programming Assignment 2 - Simple UDP Server


Total Points: 50 points
Goal: Write a simple UDP network server
Assigned: September 14, 2016
Due: September 26, 2016 by the beginning of class
Grouping: To be developed individually


Background

You will be writing your own UDP server program for the client you have developed in programming assignment 1.

Problem:

Write a simple UDP server which provides the functionality of the server which we provided for your use in programming assignment 1. Your server should accept two command line arguments.
The server needs to finish the following tasks:
  1. The server will use the appropriate port given by the command line argument and receive the message from a client.
  2. The server will append a microsecond accurate time-stamp (e.g., Timestamp: 20:11:14.918623) to the message received from the client (hint: look at time(), localtime() and gettimeofday() functions in Linux/Unix), and encrypt the whole message using the simple encryption algorithm described below.
  3. The server will send the actual encrypted message back to the client. The server will then in a separate message send the encryption key to the client as well.
  4. The server should then loop, and wait for the next incoming client connection.

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: If the message is longer than the key, using the modulo will artificially extend the key. Also, the XORing could result in some characters being encrypted as a null character. Make sure the entire response is sent by determining the size of the message to be sent before encryption.
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.

Your code should not generate any console messages unless a “fatal” error occurs (can't open socket, can't connect to client, ...). In the event of such errors, your server should exit with an appropriate error code. You may wish to add a debug flag to assist you in by printing debugging information, but the debugging information should be “off” by default when you turn in your code. Servers that output debugging code will lose points.

You need to make sure that your code compiles and executes on the student 02/03 machines, and test it with your client code from programming assignment 1 on student 00/01 machines. Please do not leave orphan copies of your server and client code running on the student machines, otherwise you might lose points. You can check for orphan copies by using the command: ps -ef | grep "your assigned port number". To stop an orphan copy, take note of the pid and use the command: kill pid.

There are three test files in: /afs/nd.edu/coursefa.16/cse/cse30264.01/files/program1/ . You need to test your program using these test files or a random input string from the client. For example (xxxx is the assigned port number you use for your server, please refer to the appendix):

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

Homework Submission

Create a README file that contains a complete listing / explanation of what files are present in the directory and a commandline example to run your code.

Your source code file must contain your name and netid or it will not be graded. Create a program2 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. Please also upload a copy of the client code you used to test your server to the "program2" folder.

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.

Evaluation Rubric (50 pts)

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

The points for the assignment are as follows:

Use the port number corresponding to your name in the appendix below.

Name Port Number
Aiello, Nicholas 41001
Beaufils, Christopher 41002
Brombach, Theodore 41003
Chang, Timothy 41004
Connolly, Mary 41005
Considine, John 41006
Crawfis, Aaron 41007
Davis, Kurt 41008
Diaz-Ortiz, Jorge 41009
Dowling, Paul 41010
Dumford, Jacob 41011
Ferrara, Lauren 41012
Freedy, Robert 41013
Garrison, Luke 41014
Haydel, Nicholas 41015
Hillmer, Michael 41016
Hutchinson, Michael 41017
Jbara, Cory 41018
Kassman, Jacob 41019
Kearney, Reilly 41020
Keenan, Ann 41021
Klamer, John 41022
Kuta, Lauren 41023
Le, Harrison 41024
Lewis, David 41025
Lubera, Andrew 41026
McMullen, Ryan 41027
Nelson, Madelyn 41028
Nolan, John 41029
Obaditch, Emily 41030
Paulson, Matthew 41031
Perez, Matthew 41032
Reilly, Matthew 41033
Riordan, John 41034
Rocha, John 41035
Rodgers, Jared 41036
Ryan, James 41037
Ryan, John 41038
Sammons, Tyler 41039
Schurr, Patrick 41040
SuarezMartinez, Jose 41041
Syers, Christopher 41042
Tan, Rosalyn 41043
Vista, Elizabeth 41044
Vuong, Alan 41045
Walsh, Maxwell 41046
Ward, Nicholas 41047
Wilson, Jenna 41048