OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man7 / tcp.7
index 476c25c..8631682 100644 (file)
@@ -1,8 +1,14 @@
 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
+.\" and Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
+.\" Note also that many pieces are drawn from the kernel source file
+.\" Documentation/networking/ip-sysctl.txt.
+.\"
+.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
 .\" Permission is granted to distribute possibly modified copies
 .\" of this page provided the header is included verbatim,
 .\" and in case of nontrivial modification author and date
 .\" of the modification is added to the header.
+.\" %%%LICENSE_END
 .\"
 .\" 2.4 Updates by Nivedita Singhvi 4/20/02 <nivedita@us.ibm.com>.
 .\" Modified, 2004-11-11, Michael Kerrisk and Andries Brouwer
 .\"     be more or less up to date and complete as at Linux 2.6.27
 .\"     (other than the remaining FIXMEs in the page source below).
 .\"
-.TH TCP  7 2012-04-23 "Linux" "Linux Programmer's Manual"
+.\" FIXME The following need to be documented
+.\"    TCP_MD5SIG (2.6.20)
+.\"        commit cfb6eeb4c860592edd123fdea908d23c6ad1c7dc
+.\"        Author was yoshfuji@linux-ipv6.org
+.\"        Needs CONFIG_TCP_MD5SIG
+.\"        From net/inet/Kconfig
+.\"        bool "TCP: MD5 Signature Option support (RFC2385) (EXPERIMENTAL)"
+.\"        RFC2385 specifies a method of giving MD5 protection to TCP sessions.
+.\"        Its main (only?) use is to protect BGP sessions between core routers
+.\"        on the Internet.
+.\"
+.\"        There is a TCP_MD5SIG option documented in FreeBSD's tcp(4),
+.\"        but probably many details are different on Linux
+.\"        http://thread.gmane.org/gmane.linux.network/47490
+.\"        http://www.daemon-systems.org/man/tcp.4.html
+.\"        http://article.gmane.org/gmane.os.netbsd.devel.network/3767/match=tcp_md5sig+freebsd
+.\"    TCP_COOKIE_TRANSACTIONS (2.6.33)
+.\"        commit 519855c508b9a17878c0977a3cdefc09b59b30df
+.\"        Author: William Allen Simpson <william.allen.simpson@gmail.com>
+.\"        commit e56fb50f2b7958b931c8a2fc0966061b3f3c8f3a
+.\"        Author: William Allen Simpson <william.allen.simpson@gmail.com>
+.\"
+.\"        REMOVED in Linux 3.10
+.\"            commit 1a2c6181c4a1922021b4d7df373bba612c3e5f04
+.\"            Author: Christoph Paasch <christoph.paasch@uclouvain.be>
+.\"
+.\"    TCP_THIN_LINEAR_TIMEOUTS (2.6.34)
+.\"        commit 36e31b0af58728071e8023cf8e20c5166b700717
+.\"        Author: Andreas Petlund <apetlund@simula.no>
+.\"    TCP_THIN_DUPACK (2.6.34)
+.\"        commit 7e38017557bc0b87434d184f8804cadb102bb903
+.\"        Author: Andreas Petlund <apetlund@simula.no>
+.\"    TCP_REPAIR (3.5)
+.\"        commit ee9952831cfd0bbe834f4a26489d7dce74582e37
+.\"        Author: Pavel Emelyanov <xemul@parallels.com>
+.\"    TCP_REPAIR_QUEUE (3.5)
+.\"        commit ee9952831cfd0bbe834f4a26489d7dce74582e37
+.\"        Author: Pavel Emelyanov <xemul@parallels.com>
+.\"    TCP_QUEUE_SEQ (3.5)
+.\"        commit ee9952831cfd0bbe834f4a26489d7dce74582e37
+.\"        Author: Pavel Emelyanov <xemul@parallels.com>
+.\"    TCP_REPAIR_OPTIONS (3.5)
+.\"        commit b139ba4e90dccbf4cd4efb112af96a5c9e0b098c
+.\"        Author: Pavel Emelyanov <xemul@parallels.com>
+.\"     TCP_FASTOPEN (3.6)
+.\"         (Fast Open server side implementation completed in 3.7)
+.\"        http://lwn.net/Articles/508865/
+.\"     TCP_TIMESTAMP (3.9)
+.\"        commit 93be6ce0e91b6a94783e012b1857a347a5e6e9f2
+.\"        Author: Andrey Vagin <avagin@openvz.org>
+.\"     TCP_NOTSENT_LOWAT (3.12)
+.\"        commit c9bee3b7fdecb0c1d070c7b54113b3bdfb9a3d36
+.\"        Author: Eric Dumazet <edumazet@google.com>
+.\"
+.TH TCP  7 2015-01-10 "Linux" "Linux Programmer's Manual"
 .SH NAME
 tcp \- TCP protocol
 .SH SYNOPSIS
