]>
Commit | Line | Data |
---|---|---|
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 | .\" |
1d767b55 | 96 | .TH TCP 7 2021-03-22 "Linux" "Linux Programmer's Manual" |
77117f4f MK |
97 | .SH NAME |
98 | tcp \- TCP protocol | |
99 | .SH SYNOPSIS | |
c7db92b9 | 100 | .nf |
77117f4f | 101 | .B #include <sys/socket.h> |
77117f4f | 102 | .B #include <netinet/in.h> |
77117f4f | 103 | .B #include <netinet/tcp.h> |
68e4db0a | 104 | .PP |
72f41c04 | 105 | .IB tcp_socket " = socket(AF_INET, SOCK_STREAM, 0);" |
c7db92b9 | 106 | .fi |
77117f4f MK |
107 | .SH DESCRIPTION |
108 | This is an implementation of the TCP protocol defined in | |
109 | RFC\ 793, RFC\ 1122 and RFC\ 2001 with the NewReno and SACK | |
110 | extensions. | |
111 | It provides a reliable, stream-oriented, | |
112 | full-duplex connection between two sockets on top of | |
113 | .BR ip (7), | |
114 | for both v4 and v6 versions. | |
115 | TCP guarantees that the data arrives in order and | |
116 | retransmits lost packets. | |
117 | It generates and checks a per-packet checksum to catch | |
118 | transmission errors. | |
119 | TCP does not preserve record boundaries. | |
5711c04f | 120 | .PP |
77117f4f MK |
121 | A newly created TCP socket has no remote or local address and is not |
122 | fully specified. | |
123 | To create an outgoing TCP connection use | |
124 | .BR connect (2) | |
125 | to establish a connection to another TCP socket. | |
126 | To receive new incoming connections, first | |
127 | .BR bind (2) | |
128 | the socket to a local address and port and then call | |
129 | .BR listen (2) | |
130 | to put the socket into the listening state. | |
412a6fd9 | 131 | After that a new socket for each incoming connection can be accepted using |
77117f4f MK |
132 | .BR accept (2). |
133 | A socket which has had | |
134 | .BR accept (2) | |
135 | or | |
136 | .BR connect (2) | |
412a6fd9 MK |
137 | successfully called on it is fully specified and may transmit data. |
138 | Data cannot be transmitted on listening or not yet connected sockets. | |
5711c04f | 139 | .PP |
77117f4f MK |
140 | Linux supports RFC\ 1323 TCP high performance |
141 | extensions. | |
142 | These include Protection Against Wrapped | |
412a6fd9 | 143 | Sequence Numbers (PAWS), Window Scaling and Timestamps. |
77117f4f | 144 | Window scaling allows the use |
ee8655b5 | 145 | of large (> 64\ kB) TCP windows in order to support links with high |
77117f4f | 146 | latency or bandwidth. |
412a6fd9 | 147 | To make use of them, the send and receive buffer sizes must be increased. |
77117f4f | 148 | They can be set globally with the |
5a2ff571 | 149 | .I /proc/sys/net/ipv4/tcp_wmem |
77117f4f | 150 | and |
5a2ff571 MK |
151 | .I /proc/sys/net/ipv4/tcp_rmem |
152 | files, or on individual sockets by using the | |
77117f4f MK |
153 | .B SO_SNDBUF |
154 | and | |
155 | .B SO_RCVBUF | |
156 | socket options with the | |
157 | .BR setsockopt (2) | |
158 | call. | |
5711c04f | 159 | .PP |
77117f4f MK |
160 | The maximum sizes for socket buffers declared via the |
161 | .B SO_SNDBUF | |
162 | and | |
163 | .B SO_RCVBUF | |
5a2ff571 MK |
164 | mechanisms are limited by the values in the |
165 | .I /proc/sys/net/core/rmem_max | |
77117f4f | 166 | and |
5a2ff571 MK |
167 | .I /proc/sys/net/core/wmem_max |
168 | files. | |
77117f4f MK |
169 | Note that TCP actually allocates twice the size of |
170 | the buffer requested in the | |
171 | .BR setsockopt (2) | |
172 | call, and so a succeeding | |
173 | .BR getsockopt (2) | |
412a6fd9 | 174 | call will not return the same size of buffer as requested in the |
77117f4f MK |
175 | .BR setsockopt (2) |
176 | call. | |
177 | TCP uses the extra space for administrative purposes and internal | |
5a2ff571 | 178 | kernel structures, and the |
412a6fd9 | 179 | .I /proc |
5a2ff571 | 180 | file values reflect the |
77117f4f | 181 | larger sizes compared to the actual TCP windows. |
412a6fd9 | 182 | On individual connections, the socket buffer size must be set prior to the |
77117f4f MK |
183 | .BR listen (2) |
184 | or | |
185 | .BR connect (2) | |
186 | calls in order to have it take effect. | |
187 | See | |
188 | .BR socket (7) | |
189 | for more information. | |
190 | .PP | |
191 | TCP supports urgent data. | |
192 | Urgent data is used to signal the | |
193 | receiver that some important message is part of the data | |
194 | stream and that it should be processed as soon as possible. | |
195 | To send urgent data specify the | |
196 | .B MSG_OOB | |
197 | option to | |
198 | .BR send (2). | |
199 | When urgent data is received, the kernel sends a | |
200 | .B SIGURG | |
201 | signal to the process or process group that has been set as the | |
202 | socket "owner" using the | |
203 | .B SIOCSPGRP | |
204 | or | |
205 | .B FIOSETOWN | |
318143d2 | 206 | ioctls (or the POSIX.1-specified |
77117f4f MK |
207 | .BR fcntl (2) |
208 | .B F_SETOWN | |
209 | operation). | |
210 | When the | |
211 | .B SO_OOBINLINE | |
212 | socket option is enabled, urgent data is put into the normal | |
213 | data stream (a program can test for its location using the | |
214 | .B SIOCATMARK | |
215 | ioctl described below), | |
33a0ccb2 | 216 | otherwise it can be received only when the |
77117f4f MK |
217 | .B MSG_OOB |
218 | flag is set for | |
219 | .BR recv (2) | |
220 | or | |
221 | .BR recvmsg (2). | |
5711c04f | 222 | .PP |
1a2e88ac MK |
223 | When out-of-band data is present, |
224 | .BR select (2) | |
225 | indicates the file descriptor as having an exceptional condition and | |
226 | .I poll (2) | |
227 | indicates a | |
228 | .B POLLPRI | |
229 | event. | |
5711c04f | 230 | .PP |
77117f4f MK |
231 | Linux 2.4 introduced a number of changes for improved |
232 | throughput and scaling, as well as enhanced functionality. | |
233 | Some of these features include support for zero-copy | |
234 | .BR sendfile (2), | |
235 | Explicit Congestion Notification, new | |
236 | management of TIME_WAIT sockets, keep-alive socket options | |
237 | and support for Duplicate SACK extensions. | |
c634028a | 238 | .SS Address formats |
77117f4f MK |
239 | TCP is built on top of IP (see |
240 | .BR ip (7)). | |
241 | The address formats defined by | |
242 | .BR ip (7) | |
243 | apply to TCP. | |
33a0ccb2 MK |
244 | TCP supports point-to-point communication only; |
245 | broadcasting and multicasting are not | |
77117f4f | 246 | supported. |
5a2ff571 MK |
247 | .SS /proc interfaces |
248 | System-wide TCP parameter settings can be accessed by files in the directory | |
249 | .IR /proc/sys/net/ipv4/ . | |
250 | In addition, most IP | |
251 | .I /proc | |
252 | interfaces also apply to TCP; see | |
77117f4f MK |
253 | .BR ip (7). |
254 | Variables described as | |
255 | .I Boolean | |
c7094399 | 256 | take an integer value, with a nonzero value ("true") meaning that |
77117f4f MK |
257 | the corresponding option is enabled, and a zero value ("false") |
258 | meaning that the option is disabled. | |
77117f4f | 259 | .TP |
a6302a4f | 260 | .IR tcp_abc " (Integer; default: 0; Linux 2.6.15 to Linux 3.8)" |
0708cba1 | 261 | .\" Since 2.6.15; removed in 3.9 |
a6302a4f | 262 | .\" commit ca2eb5679f8ddffff60156af42595df44a315ef0 |
f35985c0 | 263 | .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt |