Blame man7/tcp.7

Packit 7cfc04
.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
Packit 7cfc04
.\" and Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
Packit 7cfc04
.\" Note also that many pieces are drawn from the kernel source file
Packit 7cfc04
.\" Documentation/networking/ip-sysctl.txt.
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
Packit 7cfc04
.\" Permission is granted to distribute possibly modified copies
Packit 7cfc04
.\" of this page provided the header is included verbatim,
Packit 7cfc04
.\" and in case of nontrivial modification author and date
Packit 7cfc04
.\" of the modification is added to the header.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\" 2.4 Updates by Nivedita Singhvi 4/20/02 <nivedita@us.ibm.com>.
Packit 7cfc04
.\" Modified, 2004-11-11, Michael Kerrisk and Andries Brouwer
Packit 7cfc04
.\"	Updated details of interaction of TCP_CORK and TCP_NODELAY.
Packit 7cfc04
.\"
Packit 7cfc04
.\" 2008-11-21, mtk, many, many updates.
Packit 7cfc04
.\"     The descriptions of /proc files and socket options should now
Packit 7cfc04
.\"     be more or less up to date and complete as at Linux 2.6.27
Packit 7cfc04
.\"     (other than the remaining FIXMEs in the page source below).
Packit 7cfc04
.\"
Packit 7cfc04
.\" FIXME The following need to be documented
Packit 7cfc04
.\"	TCP_MD5SIG (2.6.20)
Packit 7cfc04
.\"	    commit cfb6eeb4c860592edd123fdea908d23c6ad1c7dc
Packit 7cfc04
.\"	    Author was yoshfuji@linux-ipv6.org
Packit 7cfc04
.\"	    Needs CONFIG_TCP_MD5SIG
Packit 7cfc04
.\" From net/inet/Kconfig:
Packit 7cfc04
.\" bool "TCP: MD5 Signature Option support (RFC2385) (EXPERIMENTAL)"
Packit 7cfc04
.\" RFC2385 specifies a method of giving MD5 protection to TCP sessions.
Packit 7cfc04
.\" Its main (only?) use is to protect BGP sessions between core routers
Packit 7cfc04
.\" on the Internet.
Packit 7cfc04
.\"
Packit 7cfc04
.\" There is a TCP_MD5SIG option documented in FreeBSD's tcp(4),
Packit 7cfc04
.\" but probably many details are different on Linux
Packit 7cfc04
.\"	    http://thread.gmane.org/gmane.linux.network/47490
Packit 7cfc04
.\"	    http://www.daemon-systems.org/man/tcp.4.html
Packit 7cfc04
.\"	    http://article.gmane.org/gmane.os.netbsd.devel.network/3767/match=tcp_md5sig+freebsd
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_COOKIE_TRANSACTIONS (2.6.33)
Packit 7cfc04
.\"	    commit 519855c508b9a17878c0977a3cdefc09b59b30df
Packit 7cfc04
.\"	    Author: William Allen Simpson <william.allen.simpson@gmail.com>
Packit 7cfc04
.\"	    commit e56fb50f2b7958b931c8a2fc0966061b3f3c8f3a
Packit 7cfc04
.\"	    Author: William Allen Simpson <william.allen.simpson@gmail.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\"	    REMOVED in Linux 3.10
Packit 7cfc04
.\" 		commit 1a2c6181c4a1922021b4d7df373bba612c3e5f04
Packit 7cfc04
.\"		Author: Christoph Paasch <christoph.paasch@uclouvain.be>
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_THIN_LINEAR_TIMEOUTS (2.6.34)
Packit 7cfc04
.\"	    commit 36e31b0af58728071e8023cf8e20c5166b700717
Packit 7cfc04
.\"	    Author: Andreas Petlund <apetlund@simula.no>
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_THIN_DUPACK (2.6.34)
Packit 7cfc04
.\"	    commit 7e38017557bc0b87434d184f8804cadb102bb903
Packit 7cfc04
.\"	    Author: Andreas Petlund <apetlund@simula.no>
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_REPAIR (3.5)
Packit 7cfc04
.\"	    commit ee9952831cfd0bbe834f4a26489d7dce74582e37
Packit 7cfc04
.\"	    Author: Pavel Emelyanov <xemul@parallels.com>
Packit 7cfc04
.\"	    See also
Packit 7cfc04
.\"		http://criu.org/TCP_connection
Packit 7cfc04
.\"		https://lwn.net/Articles/495304/
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_REPAIR_QUEUE (3.5)
Packit 7cfc04
.\"	    commit ee9952831cfd0bbe834f4a26489d7dce74582e37
Packit 7cfc04
.\"	    Author: Pavel Emelyanov <xemul@parallels.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_QUEUE_SEQ (3.5)
Packit 7cfc04
.\"	    commit ee9952831cfd0bbe834f4a26489d7dce74582e37
Packit 7cfc04
.\"	    Author: Pavel Emelyanov <xemul@parallels.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_REPAIR_OPTIONS (3.5)
Packit 7cfc04
.\"	    commit b139ba4e90dccbf4cd4efb112af96a5c9e0b098c
Packit 7cfc04
.\"	    Author: Pavel Emelyanov <xemul@parallels.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\"     TCP_FASTOPEN (3.6)
Packit 7cfc04
.\"         (Fast Open server side implementation completed in 3.7)
Packit 7cfc04
.\"	    http://lwn.net/Articles/508865/
Packit 7cfc04
.\"
Packit 7cfc04
.\"     TCP_TIMESTAMP (3.9)
Packit 7cfc04
.\"        commit 93be6ce0e91b6a94783e012b1857a347a5e6e9f2
Packit 7cfc04
.\"        Author: Andrey Vagin <avagin@openvz.org>
Packit 7cfc04
.\"
Packit 7cfc04
.\"     TCP_NOTSENT_LOWAT (3.12)
Packit 7cfc04
.\"        commit c9bee3b7fdecb0c1d070c7b54113b3bdfb9a3d36
Packit 7cfc04
.\"        Author: Eric Dumazet <edumazet@google.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_CC_INFO (4.1)
Packit 7cfc04
.\"	   commit 6e9250f59ef9efb932c84850cd221f22c2a03c4a
Packit 7cfc04
.\"	   Author: Eric Dumazet <edumazet@google.com>
Packit 7cfc04
.\"
Packit 7cfc04
.\"	TCP_SAVE_SYN, TCP_SAVED_SYN (4.2)
Packit 7cfc04
.\"	    commit cd8ae85299d54155702a56811b2e035e63064d3d
Packit 7cfc04
.\"	    Author: Eric Dumazet <edumazet@google.com>
Packit 7cfc04
.\"
Packit 7cfc04
.TH TCP  7 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
tcp \- TCP protocol
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.B #include <sys/socket.h>
Packit 7cfc04
.br
Packit 7cfc04
.B #include <netinet/in.h>
Packit 7cfc04
.br
Packit 7cfc04
.B #include <netinet/tcp.h>
Packit 7cfc04
.PP
Packit 7cfc04
.B tcp_socket = socket(AF_INET, SOCK_STREAM, 0);
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
This is an implementation of the TCP protocol defined in
Packit 7cfc04
RFC\ 793, RFC\ 1122 and RFC\ 2001 with the NewReno and SACK
Packit 7cfc04
extensions.
Packit 7cfc04
It provides a reliable, stream-oriented,
Packit 7cfc04
full-duplex connection between two sockets on top of
Packit 7cfc04
.BR ip (7),
Packit 7cfc04
for both v4 and v6 versions.
Packit 7cfc04
TCP guarantees that the data arrives in order and
Packit 7cfc04
retransmits lost packets.
Packit 7cfc04
It generates and checks a per-packet checksum to catch
Packit 7cfc04
transmission errors.
Packit 7cfc04
TCP does not preserve record boundaries.
Packit 7cfc04
.PP
Packit 7cfc04
A newly created TCP socket has no remote or local address and is not
Packit 7cfc04
fully specified.
Packit 7cfc04
To create an outgoing TCP connection use
Packit 7cfc04
.BR connect (2)
Packit 7cfc04
to establish a connection to another TCP socket.
Packit 7cfc04
To receive new incoming connections, first
Packit 7cfc04
.BR bind (2)
Packit 7cfc04
the socket to a local address and port and then call
Packit 7cfc04
.BR listen (2)
Packit 7cfc04
to put the socket into the listening state.
Packit 7cfc04
After that a new socket for each incoming connection can be accepted using
Packit 7cfc04
.BR accept (2).
Packit 7cfc04
A socket which has had
Packit 7cfc04
.BR accept (2)
Packit 7cfc04
or
Packit 7cfc04
.BR connect (2)
Packit 7cfc04
successfully called on it is fully specified and may transmit data.
Packit 7cfc04
Data cannot be transmitted on listening or not yet connected sockets.
Packit 7cfc04
.PP
Packit 7cfc04
Linux supports RFC\ 1323 TCP high performance
Packit 7cfc04
extensions.
Packit 7cfc04
These include Protection Against Wrapped
Packit 7cfc04
Sequence Numbers (PAWS), Window Scaling and Timestamps.
Packit 7cfc04
Window scaling allows the use
Packit 7cfc04
of large (> 64\ kB) TCP windows in order to support links with high
Packit 7cfc04
latency or bandwidth.
Packit 7cfc04
To make use of them, the send and receive buffer sizes must be increased.
Packit 7cfc04
They can be set globally with the
Packit 7cfc04
.I /proc/sys/net/ipv4/tcp_wmem
Packit 7cfc04
and
Packit 7cfc04
.I /proc/sys/net/ipv4/tcp_rmem
Packit 7cfc04
files, or on individual sockets by using the
Packit 7cfc04
.B SO_SNDBUF
Packit 7cfc04
and
Packit 7cfc04
.B SO_RCVBUF
Packit 7cfc04
socket options with the
Packit 7cfc04
.BR setsockopt (2)
Packit 7cfc04
call.
Packit 7cfc04
.PP
Packit 7cfc04
The maximum sizes for socket buffers declared via the
Packit 7cfc04
.B SO_SNDBUF
Packit 7cfc04
and
Packit 7cfc04
.B SO_RCVBUF
Packit 7cfc04
mechanisms are limited by the values in the
Packit 7cfc04
.I /proc/sys/net/core/rmem_max
Packit 7cfc04
and
Packit 7cfc04
.I /proc/sys/net/core/wmem_max
Packit 7cfc04
files.
Packit 7cfc04
Note that TCP actually allocates twice the size of
Packit 7cfc04
the buffer requested in the
Packit 7cfc04
.BR setsockopt (2)
Packit 7cfc04
call, and so a succeeding
Packit 7cfc04
.BR getsockopt (2)
Packit 7cfc04
call will not return the same size of buffer as requested in the
Packit 7cfc04
.BR setsockopt (2)
Packit 7cfc04
call.
Packit 7cfc04
TCP uses the extra space for administrative purposes and internal
Packit 7cfc04
kernel structures, and the
Packit 7cfc04
.I /proc
Packit 7cfc04
file values reflect the
Packit 7cfc04
larger sizes compared to the actual TCP windows.
Packit 7cfc04
On individual connections, the socket buffer size must be set prior to the
Packit 7cfc04
.BR listen (2)
Packit 7cfc04
or
Packit 7cfc04
.BR connect (2)
Packit 7cfc04
calls in order to have it take effect.
Packit 7cfc04
See
Packit 7cfc04
.BR socket (7)
Packit 7cfc04
for more information.
Packit 7cfc04
.PP
Packit 7cfc04
TCP supports urgent data.
Packit 7cfc04
Urgent data is used to signal the
Packit 7cfc04
receiver that some important message is part of the data
Packit 7cfc04
stream and that it should be processed as soon as possible.
Packit 7cfc04
To send urgent data specify the
Packit 7cfc04
.B MSG_OOB
Packit 7cfc04
option to
Packit 7cfc04
.BR send (2).
Packit 7cfc04
When urgent data is received, the kernel sends a
Packit 7cfc04
.B SIGURG
Packit 7cfc04
signal to the process or process group that has been set as the
Packit 7cfc04
socket "owner" using the
Packit 7cfc04
.B SIOCSPGRP
Packit 7cfc04
or
Packit 7cfc04
.B FIOSETOWN
Packit 7cfc04
ioctls (or the POSIX.1-specified
Packit 7cfc04
.BR fcntl (2)
Packit 7cfc04
.B F_SETOWN
Packit 7cfc04
operation).
Packit 7cfc04
When the
Packit 7cfc04
.B SO_OOBINLINE
Packit 7cfc04
socket option is enabled, urgent data is put into the normal
Packit 7cfc04
data stream (a program can test for its location using the
Packit 7cfc04
.B SIOCATMARK
Packit 7cfc04
ioctl described below),
Packit 7cfc04
otherwise it can be received only when the
Packit 7cfc04
.B MSG_OOB
Packit 7cfc04
flag is set for
Packit 7cfc04
.BR recv (2)
Packit 7cfc04
or
Packit 7cfc04
.BR recvmsg (2).
Packit 7cfc04
.PP
Packit 7cfc04
When out-of-band data is present,
Packit 7cfc04
.BR select (2)
Packit 7cfc04
indicates the file descriptor as having an exceptional condition and
Packit 7cfc04
.I poll (2)
Packit 7cfc04
indicates a
Packit 7cfc04
.B POLLPRI
Packit 7cfc04
event.
Packit 7cfc04
.PP
Packit 7cfc04
Linux 2.4 introduced a number of changes for improved
Packit 7cfc04
throughput and scaling, as well as enhanced functionality.
Packit 7cfc04
Some of these features include support for zero-copy
Packit 7cfc04
.BR sendfile (2),
Packit 7cfc04
Explicit Congestion Notification, new
Packit 7cfc04
management of TIME_WAIT sockets, keep-alive socket options
Packit 7cfc04
and support for Duplicate SACK extensions.
Packit 7cfc04
.SS Address formats
Packit 7cfc04
TCP is built on top of IP (see
Packit 7cfc04
.BR ip (7)).
Packit 7cfc04
The address formats defined by
Packit 7cfc04
.BR ip (7)
Packit 7cfc04
apply to TCP.
Packit 7cfc04
TCP supports point-to-point communication only;
Packit 7cfc04
broadcasting and multicasting are not
Packit 7cfc04
supported.
Packit 7cfc04
.SS /proc interfaces
Packit 7cfc04
System-wide TCP parameter settings can be accessed by files in the directory
Packit 7cfc04
.IR /proc/sys/net/ipv4/ .
Packit 7cfc04
In addition, most IP
Packit 7cfc04
.I /proc
Packit 7cfc04
interfaces also apply to TCP; see
Packit 7cfc04
.BR ip (7).
Packit 7cfc04
Variables described as
Packit 7cfc04
.I Boolean
Packit 7cfc04
take an integer value, with a nonzero value ("true") meaning that
Packit 7cfc04
the corresponding option is enabled, and a zero value ("false")
Packit 7cfc04
meaning that the option is disabled.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_abc " (Integer; default: 0; Linux 2.6.15 to Linux 3.8)"
Packit 7cfc04
.\" Since 2.6.15; removed in 3.9
Packit 7cfc04
.\" commit ca2eb5679f8ddffff60156af42595df44a315ef0
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
Control the Appropriate Byte Count (ABC), defined in RFC 3465.
Packit 7cfc04
ABC is a way of increasing the congestion window
Packit 7cfc04
.RI ( cwnd )
Packit 7cfc04
more slowly in response to partial acknowledgments.
Packit 7cfc04
Possible values are:
Packit 7cfc04
.RS
Packit 7cfc04
.IP 0 3
Packit 7cfc04
increase
Packit 7cfc04
.I cwnd
Packit 7cfc04
once per acknowledgment (no ABC)
Packit 7cfc04
.IP 1
Packit 7cfc04
increase
Packit 7cfc04
.I cwnd
Packit 7cfc04
once per acknowledgment of full sized segment
Packit 7cfc04
.IP 2
Packit 7cfc04
allow increase
Packit 7cfc04
.I cwnd
Packit 7cfc04
by two if acknowledgment is
Packit 7cfc04
of two segments to compensate for delayed acknowledgments.
Packit 7cfc04
.RE
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_abort_on_overflow " (Boolean; default: disabled; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.3.41
Packit 7cfc04
Enable resetting connections if the listening service is too
Packit 7cfc04
slow and unable to keep up and accept them.
Packit 7cfc04
It means that if overflow occurred due
Packit 7cfc04
to a burst, the connection will recover.
Packit 7cfc04
Enable this option
Packit 7cfc04
.I only
Packit 7cfc04
if you are really sure that the listening daemon
Packit 7cfc04
cannot be tuned to accept connections faster.
Packit 7cfc04
Enabling this option can harm the clients of your server.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_adv_win_scale " (integer; default: 2; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.4.0-test7
Packit 7cfc04
Count buffering overhead as
Packit 7cfc04
.IR "bytes/2^tcp_adv_win_scale" ,
Packit 7cfc04
if
Packit 7cfc04
.I tcp_adv_win_scale
Packit 7cfc04
is greater than 0; or
Packit 7cfc04
.IR "bytes-bytes/2^(\-tcp_adv_win_scale)" ,
Packit 7cfc04
if
Packit 7cfc04
.I tcp_adv_win_scale
Packit 7cfc04
is less than or equal to zero.
Packit 7cfc04
.IP
Packit 7cfc04
The socket receive buffer space is shared between the
Packit 7cfc04
application and kernel.
Packit 7cfc04
TCP maintains part of the buffer as
Packit 7cfc04
the TCP window, this is the size of the receive window
Packit 7cfc04
advertised to the other end.
Packit 7cfc04
The rest of the space is used
Packit 7cfc04
as the "application" buffer, used to isolate the network
Packit 7cfc04
from scheduling and application latencies.
Packit 7cfc04
The
Packit 7cfc04
.I tcp_adv_win_scale
Packit 7cfc04
default value of 2 implies that the space
Packit 7cfc04
used for the application buffer is one fourth that of the total.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_allowed_congestion_control " (String; default: see text; since Linux 2.4.20)"
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
Show/set the congestion control algorithm choices available to unprivileged
Packit 7cfc04
processes (see the description of the
Packit 7cfc04
.B TCP_CONGESTION
Packit 7cfc04
socket option).
Packit 7cfc04
The items in the list are separated by white space and
Packit 7cfc04
terminated by a newline character.
Packit 7cfc04
The list is a subset of those listed in
Packit 7cfc04
.IR tcp_available_congestion_control .
Packit 7cfc04
The default value for this list is "reno" plus the default setting of
Packit 7cfc04
.IR tcp_congestion_control .
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_autocorking " (Boolean; default: enabled; since Linux 3.14)"
Packit 7cfc04
.\" commit f54b311142a92ea2e42598e347b84e1655caf8e3
Packit 7cfc04
.\" Text heavily based on Documentation/networking/ip-sysctl.txt
Packit 7cfc04
If this option is enabled, the kernel tries to coalesce small writes
Packit 7cfc04
(from consecutive
Packit 7cfc04
.BR write (2)
Packit 7cfc04
and
Packit 7cfc04
.BR sendmsg (2)
Packit 7cfc04
calls) as much as possible,
Packit 7cfc04
in order to decrease the total number of sent packets.
Packit 7cfc04
Coalescing is done if at least one prior packet for the flow
Packit 7cfc04
is waiting in Qdisc queues or device transmit queue.
Packit 7cfc04
Applications can still use the
Packit 7cfc04
.B TCP_CORK
Packit 7cfc04
socket option to obtain optimal behavior
Packit 7cfc04
when they know how/when to uncork their sockets.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_available_congestion_control " (String; read-only; since Linux 2.4.20)"
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
Show a list of the congestion-control algorithms
Packit 7cfc04
that are registered.
Packit 7cfc04
The items in the list are separated by white space and
Packit 7cfc04
terminated by a newline character.
Packit 7cfc04
This list is a limiting set for the list in
Packit 7cfc04
.IR tcp_allowed_congestion_control .
Packit 7cfc04
More congestion-control algorithms may be available as modules,
Packit 7cfc04
but not loaded.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_app_win  " (integer; default: 31; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.4.0-test7
Packit 7cfc04
This variable defines how many
Packit 7cfc04
bytes of the TCP window are reserved for buffering overhead.
Packit 7cfc04
.IP
Packit 7cfc04
A maximum of (\fIwindow/2^tcp_app_win\fP, mss) bytes in the window
Packit 7cfc04
are reserved for the application buffer.
Packit 7cfc04
A value of 0 implies that no amount is reserved.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_base_mss " (Integer; default: 512; since Linux 2.6.17)
Packit 7cfc04
The initial value of
Packit 7cfc04
.I search_low
Packit 7cfc04
to be used by the packetization layer Path MTU discovery (MTU probing).
Packit 7cfc04
If MTU probing is enabled,
Packit 7cfc04
this is the initial MSS used by the connection.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_bic " (Boolean; default: disabled; Linux 2.4.27/2.6.6 to 2.6.13)"
Packit 7cfc04
Enable BIC TCP congestion control algorithm.
Packit 7cfc04
BIC-TCP is a sender-side-only change that ensures a linear RTT
Packit 7cfc04
fairness under large windows while offering both scalability and
Packit 7cfc04
bounded TCP-friendliness.
Packit 7cfc04
The protocol combines two schemes
Packit 7cfc04
called additive increase and binary search increase.
Packit 7cfc04
When the congestion window is large, additive increase with a large
Packit 7cfc04
increment ensures linear RTT fairness as well as good scalability.
Packit 7cfc04
Under small congestion windows, binary search
Packit 7cfc04
increase provides TCP friendliness.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_bic_low_window " (integer; default: 14; Linux 2.4.27/2.6.6 to 2.6.13)"
Packit 7cfc04
Set the threshold window (in packets) where BIC TCP starts to
Packit 7cfc04
adjust the congestion window.
Packit 7cfc04
Below this threshold BIC TCP behaves the same as the default TCP Reno.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_bic_fast_convergence " (Boolean; default: enabled; Linux 2.4.27/2.6.6 to 2.6.13)"
Packit 7cfc04
Force BIC TCP to more quickly respond to changes in congestion window.
Packit 7cfc04
Allows two flows sharing the same connection to converge more rapidly.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_congestion_control " (String; default: see text; since Linux 2.4.13)"
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
Set the default congestion-control algorithm to be used for new connections.
Packit 7cfc04
The algorithm "reno" is always available,
Packit 7cfc04
but additional choices may be available depending on kernel configuration.
Packit 7cfc04
The default value for this file is set as part of kernel configuration.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_dma_copybreak " (integer; default: 4096; since Linux 2.6.24)"
Packit 7cfc04
Lower limit, in bytes, of the size of socket reads that will be
Packit 7cfc04
offloaded to a DMA copy engine, if one is present in the system
Packit 7cfc04
and the kernel was configured with the
Packit 7cfc04
.B CONFIG_NET_DMA
Packit 7cfc04
option.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_dsack " (Boolean; default: enabled; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.4.0-test7
Packit 7cfc04
Enable RFC\ 2883 TCP Duplicate SACK support.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_ecn " (Integer; default: see below; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.4.0-test7
Packit 7cfc04
Enable RFC\ 3168 Explicit Congestion Notification.
Packit 7cfc04
.IP
Packit 7cfc04
This file can have one of the following values:
Packit 7cfc04
.RS
Packit 7cfc04
.IP 0
Packit 7cfc04
Disable ECN.
Packit 7cfc04
Neither initiate nor accept ECN.
Packit 7cfc04
This was the default up to and including Linux 2.6.30.
Packit 7cfc04
.IP 1
Packit 7cfc04
Enable ECN when requested by incoming connections and also
Packit 7cfc04
request ECN on outgoing connection attempts.
Packit 7cfc04
.IP 2
Packit 7cfc04
.\" commit 255cac91c3c9ce7dca7713b93ab03c75b7902e0e
Packit 7cfc04
Enable ECN when requested by incoming connections,
Packit 7cfc04
but do not request ECN on outgoing connections.
Packit 7cfc04
This value is supported, and is the default, since Linux 2.6.31.
Packit 7cfc04
.RE
Packit 7cfc04
.IP
Packit 7cfc04
When enabled, connectivity to some destinations could be affected
Packit 7cfc04
due to older, misbehaving middle boxes along the path, causing
Packit 7cfc04
connections to be dropped.
Packit 7cfc04
However, to facilitate and encourage deployment with option 1, and
Packit 7cfc04
to work around such buggy equipment, the
Packit 7cfc04
.B tcp_ecn_fallback
Packit 7cfc04
option has been introduced.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_ecn_fallback " (Boolean; default: enabled; since Linux 4.1)"
Packit 7cfc04
.\" commit 492135557dc090a1abb2cfbe1a412757e3ed68ab
Packit 7cfc04
Enable RFC\ 3168, Section 6.1.1.1. fallback.
Packit 7cfc04
When enabled, outgoing ECN-setup SYNs that time out within the
Packit 7cfc04
normal SYN retransmission timeout will be resent with CWR and
Packit 7cfc04
ECE cleared.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_fack " (Boolean; default: enabled; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.92
Packit 7cfc04
Enable TCP Forward Acknowledgement support.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_fin_timeout " (integer; default: 60; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.53
Packit 7cfc04
This specifies how many seconds to wait for a final FIN packet before the
Packit 7cfc04
socket is forcibly closed.
Packit 7cfc04
This is strictly a violation of the TCP specification,
Packit 7cfc04
but required to prevent denial-of-service attacks.
Packit 7cfc04
In Linux 2.2, the default value was 180.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_frto " (integer; default: see below; since Linux 2.4.21/2.6)"
Packit 7cfc04
.\" Since 2.4.21/2.5.43
Packit 7cfc04
Enable F-RTO, an enhanced recovery algorithm for TCP retransmission
Packit 7cfc04
timeouts (RTOs).
Packit 7cfc04
It is particularly beneficial in wireless environments
Packit 7cfc04
where packet loss is typically due to random radio interference
Packit 7cfc04
rather than intermediate router congestion.
Packit 7cfc04
See RFC 4138 for more details.
Packit 7cfc04
.IP
Packit 7cfc04
This file can have one of the following values:
Packit 7cfc04
.RS
Packit 7cfc04
.IP 0 3
Packit 7cfc04
Disabled.
Packit 7cfc04
This was the default up to and including Linux 2.6.23.
Packit 7cfc04
.IP 1
Packit 7cfc04
The basic version F-RTO algorithm is enabled.
Packit 7cfc04
.IP 2
Packit 7cfc04
.\" commit c96fd3d461fa495400df24be3b3b66f0e0b152f9
Packit 7cfc04
Enable SACK-enhanced F-RTO if flow uses SACK.
Packit 7cfc04
The basic version can be used also when
Packit 7cfc04
SACK is in use though in that case scenario(s) exists where F-RTO
Packit 7cfc04
interacts badly with the packet counting of the SACK-enabled TCP flow.
Packit 7cfc04
This value is the default since Linux 2.6.24.
Packit 7cfc04
.RE
Packit 7cfc04
.IP
Packit 7cfc04
Before Linux 2.6.22, this parameter was a Boolean value,
Packit 7cfc04
supporting just values 0 and 1 above.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_frto_response " (integer; default: 0; since Linux 2.6.22)"
Packit 7cfc04
When F-RTO has detected that a TCP retransmission timeout was spurious
Packit 7cfc04
(i.e., the timeout would have been avoided had TCP set a
Packit 7cfc04
longer retransmission timeout),
Packit 7cfc04
TCP has several options concerning what to do next.
Packit 7cfc04
Possible values are:
Packit 7cfc04
.RS
Packit 7cfc04
.IP 0 3
Packit 7cfc04
Rate halving based; a smooth and conservative response,
Packit 7cfc04
results in halved congestion window
Packit 7cfc04
.RI ( cwnd )
Packit 7cfc04
and slow-start threshold
Packit 7cfc04
.RI ( ssthresh )
Packit 7cfc04
after one RTT.
Packit 7cfc04
.IP 1
Packit 7cfc04
Very conservative response; not recommended because even
Packit 7cfc04
though being valid, it interacts poorly with the rest of Linux TCP; halves
Packit 7cfc04
.I cwnd
Packit 7cfc04
and
Packit 7cfc04
.I ssthresh
Packit 7cfc04
immediately.
Packit 7cfc04
.IP 2
Packit 7cfc04
Aggressive response; undoes congestion-control measures
Packit 7cfc04
that are now known to be unnecessary
Packit 7cfc04
(ignoring the possibility of a lost retransmission that would require
Packit 7cfc04
TCP to be more cautious);
Packit 7cfc04
.I cwnd
Packit 7cfc04
and
Packit 7cfc04
.I ssthresh
Packit 7cfc04
are restored to the values prior to timeout.
Packit 7cfc04
.RE
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_keepalive_intvl " (integer; default: 75; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.3.18
Packit 7cfc04
The number of seconds between TCP keep-alive probes.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_keepalive_probes " (integer; default: 9; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.43
Packit 7cfc04
The maximum number of TCP keep-alive probes to send
Packit 7cfc04
before giving up and killing the connection if
Packit 7cfc04
no response is obtained from the other end.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_keepalive_time " (integer; default: 7200; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.43
Packit 7cfc04
The number of seconds a connection needs to be idle
Packit 7cfc04
before TCP begins sending out keep-alive probes.
Packit 7cfc04
Keep-alives are sent only when the
Packit 7cfc04
.B SO_KEEPALIVE
Packit 7cfc04
socket option is enabled.
Packit 7cfc04
The default value is 7200 seconds (2 hours).
Packit 7cfc04
An idle connection is terminated after
Packit 7cfc04
approximately an additional 11 minutes (9 probes an interval
Packit 7cfc04
of 75 seconds apart) when keep-alive is enabled.
Packit 7cfc04
.IP
Packit 7cfc04
Note that underlying connection tracking mechanisms and
Packit 7cfc04
application timeouts may be much shorter.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_low_latency  " (Boolean; default: disabled; since Linux 2.4.21/2.6)"
Packit 7cfc04
.\" Since 2.4.21/2.5.60
Packit 7cfc04
If enabled, the TCP stack makes decisions that prefer lower
Packit 7cfc04
latency as opposed to higher throughput.
Packit 7cfc04
It this option is disabled, then higher throughput is preferred.
Packit 7cfc04
An example of an application where this default should be
Packit 7cfc04
changed would be a Beowulf compute cluster.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_max_orphans  " (integer; default: see below; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.3.41
Packit 7cfc04
The maximum number of orphaned (not attached to any user file
Packit 7cfc04
handle) TCP sockets allowed in the system.
Packit 7cfc04
When this number is exceeded,
Packit 7cfc04
the orphaned connection is reset and a warning is printed.
Packit 7cfc04
This limit exists only to prevent simple denial-of-service attacks.
Packit 7cfc04
Lowering this limit is not recommended.
Packit 7cfc04
Network conditions might require you to increase the number of
Packit 7cfc04
orphans allowed, but note that each orphan can eat up to ~64\ kB
Packit 7cfc04
of unswappable memory.
Packit 7cfc04
The default initial value is set equal to the kernel parameter NR_FILE.
Packit 7cfc04
This initial default is adjusted depending on the memory in the system.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_max_syn_backlog " (integer; default: see below; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.53
Packit 7cfc04
The maximum number of queued connection requests which have
Packit 7cfc04
still not received an acknowledgement from the connecting client.
Packit 7cfc04
If this number is exceeded, the kernel will begin
Packit 7cfc04
dropping requests.
Packit 7cfc04
The default value of 256 is increased to
Packit 7cfc04
1024 when the memory present in the system is adequate or
Packit 7cfc04
greater (>= 128\ MB), and reduced to 128 for those systems with
Packit 7cfc04
very low memory (<= 32\ MB).
Packit 7cfc04
.IP
Packit 7cfc04
Prior to Linux 2.6.20,
Packit 7cfc04
.\" commit 72a3effaf633bcae9034b7e176bdbd78d64a71db
Packit 7cfc04
it was recommended that if this needed to be increased above 1024,
Packit 7cfc04
the size of the SYNACK hash table
Packit 7cfc04
.RB ( TCP_SYNQ_HSIZE )
Packit 7cfc04
in
Packit 7cfc04
.I include/net/tcp.h
Packit 7cfc04
should be modified to keep
Packit 7cfc04
.IP
Packit 7cfc04
    TCP_SYNQ_HSIZE * 16 <= tcp_max_syn_backlog
