Spring 2022 IS496 Programming Assignment 1 - Simple Secure 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: January 31, 2022
Due: February 21, 2022 by the end of day (11:59 pm CST). Grouping: To be developed by a group. Note: This instruction is based on Python. The C/C++ version is available here.
You will be writing a simple and secure communication protocol using UDP client and server. The program will build a UDP connection between 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 the timestamp when it receives the message. You also need to compute the round-trip-time (RTT) of your message. More background information about public key encryption and socket programming is provided in the "Helpful Links" section at the end of this document.
Part 1: UDP Practice
In the first part of this assignment, you are asked to build a simple UDP server and client where the server can successfully 1) establish the connection with the client, and 2) send a string (e.g., "Hello World") to the client. The finished code for Part 1 can also be used for Part 2 of this assignment.
We have provided an optional starter skeleton code to get you started on the right track.
The starter code files (i.e., udpserver.py and udpclient.py) can be downloaded from here. Please refer to the "Running the programs on student machines" subsection for additional details about how to test your program on the student machines.
Part 2: Simple Secure UDP Program
Write a simple UDP client that takes in:
The hostname of the server (argument 1).
The port number on the server (argument 2).
The text to be sent (argument 3).
Also write a simple UDP server that takes in:
The port number to listen on (argument 1).
The library pg1lib.py (provided) contains the following methods:
Generate and return an encryption key
bytes: this host's encryption key
Encrypt a message with peer's encryption key
message (bytes): plaintext message to encrypt
pubkey (bytes): peer's encryption key (formatted as output to getPubKey())
bytes: base64 encoded ciphertext
""" encrypt(message, pubkey)
Decrypt a message with this host's private key
cipher (bytes): plaintext message to encrypt
bytes: decrypted plaintext message
Calculate the checksum for the input data
data (bytes): the data to process
int: the checksum
Note: You do not need to implement the encryption/decryption and checksum functions listed above, as they are provided in the file pg1lib.py. You can download it from here.
If you are not familiar with public key cryptography, please refer to the links provided in the "Helpful Links" section.
The following protocol is to be implemented in your assignment:
The client reads the host name, port number, and the message to be sent from the user input.
The client generates a public key using getPubKey(), connects to the server, and sends it its public key.
The server generates its own public key (also using getPubKey()), encrypts it using the client's public key and the method encrypt(message, pubkey), and sends the encrypted key as a response back to the client.
The client decrypts the server's public key (decrypt(cipher)).
It then calculates a checksum for the message (using checksum(data)), and prints the checksum to the screen. It then encrypts the message using the server's public key ( encrypt(message, pubkey)). The client then sends both the encrypted message and the checksum to the server. (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 server receives the encrypted message as well as the checksum. It decrypts the message (using decrypt(cipher)), and prints both the message and the received checksum to the screen.
Then it calculates the checksum with checksum(data) from the decrypted message, prints it, and compares it with the received checksum. If the checksum matches, the server sends a confirmation to the client (e.g., an integer of value 1). If the checksum does not match, the server reports an error message, and acknowledges the client (e.g., an integer of value 0).
The client receives the response message from the server, and calculates the round-trip-time (RTT), in microseconds, from the time it sent the message to when it received a response. If the response message confirms the server has received the message without errors (e.g., an integer of value 1), print the RTT to the screen; otherwise, report an error message.
Note: a suggested buffer size is 1024 characters in this assignment.
DO NOT output any debugging information, or other informational messages to the screen. Doing so will cost you points!
Running the programs on student machines
You need to run your program using a random command line string. For example:
Server [netid@is-student02 ~] $ python3 udpserver.py [port]
Note: The client and server should be executed on different student machines (e.g., if the server is running on student 00, then the client should be tested on student 01/02/03). You may use the port numbers assigned to any of your group members to test your code (refer to appendix A).
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).
Upload a gzipped tar file containing your .py files, pg1lib.py, and your README file to the corresponding assignment on Canvas. One submission per group is sufficient. Your source code files must contain the name and netid of each group member or it will not be graded.
Note: The default version of Python 3 on student machines is 3.8.10, and is located at /usr/bin/python3.
Please also specify your Python version in your readme file if your code is written a version different from Python 3.8.
Your code will be evaluated on the student 00/01/02/03 machines based on the following evaluation rubric.
Evaluation Rubric (100 pts)
The points for the assignment are as follows:
Part 1: 20 pts
[10 pts] Code successfully establishes the UDP connection between the server and client.
[10 pts] Code successfully sends a string from the client to the server.
Part 2: 80 pts
Code mechanics (35 pts total)
[5 pts] Code was properly submitted.
[5 pts] Code runs without warnings or errors.
[10 pts] Code executes error-free with the correct order / specification for arguments.