Skip to content

Commit cb4221e

Browse files
committed
Reduce minimum retransmission timeout (RTO)
Maximum ping times between Frankfurt consistently stay below 50ms, so since most friend nodes will be in the same country, a minimum RTO of 1 second will likely inflate latency unnecessarily.
1 parent f818f19 commit cb4221e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/freenet/node/PeerNode.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4105,7 +4105,7 @@ public static boolean shouldThrottle(Peer peer, Node node) {
41054105
}
41064106

41074107
static final long MAX_RTO = SECONDS.toMillis(60);
4108-
static final long MIN_RTO = SECONDS.toMillis(1);
4108+
static final long MIN_RTO = 50;
41094109
private int consecutiveRTOBackoffs;
41104110

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

0 commit comments

Comments
 (0)