@@ -133,7 +193,7 @@ socket option is enabled, urgent data is put into the normal
 data stream (a program can test for its location using the
 .B SIOCATMARK
 ioctl described below),
-otherwise it can be only received when the
+otherwise it can be received only when the
 .B MSG_OOB
 flag is set for
 .BR recv (2)
@@ -147,14 +207,14 @@ Some of these features include support for zero-copy
 Explicit Congestion Notification, new
 management of TIME_WAIT sockets, keep-alive socket options
 and support for Duplicate SACK extensions.
-.SS Address Formats
+.SS Address formats
 TCP is built on top of IP (see
 .BR ip (7)).
 The address formats defined by
 .BR ip (7)
 apply to TCP.
-TCP only supports point-to-point
-communication; broadcasting and multicasting are not
+TCP supports point-to-point communication only;
+broadcasting and multicasting are not
 supported.
 .SS /proc interfaces
 System-wide TCP parameter settings can be accessed by files in the directory
@@ -235,17 +295,36 @@ Show/set the congestion control algorithm choices available to unprivileged
 processes (see the description of the
 .B TCP_CONGESTION
 socket option).
+The items in the list are separated by white space and
+terminated by a newline character.
 The list is a subset of those listed in
 .IR tcp_available_congestion_control .
-.\" FIXME How are the items in this delimited? Null bytes, spaces, commas?
 The default value for this list is "reno" plus the default setting of
 .IR tcp_congestion_control .
 .TP
+.IR tcp_autocorking " (Boolean; default: enabled; since Linux 3.14)"
+.\" commit f54b311142a92ea2e42598e347b84e1655caf8e3
+.\" Text heavily based on Documentation/networking/ip-sysctl.txt
+If this option is enabled, the kernel tries to coalesce small writes
+(from consecutive
+.BR write (2)
+and
+.BR sendmsg (2)
+calls) as much as possible,
+in order to decrease the total number of sent packets.
+Coalescing is done if at least one prior packet for the flow
+is waiting in Qdisc queues or device transmit queue.
+Applications can still use the
+.B TCP_CORK
+socket option to obtain optimal behavior
+when they know how/when to uncork their sockets.
+.TP
 .IR tcp_available_congestion_control " (String; read-only; since Linux 2.4.20)"
 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
 Show a list of the congestion-control algorithms
 that are registered.
-.\" FIXME How are the items in this delimited? Null bytes, spaces, commas?
+The items in the list are separated by white space and
+terminated by a newline character.
 This list is a limiting set for the list in
 .IR tcp_allowed_congestion_control .
 More congestion-control algorithms may be available as modules,
@@ -273,7 +352,7 @@ this is the initial MSS used by the connection.
 .TP
 .IR tcp_bic " (Boolean; default: disabled; Linux 2.4.27/2.6.6 to 2.6.13)"
 Enable BIC TCP congestion control algorithm.
-BIC-TCP is a sender-side only change that ensures a linear RTT
+BIC-TCP is a sender-side-only change that ensures a linear RTT
 fairness under large windows while offering both scalability and
 bounded TCP-friendliness.
 The protocol combines two schemes
@@ -406,7 +485,7 @@ no response is obtained from the other end.
 .\" Since 2.1.43
 The number of seconds a connection needs to be idle
 before TCP begins sending out keep-alive probes.
-Keep-alives are only sent when the
+Keep-alives are sent only when the
 .B SO_KEEPALIVE
 socket option is enabled.
 The default value is 7200 seconds (2 hours).
@@ -701,10 +780,11 @@ building larger TSO frames.
 .TP
 .IR tcp_tw_recycle " (Boolean; default: disabled; since Linux 2.4)"
 .\" Since 2.3.15
-Enable fast recycling of TIME_WAIT sockets.
-Enabling this option is not
-recommended since this causes problems when working
-with NAT (Network Address Translation).
+Enable fast recycling of TIME_WAIT sockets. Enabling this option is
+not recommended for devices communicating with the general Internet
+or using NAT (Network Address Translation). Since some NAT gateways
+pass through IP timestamp values, one IP can appear to have
+non-increasing timestamps. See RFC 1323 (PAWS), RFC 6191.
 .\"
 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
 .TP
