Maximum segment lifetime

Maximum segment lifetime or MSL is the time a TCP segment can exist in the internetwork system. It was defined in 1981 to be {{nowrap|2 minutes}}.{{cite web | title=RFC 793 | work=Transmission Control Protocol | url=http://www.rfc-editor.org/rfc/rfc793.txt | accessdate=December 5, 2006 }}

{{quote | For this specification the MSL is taken to be 2 minutes. This is an engineering choice, and may be changed if experience indicates it is desirable to do so. }}

The specification calls for this value to be used for the "time-wait" interval, the minimum time a system must keep the socket in the {{mono|TIME_WAIT}} state before designating the socket closed, thus preventing the socket from being re-used before that interval.

Values in various operating systems

The command that can be used on Solaris systems (prior to v11) to determine the time-wait interval is:

ndd -get /dev/tcp tcp_time_wait_interval

60000 (60 seconds) is a common value.

On FreeBSD systems this description and value can be checked by the command sysctl:{{cite web | title=Tuning FreeBSD to serve 100-200 thousands of connections

| url=http://rerepi.wordpress.com/2008/04/19/tuning-freebsd-sysoev-rit/ }}

sysctl -d net.inet.tcp.msl

sysctl net.inet.tcp.msl

which gets the result:

net.inet.tcp.msl: Maximum segment lifetime

net.inet.tcp.msl: 30000

In Linux, the time-wait interval is defined by the {{mono|TCP_TIMEWAIT_LEN}}, hard-coded as 60 seconds. Linux implements several possible optimizations to shorten the {{mono|TIME_WAIT}} state through recycling, down to a minimum of 3.5s in recent kernels.{{cite web |title=Linux Kernel socket implementation| url=https://github.com/tinalinux/linux-3.10/blob/r40-v1.y/net/ipv4/inet_timewait_sock.c#L340 }}{{ cite web | title=Linux Kernel headers for TCP| url=https://github.com/torvalds/linux/blame/0983f6bf2bfc0789b51ddf7315f644ff4da50acb/include/net/tcp.h#L144}}

References