Fall 2017 CSE30264 Programming Assignment 2 - Simple UDP Server


Total Points: 50 points
Goal: Write a simple UDP network server
Assigned: September 13, 2017
Due: September 25, 2017 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 wait for a greeting message from a client.
  2. Once the server receives the greeting message, it send the encryption key to the client.
  3. The server will receive a message in plaintext from a client.
  4. 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.
  5. The server will send the actual encrypted message back to the client.
  6. 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/06 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.17/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@student06 ~] $ ./udserver xxxx key
[netid@student00 ~] $ ./udpclient student02.cse.nd.edu xxxx File1.txt
[netid@student00 ~] $ ./udpclient student06.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.17/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/06 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
Aranguren, Maria 41001
Badart, Will 41002
Bailey, Conrad 41003
Boyd, Erica 41004
Branning, Royce 41005
Brosnan, Shane 41006
Bruscia, John 41007
Burke, Michael 41008
Byrne, Brian 41009
Carballo, Camila 41010
Cervantes, Esmeralda 41011
Chao, David 41012
Cunneen, Pierce 41013
Dalgarn, Benjamin 41014
DiFalco, Anthony 41015
Falvey, Patrick 41016
Farren, Michael 41017
Ferrara, Lauren 41018
Flanagan, Matthew 41019
Hale, Patricia 41020
Herring, Katricia 41021
Higgins, Connor 41022
Hoelting, Brianna 41023
Judson, Brenden 41024
Klenke, Collin 41025
Krueger, Randall 41026
Kusters, Madeline 41027
Lynch, Thomas 41028
Marin, Brent 41029
Marvin, James 41030
McGuinness, John 41031
Mellitt, David 41032
Michalec, Ryan 41033
Minondo, Antonio 41034
Mustipher, Sam 41035
Newell, Charles 41036
Parowski, Michael 41037
Pruitt, Mark 41038
Sherman, Bradley 41039
Simari, Robert 41040
Smick, Cameron 41041
Smick, Ryan 41042
Spencer, Joseph 41043
Syers, Laura 41044
Theisen, William 41045
Thiery, Louis 41046
Turley, Erin 41047