@@ -719,7 +799,7 @@ It should not be changed without advice/request of technical experts.
 .IR tcp_vegas_cong_avoid  " (Boolean; default: disabled; Linux 2.2 to 2.6.13)"
 .\" Since 2.1.8; removed in 2.6.13
 Enable TCP Vegas congestion avoidance algorithm.
-TCP Vegas is a sender-side only change to TCP that anticipates
+TCP Vegas is a sender-side-only change to TCP that anticipates
 the onset of congestion by estimating the bandwidth.
 TCP Vegas adjusts the sending rate by modifying the congestion window.
 TCP Vegas should provide less packet loss, but it is
@@ -729,7 +809,7 @@ not as aggressive as TCP Reno.
 .TP
 .IR tcp_westwood " (Boolean; default: disabled; Linux 2.4.26/2.6.3 to 2.6.13)"
 Enable TCP Westwood+ congestion control algorithm.
-TCP Westwood+ is a sender-side only modification of the TCP Reno
+TCP Westwood+ is a sender-side-only modification of the TCP Reno
 protocol stack that optimizes the performance of TCP congestion control.
 It is based on end-to-end bandwidth estimation to set
 congestion window and slow start threshold after a congestion episode.
@@ -806,13 +886,17 @@ If enabled, assume that no receipt of a window-scaling option means that the
 remote TCP is broken and treats the window as a signed quantity.
 If disabled, assume that the remote TCP is not broken even if we do
 not receive a window scaling option from it.
-.SS Socket Options
+.SS Socket options
 To set or get a TCP socket option, call
 .BR getsockopt (2)
 to read or
 .BR setsockopt (2)
 to write the option with the option level argument set to
 .BR IPPROTO_TCP .
+Unless otherwise noted,
+.I optval
+is a pointer to an
+.IR int .
 .\" or SOL_TCP on Linux
 In addition,
 most
@@ -820,7 +904,22 @@ most
 socket options are valid on TCP sockets.
 For more information see
 .BR ip (7).
-.\" FIXME Document TCP_CONGESTION (new in 2.6.13)
+.TP
+.BR TCP_CONGESTION " (since Linux 2.6.13)"
+.\"        commit 5f8ef48d240963093451bcf83df89f1a1364f51d
+.\"        Author: Stephen Hemminger <shemminger@osdl.org>
+The argument for this option is a string.
+This option allows the caller to set the TCP congestion control
+algorithm to be used, on a per-socket basis.
+Unprivileged processes are restricted to choosing one of the algorithms in
+.IR tcp_allowed_congestion_control
+(described above).
+Privileged processes
+.RB ( CAP_NET_ADMIN )
+can choose from any of the available congestion-control algorithms
+(see the description of
+.IR tcp_available_congestion_control
+above).
 .TP
 .BR TCP_CORK " (since Linux 2.2)"
 .\" precisely: since 2.1.127
@@ -840,6 +939,9 @@ This option should not be used in code intended to be portable.
 .TP
 .BR TCP_DEFER_ACCEPT " (since Linux 2.4)"
 .\" Precisely: since 2.3.38
+.\" Useful references:
+.\" http://www.techrepublic.com/article/take-advantage-of-tcp-ip-options-to-optimize-data-transmission/
+.\" http://unix.stackexchange.com/questions/94104/real-world-use-of-tcp-defer-accept
 Allow a listener to be awakened only when data arrives on the socket.
 Takes an integer value (seconds), this can
 bound the maximum number of attempts TCP will make to
@@ -894,21 +996,6 @@ changes the MSS value announced to the other end in the initial packet.
 Values greater than the (eventual) interface MTU have no effect.
 TCP will also impose
 its minimum and maximum bounds over the value provided.
-.\" FIXME
-.\" Document TCP_MD5SIG, added in Linux 2.6.20,
-.\" Needs CONFIG_TCP_MD5SIG
-.\" From net/inet/Kconfig
-.\" bool "TCP: MD5 Signature Option support (RFC2385) (EXPERIMENTAL)"
-.\" RFC2385 specifies a method of giving MD5 protection to TCP sessions.
-.\" Its main (only?) use is to protect BGP sessions between core routers
-.\" on the Internet.
-.\"
-.\" There is a TCP_MD5SIG option documented in FreeBSD's tcp(4),
-.\" but probably many details are different on Linux
-.\" Authors were yoshfuji@linux-ipv6.org and Dave Muller
-.\" http://thread.gmane.org/gmane.linux.network/47490
-.\" http://www.daemon-systems.org/man/tcp.4.html
-.\" http://article.gmane.org/gmane.os.netbsd.devel.network/3767/match=tcp_md5sig+freebsd
 .TP
 .B TCP_NODELAY
 .\" Present in Linux 1.0
