From owner-freebsd-questions@FreeBSD.ORG Wed Aug 20 18:12:23 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 392191065689 for ; Wed, 20 Aug 2008 18:12:23 +0000 (UTC) (envelope-from mahan@mahan.org) Received: from ns.mahan.org (ns.mahan.org [67.116.10.138]) by mx1.freebsd.org (Postfix) with ESMTP id D15EA8FC1A for ; Wed, 20 Aug 2008 18:12:22 +0000 (UTC) (envelope-from mahan@mahan.org) Received: from widowmaker.local (crowTrobot [67.116.10.140]) by ns.mahan.org (8.13.6/8.13.6) with ESMTP id m7KIDp2h076221; Wed, 20 Aug 2008 11:13:52 -0700 (PDT) (envelope-from mahan@mahan.org) Message-ID: <48AC5E80.4000206@mahan.org> Date: Wed, 20 Aug 2008 11:12:16 -0700 From: Patrick Mahan User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.16) Gecko/20080707 Thunderbird/2.0.0.16 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: EdwardKing , freebsd-questions@freebsd.org References: <002501c90262$8e302420$3f83a8c0@neusofteaf5839> <48AB7A6A.7000100@mahan.org> <006c01c9026a$6d7a2480$3e83a8c0@neusofteaf5839> <48AB984C.6010607@mahan.org> <011d01c9027e$c8629ad0$3e83a8c0@neusofteaf5839> In-Reply-To: <011d01c9027e$c8629ad0$3e83a8c0@neusofteaf5839> Content-Type: multipart/mixed; boundary="------------090302000801010808030702" Cc: Subject: Re: How to set TCP parameter? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Aug 2008 18:12:23 -0000 This is a multi-part message in MIME format. --------------090302000801010808030702 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit EdwardKing presented these words - circa 8/19/08 9:39 PM-> > $sysctl net.inet.tcp.msl > net.inet.tcp.msl 30000 > > It is 30000ms or 30000s? > It's ms, basically it is 30*hz (see tcp_timer.h). So it is by default, 30 secs. > I want to modify it,because I met with following question: > > There is a server and a client,when client send a message to server,server can send a reply to client. The status of server and client is ESTABLISHED.Then I halt the client by press ctrl+c,I find the server status is CLOSE_WAIT and the client status is FIN_WAIT_2. Many minutes passed,I find the the server status still is CLOSE_WAIT and the client status still is FIN_WAIT_2. At last,the client status is disappeared,but the server status still is CLOSE_WAIT.Why the status of server isn't CLOSED? I am puzzled with it for a very long time. Would you tell the reason? This is going to require you digging into the TCP protocol (you can start with RFC-793 but I would also recommend some books on the subject, I prefer the Stevens book "TCP/IP Illustrated, Vol 1"). I've attached the TCP state diagram to this email for you. Let's look at what happens, we start with both the client and the server in the TCP state ESTAB Client Event Server ====== ====== ====== ESTAB ESTAB You issue a CTRL-C, causing the client to close the connection to the server. This causes the following: ESTAB->CLOSE ESTAB --> CLOSE->FIN_WAIT_1 ESTAB The TCP layer moves the connection to CLOSE state and sends a FIN to start connection tear down. The server receives the FIN. ESTAB <-- FIN_WAIT_1 ESTAB->CLOSE_WAIT On the server the reception of the FIN causes the TCP layer to send an ACK of the FIN and moves the connection to the CLOSE_WAIT state. FIN_WAIT_1->FIN_WAIT_2 CLOSE_WAIT What should be happening is that now the server should send a FIN in response, but either 1) it fails too or 2) it is lost in between. Eventually, the TCP layer on the client times out the FIN_WAIT_2 state and moves the connection to the CLOSED state. However, the server cannot move out of the CLOSE_WAIT state since it hasn't seen the ACK to it's FIN. There is no TCP variable in the FreeBSD implementation to change this (that I know of). I have seen this happen at times when there is a buggy NAT firewall between you and the server that causes the FIN from the server to get dropped. If you have control of both sides, you can do packet traces using tcpdump to see if the FIN from the server is ever sent or receive. It is possible that your client is dropping the packet itself. Good luck, Patrick > > Thanks. > > ----- Original Message ----- > From: "Patrick Mahan" > To: "EdwardKing" > Sent: Wednesday, August 20, 2008 12:06 PM > Subject: Re: How to set TCP parameter? > > >> >> EdwardKing presented these words - circa 8/19/08 7:14 PM-> >>> Yes,I want to modify spent in the "TIME_WAIT" state? How to realize it? >>> >>> I use sysctl to view TCP parameter,but it failed >>> $sysctl TCP_TIME_WAIT_INTERVAL >>> sysctl: unknown oid 'TCP_TIME_WAIT_INTERVAL' >>> >>> Where is wrong? >>> >> There is no such variable in the TCP protocol implementation on FreeBSD >> (that I can see). Instead, you can try to modify the TCP Maximum Segment >> Lifetime (sysctl net.inet.tcp.msl). TIME_WAIT should wait a maximum of >> 2*msl before timing out. However, changing it can adversly affect other parts >> of the protocol. >> >> Why do you want to modify it? >> >> Patrick >> >>> ----- Original Message ----- >>> From: "Patrick Mahan" >>> To: "EdwardKing" >>> Cc: "FreeBSD" >>> Sent: Wednesday, August 20, 2008 9:59 AM >>> Subject: Re: How to set TCP parameter? >>> >>> >>>> EdwardKing presented these words - circa 8/19/08 6:17 PM-> >>>>> How to set TCP parameters,such as tcp_time_wait_interval? >>>>> >>>> You should use 'sysctl'. See 'man 8 sysctl'. >>>> >>>> However, I don't see any time wait variables available via sysctl. Are you >>>> trying to modify the time spent in the "TIME_WAIT" state? >>>> >>>> Patrick >>>> >>>>> Thanks >>>>> >>>>> >>>>> ---------------------------------------------------------------------------------------------- >>>>> Confidentiality Notice: The information contained in this e-mail and any >>>>> accompanying attachment(s) is intended only for the use of the intended >>>>> recipient and may be confidential and/or privileged of Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying is strictly prohibited, and may be unlawful. If you have received this communication in error, please immediately notify the sender by return e-mail, and delete the original message and all copies from your system. Thank you. >>>>> ----------------------------------------------------------------------------------------------- >>>>> >>>>> _______________________________________________ >>>>> freebsd-questions@freebsd.org mailing list >>>>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions >>>>> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >>>>> >>>>> >>> >>> ---------------------------------------------------------------------------------------------- >>> Confidentiality Notice: The information contained in this e-mail and any >>> accompanying attachment(s) is intended only for the use of the intended >>> recipient and may be confidential and/or privileged of Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying is strictly prohibited, and may be unlawful. If you have received this communication in error, please immediately notify the sender by return e-mail, and delete the original message and all copies from your system. Thank you. >>> ----------------------------------------------------------------------------------------------- >>> >>> _______________________________________________ >>> freebsd-questions@freebsd.org mailing list >>> http://lists.freebsd.org/mailman/listinfo/freebsd-questions >>> To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >>> >>> > > > ---------------------------------------------------------------------------------------------- > Confidentiality Notice: The information contained in this e-mail and any > accompanying attachment(s) is intended only for the use of the intended > recipient and may be confidential and/or privileged of Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is not the intended recipient, unauthorized use, forwarding, printing, storing, disclosure or copying is strictly prohibited, and may be unlawful. If you have received this communication in error, please immediately notify the sender by return e-mail, and delete the original message and all copies from your system. Thank you. > ----------------------------------------------------------------------------------------------- > > --------------090302000801010808030702 Content-Type: text/plain; name="tcp-states.txt" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="tcp-states.txt" ClNlcHRlbWJlciAxOTgxICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgVHJhbnNtaXNzaW9uIENvbnRyb2wgUHJvdG9jb2wKICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgRnVuY3Rpb25hbCBTcGVjaWZpY2F0 aW9uCgoKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tKyAtLS0tLS0tLS1cICAgICAgYWN0aXZl IE9QRU4gIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICBDTE9TRUQgfCAgICAg ICAgICAgIFwgICAgLS0tLS0tLS0tLS0gIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICArLS0tLS0tLS0tKzwtLS0tLS0tLS1cICAgXCAgIGNyZWF0ZSBUQ0IgIAogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIHwgICAgIF4gICAgICAgICAgICAgIFwgICBcICBzbmQg U1lOICAgIAogICAgICAgICAgICAgICAgICAgcGFzc2l2ZSBPUEVOIHwgICAgIHwgICBDTE9T RSAgICAgICAgXCAgIFwgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgLS0tLS0tLS0t LS0tIHwgICAgIHwgLS0tLS0tLS0tLSAgICAgICBcICAgXCAgICAgICAgIAogICAgICAgICAg ICAgICAgICAgIGNyZWF0ZSBUQ0IgIHwgICAgIHwgZGVsZXRlIFRDQiAgICAgICAgIFwgICBc ICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFYgICAgIHwgICAgICAg ICAgICAgICAgICAgICAgXCAgIFwgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICArLS0tLS0tLS0tKyAgICAgICAgICAgIENMT1NFICAgIHwgICAgXCAgIAogICAgICAgICAg ICAgICAgICAgICAgICAgICAgICB8ICBMSVNURU4gfCAgICAgICAgICAtLS0tLS0tLS0tIHwg ICAgIHwgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tKyAgICAg ICAgICBkZWxldGUgVENCIHwgICAgIHwgIAogICAgICAgICAgICAgICAgICAgcmN2IFNZTiAg ICAgIHwgICAgIHwgICAgIFNFTkQgICAgICAgICAgICAgIHwgICAgIHwgIAogICAgICAgICAg ICAgICAgICAtLS0tLS0tLS0tLSAgIHwgICAgIHwgICAgLS0tLS0tLSAgICAgICAgICAgIHwg ICAgIFYgIAogKy0tLS0tLS0tLSsgICAgICBzbmQgU1lOLEFDSyAgLyAgICAgICBcICAgc25k IFNZTiAgICAgICAgICArLS0tLS0tLS0tKwogfCAgICAgICAgIHw8LS0tLS0tLS0tLS0tLS0t LS0gICAgICAgICAgIC0tLS0tLS0tLS0tLS0tLS0tLT58ICAgICAgICAgfAogfCAgIFNZTiAg IHwgICAgICAgICAgICAgICAgICAgIHJjdiBTWU4gICAgICAgICAgICAgICAgICAgICB8ICAg U1lOICAgfAogfCAgIFJDVkQgIHw8LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t LS0tLS0tLS0tLS0tLS18ICAgU0VOVCAgfAogfCAgICAgICAgIHwgICAgICAgICAgICAgICAg ICAgIHNuZCBBQ0sgICAgICAgICAgICAgICAgICAgICB8ICAgICAgICAgfAogfCAgICAgICAg IHwtLS0tLS0tLS0tLS0tLS0tLS0gICAgICAgICAgIC0tLS0tLS0tLS0tLS0tLS0tLS18ICAg ICAgICAgfAogKy0tLS0tLS0tLSsgICByY3YgQUNLIG9mIFNZTiAgXCAgICAgICAvICByY3Yg U1lOLEFDSyAgICAgICArLS0tLS0tLS0tKwogICB8ICAgICAgICAgICAtLS0tLS0tLS0tLS0t LSAgIHwgICAgIHwgICAtLS0tLS0tLS0tLSAgICAgICAgICAgICAgICAgIAogICB8ICAgICAg ICAgICAgICAgICAgeCAgICAgICAgIHwgICAgIHwgICAgIHNuZCBBQ0sgICAgICAgICAgICAg ICAgICAgIAogICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgIFYgICAgIFYgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIAogICB8ICBDTE9TRSAgICAgICAgICAgICAgICAg ICArLS0tLS0tLS0tKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICB8IC0tLS0t LS0gICAgICAgICAgICAgICAgICB8ICBFU1RBQiAgfCAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIAogICB8IHNuZCBGSU4gICAgICAgICAgICAgICAgICArLS0tLS0tLS0tKyAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIAogICB8ICAgICAgICAgICAgICAgICAgIENMT1NF ICAgIHwgICAgIHwgICAgcmN2IEZJTiAgICAgICAgICAgICAgICAgICAgIAogICBWICAgICAg ICAgICAgICAgICAgLS0tLS0tLSAgIHwgICAgIHwgICAgLS0tLS0tLSAgICAgICAgICAgICAg ICAgICAgIAogKy0tLS0tLS0tLSsgICAgICAgICAgc25kIEZJTiAgLyAgICAgICBcICAgc25k IEFDSyAgICAgICAgICArLS0tLS0tLS0tKwogfCAgRklOICAgIHw8LS0tLS0tLS0tLS0tLS0t LS0gICAgICAgICAgIC0tLS0tLS0tLS0tLS0tLS0tLT58ICBDTE9TRSAgfAogfCBXQUlULTEg IHwtLS0tLS0tLS0tLS0tLS0tLS0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICB8ICAg V0FJVCAgfAogKy0tLS0tLS0tLSsgICAgICAgICAgcmN2IEZJTiAgXCAgICAgICAgICAgICAg ICAgICAgICAgICAgICArLS0tLS0tLS0tKwogICB8IHJjdiBBQ0sgb2YgRklOICAgLS0tLS0t LSAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ0xPU0UgIHwgIAogICB8IC0tLS0t LS0tLS0tLS0tICAgc25kIEFDSyAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAtLS0t LS0tIHwgIAogICBWICAgICAgICB4ICAgICAgICAgICAgICAgICAgIFYgICAgICAgICAgICAg ICAgICAgICAgICAgICBzbmQgRklOIFYgIAogKy0tLS0tLS0tLSsgICAgICAgICAgICAgICAg ICArLS0tLS0tLS0tKyAgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tKwogfEZJTldBSVQt MnwgICAgICAgICAgICAgICAgICB8IENMT1NJTkcgfCAgICAgICAgICAgICAgICAgICB8IExB U1QtQUNLfAogKy0tLS0tLS0tLSsgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tKyAgICAg ICAgICAgICAgICAgICArLS0tLS0tLS0tKwogICB8ICAgICAgICAgICAgICAgIHJjdiBBQ0sg b2YgRklOIHwgICAgICAgICAgICAgICAgIHJjdiBBQ0sgb2YgRklOIHwgIAogICB8ICByY3Yg RklOICAgICAgIC0tLS0tLS0tLS0tLS0tIHwgICAgVGltZW91dD0yTVNMIC0tLS0tLS0tLS0t LS0tIHwgIAogICB8ICAtLS0tLS0tICAgICAgICAgICAgICB4ICAgICAgIFYgICAgLS0tLS0t LS0tLS0tICAgICAgICB4ICAgICAgIFYgIAogICAgXCBzbmQgQUNLICAgICAgICAgICAgICAg ICArLS0tLS0tLS0tK2RlbGV0ZSBUQ0IgICAgICAgICArLS0tLS0tLS0tKwogICAgIC0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLT58VElNRSBXQUlUfC0tLS0tLS0tLS0tLS0tLS0tLT58IENM T1NFRCAgfAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICArLS0tLS0tLS0tKyAgICAg ICAgICAgICAgICAgICArLS0tLS0tLS0tKwoKICAgICAgICAgICAgICAgICAgICAgIFRDUCBD b25uZWN0aW9uIFN0YXRlIERpYWdyYW0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg IEZpZ3VyZSA2LgoKCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIFtQYWdlIDIzXQo= --------------090302000801010808030702--