What you have to implement
You have a message that can be sent on a port. Before sending the message you have to encode the
message to ASCII or Unicode as hexadecimal. Sending the message over the network as a continuous
string stream is quite simple. The recipient simply has to decode the hexadecimal string and will know
what the message is.
The problem must now be expanded as follows. Split the message in two and send it over the network to
another computer, where it receives the message over a range (predefined by yourself) of ports randomly.
You now have two parts of the message that need to be reconstructed to create the original message.
For instance, if your message is: “Adam ate the apple.” It should first be converted to a hexadecimal string
in either ASCII or Unicode. (% indicated the beginning of a new character.) The following is the new
hexadecimal string that has been converted to ASCII:
“%41%64%61%6D%20%61%74%65%20%74%68%65%20%61%70%70% 6C%65%2E%20”
Splitting the message in two renders the following two strings:
“%41%64%61%6D%20%61%74%65%20%74”
“%68%65%20%61%70%70%6C%65%2E%20”
Choosing a port range of 1000 – 1010, the message is split in two, randomly selecting two means that the
first string will be sent to port 1002 and the second to port 1007. The receiving computer gets two messages
on two different ports, not knowing the order. Decoding the message on the other side will render the
following two strings:
“Adam ate t”
“he apple.”
They will have to be reconstructed either as:
“Adam ate the apple.” or “he apple.Adam ate t”.
You have to ensure that the message is reconstructed as closely to the original message by using any
programmatic means possible. The difficulty of reconstruction increases as the message is split into
increasing number of chunks. 3 chunks over 3 ports will render 3 Permutation 3, resulting in 6 possible
permutations. nPn is the formula for the total number of permutations for n number of chunks. Make sure
that you are aware of the granularity of your message as it will have an influence on reconstruction. The
message “abc” might seem logical but you will not know what the original message is if it was divided into
3 chunks. Taking the same message and dividing it into two chunks will render another problem.
Bonus marks will be awarded for where ports are blocked by the receiving computer, these message chunks
will have to be resent to ensure that all the chunks have been received. You may make use of either UDP or
TCP transfer protocols. You may also make use of any Programming language that suits your needs. Code
reuse is one of the OO characteristics that you should make use of in this project.