However, the sample code provided In the lecture notes is in C. Therefore, this mall task is divided into the following sub-tasks: Port the SSP code to Java Implement missing timer related classes and functions The following sections will cover these three sub-tasks. Porting the code Minor changes were made in order to change the syntax of the code to Java. As see_nor was not specified in the given files, it was replaced with into type. In the original code, to declare a frame named s, it used the following syntax:
However, to create a frame object in Java, the code was modified accordingly. The same change was made to the following code: The resulting code was shown below. The out_buff and event were not declared here because they were pre-set in the given code. In order to make the piece of code below work, credits were added as parameter. As a result, it was changed to NOR_BUFFS was the maximum buffer size (window size) that could be held to avoid redundant retransmission. Therefore, It was put In as credit to Initialize the network layer with the same number of buffers. Implementation of classes and functions
Two timer related classes were Implemented for different timer purposes. D Peacetimes Peacetimes was to monitor and time how long had passed since a packet was transmitted. Cacciatore Cacciatore was to monitor the expiration of an acknowledgement timer. Both of them extended from the Timer Task class and overrode the run method to generate cacciatore_event. On the other hand, five functions were implemented to complete the protocol. Private void start_timer(into see) The start_timer started a timer function for each packet transmitted. If a packet timer already existed, it was cancelled.
When the timer of a packet had expired (time_out), that packet would be required to resend. Private void stop_timer(see) The stop_timer was to cancel the timer of a packet when it was called. Private void start_jack_timer() The start_jack_timer was to set a timer for an acknowledgement. This was to ensure that the sender could receive an acknowledgement within a reasonable time constraint. Originally, an acknowledgement should take advantage of piggybacking to travel to the sender. However, when there was no outgoing packet back to the sender, retransmission might take place. This caused redundant retransmission.
Therefore, his timer was created. If it timed out, a separate acknowledgement would be sent to the sender to indicate the packet was received successfully. If there was already an acknowledgement timer, the current timer would be cancelled. Private void stop_jack_timer() The stop_jack_timer was to stop the acknowledgement timer if there already existed one. However, in order to get the timers work, two files were imported. Inc(mum) This Inc function simply incremented the input parameter’s value by 1 . As there implemented as (mum + 1) % (MAX_SEE + 1). This would ensure that the number would increment in a circular manner.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.Read more
Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.Read more
Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.Read more
Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.Read more
By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.Read more