Packit 7cfc04
.IP
Packit 7cfc04
and the kernel should be
Packit 7cfc04
recompiled.
Packit 7cfc04
In Linux 2.6.20, the fixed sized
Packit 7cfc04
.B TCP_SYNQ_HSIZE
Packit 7cfc04
was removed in favor of dynamic sizing.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_max_tw_buckets " (integer; default: see below; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.3.41
Packit 7cfc04
The maximum number of sockets in TIME_WAIT state allowed in
Packit 7cfc04
the system.
Packit 7cfc04
This limit exists only to prevent simple denial-of-service attacks.
Packit 7cfc04
The default value of NR_FILE*2 is adjusted
Packit 7cfc04
depending on the memory in the system.
Packit 7cfc04
If this number is
Packit 7cfc04
exceeded, the socket is closed and a warning is printed.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_moderate_rcvbuf " (Boolean; default: enabled; since Linux 2.4.17/2.6.7)"
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
If enabled, TCP performs receive buffer auto-tuning,
Packit 7cfc04
attempting to automatically size the buffer (no greater than
Packit 7cfc04
.IR tcp_rmem[2] )
Packit 7cfc04
to match the size required by the path for full throughput.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_mem " (since Linux 2.4)
Packit 7cfc04
.\" Since 2.4.0-test7
Packit 7cfc04
This is a vector of 3 integers: [low, pressure, high].
Packit 7cfc04
These bounds, measured in units of the system page size,
Packit 7cfc04
are used by TCP to track its memory usage.
Packit 7cfc04
The defaults are calculated at boot time from the amount of
Packit 7cfc04
available memory.
Packit 7cfc04
(TCP can only use
Packit 7cfc04
.I "low memory"
Packit 7cfc04
for this, which is limited to around 900 megabytes on 32-bit systems.
Packit 7cfc04
64-bit systems do not suffer this limitation.)
Packit 7cfc04
.RS
Packit 7cfc04
.TP 10
Packit 7cfc04
.I low
Packit 7cfc04
TCP doesn't regulate its memory allocation when the number
Packit 7cfc04
of pages it has allocated globally is below this number.
Packit 7cfc04
.TP
Packit 7cfc04
.I pressure
Packit 7cfc04
When the amount of memory allocated by TCP
Packit 7cfc04
exceeds this number of pages, TCP moderates its memory consumption.
Packit 7cfc04
This memory pressure state is exited
Packit 7cfc04
once the number of pages allocated falls below
Packit 7cfc04
the
Packit 7cfc04
.I low
Packit 7cfc04
mark.
Packit 7cfc04
.TP
Packit 7cfc04
.I high
Packit 7cfc04
The maximum number of pages, globally, that TCP will allocate.
Packit 7cfc04
This value overrides any other limits imposed by the kernel.
Packit 7cfc04
.RE
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_mtu_probing " (integer; default: 0; since Linux 2.6.17)"
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
This parameter controls TCP Packetization-Layer Path MTU Discovery.
Packit 7cfc04
The following values may be assigned to the file:
Packit 7cfc04
.RS
Packit 7cfc04
.IP 0 3
Packit 7cfc04
Disabled
Packit 7cfc04
.IP 1
Packit 7cfc04
Disabled by default, enabled when an ICMP black hole detected
Packit 7cfc04
.IP 2
Packit 7cfc04
Always enabled, use initial MSS of
Packit 7cfc04
.IR tcp_base_mss .
Packit 7cfc04
.RE
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_no_metrics_save " (Boolean; default: disabled; since Linux 2.6.6)"
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
By default, TCP saves various connection metrics in the route cache
Packit 7cfc04
when the connection closes, so that connections established in the
Packit 7cfc04
near future can use these to set initial conditions.
Packit 7cfc04
Usually, this increases overall performance,
Packit 7cfc04
but it may sometimes cause performance degradation.
Packit 7cfc04
If
Packit 7cfc04
.I tcp_no_metrics_save
Packit 7cfc04
is enabled, TCP will not cache metrics on closing connections.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_orphan_retries " (integer; default: 8; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.3.41
Packit 7cfc04
The maximum number of attempts made to probe the other
Packit 7cfc04
end of a connection which has been closed by our end.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_reordering " (integer; default: 3; since Linux 2.4)"
Packit 7cfc04
.\" Since 2.4.0-test7
Packit 7cfc04
The maximum a packet can be reordered in a TCP packet stream
Packit 7cfc04
without TCP assuming packet loss and going into slow start.
Packit 7cfc04
It is not advisable to change this number.
Packit 7cfc04
This is a packet reordering detection metric designed to
Packit 7cfc04
minimize unnecessary back off and retransmits provoked by
Packit 7cfc04
reordering of packets on a connection.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_retrans_collapse " (Boolean; default: enabled; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.96
Packit 7cfc04
Try to send full-sized packets during retransmit.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_retries1 " (integer; default: 3; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.43
Packit 7cfc04
The number of times TCP will attempt to retransmit a
Packit 7cfc04
packet on an established connection normally,
Packit 7cfc04
without the extra effort of getting the network layers involved.
Packit 7cfc04
Once we exceed this number of
Packit 7cfc04
retransmits, we first have the network layer
Packit 7cfc04
update the route if possible before each new retransmit.
Packit 7cfc04
The default is the RFC specified minimum of 3.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_retries2 " (integer; default: 15; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.43
Packit 7cfc04
The maximum number of times a TCP packet is retransmitted
Packit 7cfc04
in established state before giving up.
Packit 7cfc04
The default value is 15, which corresponds to a duration of
Packit 7cfc04
approximately between 13 to 30 minutes, depending
Packit 7cfc04
on the retransmission timeout.
Packit 7cfc04
The RFC\ 1122 specified
Packit 7cfc04
minimum limit of 100 seconds is typically deemed too short.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_rfc1337 " (Boolean; default: disabled; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.90
Packit 7cfc04
Enable TCP behavior conformant with RFC\ 1337.
Packit 7cfc04
When disabled,
Packit 7cfc04
if a RST is received in TIME_WAIT state, we close
Packit 7cfc04
the socket immediately without waiting for the end
Packit 7cfc04
of the TIME_WAIT period.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_rmem " (since Linux 2.4)"
Packit 7cfc04
.\" Since 2.4.0-test7
Packit 7cfc04
This is a vector of 3 integers: [min, default, max].
Packit 7cfc04
These parameters are used by TCP to regulate receive buffer sizes.
Packit 7cfc04
TCP dynamically adjusts the size of the
Packit 7cfc04
receive buffer from the defaults listed below, in the range
Packit 7cfc04
of these values, depending on memory available in the system.
Packit 7cfc04
.RS
Packit 7cfc04
.TP 10
Packit 7cfc04
.I min
Packit 7cfc04
minimum size of the receive buffer used by each TCP socket.
Packit 7cfc04
The default value is the system page size.
Packit 7cfc04
(On Linux 2.4, the default value is 4\ kB, lowered to
Packit 7cfc04
.B PAGE_SIZE
Packit 7cfc04
bytes in low-memory systems.)
Packit 7cfc04
This value
Packit 7cfc04
is used to ensure that in memory pressure mode,
Packit 7cfc04
allocations below this size will still succeed.
Packit 7cfc04
This is not
Packit 7cfc04
used to bound the size of the receive buffer declared
Packit 7cfc04
using
Packit 7cfc04
.B SO_RCVBUF
Packit 7cfc04
on a socket.
Packit 7cfc04
.TP
Packit 7cfc04
.I default
Packit 7cfc04
the default size of the receive buffer for a TCP socket.
Packit 7cfc04
This value overwrites the initial default buffer size from
Packit 7cfc04
the generic global
Packit 7cfc04
.I net.core.rmem_default
Packit 7cfc04
defined for all protocols.
Packit 7cfc04
The default value is 87380 bytes.
Packit 7cfc04
(On Linux 2.4, this will be lowered to 43689 in low-memory systems.)
Packit 7cfc04
If larger receive buffer sizes are desired, this value should
Packit 7cfc04
be increased (to affect all sockets).
Packit 7cfc04
To employ large TCP windows, the
Packit 7cfc04
.I net.ipv4.tcp_window_scaling
Packit 7cfc04
must be enabled (default).
Packit 7cfc04
.TP
Packit 7cfc04
.I max
Packit 7cfc04
the maximum size of the receive buffer used by each TCP socket.
Packit 7cfc04
This value does not override the global
Packit 7cfc04
.IR net.core.rmem_max .
Packit 7cfc04
This is not used to limit the size of the receive buffer declared using
Packit 7cfc04
.B SO_RCVBUF
Packit 7cfc04
on a socket.
Packit 7cfc04
The default value is calculated using the formula
Packit 7cfc04
.IP
Packit 7cfc04
    max(87380, min(4\ MB, \fItcp_mem\fP[1]*PAGE_SIZE/128))
