From owner-freebsd-net@FreeBSD.ORG Tue Mar 1 12:25:25 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB8451065677 for ; Tue, 1 Mar 2011 12:25:25 +0000 (UTC) (envelope-from dhartmei@insomnia.benzedrine.cx) Received: from insomnia.benzedrine.cx (106-30.3-213.fix.bluewin.ch [213.3.30.106]) by mx1.freebsd.org (Postfix) with ESMTP id 0BD448FC23 for ; Tue, 1 Mar 2011 12:25:24 +0000 (UTC) Received: from insomnia.benzedrine.cx (localhost.benzedrine.cx [127.0.0.1]) by insomnia.benzedrine.cx (8.14.1/8.13.4) with ESMTP id p21C5esZ027102 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Tue, 1 Mar 2011 13:05:40 +0100 (MET) Received: (from dhartmei@localhost) by insomnia.benzedrine.cx (8.14.1/8.12.10/Submit) id p21C5d44008944; Tue, 1 Mar 2011 13:05:39 +0100 (MET) Date: Tue, 1 Mar 2011 13:05:39 +0100 From: Daniel Hartmeier To: Saurav Dasgupta Message-ID: <20110301120539.GB3446@insomnia.benzedrine.cx> References: <6072DA4A344C23459096E69EB3F4570D020B03B5BD@GUREXMB02.ASIAN.AD.ARICENT.COM> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6072DA4A344C23459096E69EB3F4570D020B03B5BD@GUREXMB02.ASIAN.AD.ARICENT.COM> User-Agent: Mutt/1.5.12-2006-07-14 Cc: "freebsd-net@freebsd.org" Subject: Re: TCP Buffer window size is not getting updated X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Mar 2011 12:25:25 -0000 On Tue, Mar 01, 2011 at 02:49:29PM +0530, Saurav Dasgupta wrote: > TCP session is up. By default the rx buffer window size is 64k.Traffic flow is fine. When the buffer size is increased while connection is up, rx buffer window size is updated automatically with the new value. > But if we decrease the buffer size below the default value i.e. 64k, window size is not getting updated. To get it updated, we need to prune the connection and setup with the new value(which is lesser than the default window size). You mean you're decreasing SO_RCVBUF with setsockopt(2) on an already established connection? I'm not sure that is well-defined in Posix, the usual case is setting SO_RCVBUF once before connect(2), changing it afterwards is probably implementation-defined and not portable, at least a brief search shows similar issues on other OSs. Looking at sys/netinet/tcp_input|output.c, it looks like the expected case is only when the buffer increases (potentially automatically with SB_AUTOSIZE), and window updates are only triggered by increasing windows. Are you only missing explicit window updates, or do you see th_win in ACKs not adjusting? There's also the question of what should happen when you start with a default buffer size, advertise that to the peer, and then (while the peer is sending segments), you decrease the buffer size. This could cause the peer to accidentially violate the (shorter) window, and you'd drop segments and cause retransmission. I haven't found the section in the TCP RFC that says you're even allowed to break a previous advertisement with a shorter, subsequent one. Also, if the default buffer size causes activation of window scaling (say, with a scaling factor of 2^7 or such), and you subsequently decrease the buffer size dramatically, you might end up with a permanent zero size window. Maybe you can explain why you are decreasing the receive buffer size on an established connection, what is the purpose or intended effect? Kind regards, Daniel