Open In App

Karn’s Algorithm For Optimizing TCP

Improve
Improve
Like Article
Like
Save
Share
Report

Karn’s approach solves the issue of obtaining accurate round-trip time estimates for messages while utilizing the Transmission Control Protocol (TCP) in computer networking. Phil Karn and Craig Partridge proposed the technique, commonly known as the Karn-Partridge algorithm, in 1987.

Because of the ambiguity produced by retransmitted segments, accurate round-trip estimates in TCP might be difficult to determine. The round trip time is calculated as the difference between the time a segment was sent and the time its acknowledgment was returned to the sender, but there is an ambiguity when packets are re-transmitted: the acknowledgment may be a response to the first transmission of the segment or to a subsequent re-transmission.

When adjusting the round-trip time estimation, Karn’s Algorithm ignores retransmitted segments. Only unambiguous acknowledgments, which are acknowledgments for segments delivered only once, are used to estimate round trip time.

This overly simplified implementation of Karn’s algorithm may also cause issues. Consider what occurs when TCP sends a segment after a significant delay increase. TCP computes a timeout and retransmits a segment based on the previous round-trip time estimate. If TCP ignores the round-trip time of all retransmitted packets, the round-trip estimate is never updated, and TCP continues to retransmit every segment, never adjusting to the increased delay.

 

Need of Karn’s Algorithm

Karn’s Algorithm improves TCP behavior in less-than-ideal network situations. We can identify network issues as they develop by continuously tracking changes in RTOs and RTT, and then rapidly pinpoint where we can repair the problems. Perhaps then we will see less of Karn’s Algorithm and slightly better performance from the applications we support. When a packet is retransmitted, a problem occurs. If the packet is resent, a timeout occurs, and the RTO is rolled back. An acknowledgment is obtained once the packet is retransmitted with the longer RTO. Whether it is the first or second broadcast, the received acknowledgment remains the same. The problem is known as retransmission ambiguity.

How Karn’s Algorithm Works

When a sender retransmits a packet and receives an acknowledgment (ACK) for the data, the retransmission ambiguity problem emerges. The sender is unsure if the ACK received was for the original (said lost) packet or the reissued packet. The RTT sample is much longer than the current SRTT value if the receiver acknowledges (ACK) the originating packet. If the receiver acknowledges the retransmitted packet (ACK), RTT is likely closer to the current SRTT value, and the original packet or ACK was lost. To avoid wrongly skewing SRTT, the first section of Karn’s Algorithm stipulates that when there is retransmission ambiguity, RTT values are disregarded rather than being integrated into SRTT.

TCP assigns a “backoff factor” to each RTO for each retransmission, so successive retransmission timings are double the previous. The backoff factor is not reset until a successful data transmission occurs that does not necessitate retransmission. These algorithms, when combined, form the second part of Karn’s Algorithm. This procedure prevents the network from being overwhelmed with duplicate packets, allowing it to recover from any congestion concerns. It also ensures that vital RTT information is not lost. Because data is retransmitted, the first section of Karn’s Algorithm ignores all RTT values during the RTO backoff. When data is successfully transmitted without retransmission, the accompanying RTT measurement, which is most likely close to the current RTO value, can be added into SRTT.


Last Updated : 09 Mar, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads