feat: add ResetRTO API for immediate recovery#344
Open
lonnywong wants to merge 1 commit into
Open
Conversation
Implement `ResetRTO` at both the `KCP` and `UDPSession` levels to reset retransmission timers for all unacknowledged segments. When network connectivity is restored after an interruption, existing retransmission timers might have exponentially backed off, causing unnecessary delays. This feature allows the application layer to hint the underlying session to reset the RTO and schedule retransmissions immediately. By design, `UDPSession.ResetRTO()` avoids a synchronous `flush` to prevent immediate I/O bursts and minimize lock contention. The actual retransmissions are naturally picked up by the background `update()` tick, governed by the configured `interval` (e.g., 10ms-100ms via SetNoDelay), providing a smooth and predictable recovery.
lonnywong
added a commit
to trzsz/kcp-go
that referenced
this pull request
Jun 20, 2026
Changed the module path directly instead of using a replace directive, as `go install` does not support `go mod replace`. This ensures downstream users can install and build the binary properly via `go install`. We will consider switching back to the upstream repository if the maintainer merges the PR (kcp-go#344) in the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #343.
Introduces
ResetRTO()to help applications quickly resume data delivery once they detect that network connectivity has been restored.This is highly beneficial in mobile or volatile network environments. When the application detects link restoration (e.g., cellular to Wi-Fi handover) via out-of-band signals, it can use this API to resume data delivery immediately without waiting for long penalizing RTO timers to expire.