Fall 2018 CSE30264 Programming Assignment 1 - Simple UDP Program
Total Points: 100 points
Goal: Refresh how to compile code, gain experience with network syscalls
Write a simple UDP network client and server
Assigned: September 3, 2018
Due: September 17, 2018 by the beginning of class. Grouping: To be developed individually.
Background
You will be writing a simple UDP client and server. The program will build a UDP connection between the two hosts and exchange encryption keys. The client will then send an encrypted message to the server. The server will decrypt the message and reply with a checksum of the received message. You also need to compute the round-trip-time (RTT) of your messages. More background information about public key encryption and socket programming is provided in "Helpful Links" section at the end of this handout.
Problem:
Write a simple UDP client that takes in:
The host name of the server (argument 1).
The port number on the server (argument 2).
The text to send (argument 3). Note that arg3 could be a string or a file name. You need to handle both.
Also write a simple UDP server that takes in:
The port number to listen on (argument 1).
The library pg1lib.h (provided) contains the following methods:
/* Generate and return an encryption key
* (won't generate a new one if one exists already)
* return: this host's encryption key
*/
char* getPubKey();
/* Encrypt a message with peer's encryption key
* char *message: plaintext message to encrypt
* char *pubkey: peer's encryption key (formatted as output to getPubKey())
* return: base64 encoded ciphertext
*/
char* encrypt(char *message, char *pubkey);
/* Decrypt a message with this host's private key
* char *cipher: base64 encoded ciphertext
* return: decrypted plaintext message
*/
char* decrypt(char *cipher);
/* Calculate the checksum for the input data
* char *data: the null terminated data to process
* return: the checksum as an unsigned long
*/
unsigned long checksum(char *data);
Note: You do not need to implement the encryption/decryption and checksum functions listed above, as they are provided in the file /afs/nd.edu/coursefa.18/cse/cse30264.01/files/program1/pg1lib.h. Feel free to copy pg1lib.h to your own directory. Two libraries must be linked: -lcrypto and -lz when you compile the pg1lib.h. If you are not familiar with public key cryptography, please refer to the links provided in "Helpful Links" section.
The following protocol is to be implemented in your assignment:
The client generates a public key using char* getPubKey(), connects to the server, and sends it its public key
The server generates its own public key (also using char* getPubKey()), encrypts it using the client's public key and the method char* encrypt(char *message, char *pubkey), and sends the encrypted key as a response back to the client.
The client decrypts the server's public key (char* decrypt(char *cipher)). It then reads a file (or string) into a temporary buffer (please set the size of the buffer to be no smaller than 4096 characters in this assignment), calculates a checksum for the message (using unsigned long checksum(char *data)), and prints the checksum to the screen. It then encrypts the message using the server's public key ( char* encrypt(char *message, char *pubkey)) and sends the encrypted message over the network.
The server receives and decrypts the message (using char* decrypt(char *cipher)), calculates the checksum with unsigned long checksum(char *data), and prints both the message and the checksum to screen. It then sends the checksum back to the client (the checksum does not need to be encrypted as it cannot be used to reconstruct the original message.). Hint: The checksum is an unsigned long, and you will need to take into account endianness to transmit it correctly.
The client calculates the round-trip-time (RTT), in microseconds, from the time it sent the message to when it received a response. It also verifies that the server has received the message without errors by comparing the reported checksum with what it had calculated in step c. It prints both the checksum and the RTT to the screen.
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.18/cse/cse30264.01/files/program1/
You need to run your program using these test files and a random command line string. For example:
Server [netid@student02 ~] $ ./udpserver 41100
Client [netid@student00 ~] $ ./udpclient student02.cse.nd.edu 41100 File1.txt [netid@student00 ~] $ ./udpclient student02.cse.nd.edu 41100 "This is a test"
Note: The client and server should be executed on different student machines (e.g., if the server is running on student 02, then the client should be tested on student 00/01/06).
Demo
Submission
Create a README file that contains a complete listing / explanation of what files are present in the directory and the instructions to compile and 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.18/cse/cse30264.01/dropbox/yournetid), and copy your .c or .cpp file, pg1lib.h, 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 are encouraged to submit a Makefile for your code. If you do not submit one, please make sure to include the instructions on how to compile your code in your README file.
Your code will be evaluated on one of the student 00/01/02/06 machines based on the following evaluation rubric.
Evaluation Rubric (100 pts)
The points for the assignment are as follows:
25 pts - Code mechanics
2 pts - Code was properly submitted.
3 pts - Code compiles without warnings or errors.
10 pts - Code executes error-free with the correct order / specification for arguments.
5 pts - Code has an appropriate comment block explaining the code, and your name.
10 pts - Code correctly uses the encryption and decryption functions.
10 pts each - Code obtains correct results when run using the three test files.
10 pts - Code obtains proper results when run with a random command line string as input.
10 pts - Code obtains proper results of the RTT time
10 pts - Code obtains proper results of the checksum
5 pts - README file is present and correctly documented including the instructions to run your code (e.g., give a command line example to test your code with a sample file or random string)