How to use. When the program starts, it asks for an inputcommand. Press 1 to be prompted to enter a message and send it to the server. The program will perform a 3-way handshake and will print the message received by the server. Press 2 to emulate the handling of message reordering. The program will perform a 3-way handshake and send a slice of unordered integers. The server will sort the slice and print the contents.
a) We use struct to imitate packets. They contain the metadata in the form of hashcode, sender, sync and ack count. the data itself, we use strings to send a message.
b) We use threads. its not realistic cause they are part of the same process, where as with a real network consists of multiple processes.
c) We are not actually handling message reordering. Instead we are simulating it through a premade int slice that we reverse. The server will then sort this array when it has been received. In reality the server would not receive an int slice, but packets with headers containing an int indicating said packets index.
d) We hash the complete message string, and send it with the packet. the server then hashes the received message and compares the 2 hash results. if they are the same, it sends a confirm order to the client, otherwise the client resends the packet until it receives a confirmation or times out.
e) To make sure that the connection works both ways and to ensure data will be sent and received.