Prerequisites
- The assigned readings in module 5 on Canvas
- Lecture videos from Canvas/ or class
- Running and understanding the examples listed on the Canvas Module 5 page
Learning outcomes of this assignment are:
- Understand basics of Distributed Algorithms
- Evaluate distributed algorithms
- Understand the basics of Consensus algorithms
Preliminary things
I strongly advise you to work on Git and GitHub, to version control and also to practice. If you work on GitHub make sure your repository is private.
Submit your assignment as always on GitHub in the appropriate directory and as zip on Canvas .
What you definitely need: 15 points
This part has a lot of points for general things, please make sure to not miss these points.
- You will create one project from scratch, your program needs to have a useful build.gradle file
- A README.md
- Design your calls and user interaction in a way that they are easy.
- Include the command how we can run your program and in what order we need to call what in Gradle c) Explain your program
- Explain your protocol in detail (you can use any protocol type you want)
- Explain your encryption method
- Include a list of the requirements you think you fulfilled
- As always include a screencast that shows all your functionality – go through all requirements you fulfilled so we can already see it in your screencast if it works before we try it ourselves.
Distributed algorithm (85 points)
You start this activity from scratch. You can use example code from the example repo for inspiration.
The idea is to build a very simplified distributed algorithm network to encrypt a sentence. We also include a little simplified consensus algorithm. This is all very simplified just to give you a taste, you do not have to worry about security etc. but you should make sure your program is robust and well implemented.
Requirements
In here we will also grade with partial credit if you get part of it going and we can see these parts (based on when we run it, your Readme and your video). If we cannot run it we cannot award points.
You will need different parts that can be started:
- A Client: this is where the user interacts with the system.
- A Leader: this is where the Client sends a user request, a leader can be connected to many nodes.
- Nodes: all nodes have the same code, many nodes are connected to one leader.
The basic idea is that the user can input a sentence into the terminal of the Client and that request will be send to the Leader. The Leader will split up the sentence as numberOfSymbols/nodesInNetwork. The Leader will send a part of each sentence to a node to encrypt. What encryption you use does not matter as long as it is symbol by symbol (can be very simple). For example just a simple shift. Each Node uses the same encryption method. So no matter if the sentence is split up between 1 or 50 Nodes, the encrypted message should be the same. The Node will send the encrypted string back to the Leader.
The Leader will then do a check to make sure no Node is faulty. To do so the Leader will send over an encrypted part and the corresponding decrypted part to each Node (to a different one than the one that initially encrypt it) and the node needs to check if the decrypted matches the encrypted string. It will return a yes/no if it thinks the encryption is valid. Only when all nodes return “yes” will the Leader put the encrypted sentence back together and return it to the client.
See below for the requirements split up in more detail.
- (3 points) Leader can be started through gradlerunLeader
- (3 points) Client can be started through gradlerunClient
- (3 points) Nodes can be started through gradlerunNode−pPort = X−pLeaderPort = Y (port is its own port, leaderPort the leaders port)
- (3 points) At least 3 Nodes should always be connected to the Leader
- (2 points) Encryption should not work with less than 3 Nodes, Leader would just send an error message to the Client
- (5 points) The Leader should be able to handle up to 8 Nodes (you can do even more if you like)
- (4 points) Client connects to Leader, the Leader will then ask the Client for a sentence to encrypt. The Client needs to display that question and allow the user to enter a sentence. The sentence is then send back to the Leader
- (4 points) The sentence received is split up by the Leader based on the number of
Nodes. If the sentence cannot be split up evenly then split it up as best as possible
- (3 points) Leader sends each connected Node a part of the sentence (each Node gets a different part)
- (5 points) Leader should send it threaded so that the Nodes work in parallel on the encryption (imagine it is a really complicated encryption algorithm that takes a long time – in your case it is not complicated of course)
- (6 points) Node receives the part of the sentence and runs some encryption algorithm
(you choose which one – simple shift is fine)
- (4 points) Node sends the encrypted part of the sentence back to Leader
- (3 points) Leader receives the encrypted sentence parts
- Leader starts a consensus for double checking the result
- (5 points) Leader sends each Node an encrypted and the corresponding decrypted part of the sentence (make sure it is not the same as the Node initially had – you can just shift to the next node)
- (3 points) This sending also happens in threads
- (5 points) Node encrypts the string it gets and matches against the encrypted one it received. If it matches it sends back an ok (or yes).
- (8 points) Nodes can be faulty: with a Gradle flag -pFault=1 allow that the node encrypts a received String wrong, thus during this check no consensus is reached if a faulty node is in the network.
- (10 points) The Leader receives the answers, only when all vote “yes” will the encrypted message be put together again (make sure it is the correct order) and send to the Client where it is displayed.
- (13 points) If one node votes “no” (or more than one) you need to handle that since it means something if faulty. If the Leader catches this, then they should send a test String (from which it knows the encrypted answer) to the two Nodes which seem to have the discrepancy to check which one is faulty. It should receive an answer and should then eliminate the faulty Node from the Network. If both are faulty, remove both.
- (5 points extra) If there was an issue then run the encryption again, after the faulty node(s) were removed.
- Overall good error handling, no crashing, users are informed of what is going on.
Should go without saying. We might deduct up to 10% if this is bad.
Submission
Push your Assignment 5 folder to GitHub and paste the link to Canvas and also zip up the Assignment 5 folder and place it into your Canvas submission.





