LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-11-2011, 12:22 PM   #1
fancylad
Member
 
Registered: Mar 2008
Distribution: slackware
Posts: 175

Rep: Reputation: 19
how to really decrease TIME_WAIT


I'm trying to decrease the tcp TIME_WAIT state which, from what I understand, occurs on the host that initiates the closing of a socket by sending a packet with the FIN bit set.

Most people say to change /proc/sys/net/ipv4/tcp_fin_timeout to a lesser value. I have tried this many times and it makes no difference. The TIME_WAIT's still linger for ~ 60 seconds.

This link says that it actually adjusts the FIN-WAIT-2 state and I think they're right. http://lartc.org/howto/lartc.kernel.obscure.html:

Quote:
/proc/sys/net/ipv4/tcp_fin_timeout

Time to hold socket in state FIN-WAIT-2, if it was closed by our side. Peer can be broken and never close its side, or even died unexpectedly. Default value is 60sec. Usual value used in 2.2 was 180 seconds, you may restore it, but remember that if your machine is even underloaded WEB server, you risk to overflow memory with kilotons of dead sockets, FIN-WAIT-2 sockets are less dangerous than FIN-WAIT-1, because they eat maximum 1.5K of memory, but they tend to live longer. Cf. tcp_max_orphans.
Here's what the netstat man page says about these two different states:

Quote:
TIME_WAIT
The socket is waiting after close to handle packets still in the network.

FIN_WAIT2
Connection is closed, and the socket is waiting for a shutdown from the remote end.
Can someone tell me how to actually decrease the TIME_WAIT state?
 
Old 05-11-2011, 02:24 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi there,

Well first of all I would like to say that TIME_WAIT is for maintaining the reliability. It is not a good idea to close a connection forcefully when it is in TIME_WAIT state.

Have a look at the following link to understand how it works: http://www.ssfnet.org/Exchange/tcp/t...rialNotes.html

Although I would not suggest but you can change the TIME_WAIT settings in the following files to lower the limit. Default is 0 which means it will wait until the connection clears itself:

/proc/sys/net/ipv4/tcp_tw_recycle

and

/proc/sys/net/ipv4/tcp_tw_reuse

Also an easy way of clearing up the time_wait connection is to restart your network service which I think you would not like to do: service network restart.
 
Old 05-11-2011, 02:38 PM   #3
fancylad
Member
 
Registered: Mar 2008
Distribution: slackware
Posts: 175

Original Poster
Rep: Reputation: 19
To me, TIME_WAIT is not so much about "reliability." It is there just in case the host receives any stray packets after the connection has already been closed.

Changing /proc/sys/net/ipv4/tcp_tw_recycle and /proc/sys/net/ipv4/tcp_tw_reuse to 1 seem to allow the OS to quickly reuse those TIME_WAIT sockets;however this seems a bit too aggressive. I still would like the TIME_WAIT to expire, just would like to do it quickly, like after 5 seconds instead of ~ 1 minute.

Last edited by fancylad; 05-11-2011 at 02:41 PM.
 
Old 05-11-2011, 03:03 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

As you have already set a lesser value for tcp_fin_timeout try reducing the value of tcp_keepalive_time and see if that helps.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
netstat TIME_WAIT xxclixxx Linux - Server 4 09-07-2010 06:16 AM
11k time_wait? Stephan_Craft Linux - Networking 4 07-18-2009 12:06 PM
decrease TIME_WAIT izghitu Linux - Networking 3 06-14-2007 10:51 PM
TIME_WAIT and CLOSE_WAIT echox Linux - Enterprise 1 09-03-2006 09:26 PM
time_wait problem gecoool Linux - Software 3 08-31-2005 01:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration