Project 1: HELLO-ACK Protocol
Get started writing asynchronous network code
Project 1: Hello-Ack
Introduction
You are to develop an asynchronous program that implements the protocol below.
Hello-Ack Protocol
Each peer implements this protocol:
-
Over a single UDP socket on the default port 50000:
- Send an ASCII ‘HELLO’ message to all known peers (given on the command line)
- Send an ‘ACK’ message back to the source of every ‘HELLO’ message received
-
Once a peer has received an ‘ACK’ from all known peers and sent an ACK in response to the HELLO messages from all its peers,
- If the node has the lowest IP address of all the peers, it prints “DONE: ” followed by a comma separated list of the “(domain name, IP address)” of the source of each of the received ‘ACK’ message
- Else, it prints only “DONE”
Your program should print exactly one line of output. Either “DONE” or “DONE: [followed by the list specified above]”.
There must be NO extra debugging output, or you will lose points.
Your program should have a deterministic result, i.e., it should always find the correct solution and none of the peers should crash.
Your program
Your program, proj1
, must execute on the command line using the following command.
$ ./proj1 [-h] --peers PEERS [PEERS ...] [--port PORT] [--timeout TIMEOUT] [--verbose]
--peers
is required on the command line.
--port
, --timeout
, and --verbose
must be implemented, but are optional on the command line.
A Dockerfile
and Docker Compose file, proj1-compose.yml
, are supplied in the starter code. While you may change either file, the evaluation will use the supplied Compose file.
docker compose -f proj1-compose.yml up --build
docker compose -f proj1-compose.yml up
Asynchronous communication
We encourage you to write your code in an event-driven style, using select() or poll() on the datagram socket to which the peer is connected (see the starter code for an example). This will keep your code single-threaded, making debugging significantly easier. Alternatively, you can implement your router in a threaded model (with one thread handling each socket), but expect it to be substantially more challenging to debug.
Starter code
A template repository of fundamental starter code for the assignment in Python using Docker is available on the Khoury GitHub server. Provided is a simple implementation of a peer that opens a UDP socket, sends a HELLO message to its peers, and prints out every message it receives. You may use this code as a basis for your project if you wish.
Submitting Your Project
Your Dockerfile
, proj1-compose.yml
, and source code, etc. should all be placed in the root directory of a compressed archive (i.e., a .zip file) and then uploaded to Gradescope. Alternatively, you can check all these items into Khoury’s GitHub, download a zip file from Khoury’s GitHub, and submit that to Gradescope, or any other upload/submission option Gradescope permits. If your submission is missing any required file for evaluation, it will receive 0 points.
There is NO autograder for this project. Your submission will be evaluated by hand.
Grading
The grading of this project will be broken down as follows:
Item | Percentage of Grade |
---|---|
Program correctness | 50% |
Style and documentation | 50% |
Questions
Ask on Piazza or come to office hours (the TA’s or Prof. Jackson’s).