Tuesday, January 14, 2020
Website report
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. Therefor e, It was put In as credit to Initialize the network layer with the same number of buffers. Implementation of classes and functionsTwo 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 a cknowledgement. 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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.