Packit 7cfc04
.IP
Packit 7cfc04
(On Linux 2.4, the default is 87380*2 bytes,
Packit 7cfc04
lowered to 87380 in low-memory systems).
Packit 7cfc04
.RE
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_sack " (Boolean; default: enabled; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.36
Packit 7cfc04
Enable RFC\ 2018 TCP Selective Acknowledgements.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_slow_start_after_idle " (Boolean; default: enabled; since Linux 2.6.18)"
Packit 7cfc04
.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
If enabled, provide RFC 2861 behavior and time out the congestion
Packit 7cfc04
window after an idle period.
Packit 7cfc04
An idle period is defined as the current RTO (retransmission timeout).
Packit 7cfc04
If disabled, the congestion window will not
Packit 7cfc04
be timed out after an idle period.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_stdurg " (Boolean; default: disabled; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.44
Packit 7cfc04
If this option is enabled, then use the RFC\ 1122 interpretation
Packit 7cfc04
of the TCP urgent-pointer field.
Packit 7cfc04
.\" RFC 793 was ambiguous in its specification of the meaning of the
Packit 7cfc04
.\" urgent pointer.  RFC 1122 (and RFC 961) fixed on a particular
Packit 7cfc04
.\" resolution of this ambiguity (unfortunately the "wrong" one).
Packit 7cfc04
According to this interpretation, the urgent pointer points
Packit 7cfc04
to the last byte of urgent data.
Packit 7cfc04
If this option is disabled, then use the BSD-compatible interpretation of
Packit 7cfc04
the urgent pointer:
Packit 7cfc04
the urgent pointer points to the first byte after the urgent data.
Packit 7cfc04
Enabling this option may lead to interoperability problems.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_syn_retries  " (integer; default: 5; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.38
Packit 7cfc04
The maximum number of times initial SYNs for an active TCP
Packit 7cfc04
connection attempt will be retransmitted.
Packit 7cfc04
This value should not be higher than 255.
Packit 7cfc04
The default value is 5, which corresponds to approximately 180 seconds.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_synack_retries " (integer; default: 5; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.38
Packit 7cfc04
The maximum number of times a SYN/ACK segment
Packit 7cfc04
for a passive TCP connection will be retransmitted.
Packit 7cfc04
This number should not be higher than 255.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_syncookies " (Boolean; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.43
Packit 7cfc04
Enable TCP syncookies.
Packit 7cfc04
The kernel must be compiled with
Packit 7cfc04
.BR CONFIG_SYN_COOKIES .
Packit 7cfc04
Send out syncookies when the syn backlog queue of a socket overflows.
Packit 7cfc04
The syncookies feature attempts to protect a
Packit 7cfc04
socket from a SYN flood attack.
Packit 7cfc04
This should be used as a last resort, if at all.
Packit 7cfc04
This is a violation of the TCP protocol,
Packit 7cfc04
and conflicts with other areas of TCP such as TCP extensions.
Packit 7cfc04
It can cause problems for clients and relays.
Packit 7cfc04
It is not recommended as a tuning mechanism for heavily
Packit 7cfc04
loaded servers to help with overloaded or misconfigured conditions.
Packit 7cfc04
For recommended alternatives see
Packit 7cfc04
.IR tcp_max_syn_backlog ,
Packit 7cfc04
.IR tcp_synack_retries ,
Packit 7cfc04
and
Packit 7cfc04
.IR tcp_abort_on_overflow .
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_timestamps " (integer; default: 1; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.36
Packit 7cfc04
Set to one of the following values to enable or disable RFC\ 1323
Packit 7cfc04
TCP timestamps:
Packit 7cfc04
.RS
Packit 7cfc04
.IP 0 3
Packit 7cfc04
Disable timestamps.
Packit 7cfc04
.IP 1
Packit 7cfc04
Enable timestamps as defined in RFC1323 and use random offset for
Packit 7cfc04
each connection rather than only using the current time.
Packit 7cfc04
.IP 2
Packit 7cfc04
As for the value 1, but without random offsets.
Packit 7cfc04
.\" commit 25429d7b7dca01dc4f17205de023a30ca09390d0
Packit 7cfc04
Setting
Packit 7cfc04
.I tcp_timestamps
Packit 7cfc04
to this value is meaningful since Linux 4.10.
Packit 7cfc04
.RE
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_tso_win_divisor " (integer; default: 3; since Linux 2.6.9)"
Packit 7cfc04
This parameter controls what percentage of the congestion window
Packit 7cfc04
can be consumed by a single TCP Segmentation Offload (TSO) frame.
Packit 7cfc04
The setting of this parameter is a tradeoff between burstiness and
Packit 7cfc04
building larger TSO frames.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_tw_recycle " (Boolean; default: disabled; Linux 2.4 to 4.11)"
Packit 7cfc04
.\" Since 2.3.15
Packit 7cfc04
.\" removed in 4.12; commit 4396e46187ca5070219b81773c4e65088dac50cc
Packit 7cfc04
Enable fast recycling of TIME_WAIT sockets.
Packit 7cfc04
Enabling this option is
Packit 7cfc04
not recommended as the remote IP may not use monotonically increasing
Packit 7cfc04
timestamps (devices behind NAT, devices with per-connection timestamp
Packit 7cfc04
offsets).
Packit 7cfc04
See RFC 1323 (PAWS) and RFC 6191.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_tw_reuse " (Boolean; default: disabled; since Linux 2.4.19/2.6)"
Packit 7cfc04
.\" Since 2.4.19/2.5.43
Packit 7cfc04
Allow to reuse TIME_WAIT sockets for new connections when it is
Packit 7cfc04
safe from protocol viewpoint.
Packit 7cfc04
It should not be changed without advice/request of technical experts.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_vegas_cong_avoid  " (Boolean; default: disabled; Linux 2.2 to 2.6.13)"
Packit 7cfc04
.\" Since 2.1.8; removed in 2.6.13
Packit 7cfc04
Enable TCP Vegas congestion avoidance algorithm.
Packit 7cfc04
TCP Vegas is a sender-side-only change to TCP that anticipates
Packit 7cfc04
the onset of congestion by estimating the bandwidth.
Packit 7cfc04
TCP Vegas adjusts the sending rate by modifying the congestion window.
Packit 7cfc04
TCP Vegas should provide less packet loss, but it is
Packit 7cfc04
not as aggressive as TCP Reno.
Packit 7cfc04
.\"
Packit 7cfc04
.\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_westwood " (Boolean; default: disabled; Linux 2.4.26/2.6.3 to 2.6.13)"
Packit 7cfc04
Enable TCP Westwood+ congestion control algorithm.
Packit 7cfc04
TCP Westwood+ is a sender-side-only modification of the TCP Reno
Packit 7cfc04
protocol stack that optimizes the performance of TCP congestion control.
Packit 7cfc04
It is based on end-to-end bandwidth estimation to set
Packit 7cfc04
congestion window and slow start threshold after a congestion episode.
Packit 7cfc04
Using this estimation, TCP Westwood+ adaptively sets a
Packit 7cfc04
slow start threshold and a congestion window which takes into
Packit 7cfc04
account the bandwidth used at the time congestion is experienced.
Packit 7cfc04
TCP Westwood+ significantly increases fairness with respect to
Packit 7cfc04
TCP Reno in wired networks and throughput over wireless links.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_window_scaling " (Boolean; default: enabled; since Linux 2.2)"
Packit 7cfc04
.\" Since 2.1.36
Packit 7cfc04
Enable RFC\ 1323 TCP window scaling.
Packit 7cfc04
This feature allows the use of a large window
Packit 7cfc04
(> 64\ kB) on a TCP connection, should the other end support it.
Packit 7cfc04
Normally, the 16 bit window length field in the TCP header
Packit 7cfc04
limits the window size to less than 64\ kB.
Packit 7cfc04
If larger windows are desired, applications can increase the size of
Packit 7cfc04
their socket buffers and the window scaling option will be employed.
Packit 7cfc04
If
Packit 7cfc04
.I tcp_window_scaling
Packit 7cfc04
is disabled, TCP will not negotiate the use of window
Packit 7cfc04
scaling with the other end during connection setup.
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_wmem " (since Linux 2.4)"
Packit 7cfc04
.\" Since 2.4.0-test7
Packit 7cfc04
This is a vector of 3 integers: [min, default, max].
Packit 7cfc04
These parameters are used by TCP to regulate send buffer sizes.
Packit 7cfc04
TCP dynamically adjusts the size of the send buffer from the
Packit 7cfc04
default values listed below, in the range of these values,
Packit 7cfc04
depending on memory available.
Packit 7cfc04
.RS
Packit 7cfc04
.TP 10
Packit 7cfc04
.I min
Packit 7cfc04
Minimum size of the send buffer used by each TCP socket.
Packit 7cfc04
The default value is the system page size.
Packit 7cfc04
(On Linux 2.4, the default value is 4\ kB.)
Packit 7cfc04
This value is used to ensure that in memory pressure mode,
Packit 7cfc04
allocations below this size will still succeed.
Packit 7cfc04
This is not used to bound the size of the send buffer declared using
Packit 7cfc04
.B SO_SNDBUF
Packit 7cfc04
on a socket.
Packit 7cfc04
.TP
Packit 7cfc04
.I default
Packit 7cfc04
The default size of the send buffer for a TCP socket.
Packit 7cfc04
This value overwrites the initial default buffer size from
Packit 7cfc04
the generic global
Packit 7cfc04
.I /proc/sys/net/core/wmem_default
Packit 7cfc04
defined for all protocols.
Packit 7cfc04
The default value is 16\ kB.
Packit 7cfc04
.\" True in Linux 2.4 and 2.6
Packit 7cfc04
If larger send buffer sizes are desired, this value
Packit 7cfc04
should be increased (to affect all sockets).
Packit 7cfc04
To employ large TCP windows, the
Packit 7cfc04
.I /proc/sys/net/ipv4/tcp_window_scaling
Packit 7cfc04
must be set to a nonzero value (default).
Packit 7cfc04
.TP
Packit 7cfc04
.I max
Packit 7cfc04
The maximum size of the send buffer used by each TCP socket.
Packit 7cfc04
This value does not override the value in
Packit 7cfc04
.IR /proc/sys/net/core/wmem_max .
Packit 7cfc04
This is not used to limit the size of the send buffer declared using
Packit 7cfc04
.B SO_SNDBUF
Packit 7cfc04
on a socket.
Packit 7cfc04
The default value is calculated using the formula
Packit 7cfc04
.IP
Packit 7cfc04
    max(65536, min(4\ MB, \fItcp_mem\fP[1]*PAGE_SIZE/128))
