]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/tcp.7
sched.7: Note error that occurs when writing invalid value to /proc/PID/autogroup
[thirdparty/man-pages.git] / man7 / tcp.7
CommitLineData
77117f4f 1.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
60e01ea4
MK
2.\" and Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
3.\" Note also that many pieces are drawn from the kernel source file
4.\" Documentation/networking/ip-sysctl.txt.
2297bf0e 5.\"
00acdba1 6.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
77117f4f
MK
7.\" Permission is granted to distribute possibly modified copies
8.\" of this page provided the header is included verbatim,
9.\" and in case of nontrivial modification author and date
10.\" of the modification is added to the header.
8ff7380d 11.\" %%%LICENSE_END
77117f4f
MK
12.\"
13.\" 2.4 Updates by Nivedita Singhvi 4/20/02 <nivedita@us.ibm.com>.
14.\" Modified, 2004-11-11, Michael Kerrisk and Andries Brouwer
15.\" Updated details of interaction of TCP_CORK and TCP_NODELAY.
16.\"
5b91ca25
MK
17.\" 2008-11-21, mtk, many, many updates.
18.\" The descriptions of /proc files and socket options should now
2a4ed415
MK
19.\" be more or less up to date and complete as at Linux 2.6.27
20.\" (other than the remaining FIXMEs in the page source below).
e6d86b41 21.\"
08df16d4 22.\" FIXME The following need to be documented
08df16d4
MK
23.\" TCP_MD5SIG (2.6.20)
24.\" commit cfb6eeb4c860592edd123fdea908d23c6ad1c7dc
25.\" Author was yoshfuji@linux-ipv6.org
26.\" Needs CONFIG_TCP_MD5SIG
a933bc9e
MK
27.\" From net/inet/Kconfig:
28.\" bool "TCP: MD5 Signature Option support (RFC2385) (EXPERIMENTAL)"
29.\" RFC2385 specifies a method of giving MD5 protection to TCP sessions.
30.\" Its main (only?) use is to protect BGP sessions between core routers
31.\" on the Internet.
32.\"
33.\" There is a TCP_MD5SIG option documented in FreeBSD's tcp(4),
34.\" but probably many details are different on Linux
08df16d4
MK
35.\" http://thread.gmane.org/gmane.linux.network/47490
36.\" http://www.daemon-systems.org/man/tcp.4.html
37.\" http://article.gmane.org/gmane.os.netbsd.devel.network/3767/match=tcp_md5sig+freebsd
a933bc9e 38.\"
08df16d4
MK
39.\" TCP_COOKIE_TRANSACTIONS (2.6.33)
40.\" commit 519855c508b9a17878c0977a3cdefc09b59b30df
41.\" Author: William Allen Simpson <william.allen.simpson@gmail.com>
42.\" commit e56fb50f2b7958b931c8a2fc0966061b3f3c8f3a
43.\" Author: William Allen Simpson <william.allen.simpson@gmail.com>
bd0e4cd5
MK
44.\"
45.\" REMOVED in Linux 3.10
46.\" commit 1a2c6181c4a1922021b4d7df373bba612c3e5f04
47.\" Author: Christoph Paasch <christoph.paasch@uclouvain.be>
48.\"
08df16d4
MK
49.\" TCP_THIN_LINEAR_TIMEOUTS (2.6.34)
50.\" commit 36e31b0af58728071e8023cf8e20c5166b700717
51.\" Author: Andreas Petlund <apetlund@simula.no>
a933bc9e 52.\"
9cfc5a02 53.\" TCP_THIN_DUPACK (2.6.34)
08df16d4
MK
54.\" commit 7e38017557bc0b87434d184f8804cadb102bb903
55.\" Author: Andreas Petlund <apetlund@simula.no>
a933bc9e 56.\"
08df16d4
MK
57.\" TCP_REPAIR (3.5)
58.\" commit ee9952831cfd0bbe834f4a26489d7dce74582e37
59.\" Author: Pavel Emelyanov <xemul@parallels.com>
e464d6b2
MK
60.\" See also
61.\" http://criu.org/TCP_connection
62.\" https://lwn.net/Articles/495304/
a933bc9e 63.\"
08df16d4
MK
64.\" TCP_REPAIR_QUEUE (3.5)
65.\" commit ee9952831cfd0bbe834f4a26489d7dce74582e37
66.\" Author: Pavel Emelyanov <xemul@parallels.com>
a933bc9e 67.\"
08df16d4
MK
68.\" TCP_QUEUE_SEQ (3.5)
69.\" commit ee9952831cfd0bbe834f4a26489d7dce74582e37
70.\" Author: Pavel Emelyanov <xemul@parallels.com>
a933bc9e 71.\"
08df16d4
MK
72.\" TCP_REPAIR_OPTIONS (3.5)
73.\" commit b139ba4e90dccbf4cd4efb112af96a5c9e0b098c
74.\" Author: Pavel Emelyanov <xemul@parallels.com>
a933bc9e 75.\"
0decd92d 76.\" TCP_FASTOPEN (3.6)
9cfc5a02 77.\" (Fast Open server side implementation completed in 3.7)
ee892237 78.\" http://lwn.net/Articles/508865/
a933bc9e 79.\"
0decd92d
MK
80.\" TCP_TIMESTAMP (3.9)
81.\" commit 93be6ce0e91b6a94783e012b1857a347a5e6e9f2
82.\" Author: Andrey Vagin <avagin@openvz.org>
a933bc9e 83.\"
0decd92d
MK
84.\" TCP_NOTSENT_LOWAT (3.12)
85.\" commit c9bee3b7fdecb0c1d070c7b54113b3bdfb9a3d36
86.\" Author: Eric Dumazet <edumazet@google.com>
a933bc9e 87.\"
af54e3b7
MK
88.\" TCP_CC_INFO (4.1)
89.\" commit 6e9250f59ef9efb932c84850cd221f22c2a03c4a
90.\" Author: Eric Dumazet <edumazet@google.com>
a933bc9e 91.\"
af54e3b7
MK
92.\" TCP_SAVE_SYN, TCP_SAVED_SYN (4.2)
93.\" commit cd8ae85299d54155702a56811b2e035e63064d3d
94.\" Author: Eric Dumazet <edumazet@google.com>
0decd92d 95.\"
6f3c74a8 96.TH TCP 7 2015-12-05 "Linux" "Linux Programmer's Manual"
77117f4f
MK
97.SH NAME
98tcp \- TCP protocol
99.SH SYNOPSIS
100.B #include <sys/socket.h>
101.br
102.B #include <netinet/in.h>
103.br
104.B #include <netinet/tcp.h>
105.sp
d4c8c97c 106.B tcp_socket = socket(AF_INET, SOCK_STREAM, 0);
77117f4f
MK
107.SH DESCRIPTION
108This is an implementation of the TCP protocol defined in
109RFC\ 793, RFC\ 1122 and RFC\ 2001 with the NewReno and SACK
110extensions.
111It provides a reliable, stream-oriented,
112full-duplex connection between two sockets on top of
113.BR ip (7),
114for both v4 and v6 versions.
115TCP guarantees that the data arrives in order and
116retransmits lost packets.
117It generates and checks a per-packet checksum to catch
118transmission errors.
119TCP does not preserve record boundaries.
120
121A newly created TCP socket has no remote or local address and is not
122fully specified.
123To create an outgoing TCP connection use
124.BR connect (2)
125to establish a connection to another TCP socket.
126To receive new incoming connections, first
127.BR bind (2)
128the socket to a local address and port and then call
129.BR listen (2)
130to put the socket into the listening state.
412a6fd9 131After that a new socket for each incoming connection can be accepted using
77117f4f
MK
132.BR accept (2).
133A socket which has had
134.BR accept (2)
135or
136.BR connect (2)
412a6fd9
MK
137successfully called on it is fully specified and may transmit data.
138Data cannot be transmitted on listening or not yet connected sockets.
77117f4f
MK
139
140Linux supports RFC\ 1323 TCP high performance
141extensions.
142These include Protection Against Wrapped
412a6fd9 143Sequence Numbers (PAWS), Window Scaling and Timestamps.
77117f4f
MK
144Window scaling allows the use
145of large (> 64K) TCP windows in order to support links with high
146latency or bandwidth.
412a6fd9 147To make use of them, the send and receive buffer sizes must be increased.
77117f4f 148They can be set globally with the
5a2ff571 149.I /proc/sys/net/ipv4/tcp_wmem
77117f4f 150and
5a2ff571
MK
151.I /proc/sys/net/ipv4/tcp_rmem
152files, or on individual sockets by using the
77117f4f
MK
153.B SO_SNDBUF
154and
155.B SO_RCVBUF
156socket options with the
157.BR setsockopt (2)
158call.
159
160The maximum sizes for socket buffers declared via the
161.B SO_SNDBUF
162and
163.B SO_RCVBUF
5a2ff571
MK
164mechanisms are limited by the values in the
165.I /proc/sys/net/core/rmem_max
77117f4f 166and
5a2ff571
MK
167.I /proc/sys/net/core/wmem_max
168files.
77117f4f
MK
169Note that TCP actually allocates twice the size of
170the buffer requested in the
171.BR setsockopt (2)
172call, and so a succeeding
173.BR getsockopt (2)
412a6fd9 174call will not return the same size of buffer as requested in the
77117f4f
MK
175.BR setsockopt (2)
176call.
177TCP uses the extra space for administrative purposes and internal
5a2ff571 178kernel structures, and the
412a6fd9 179.I /proc
5a2ff571 180file values reflect the
77117f4f 181larger sizes compared to the actual TCP windows.
412a6fd9 182On individual connections, the socket buffer size must be set prior to the
77117f4f
MK
183.BR listen (2)
184or
185.BR connect (2)
186calls in order to have it take effect.
187See
188.BR socket (7)
189for more information.
190.PP
191TCP supports urgent data.
192Urgent data is used to signal the
193receiver that some important message is part of the data
194stream and that it should be processed as soon as possible.
195To send urgent data specify the
196.B MSG_OOB
197option to
198.BR send (2).
199When urgent data is received, the kernel sends a
200.B SIGURG
201signal to the process or process group that has been set as the
202socket "owner" using the
203.B SIOCSPGRP
204or
205.B FIOSETOWN
318143d2 206ioctls (or the POSIX.1-specified
77117f4f
MK
207.BR fcntl (2)
208.B F_SETOWN
209operation).
210When the
211.B SO_OOBINLINE
212socket option is enabled, urgent data is put into the normal
213data stream (a program can test for its location using the
214.B SIOCATMARK
215ioctl described below),
33a0ccb2 216otherwise it can be received only when the
77117f4f
MK
217.B MSG_OOB
218flag is set for
219.BR recv (2)
220or
221.BR recvmsg (2).
222
223Linux 2.4 introduced a number of changes for improved
224throughput and scaling, as well as enhanced functionality.
225Some of these features include support for zero-copy
226.BR sendfile (2),
227Explicit Congestion Notification, new
228management of TIME_WAIT sockets, keep-alive socket options
229and support for Duplicate SACK extensions.
c634028a 230.SS Address formats
77117f4f
MK
231TCP is built on top of IP (see
232.BR ip (7)).
233The address formats defined by
234.BR ip (7)
235apply to TCP.
33a0ccb2
MK
236TCP supports point-to-point communication only;
237broadcasting and multicasting are not
77117f4f 238supported.
5a2ff571
MK
239.SS /proc interfaces
240System-wide TCP parameter settings can be accessed by files in the directory
241.IR /proc/sys/net/ipv4/ .
242In addition, most IP
243.I /proc
244interfaces also apply to TCP; see
77117f4f
MK
245.BR ip (7).
246Variables described as
247.I Boolean
c7094399 248take an integer value, with a nonzero value ("true") meaning that
77117f4f
MK
249the corresponding option is enabled, and a zero value ("false")
250meaning that the option is disabled.
77117f4f 251.TP
f35985c0
MK
252.IR tcp_abc " (Integer; default: 0; since Linux 2.6.15)"
253.\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt