Yet another TCP fix

Eric Schenk (schenk@rnode84.cs.toronto.edu)
Wed, 17 Apr 1996 10:20:58 -0400


It seems my last patch to fix the initial values for sk->mdev
make the timeouts a bit too long. Looking at the BSD code
and rereading the Jacobson paper it seems that we haven't quite
been dealing with the initial rtt measurement correctly.
What should be happening is that the initial rtt measure should
set rtt and mdev such that rto = 3*rtt. The following patch
fixes this. This should fix the problem a few people have noticed
with Netscape connections failing too easily.

-- eric

---------------------------------------------------------------------------
Eric Schenk www: http://www.cs.toronto.edu/~schenk
Department of Computer Science email: schenk@cs.toronto.edu
University of Toronto

diff -u -r linux-1.3.90/net/ipv4/tcp_input.c linux/net/ipv4/tcp_input.c
--- linux-1.3.90/net/ipv4/tcp_input.c Tue Apr 16 23:10:30 1996
+++ linux/net/ipv4/tcp_input.c Wed Apr 17 02:19:42 1996
@@ -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.