@@ -941,8 +1028,6 @@ internal protocol processing and factors such as
 delayed ack timeouts occurring and data transfer.
 This option should not be used in code intended to be
 portable.
-.\" FIXME Document TCP_USER_TIMEOUT (new in 2.6.37)
-.\" See commit dca43c75e7e545694a9dd6288553f55c53e2a3a3
 .TP
 .BR TCP_SYNCNT " (since Linux 2.4)"
 .\" Precisely: since 2.3.18
@@ -951,6 +1036,51 @@ aborting the attempt to connect.
 It cannot exceed 255.
 This option should not be used in code intended to be portable.
 .TP
+.BR TCP_USER_TIMEOUT " (since Linux 2.6.37)"
+.\"        commit dca43c75e7e545694a9dd6288553f55c53e2a3a3
+.\"        Author: Jerry Chu <hkchu@google.com>
+.\" The following text taken nearly verbatim from Jerry Chu's (excellent)
+.\" commit message.
+.\"
+This option takes an
+.IR "unsigned int"
+as an argument.
+When the value is greater than 0,
+it specifies the maximum amount of time in milliseconds that transmitted
+data may remain unacknowledged before TCP will forcibly close the
+corresponding connection and return
+.B ETIMEDOUT
+to the application.
+If the option value is specified as 0,
+TCP will to use the system default.
+
+Increasing user timeouts allows a TCP connection to survive extended
+periods without end-to-end connectivity.
+Decreasing user timeouts
+allows applications to "fail fast", if so desired.
+Otherwise, failure may take up to 20 minutes with
+the current system defaults in a normal WAN environment.
+
+This option can be set during any state of a TCP connection,
+but is effective only during the synchronized states of a connection
+(ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, and LAST-ACK).
+Moreover, when used with the TCP keepalive
+.RB ( SO_KEEPALIVE )
+option,
+.B TCP_USER_TIMEOUT
+will override keepalive to determine when to close a
+connection due to keepalive failure.
+
+The option has no effect on when TCP retransmits a packet,
+nor when a keepalive probe is sent.
+
+This option, like many others, will be inherited by the socket returned by
+.BR accept (2),
+if it was set on the listening socket.
+
+Further details on the user timeout feature can be found in
+RFC\ 793 and RFC\ 5482 ("TCP User Timeout Option").
+.TP
 .BR TCP_WINDOW_CLAMP " (since Linux 2.4)"
 .\" Precisely: since 2.3.41
 Bound the size of the advertised window to this value.
@@ -975,7 +1105,7 @@ It can be changed via
 .IR /proc/sys/net/ipv4/tcp_stdurg .
 
 It is possible to peek at out-of-band data using the
-.IR recv (2)
+.BR recv (2)
 .B MSG_PEEK
 flag.
 
@@ -990,7 +1120,7 @@ argument of
 This flag causes the received bytes of data to be discarded,
 rather than passed back in a caller-supplied buffer.
 Since Linux 2.4.4,
-.BR MSG_PEEK
+.BR MSG_TRUNC
 also has this effect when used in conjunction with
 .BR MSG_OOB
 to receive out-of-band data.
@@ -1070,14 +1200,14 @@ is returned.
 .B SIOCOUTQ
 is defined in
 .IR <linux/sockios.h> .
-.\" FIXME http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002,
+.\" FIXME http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002,
 .\" filed 2010-09-10, may cause SIOCOUTQ to be defined in glibc headers
 Alternatively,
 you can use the synonymous
 .BR TIOCOUTQ ,
 defined in
 .IR <sys/ioctl.h> .
-.SS Error Handling
+.SS Error handling
 When a network error occurs, TCP tries to resend the packet.
 If it doesn't succeed after some time, either
 .B ETIMEDOUT
@@ -1130,7 +1260,7 @@ IPv6 is not described.
 .\" It was updated for 2.4 by Nivedita Singhvi with input from
 .\" Alexey Kuznetsov's Documentation/networking/ip-sysctl.txt
 .\" document.
-.SH "SEE ALSO"
+.SH SEE ALSO
 .BR accept (2),
 .BR bind (2),
 .BR connect (2),
@@ -1156,3 +1286,12 @@ RFC\ 3168 for a description of Explicit Congestion Notification.
 RFC\ 2581 for TCP congestion control algorithms.
 .br
 RFC\ 2018 and RFC\ 2883 for SACK and extensions to SACK.
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.