Author: toad
Date: 2008-02-12 01:39:57 +0000 (Tue, 12 Feb 2008)
New Revision: 17803

Modified:
   trunk/freenet/src/freenet/node/KeyTracker.java
Log:
Resend after 2 RTTs, and re-resend after another 2

Modified: trunk/freenet/src/freenet/node/KeyTracker.java
===================================================================
--- trunk/freenet/src/freenet/node/KeyTracker.java      2008-02-12 00:57:14 UTC 
(rev 17802)
+++ trunk/freenet/src/freenet/node/KeyTracker.java      2008-02-12 01:39:57 UTC 
(rev 17803)
@@ -400,7 +400,7 @@

        long initialActiveTime(long now) {
                // Request an ack after four RTTs
-               activeDelay = fourRTTs();
+               activeDelay = twoRTTs();
                return now + activeDelay;
         }

@@ -452,9 +452,11 @@
         queueAck(seqNumber);
     }

-    public long fourRTTs() {
+    // TCP uses four RTTs with no ack to resend ... but we have a more drawn 
out protocol, we
+    // should use only two.
+    public long twoRTTs() {
        // FIXME upper bound necessary ?
-       return (long) Math.min(Math.max(500, pn.averagePingTime()*4), 5000);
+       return (long) Math.min(Math.max(500, pn.averagePingTime()*2), 2500);
     }

     protected void receivedPacketNumber(int seqNumber) {
@@ -1045,7 +1047,7 @@
     public int[] grabResendPackets(Vector rpiTemp, int[] numbers) {
        rpiTemp.clear();
         long now = System.currentTimeMillis();
-        long fourRTTs = fourRTTs();
+        long fourRTTs = twoRTTs();
         int count=0;
         synchronized(packetsToResend) {
             int len = packetsToResend.size();


Reply via email to