patch-1.3.91 linux/net/ipv4/tcp_input.c

Next file: linux/net/ipv4/udp.c
Previous file: linux/net/ipv4/raw.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.90/linux/net/ipv4/tcp_input.c linux/net/ipv4/tcp_input.c
@@ -92,14 +92,20 @@
 	 */
 	
 	m = jiffies - oskb->when;  /* RTT */
-	if(m<=0)
-		m=1;		/* IS THIS RIGHT FOR <0 ??? */
-	m -= (sk->rtt >> 3);    /* m is now error in rtt est */
-	sk->rtt += m;           /* rtt = 7/8 rtt + 1/8 new */
-	if (m < 0)
-		m = -m;		/* m is now abs(error) */
-	m -= (sk->mdev >> 2);   /* similar update on mdev */
-	sk->mdev += m;	    	/* mdev = 3/4 mdev + 1/4 new */
+	if (sk->rtt != 0) {
+		if(m<=0)
+			m=1;		/* IS THIS RIGHT FOR <0 ??? */
+		m -= (sk->rtt >> 3);    /* m is now error in rtt est */
+		sk->rtt += m;           /* rtt = 7/8 rtt + 1/8 new */
+		if (m < 0)
+			m = -m;		/* m is now abs(error) */
+		m -= (sk->mdev >> 2);   /* similar update on mdev */
+		sk->mdev += m;	    	/* mdev = 3/4 mdev + 1/4 new */
+	} else {
+		/* no previous measure. */
+		sk->rtt = m<<3;		/* take the measured time to be rtt */
+		sk->mdev = m<<2;	/* make sure rto = 3*rtt */
+	}
 
 	/*
 	 *	Now update timeout.  Note that this removes any backoff.
@@ -714,7 +720,7 @@
 	 * (2) it has the same window as the last ACK,
 	 * (3) we have outstanding data that has not been ACKed
 	 * (4) The packet was not carrying any data.
-	 * I've tried to order these in occurance of most likely to fail
+	 * I've tried to order these in occurrence of most likely to fail
 	 * to least likely to fail.
 	 * [These are the rules BSD stacks use to determine if an ACK is a
 	 *  duplicate.]

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this