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:
Also write a simple UDP server that takes in:
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:
  1. The client generates a public key using char* getPubKey(), connects to the server, and sends it its public key
  2. 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.
  3. 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.
  4. 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.
  5. 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:

Helpful Links

*Socket Programming in Linux : Beej's Guide to Network Programming and UDP Socket Example
*Public-key Cryptography : Public Key and Private Keys and Wikipedia Link



Appendix

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

Table 1. Port Assignments
TCP Port to UseName
41001Abrar Ahmed
41002Sam Alptekin
41003Alejandro Rafael Ayala
41004Jacob Beiter
41005James Bodeau
41006James Bonadonna
41007Patrick Bouchon
41008Elisabetta Caldesi
41009Meghan Cullen
41010Joseph DiMaria
41011Kevin Dingens
41012Quang Do
41013Steven Eisemann
41014Brandon Fite
41015Angelica Franco
41016William Fritz
41017Michelle Galbavy
41018Justin Garrard
41019Maria Gund
41020Jessica Hardey
41021Libertad Heredia
41022Sarah Hynds
41023Joshua Johnson
41024Grace Kopp
41025Kendyll Kraus
41026Sophie Lancaster
41027Jose Leon
41028Ale Lopez
41029Anthony Luc
41030Donald Luc
41031Kelly Malecki
41032Ryker McIntyre
41033Stephen Meisenbacher
41034John Meyer
41035Grace Milton
41036Josefa Osorio
41037Molly Pierce
41038Thomas Plummer
41039Allison Raines
41040Marcus Schimizzi
41041Madalyn Schulte
41042Benjamin Shadid
41043Abigail Shirey
41044Rita Shultz
41045Anna Smith
41046Kwan Ho Herman Tong
41047John Villaflor
41048Michael Wang
41049Daniel Wilborn
41050Roann Yanes