Packit 7cfc04
.IP
Packit 7cfc04
(On Linux 2.4, the default value is 128\ kB,
Packit 7cfc04
lowered 64\ kB depending on low-memory systems.)
Packit 7cfc04
.RE
Packit 7cfc04
.TP
Packit 7cfc04
.IR tcp_workaround_signed_windows " (Boolean; default: disabled; since Linux 2.6.26)"
Packit 7cfc04
If enabled, assume that no receipt of a window-scaling option means that the
Packit 7cfc04
remote TCP is broken and treats the window as a signed quantity.
Packit 7cfc04
If disabled, assume that the remote TCP is not broken even if we do
Packit 7cfc04
not receive a window scaling option from it.
Packit 7cfc04
.SS Socket options
Packit 7cfc04
To set or get a TCP socket option, call
Packit 7cfc04
.BR getsockopt (2)
Packit 7cfc04
to read or
Packit 7cfc04
.BR setsockopt (2)
Packit 7cfc04
to write the option with the option level argument set to
Packit 7cfc04
.BR IPPROTO_TCP .
Packit 7cfc04
Unless otherwise noted,
Packit 7cfc04
.I optval
Packit 7cfc04
is a pointer to an
Packit 7cfc04
.IR int .
Packit 7cfc04
.\" or SOL_TCP on Linux
Packit 7cfc04
In addition,
Packit 7cfc04
most
Packit 7cfc04
.B IPPROTO_IP
Packit 7cfc04
socket options are valid on TCP sockets.
Packit 7cfc04
For more information see
Packit 7cfc04
.BR ip (7).
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_CONGESTION " (since Linux 2.6.13)"
Packit 7cfc04
.\"	    commit 5f8ef48d240963093451bcf83df89f1a1364f51d
Packit 7cfc04
.\"	    Author: Stephen Hemminger <shemminger@osdl.org>
Packit 7cfc04
The argument for this option is a string.
Packit 7cfc04
This option allows the caller to set the TCP congestion control
Packit 7cfc04
algorithm to be used, on a per-socket basis.
Packit 7cfc04
Unprivileged processes are restricted to choosing one of the algorithms in
Packit 7cfc04
.IR tcp_allowed_congestion_control
Packit 7cfc04
(described above).
Packit 7cfc04
Privileged processes
Packit 7cfc04
.RB ( CAP_NET_ADMIN )
Packit 7cfc04
can choose from any of the available congestion-control algorithms
Packit 7cfc04
(see the description of
Packit 7cfc04
.IR tcp_available_congestion_control
Packit 7cfc04
above).
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_CORK " (since Linux 2.2)"
Packit 7cfc04
.\" precisely: since 2.1.127
Packit 7cfc04
If set, don't send out partial frames.
Packit 7cfc04
All queued partial frames are sent when the option is cleared again.
Packit 7cfc04
This is useful for prepending headers before calling
Packit 7cfc04
.BR sendfile (2),
Packit 7cfc04
or for throughput optimization.
Packit 7cfc04
As currently implemented, there is a 200 millisecond ceiling on the time
Packit 7cfc04
for which output is corked by
Packit 7cfc04
.BR TCP_CORK .
Packit 7cfc04
If this ceiling is reached, then queued data is automatically transmitted.
Packit 7cfc04
This option can be combined with
Packit 7cfc04
.B TCP_NODELAY
Packit 7cfc04
only since Linux 2.5.71.
Packit 7cfc04
This option should not be used in code intended to be portable.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_DEFER_ACCEPT " (since Linux 2.4)"
Packit 7cfc04
.\" Precisely: since 2.3.38
Packit 7cfc04
.\" Useful references:
Packit 7cfc04
.\" http://www.techrepublic.com/article/take-advantage-of-tcp-ip-options-to-optimize-data-transmission/
Packit 7cfc04
.\" http://unix.stackexchange.com/questions/94104/real-world-use-of-tcp-defer-accept
Packit 7cfc04
Allow a listener to be awakened only when data arrives on the socket.
Packit 7cfc04
Takes an integer value (seconds), this can
Packit 7cfc04
bound the maximum number of attempts TCP will make to
Packit 7cfc04
complete the connection.
Packit 7cfc04
This option should not be used in code intended to be portable.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_INFO " (since Linux 2.4)"
Packit 7cfc04
Used to collect information about this socket.
Packit 7cfc04
The kernel returns a \fIstruct tcp_info\fP as defined in the file
Packit 7cfc04
.IR /usr/include/linux/tcp.h .
Packit 7cfc04
This option should not be used in code intended to be portable.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_KEEPCNT " (since Linux 2.4)"
Packit 7cfc04
.\" Precisely: since 2.3.18
Packit 7cfc04
The maximum number of keepalive probes TCP should send
Packit 7cfc04
before dropping the connection.
Packit 7cfc04
This option should not be
Packit 7cfc04
used in code intended to be portable.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_KEEPIDLE " (since Linux 2.4)"
Packit 7cfc04
.\" Precisely: since 2.3.18
Packit 7cfc04
The time (in seconds) the connection needs to remain idle
Packit 7cfc04
before TCP starts sending keepalive probes, if the socket
Packit 7cfc04
option
Packit 7cfc04
.B SO_KEEPALIVE
Packit 7cfc04
has been set on this socket.
Packit 7cfc04
This option should not be used in code intended to be portable.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_KEEPINTVL " (since Linux 2.4)"
Packit 7cfc04
.\" Precisely: since 2.3.18
Packit 7cfc04
The time (in seconds) between individual keepalive probes.
Packit 7cfc04
This option should not be used in code intended to be portable.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_LINGER2 " (since Linux 2.4)"
Packit 7cfc04
.\" Precisely: since 2.3.41
Packit 7cfc04
The lifetime of orphaned FIN_WAIT2 state sockets.
Packit 7cfc04
This option can be used to override the system-wide setting in the file
Packit 7cfc04
.I /proc/sys/net/ipv4/tcp_fin_timeout
Packit 7cfc04
for this socket.
Packit 7cfc04
This is not to be confused with the
Packit 7cfc04
.BR socket (7)
Packit 7cfc04
level option
Packit 7cfc04
.BR SO_LINGER .
Packit 7cfc04
This option should not be used in code intended to be portable.
Packit 7cfc04
.TP
Packit 7cfc04
.B TCP_MAXSEG
Packit 7cfc04
.\" Present in Linux 1.0
Packit 7cfc04
The maximum segment size for outgoing TCP packets.
Packit 7cfc04
In Linux 2.2 and earlier, and in Linux 2.6.28 and later,
Packit 7cfc04
if this option is set before connection establishment, it also
Packit 7cfc04
changes the MSS value announced to the other end in the initial packet.
Packit 7cfc04
Values greater than the (eventual) interface MTU have no effect.
Packit 7cfc04
TCP will also impose
Packit 7cfc04
its minimum and maximum bounds over the value provided.
Packit 7cfc04
.TP
Packit 7cfc04
.B TCP_NODELAY
Packit 7cfc04
.\" Present in Linux 1.0
Packit 7cfc04
If set, disable the Nagle algorithm.
Packit 7cfc04
This means that segments
Packit 7cfc04
are always sent as soon as possible, even if there is only a
Packit 7cfc04
small amount of data.
Packit 7cfc04
When not set, data is buffered until there
Packit 7cfc04
is a sufficient amount to send out, thereby avoiding the
Packit 7cfc04
frequent sending of small packets, which results in poor
Packit 7cfc04
utilization of the network.
Packit 7cfc04
This option is overridden by
Packit 7cfc04
.BR TCP_CORK ;
Packit 7cfc04
however, setting this option forces an explicit flush of
Packit 7cfc04
pending output, even if
Packit 7cfc04
.B TCP_CORK
Packit 7cfc04
is currently set.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_QUICKACK " (since Linux 2.4.4)"
Packit 7cfc04
Enable quickack mode if set or disable quickack
Packit 7cfc04
mode if cleared.
Packit 7cfc04
In quickack mode, acks are sent
Packit 7cfc04
immediately, rather than delayed if needed in accordance
Packit 7cfc04
to normal TCP operation.
Packit 7cfc04
This flag is not permanent,
Packit 7cfc04
it only enables a switch to or from quickack mode.
Packit 7cfc04
Subsequent operation of the TCP protocol will
Packit 7cfc04
once again enter/leave quickack mode depending on
Packit 7cfc04
internal protocol processing and factors such as
Packit 7cfc04
delayed ack timeouts occurring and data transfer.
Packit 7cfc04
This option should not be used in code intended to be
Packit 7cfc04
portable.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_SYNCNT " (since Linux 2.4)"
Packit 7cfc04
.\" Precisely: since 2.3.18
Packit 7cfc04
Set the number of SYN retransmits that TCP should send before
Packit 7cfc04
aborting the attempt to connect.
Packit 7cfc04
It cannot exceed 255.
Packit 7cfc04
This option should not be used in code intended to be portable.
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_USER_TIMEOUT " (since Linux 2.6.37)"
Packit 7cfc04
.\"	    commit dca43c75e7e545694a9dd6288553f55c53e2a3a3
Packit 7cfc04
.\"	    Author: Jerry Chu <hkchu@google.com>
Packit 7cfc04
.\" The following text taken nearly verbatim from Jerry Chu's (excellent)
Packit 7cfc04
.\" commit message.
Packit 7cfc04
.\"
Packit 7cfc04
This option takes an
Packit 7cfc04
.IR "unsigned int"
Packit 7cfc04
as an argument.
Packit 7cfc04
When the value is greater than 0,
Packit 7cfc04
it specifies the maximum amount of time in milliseconds that transmitted
Packit 7cfc04
data may remain unacknowledged before TCP will forcibly close the
Packit 7cfc04
corresponding connection and return
Packit 7cfc04
.B ETIMEDOUT
Packit 7cfc04
to the application.
Packit 7cfc04
If the option value is specified as 0,
Packit 7cfc04
TCP will to use the system default.
Packit 7cfc04
.IP
Packit 7cfc04
Increasing user timeouts allows a TCP connection to survive extended
Packit 7cfc04
periods without end-to-end connectivity.
Packit 7cfc04
Decreasing user timeouts
Packit 7cfc04
allows applications to "fail fast", if so desired.
Packit 7cfc04
Otherwise, failure may take up to 20 minutes with
Packit 7cfc04
the current system defaults in a normal WAN environment.
Packit 7cfc04
.IP
Packit 7cfc04
This option can be set during any state of a TCP connection,
Packit 7cfc04
but is effective only during the synchronized states of a connection
Packit 7cfc04
(ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, and LAST-ACK).
Packit 7cfc04
Moreover, when used with the TCP keepalive
Packit 7cfc04
.RB ( SO_KEEPALIVE )
Packit 7cfc04
option,
Packit 7cfc04
.B TCP_USER_TIMEOUT
Packit 7cfc04
will override keepalive to determine when to close a
Packit 7cfc04
connection due to keepalive failure.
Packit 7cfc04
.IP
Packit 7cfc04
The option has no effect on when TCP retransmits a packet,
Packit 7cfc04
nor when a keepalive probe is sent.
Packit 7cfc04
.IP
Packit 7cfc04
This option, like many others, will be inherited by the socket returned by
Packit 7cfc04
.BR accept (2),
Packit 7cfc04
if it was set on the listening socket.
Packit 7cfc04
.IP
Packit 7cfc04
Further details on the user timeout feature can be found in
Packit 7cfc04
RFC\ 793 and RFC\ 5482 ("TCP User Timeout Option").
Packit 7cfc04
.TP
Packit 7cfc04
.BR TCP_WINDOW_CLAMP " (since Linux 2.4)"
Packit 7cfc04
.\" Precisely: since 2.3.41
Packit 7cfc04
Bound the size of the advertised window to this value.
Packit 7cfc04
The kernel imposes a minimum size of SOCK_MIN_RCVBUF/2.
Packit 7cfc04
This option should not be used in code intended to be
Packit 7cfc04
portable.
Packit 7cfc04
.SS Sockets API
Packit 7cfc04
TCP provides limited support for out-of-band data,
Packit 7cfc04
in the form of (a single byte of) urgent data.
Packit 7cfc04
In Linux this means if the other end sends newer out-of-band
Packit 7cfc04
data the older urgent data is inserted as normal data into
Packit 7cfc04
the stream (even when
Packit 7cfc04
.B SO_OOBINLINE
Packit 7cfc04
is not set).
Packit 7cfc04
This differs from BSD-based stacks.
Packit 7cfc04
.PP
Packit 7cfc04
Linux uses the BSD compatible interpretation of the urgent
Packit 7cfc04
pointer field by default.
Packit 7cfc04
This violates RFC\ 1122, but is
Packit 7cfc04
required for interoperability with other stacks.
Packit 7cfc04
It can be changed via
Packit 7cfc04
.IR /proc/sys/net/ipv4/tcp_stdurg .
Packit 7cfc04
.PP
Packit 7cfc04
It is possible to peek at out-of-band data using the
Packit 7cfc04
.BR recv (2)
Packit 7cfc04
.B MSG_PEEK
Packit 7cfc04
flag.
Packit 7cfc04
.PP
Packit 7cfc04
Since version 2.4, Linux supports the use of
Packit 7cfc04
.B MSG_TRUNC
Packit 7cfc04
in the
Packit 7cfc04
.I flags
Packit 7cfc04
argument of
Packit 7cfc04
.BR recv (2)
Packit 7cfc04
(and
Packit 7cfc04
.BR recvmsg (2)).
Packit 7cfc04
This flag causes the received bytes of data to be discarded,
Packit 7cfc04
rather than passed back in a caller-supplied buffer.
Packit 7cfc04
Since Linux 2.4.4,
Packit 7cfc04
.BR MSG_TRUNC
Packit 7cfc04
also has this effect when used in conjunction with
Packit 7cfc04
.BR MSG_OOB
Packit 7cfc04
to receive out-of-band data.
Packit 7cfc04
.SS Ioctls
Packit 7cfc04
The following
Packit 7cfc04
.BR ioctl (2)
Packit 7cfc04
calls return information in
Packit 7cfc04
.IR value .
Packit 7cfc04
The correct syntax is:
Packit 7cfc04
.PP
Packit 7cfc04
.RS
Packit 7cfc04
.nf
Packit 7cfc04
.BI int " value";
Packit 7cfc04
.IB error " = ioctl(" tcp_socket ", " ioctl_type ", &" value ");"
Packit 7cfc04
.fi
Packit 7cfc04
.RE
Packit 7cfc04
.PP
Packit 7cfc04
.I ioctl_type
Packit 7cfc04
is one of the following:
Packit 7cfc04
.TP
Packit 7cfc04
.B SIOCINQ
Packit 7cfc04
Returns the amount of queued unread data in the receive buffer.
Packit 7cfc04
The socket must not be in LISTEN state, otherwise an error
Packit 7cfc04
.RB ( EINVAL )
Packit 7cfc04
is returned.
Packit 7cfc04
.B SIOCINQ
Packit 7cfc04
is defined in
Packit 7cfc04
.IR <linux/sockios.h> .
Packit 7cfc04
.\" FIXME http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002,
Packit 7cfc04
.\" filed 2010-09-10, may cause SIOCINQ to be defined in glibc headers
Packit 7cfc04
Alternatively,
Packit 7cfc04
you can use the synonymous
Packit 7cfc04
.BR FIONREAD ,
Packit 7cfc04
defined in
Packit 7cfc04
.IR <sys/ioctl.h> .
Packit 7cfc04
.TP
Packit 7cfc04
.B SIOCATMARK
Packit 7cfc04
Returns true (i.e.,
Packit 7cfc04
.I value
Packit 7cfc04
is nonzero) if the inbound data stream is at the urgent mark.
Packit 7cfc04
.IP
Packit 7cfc04
If the
Packit 7cfc04
.B SO_OOBINLINE
Packit 7cfc04
socket option is set, and
Packit 7cfc04
.B SIOCATMARK
Packit 7cfc04
returns true, then the
Packit 7cfc04
next read from the socket will return the urgent data.
Packit 7cfc04
If the
Packit 7cfc04
.B SO_OOBINLINE
Packit 7cfc04
socket option is not set, and
Packit 7cfc04
.B SIOCATMARK
Packit 7cfc04
returns true, then the
Packit 7cfc04
next read from the socket will return the bytes following
Packit 7cfc04
the urgent data (to actually read the urgent data requires the
Packit 7cfc04
.B recv(MSG_OOB)
Packit 7cfc04
flag).
Packit 7cfc04
.IP
Packit 7cfc04
Note that a read never reads across the urgent mark.
Packit 7cfc04
If an application is informed of the presence of urgent data via
Packit 7cfc04
.BR select (2)
Packit 7cfc04
(using the
Packit 7cfc04
.I exceptfds
Packit 7cfc04
argument) or through delivery of a
Packit 7cfc04
.B SIGURG
Packit 7cfc04
signal,
Packit 7cfc04
then it can advance up to the mark using a loop which repeatedly tests
Packit 7cfc04
.B SIOCATMARK
Packit 7cfc04
and performs a read (requesting any number of bytes) as long as
Packit 7cfc04
.B SIOCATMARK
Packit 7cfc04
returns false.
Packit 7cfc04
.TP
Packit 7cfc04
.B SIOCOUTQ
Packit 7cfc04
Returns the amount of unsent data in the socket send queue.
Packit 7cfc04
The socket must not be in LISTEN state, otherwise an error
Packit 7cfc04
.RB ( EINVAL )
Packit 7cfc04
is returned.
Packit 7cfc04
.B SIOCOUTQ
Packit 7cfc04
is defined in
Packit 7cfc04
.IR <linux/sockios.h> .
Packit 7cfc04
.\" FIXME . http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002,
Packit 7cfc04
.\" filed 2010-09-10, may cause SIOCOUTQ to be defined in glibc headers
Packit 7cfc04
Alternatively,
Packit 7cfc04
you can use the synonymous
Packit 7cfc04
.BR TIOCOUTQ ,
Packit 7cfc04
defined in
Packit 7cfc04
.IR <sys/ioctl.h> .
Packit 7cfc04
.SS Error handling
Packit 7cfc04
When a network error occurs, TCP tries to resend the packet.
Packit 7cfc04
If it doesn't succeed after some time, either
Packit 7cfc04
.B ETIMEDOUT
Packit 7cfc04
or the last received error on this connection is reported.
Packit 7cfc04
.PP
Packit 7cfc04
Some applications require a quicker error notification.
Packit 7cfc04
This can be enabled with the
Packit 7cfc04
.B IPPROTO_IP
Packit 7cfc04
level
Packit 7cfc04
.B IP_RECVERR
Packit 7cfc04
socket option.
Packit 7cfc04
When this option is enabled, all incoming
Packit 7cfc04
errors are immediately passed to the user program.
Packit 7cfc04
Use this option with care \(em it makes TCP less tolerant to routing
Packit 7cfc04
changes and other normal network conditions.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EAFNOTSUPPORT
Packit 7cfc04
Passed socket address type in
Packit 7cfc04
.I sin_family
Packit 7cfc04
was not
Packit 7cfc04
.BR AF_INET .
Packit 7cfc04
.TP
Packit 7cfc04
.B EPIPE
Packit 7cfc04
The other end closed the socket unexpectedly or a read is
Packit 7cfc04
executed on a shut down socket.
Packit 7cfc04
.TP
Packit 7cfc04
.B ETIMEDOUT
Packit 7cfc04
The other end didn't acknowledge retransmitted data after some time.
Packit 7cfc04
.PP
Packit 7cfc04
Any errors defined for
Packit 7cfc04
.BR ip (7)
Packit 7cfc04
or the generic socket layer may also be returned for TCP.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
Support for Explicit Congestion Notification, zero-copy
Packit 7cfc04
.BR sendfile (2),
Packit 7cfc04
reordering support and some SACK extensions
Packit 7cfc04
(DSACK) were introduced in 2.4.
Packit 7cfc04
Support for forward acknowledgement (FACK), TIME_WAIT recycling,
Packit 7cfc04
and per-connection keepalive socket options were introduced in 2.3.
Packit 7cfc04
.SH BUGS
Packit 7cfc04
Not all errors are documented.
Packit 7cfc04
.br
Packit 7cfc04
IPv6 is not described.
Packit 7cfc04
.\" Only a single Linux kernel version is described
Packit 7cfc04
.\" Info for 2.2 was lost. Should be added again,
Packit 7cfc04
.\" or put into a separate page.
Packit 7cfc04
.\" .SH AUTHORS
Packit 7cfc04
.\" This man page was originally written by Andi Kleen.
Packit 7cfc04
.\" It was updated for 2.4 by Nivedita Singhvi with input from
Packit 7cfc04
.\" Alexey Kuznetsov's Documentation/networking/ip-sysctl.txt
Packit 7cfc04
.\" document.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR accept (2),
Packit 7cfc04
.BR bind (2),
Packit 7cfc04
.BR connect (2),
Packit 7cfc04
.BR getsockopt (2),
Packit 7cfc04
.BR listen (2),
Packit 7cfc04
.BR recvmsg (2),
Packit 7cfc04
.BR sendfile (2),
Packit 7cfc04
.BR sendmsg (2),
Packit 7cfc04
.BR socket (2),
Packit 7cfc04
.BR ip (7),
Packit 7cfc04
.BR socket (7)
Packit 7cfc04
.PP
Packit 7cfc04
RFC\ 793 for the TCP specification.
Packit 7cfc04
.br
Packit 7cfc04
RFC\ 1122 for the TCP requirements and a description of the Nagle algorithm.
Packit 7cfc04
.br
Packit 7cfc04
RFC\ 1323 for TCP timestamp and window scaling options.
Packit 7cfc04
.br
Packit 7cfc04
RFC\ 1337 for a description of TIME_WAIT assassination hazards.
Packit 7cfc04
.br
Packit 7cfc04
RFC\ 3168 for a description of Explicit Congestion Notification.
Packit 7cfc04
.br
Packit 7cfc04
RFC\ 2581 for TCP congestion control algorithms.
Packit 7cfc04
.br
Packit 7cfc04
RFC\ 2018 and RFC\ 2883 for SACK and extensions to SACK.
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.