Subject: Re: very slow TCP connection on localhost
To: Kevin Lahey <kml@patheticgeek.net>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-net
Date: 09/06/2006 10:05:36
On Tue, Sep 05, 2006 at 09:09:40PM -0700, Kevin Lahey wrote:
> On Tue, 5 Sep 2006 18:49:08 +0200
> Manuel Bouyer <bouyer@antioche.eu.org> wrote:
> 
> > On Tue, Sep 05, 2006 at 06:45:24PM +0200, Manuel Bouyer wrote:
> > > [...]
> > > Attached is the output of tcpdump -w on lo0 for this TCP connection.
> > 
> > With the file attached, this time. Sorry
> 
> Yow, that's a weird trace.  I was just going to suggest that you
> increase the socket buffer size, but that was before I saw the
> retransmissions and other stuff in the trace.  Could you make a
> trace that shows the three way handshake when the connection starts up,
> so we can see the window scaling that gets set up?

Not easy because I don't know when each backup will start, and they
use dynamic ports on both ends. And there is other traffic on
lo0.
But I suspect it's the same as if I start e.g a ssh connection.
So here is the tcpdump of a ssh connection startup on lo0:

vlaminck#/root>tcpdump -n -p -i lo0 port 22                                     tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo0, link-type NULL (BSD loopback), capture size 96 bytes
10:01:30.952621 IP 127.0.0.1.65244 > 127.0.0.1.22: S 2929409806:2929409806(0) win 32768 <mss 33152,nop,wscale 0,sackOK,nop,nop,nop,nop,timestamp 0 0>
10:01:30.952663 IP 127.0.0.1.22 > 127.0.0.1.65244: S 2945836783:2945836783(0) ack 2929409807 win 32768 <mss 33152,nop,wscale 0,nop,nop,timestamp 0 0,sackOK,nop,nop>
10:01:30.952675 IP 127.0.0.1.65244 > 127.0.0.1.22: . ack 1 win 32768 <nop,nop,timestamp 0 0>
10:01:30.965058 IP 127.0.0.1.22 > 127.0.0.1.65244: P 1:51(50) ack 1 win 32768 <nop,nop,timestamp 0 0>
10:01:31.159034 IP 127.0.0.1.65244 > 127.0.0.1.22: . ack 51 win 32768 <nop,nop,timestamp 1 0>


> (And, it'd be interesting to see what happens if you increase the socket
> buffer size.)

net.inet.tcp.sendspace and recvspace are set to 32k, but maybe one side
increases it to 64k, because I see with netstat:
tcp        0      0  localhost.65249        localhost.65248        ESTABLISHED
tcp        0  65536  localhost.65248        localhost.65249        ESTABLISHED

-- 
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
     NetBSD: 26 ans d'experience feront toujours la difference
--