Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce minimum retransmission timeout (RTO) #1037

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/freenet/node/PeerNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -3190,7 +3190,7 @@ public double averagePingTime() {
/** Calculated as per RFC 2988 */
@Override
public synchronized double averagePingTimeCorrected() {
return RTO;
return RTO;
}

@Override
Expand Down Expand Up @@ -4105,7 +4105,7 @@ public static boolean shouldThrottle(Peer peer, Node node) {
}

static final long MAX_RTO = SECONDS.toMillis(60);
static final long MIN_RTO = SECONDS.toMillis(1);
static final long MIN_RTO = 50;
private int consecutiveRTOBackoffs;

// Clock generally has 20ms granularity or better, right?
Expand Down Expand Up @@ -4135,19 +4135,19 @@ public void reportPing(long t) {
reportedRTT = true;
if(logMINOR) Logger.minor(this, "Received first packet on "+shortToString()+" setting RTO to "+RTO);
if(oldRTO > RTO) {
// We have backed off
// After resetting RTO and starting from scratch,
// RTO is lower again, so the old time may have
// been inflated by temorary failure.
if(logMINOR) Logger.minor(this, "Received first packet after backing off on resend. RTO is "+RTO+" but was "+oldRTO);
// FIXME: do something???
}
} else {
// Update
RTTVAR = 0.75 * RTTVAR + 0.25 * Math.abs(SRTT - t);
SRTT = 0.875 * SRTT + 0.125 * t;
RTO = SRTT + Math.max(CLOCK_GRANULARITY, RTTVAR * 4);
// RFC 2988 specifies a 1 second minimum RTT, mostly due to legacy issues,
// but given that Freenet is mostly used on very slow upstream links, it
// probably makes sense for us too for now, to avoid excessive retransmits.
// FIXME !!!
// but given that ping times inside a country (where we expect most friend-connections)
// are at a max of 50ms in 2025, we use 50ms to reduce the effect of packet loss.
if(RTO < MIN_RTO)
RTO = MIN_RTO;
if(RTO > MAX_RTO)
Expand Down
Loading