membarrier.2: Add ENOSYS error for 'nohz_full' CPU setting
[man-pages.git] / man7 / tcp.7
blobe654f02420a6f4b151321608d53787f5a8a83b0c
1 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
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.
5 .\"
6 .\" %%%LICENSE_START(VERBATIM_ONE_PARA)
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.
11 .\" %%%LICENSE_END
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 .\"
17 .\" 2008-11-21, mtk, many, many updates.
18 .\"     The descriptions of /proc files and socket options should now
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).
21 .\"
22 .\" FIXME The following need to be documented
23 .\"     TCP_MD5SIG (2.6.20)
24 .\"         commit cfb6eeb4c860592edd123fdea908d23c6ad1c7dc
25 .\"         Author was yoshfuji@linux-ipv6.org
26 .\"         Needs CONFIG_TCP_MD5SIG
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
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
38 .\"
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>
44 .\"
45 .\"         REMOVED in Linux 3.10
46 .\"             commit 1a2c6181c4a1922021b4d7df373bba612c3e5f04
47 .\"             Author: Christoph Paasch <christoph.paasch@uclouvain.be>
48 .\"
49 .\"     TCP_THIN_LINEAR_TIMEOUTS (2.6.34)
50 .\"         commit 36e31b0af58728071e8023cf8e20c5166b700717
51 .\"         Author: Andreas Petlund <apetlund@simula.no>
52 .\"
53 .\"     TCP_THIN_DUPACK (2.6.34)
54 .\"         commit 7e38017557bc0b87434d184f8804cadb102bb903
55 .\"         Author: Andreas Petlund <apetlund@simula.no>
56 .\"
57 .\"     TCP_REPAIR (3.5)
58 .\"         commit ee9952831cfd0bbe834f4a26489d7dce74582e37
59 .\"         Author: Pavel Emelyanov <xemul@parallels.com>
60 .\"         See also
61 .\"             http://criu.org/TCP_connection
62 .\"             https://lwn.net/Articles/495304/
63 .\"
64 .\"     TCP_REPAIR_QUEUE (3.5)
65 .\"         commit ee9952831cfd0bbe834f4a26489d7dce74582e37
66 .\"         Author: Pavel Emelyanov <xemul@parallels.com>
67 .\"
68 .\"     TCP_QUEUE_SEQ (3.5)
69 .\"         commit ee9952831cfd0bbe834f4a26489d7dce74582e37
70 .\"         Author: Pavel Emelyanov <xemul@parallels.com>
71 .\"
72 .\"     TCP_REPAIR_OPTIONS (3.5)
73 .\"         commit b139ba4e90dccbf4cd4efb112af96a5c9e0b098c
74 .\"         Author: Pavel Emelyanov <xemul@parallels.com>
75 .\"
76 .\"     TCP_FASTOPEN (3.6)
77 .\"         (Fast Open server side implementation completed in 3.7)
78 .\"         http://lwn.net/Articles/508865/
79 .\"
80 .\"     TCP_TIMESTAMP (3.9)
81 .\"        commit 93be6ce0e91b6a94783e012b1857a347a5e6e9f2
82 .\"        Author: Andrey Vagin <avagin@openvz.org>
83 .\"
84 .\"     TCP_NOTSENT_LOWAT (3.12)
85 .\"        commit c9bee3b7fdecb0c1d070c7b54113b3bdfb9a3d36
86 .\"        Author: Eric Dumazet <edumazet@google.com>
87 .\"
88 .\"     TCP_CC_INFO (4.1)
89 .\"        commit 6e9250f59ef9efb932c84850cd221f22c2a03c4a
90 .\"        Author: Eric Dumazet <edumazet@google.com>
91 .\"
92 .\"     TCP_SAVE_SYN, TCP_SAVED_SYN (4.2)
93 .\"         commit cd8ae85299d54155702a56811b2e035e63064d3d
94 .\"         Author: Eric Dumazet <edumazet@google.com>
95 .\"
96 .TH TCP  7 2017-05-03 "Linux" "Linux Programmer's Manual"
97 .SH NAME
98 tcp \- TCP protocol
99 .SH SYNOPSIS
100 .B #include <sys/socket.h>
102 .B #include <netinet/in.h>
104 .B #include <netinet/tcp.h>
106 .B tcp_socket = socket(AF_INET, SOCK_STREAM, 0);
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.
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.
131 After that a new socket for each incoming connection can be accepted using
132 .BR accept (2).
133 A socket which has had
134 .BR accept (2)
136 .BR connect (2)
137 successfully called on it is fully specified and may transmit data.
138 Data cannot be transmitted on listening or not yet connected sockets.
140 Linux supports RFC\ 1323 TCP high performance
141 extensions.
142 These include Protection Against Wrapped
143 Sequence Numbers (PAWS), Window Scaling and Timestamps.
144 Window scaling allows the use
145 of large (> 64K) TCP windows in order to support links with high
146 latency or bandwidth.
147 To make use of them, the send and receive buffer sizes must be increased.
148 They can be set globally with the
149 .I /proc/sys/net/ipv4/tcp_wmem
151 .I /proc/sys/net/ipv4/tcp_rmem
152 files, or on individual sockets by using the
153 .B SO_SNDBUF
155 .B SO_RCVBUF
156 socket options with the
157 .BR setsockopt (2)
158 call.
160 The maximum sizes for socket buffers declared via the
161 .B SO_SNDBUF
163 .B SO_RCVBUF
164 mechanisms are limited by the values in the
165 .I /proc/sys/net/core/rmem_max
167 .I /proc/sys/net/core/wmem_max
168 files.
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)
174 call will not return the same size of buffer as requested in the
175 .BR setsockopt (2)
176 call.
177 TCP uses the extra space for administrative purposes and internal
178 kernel structures, and the
179 .I /proc
180 file values reflect the
181 larger sizes compared to the actual TCP windows.
182 On individual connections, the socket buffer size must be set prior to the
183 .BR listen (2)
185 .BR connect (2)
186 calls in order to have it take effect.
188 .BR socket (7)
189 for more information.
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
205 .B FIOSETOWN
206 ioctls (or the POSIX.1-specified
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),
216 otherwise it can be received only when the
217 .B MSG_OOB
218 flag is set for
219 .BR recv (2)
221 .BR recvmsg (2).
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.
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.
238 .SS Address formats
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.
244 TCP supports point-to-point communication only;
245 broadcasting and multicasting are not
246 supported.
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
253 .BR ip (7).
254 Variables described as
255 .I Boolean
256 take an integer value, with a nonzero value ("true") meaning that
257 the corresponding option is enabled, and a zero value ("false")
258 meaning that the option is disabled.
260 .IR tcp_abc " (Integer; default: 0; Linux 2.6.15 to Linux 3.8)"
261 .\" Since 2.6.15; removed in 3.9
262 .\" commit ca2eb5679f8ddffff60156af42595df44a315ef0
263 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
264 Control the Appropriate Byte Count (ABC), defined in RFC 3465.
265 ABC is a way of increasing the congestion window
266 .RI ( cwnd )
267 more slowly in response to partial acknowledgments.
268 Possible values are:
270 .IP 0 3
271 increase
272 .I cwnd
273 once per acknowledgment (no ABC)
274 .IP 1
275 increase
276 .I cwnd
277 once per acknowledgment of full sized segment
278 .IP 2
279 allow increase
280 .I cwnd
281 by two if acknowledgment is
282 of two segments to compensate for delayed acknowledgments.
285 .IR tcp_abort_on_overflow " (Boolean; default: disabled; since Linux 2.4)"
286 .\" Since 2.3.41
287 Enable resetting connections if the listening service is too
288 slow and unable to keep up and accept them.
289 It means that if overflow occurred due
290 to a burst, the connection will recover.
291 Enable this option
292 .I only
293 if you are really sure that the listening daemon
294 cannot be tuned to accept connections faster.
295 Enabling this option can harm the clients of your server.
297 .IR tcp_adv_win_scale " (integer; default: 2; since Linux 2.4)"
298 .\" Since 2.4.0-test7
299 Count buffering overhead as
300 .IR "bytes/2^tcp_adv_win_scale" ,
302 .I tcp_adv_win_scale
303 is greater than 0; or
304 .IR "bytes-bytes/2^(\-tcp_adv_win_scale)" ,
306 .I tcp_adv_win_scale
307 is less than or equal to zero.
309 The socket receive buffer space is shared between the
310 application and kernel.
311 TCP maintains part of the buffer as
312 the TCP window, this is the size of the receive window
313 advertised to the other end.
314 The rest of the space is used
315 as the "application" buffer, used to isolate the network
316 from scheduling and application latencies.
318 .I tcp_adv_win_scale
319 default value of 2 implies that the space
320 used for the application buffer is one fourth that of the total.
322 .IR tcp_allowed_congestion_control " (String; default: see text; since Linux 2.4.20)"
323 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
324 Show/set the congestion control algorithm choices available to unprivileged
325 processes (see the description of the
326 .B TCP_CONGESTION
327 socket option).
328 The items in the list are separated by white space and
329 terminated by a newline character.
330 The list is a subset of those listed in
331 .IR tcp_available_congestion_control .
332 The default value for this list is "reno" plus the default setting of
333 .IR tcp_congestion_control .
335 .IR tcp_autocorking " (Boolean; default: enabled; since Linux 3.14)"
336 .\" commit f54b311142a92ea2e42598e347b84e1655caf8e3
337 .\" Text heavily based on Documentation/networking/ip-sysctl.txt
338 If this option is enabled, the kernel tries to coalesce small writes
339 (from consecutive
340 .BR write (2)
342 .BR sendmsg (2)
343 calls) as much as possible,
344 in order to decrease the total number of sent packets.
345 Coalescing is done if at least one prior packet for the flow
346 is waiting in Qdisc queues or device transmit queue.
347 Applications can still use the
348 .B TCP_CORK
349 socket option to obtain optimal behavior
350 when they know how/when to uncork their sockets.
352 .IR tcp_available_congestion_control " (String; read-only; since Linux 2.4.20)"
353 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
354 Show a list of the congestion-control algorithms
355 that are registered.
356 The items in the list are separated by white space and
357 terminated by a newline character.
358 This list is a limiting set for the list in
359 .IR tcp_allowed_congestion_control .
360 More congestion-control algorithms may be available as modules,
361 but not loaded.
363 .IR tcp_app_win  " (integer; default: 31; since Linux 2.4)"
364 .\" Since 2.4.0-test7
365 This variable defines how many
366 bytes of the TCP window are reserved for buffering overhead.
368 A maximum of (\fIwindow/2^tcp_app_win\fP, mss) bytes in the window
369 are reserved for the application buffer.
370 A value of 0 implies that no amount is reserved.
372 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
374 .IR tcp_base_mss " (Integer; default: 512; since Linux 2.6.17)
375 The initial value of
376 .I search_low
377 to be used by the packetization layer Path MTU discovery (MTU probing).
378 If MTU probing is enabled,
379 this is the initial MSS used by the connection.
381 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
383 .IR tcp_bic " (Boolean; default: disabled; Linux 2.4.27/2.6.6 to 2.6.13)"
384 Enable BIC TCP congestion control algorithm.
385 BIC-TCP is a sender-side-only change that ensures a linear RTT
386 fairness under large windows while offering both scalability and
387 bounded TCP-friendliness.
388 The protocol combines two schemes
389 called additive increase and binary search increase.
390 When the congestion window is large, additive increase with a large
391 increment ensures linear RTT fairness as well as good scalability.
392 Under small congestion windows, binary search
393 increase provides TCP friendliness.
395 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
397 .IR tcp_bic_low_window " (integer; default: 14; Linux 2.4.27/2.6.6 to 2.6.13)"
398 Set the threshold window (in packets) where BIC TCP starts to
399 adjust the congestion window.
400 Below this threshold BIC TCP behaves the same as the default TCP Reno.
402 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
404 .IR tcp_bic_fast_convergence " (Boolean; default: enabled; Linux 2.4.27/2.6.6 to 2.6.13)"
405 Force BIC TCP to more quickly respond to changes in congestion window.
406 Allows two flows sharing the same connection to converge more rapidly.
408 .IR tcp_congestion_control " (String; default: see text; since Linux 2.4.13)"
409 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
410 Set the default congestion-control algorithm to be used for new connections.
411 The algorithm "reno" is always available,
412 but additional choices may be available depending on kernel configuration.
413 The default value for this file is set as part of kernel configuration.
415 .IR tcp_dma_copybreak " (integer; default: 4096; since Linux 2.6.24)"
416 Lower limit, in bytes, of the size of socket reads that will be
417 offloaded to a DMA copy engine, if one is present in the system
418 and the kernel was configured with the
419 .B CONFIG_NET_DMA
420 option.
422 .IR tcp_dsack " (Boolean; default: enabled; since Linux 2.4)"
423 .\" Since 2.4.0-test7
424 Enable RFC\ 2883 TCP Duplicate SACK support.
426 .IR tcp_ecn " (Integer; default: see below; since Linux 2.4)"
427 .\" Since 2.4.0-test7
428 Enable RFC\ 3168 Explicit Congestion Notification.
430 This file can have one of the following values:
432 .IP 0
433 Disable ECN.
434 Neither initiate nor accept ECN.
435 This was the default up to and including Linux 2.6.30.
436 .IP 1
437 Enable ECN when requested by incoming connections and also
438 request ECN on outgoing connection attempts.
439 .IP 2
440 .\" commit 255cac91c3c9ce7dca7713b93ab03c75b7902e0e
441 Enable ECN when requested by incoming connections,
442 but do not request ECN on outgoing connections.
443 This value is supported, and is the default, since Linux 2.6.31.
446 When enabled, connectivity to some destinations could be affected
447 due to older, misbehaving middle boxes along the path, causing
448 connections to be dropped.
449 However, to facilitate and encourage deployment with option 1, and
450 to work around such buggy equipment, the
451 .B tcp_ecn_fallback
452 option has been introduced.
454 .IR tcp_ecn_fallback " (Boolean; default: enabled; since Linux 4.1)"
455 .\" commit 492135557dc090a1abb2cfbe1a412757e3ed68ab
456 Enable RFC\ 3168, Section 6.1.1.1. fallback.
457 When enabled, outgoing ECN-setup SYNs that time out within the
458 normal SYN retransmission timeout will be resent with CWR and
459 ECE cleared.
461 .IR tcp_fack " (Boolean; default: enabled; since Linux 2.2)"
462 .\" Since 2.1.92
463 Enable TCP Forward Acknowledgement support.
465 .IR tcp_fin_timeout " (integer; default: 60; since Linux 2.2)"
466 .\" Since 2.1.53
467 This specifies how many seconds to wait for a final FIN packet before the
468 socket is forcibly closed.
469 This is strictly a violation of the TCP specification,
470 but required to prevent denial-of-service attacks.
471 In Linux 2.2, the default value was 180.
473 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
475 .IR tcp_frto " (integer; default: see below; since Linux 2.4.21/2.6)"
476 .\" Since 2.4.21/2.5.43
477 Enable F-RTO, an enhanced recovery algorithm for TCP retransmission
478 timeouts (RTOs).
479 It is particularly beneficial in wireless environments
480 where packet loss is typically due to random radio interference
481 rather than intermediate router congestion.
482 See RFC 4138 for more details.
484 This file can have one of the following values:
486 .IP 0 3
487 Disabled.
488 This was the default up to and including Linux 2.6.23.
489 .IP 1
490 The basic version F-RTO algorithm is enabled.
491 .IP 2
492 .\" commit c96fd3d461fa495400df24be3b3b66f0e0b152f9
493 Enable SACK-enhanced F-RTO if flow uses SACK.
494 The basic version can be used also when
495 SACK is in use though in that case scenario(s) exists where F-RTO
496 interacts badly with the packet counting of the SACK-enabled TCP flow.
497 This value is the default since Linux 2.6.24.
500 Before Linux 2.6.22, this parameter was a Boolean value,
501 supporting just values 0 and 1 above.
503 .IR tcp_frto_response " (integer; default: 0; since Linux 2.6.22)"
504 When F-RTO has detected that a TCP retransmission timeout was spurious
505 (i.e., the timeout would have been avoided had TCP set a
506 longer retransmission timeout),
507 TCP has several options concerning what to do next.
508 Possible values are:
510 .IP 0 3
511 Rate halving based; a smooth and conservative response,
512 results in halved congestion window
513 .RI ( cwnd )
514 and slow-start threshold
515 .RI ( ssthresh )
516 after one RTT.
517 .IP 1
518 Very conservative response; not recommended because even
519 though being valid, it interacts poorly with the rest of Linux TCP; halves
520 .I cwnd
522 .I ssthresh
523 immediately.
524 .IP 2
525 Aggressive response; undoes congestion-control measures
526 that are now known to be unnecessary
527 (ignoring the possibility of a lost retransmission that would require
528 TCP to be more cautious);
529 .I cwnd
531 .I ssthresh
532 are restored to the values prior to timeout.
535 .IR tcp_keepalive_intvl " (integer; default: 75; since Linux 2.4)"
536 .\" Since 2.3.18
537 The number of seconds between TCP keep-alive probes.
539 .IR tcp_keepalive_probes " (integer; default: 9; since Linux 2.2)"
540 .\" Since 2.1.43
541 The maximum number of TCP keep-alive probes to send
542 before giving up and killing the connection if
543 no response is obtained from the other end.
545 .IR tcp_keepalive_time " (integer; default: 7200; since Linux 2.2)"
546 .\" Since 2.1.43
547 The number of seconds a connection needs to be idle
548 before TCP begins sending out keep-alive probes.
549 Keep-alives are sent only when the
550 .B SO_KEEPALIVE
551 socket option is enabled.
552 The default value is 7200 seconds (2 hours).
553 An idle connection is terminated after
554 approximately an additional 11 minutes (9 probes an interval
555 of 75 seconds apart) when keep-alive is enabled.
557 Note that underlying connection tracking mechanisms and
558 application timeouts may be much shorter.
560 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
562 .IR tcp_low_latency  " (Boolean; default: disabled; since Linux 2.4.21/2.6)"
563 .\" Since 2.4.21/2.5.60
564 If enabled, the TCP stack makes decisions that prefer lower
565 latency as opposed to higher throughput.
566 It this option is disabled, then higher throughput is preferred.
567 An example of an application where this default should be
568 changed would be a Beowulf compute cluster.
570 .IR tcp_max_orphans  " (integer; default: see below; since Linux 2.4)"
571 .\" Since 2.3.41
572 The maximum number of orphaned (not attached to any user file
573 handle) TCP sockets allowed in the system.
574 When this number is exceeded,
575 the orphaned connection is reset and a warning is printed.
576 This limit exists only to prevent simple denial-of-service attacks.
577 Lowering this limit is not recommended.
578 Network conditions might require you to increase the number of
579 orphans allowed, but note that each orphan can eat up to ~64K
580 of unswappable memory.
581 The default initial value is set equal to the kernel parameter NR_FILE.
582 This initial default is adjusted depending on the memory in the system.
584 .IR tcp_max_syn_backlog " (integer; default: see below; since Linux 2.2)"
585 .\" Since 2.1.53
586 The maximum number of queued connection requests which have
587 still not received an acknowledgement from the connecting client.
588 If this number is exceeded, the kernel will begin
589 dropping requests.
590 The default value of 256 is increased to
591 1024 when the memory present in the system is adequate or
592 greater (>= 128Mb), and reduced to 128 for those systems with
593 very low memory (<= 32Mb).
595 Prior to Linux 2.6.20,
596 .\" commit 72a3effaf633bcae9034b7e176bdbd78d64a71db
597 it was recommended that if this needed to be increased above 1024,
598 the size of the SYNACK hash table
599 .RB ( TCP_SYNQ_HSIZE )
601 .I include/net/tcp.h
602 should be modified to keep
604     TCP_SYNQ_HSIZE * 16 <= tcp_max_syn_backlog
606 and the kernel should be
607 recompiled.
608 In Linux 2.6.20, the fixed sized
609 .B TCP_SYNQ_HSIZE
610 was removed in favor of dynamic sizing.
612 .IR tcp_max_tw_buckets " (integer; default: see below; since Linux 2.4)"
613 .\" Since 2.3.41
614 The maximum number of sockets in TIME_WAIT state allowed in
615 the system.
616 This limit exists only to prevent simple denial-of-service attacks.
617 The default value of NR_FILE*2 is adjusted
618 depending on the memory in the system.
619 If this number is
620 exceeded, the socket is closed and a warning is printed.
622 .IR tcp_moderate_rcvbuf " (Boolean; default: enabled; since Linux 2.4.17/2.6.7)"
623 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
624 If enabled, TCP performs receive buffer auto-tuning,
625 attempting to automatically size the buffer (no greater than
626 .IR tcp_rmem[2] )
627 to match the size required by the path for full throughput.
629 .IR tcp_mem " (since Linux 2.4)
630 .\" Since 2.4.0-test7
631 This is a vector of 3 integers: [low, pressure, high].
632 These bounds, measured in units of the system page size,
633 are used by TCP to track its memory usage.
634 The defaults are calculated at boot time from the amount of
635 available memory.
636 (TCP can only use
637 .I "low memory"
638 for this, which is limited to around 900 megabytes on 32-bit systems.
639 64-bit systems do not suffer this limitation.)
641 .TP 10
642 .I low
643 TCP doesn't regulate its memory allocation when the number
644 of pages it has allocated globally is below this number.
646 .I pressure
647 When the amount of memory allocated by TCP
648 exceeds this number of pages, TCP moderates its memory consumption.
649 This memory pressure state is exited
650 once the number of pages allocated falls below
652 .I low
653 mark.
655 .I high
656 The maximum number of pages, globally, that TCP will allocate.
657 This value overrides any other limits imposed by the kernel.
660 .IR tcp_mtu_probing " (integer; default: 0; since Linux 2.6.17)"
661 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
662 This parameter controls TCP Packetization-Layer Path MTU Discovery.
663 The following values may be assigned to the file:
665 .IP 0 3
666 Disabled
667 .IP 1
668 Disabled by default, enabled when an ICMP black hole detected
669 .IP 2
670 Always enabled, use initial MSS of
671 .IR tcp_base_mss .
674 .IR tcp_no_metrics_save " (Boolean; default: disabled; since Linux 2.6.6)"
675 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
676 By default, TCP saves various connection metrics in the route cache
677 when the connection closes, so that connections established in the
678 near future can use these to set initial conditions.
679 Usually, this increases overall performance,
680 but it may sometimes cause performance degradation.
682 .I tcp_no_metrics_save
683 is enabled, TCP will not cache metrics on closing connections.
685 .IR tcp_orphan_retries " (integer; default: 8; since Linux 2.4)"
686 .\" Since 2.3.41
687 The maximum number of attempts made to probe the other
688 end of a connection which has been closed by our end.
690 .IR tcp_reordering " (integer; default: 3; since Linux 2.4)"
691 .\" Since 2.4.0-test7
692 The maximum a packet can be reordered in a TCP packet stream
693 without TCP assuming packet loss and going into slow start.
694 It is not advisable to change this number.
695 This is a packet reordering detection metric designed to
696 minimize unnecessary back off and retransmits provoked by
697 reordering of packets on a connection.
699 .IR tcp_retrans_collapse " (Boolean; default: enabled; since Linux 2.2)"
700 .\" Since 2.1.96
701 Try to send full-sized packets during retransmit.
703 .IR tcp_retries1 " (integer; default: 3; since Linux 2.2)"
704 .\" Since 2.1.43
705 The number of times TCP will attempt to retransmit a
706 packet on an established connection normally,
707 without the extra effort of getting the network layers involved.
708 Once we exceed this number of
709 retransmits, we first have the network layer
710 update the route if possible before each new retransmit.
711 The default is the RFC specified minimum of 3.
713 .IR tcp_retries2 " (integer; default: 15; since Linux 2.2)"
714 .\" Since 2.1.43
715 The maximum number of times a TCP packet is retransmitted
716 in established state before giving up.
717 The default value is 15, which corresponds to a duration of
718 approximately between 13 to 30 minutes, depending
719 on the retransmission timeout.
720 The RFC\ 1122 specified
721 minimum limit of 100 seconds is typically deemed too short.
723 .IR tcp_rfc1337 " (Boolean; default: disabled; since Linux 2.2)"
724 .\" Since 2.1.90
725 Enable TCP behavior conformant with RFC\ 1337.
726 When disabled,
727 if a RST is received in TIME_WAIT state, we close
728 the socket immediately without waiting for the end
729 of the TIME_WAIT period.
731 .IR tcp_rmem " (since Linux 2.4)"
732 .\" Since 2.4.0-test7
733 This is a vector of 3 integers: [min, default, max].
734 These parameters are used by TCP to regulate receive buffer sizes.
735 TCP dynamically adjusts the size of the
736 receive buffer from the defaults listed below, in the range
737 of these values, depending on memory available in the system.
739 .TP 10
740 .I min
741 minimum size of the receive buffer used by each TCP socket.
742 The default value is the system page size.
743 (On Linux 2.4, the default value is 4K, lowered to
744 .B PAGE_SIZE
745 bytes in low-memory systems.)
746 This value
747 is used to ensure that in memory pressure mode,
748 allocations below this size will still succeed.
749 This is not
750 used to bound the size of the receive buffer declared
751 using
752 .B SO_RCVBUF
753 on a socket.
755 .I default
756 the default size of the receive buffer for a TCP socket.
757 This value overwrites the initial default buffer size from
758 the generic global
759 .I net.core.rmem_default
760 defined for all protocols.
761 The default value is 87380 bytes.
762 (On Linux 2.4, this will be lowered to 43689 in low-memory systems.)
763 If larger receive buffer sizes are desired, this value should
764 be increased (to affect all sockets).
765 To employ large TCP windows, the
766 .I net.ipv4.tcp_window_scaling
767 must be enabled (default).
769 .I max
770 the maximum size of the receive buffer used by each TCP socket.
771 This value does not override the global
772 .IR net.core.rmem_max .
773 This is not used to limit the size of the receive buffer declared using
774 .B SO_RCVBUF
775 on a socket.
776 The default value is calculated using the formula
778     max(87380, min(4MB, \fItcp_mem\fP[1]*PAGE_SIZE/128))
780 (On Linux 2.4, the default is 87380*2 bytes,
781 lowered to 87380 in low-memory systems).
784 .IR tcp_sack " (Boolean; default: enabled; since Linux 2.2)"
785 .\" Since 2.1.36
786 Enable RFC\ 2018 TCP Selective Acknowledgements.
788 .IR tcp_slow_start_after_idle " (Boolean; default: enabled; since Linux 2.6.18)"
789 .\" The following is from 2.6.28-rc4: Documentation/networking/ip-sysctl.txt
790 If enabled, provide RFC 2861 behavior and time out the congestion
791 window after an idle period.
792 An idle period is defined as the current RTO (retransmission timeout).
793 If disabled, the congestion window will not
794 be timed out after an idle period.
796 .IR tcp_stdurg " (Boolean; default: disabled; since Linux 2.2)"
797 .\" Since 2.1.44
798 If this option is enabled, then use the RFC\ 1122 interpretation
799 of the TCP urgent-pointer field.
800 .\" RFC 793 was ambiguous in its specification of the meaning of the
801 .\" urgent pointer.  RFC 1122 (and RFC 961) fixed on a particular
802 .\" resolution of this ambiguity (unfortunately the "wrong" one).
803 According to this interpretation, the urgent pointer points
804 to the last byte of urgent data.
805 If this option is disabled, then use the BSD-compatible interpretation of
806 the urgent pointer:
807 the urgent pointer points to the first byte after the urgent data.
808 Enabling this option may lead to interoperability problems.
810 .IR tcp_syn_retries  " (integer; default: 5; since Linux 2.2)"
811 .\" Since 2.1.38
812 The maximum number of times initial SYNs for an active TCP
813 connection attempt will be retransmitted.
814 This value should not be higher than 255.
815 The default value is 5, which corresponds to approximately 180 seconds.
817 .IR tcp_synack_retries " (integer; default: 5; since Linux 2.2)"
818 .\" Since 2.1.38
819 The maximum number of times a SYN/ACK segment
820 for a passive TCP connection will be retransmitted.
821 This number should not be higher than 255.
823 .IR tcp_syncookies " (Boolean; since Linux 2.2)"
824 .\" Since 2.1.43
825 Enable TCP syncookies.
826 The kernel must be compiled with
827 .BR CONFIG_SYN_COOKIES .
828 Send out syncookies when the syn backlog queue of a socket overflows.
829 The syncookies feature attempts to protect a
830 socket from a SYN flood attack.
831 This should be used as a last resort, if at all.
832 This is a violation of the TCP protocol,
833 and conflicts with other areas of TCP such as TCP extensions.
834 It can cause problems for clients and relays.
835 It is not recommended as a tuning mechanism for heavily
836 loaded servers to help with overloaded or misconfigured conditions.
837 For recommended alternatives see
838 .IR tcp_max_syn_backlog ,
839 .IR tcp_synack_retries ,
841 .IR tcp_abort_on_overflow .
843 .IR tcp_timestamps " (integer; default: 1; since Linux 2.2)"
844 .\" Since 2.1.36
845 Set to one of the following values to enable or disable RFC\ 1323
846 TCP timestamps:
848 .IP 0 3
849 Disable timestamps.
850 .IP 1
851 Enable timestamps as defined in RFC1323 and use random offset for
852 each connection rather than only using the current time.
853 .IP 2
854 As for the value 1, but without random offsets.
855 .\" commit 25429d7b7dca01dc4f17205de023a30ca09390d0
856 Setting
857 .I tcp_timestamps
858 to this value is meaningful since Linux 4.10.
861 .IR tcp_tso_win_divisor " (integer; default: 3; since Linux 2.6.9)"
862 This parameter controls what percentage of the congestion window
863 can be consumed by a single TCP Segmentation Offload (TSO) frame.
864 The setting of this parameter is a tradeoff between burstiness and
865 building larger TSO frames.
867 .IR tcp_tw_recycle " (Boolean; default: disabled; since Linux 2.4)"
868 .\" Since 2.3.15
869 Enable fast recycling of TIME_WAIT sockets.
870 Enabling this option is
871 not recommended for devices communicating with the general Internet
872 or using NAT (Network Address Translation).
873 Since some NAT gateways
874 pass through IP timestamp values, one IP can appear to have
875 non-increasing timestamps.
876 See RFC 1323 (PAWS), RFC 6191.
878 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
880 .IR tcp_tw_reuse " (Boolean; default: disabled; since Linux 2.4.19/2.6)"
881 .\" Since 2.4.19/2.5.43
882 Allow to reuse TIME_WAIT sockets for new connections when it is
883 safe from protocol viewpoint.
884 It should not be changed without advice/request of technical experts.
886 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
888 .IR tcp_vegas_cong_avoid  " (Boolean; default: disabled; Linux 2.2 to 2.6.13)"
889 .\" Since 2.1.8; removed in 2.6.13
890 Enable TCP Vegas congestion avoidance algorithm.
891 TCP Vegas is a sender-side-only change to TCP that anticipates
892 the onset of congestion by estimating the bandwidth.
893 TCP Vegas adjusts the sending rate by modifying the congestion window.
894 TCP Vegas should provide less packet loss, but it is
895 not as aggressive as TCP Reno.
897 .\" The following is from 2.6.12: Documentation/networking/ip-sysctl.txt
899 .IR tcp_westwood " (Boolean; default: disabled; Linux 2.4.26/2.6.3 to 2.6.13)"
900 Enable TCP Westwood+ congestion control algorithm.
901 TCP Westwood+ is a sender-side-only modification of the TCP Reno
902 protocol stack that optimizes the performance of TCP congestion control.
903 It is based on end-to-end bandwidth estimation to set
904 congestion window and slow start threshold after a congestion episode.
905 Using this estimation, TCP Westwood+ adaptively sets a
906 slow start threshold and a congestion window which takes into
907 account the bandwidth used at the time congestion is experienced.
908 TCP Westwood+ significantly increases fairness with respect to
909 TCP Reno in wired networks and throughput over wireless links.
911 .IR tcp_window_scaling " (Boolean; default: enabled; since Linux 2.2)"
912 .\" Since 2.1.36
913 Enable RFC\ 1323 TCP window scaling.
914 This feature allows the use of a large window
915 (> 64K) on a TCP connection, should the other end support it.
916 Normally, the 16 bit window length field in the TCP header
917 limits the window size to less than 64K bytes.
918 If larger windows are desired, applications can increase the size of
919 their socket buffers and the window scaling option will be employed.
921 .I tcp_window_scaling
922 is disabled, TCP will not negotiate the use of window
923 scaling with the other end during connection setup.
925 .IR tcp_wmem " (since Linux 2.4)"
926 .\" Since 2.4.0-test7
927 This is a vector of 3 integers: [min, default, max].
928 These parameters are used by TCP to regulate send buffer sizes.
929 TCP dynamically adjusts the size of the send buffer from the
930 default values listed below, in the range of these values,
931 depending on memory available.
933 .TP 10
934 .I min
935 Minimum size of the send buffer used by each TCP socket.
936 The default value is the system page size.
937 (On Linux 2.4, the default value is 4K bytes.)
938 This value is used to ensure that in memory pressure mode,
939 allocations below this size will still succeed.
940 This is not used to bound the size of the send buffer declared using
941 .B SO_SNDBUF
942 on a socket.
944 .I default
945 The default size of the send buffer for a TCP socket.
946 This value overwrites the initial default buffer size from
947 the generic global
948 .I /proc/sys/net/core/wmem_default
949 defined for all protocols.
950 The default value is 16K bytes.
951 .\" True in Linux 2.4 and 2.6
952 If larger send buffer sizes are desired, this value
953 should be increased (to affect all sockets).
954 To employ large TCP windows, the
955 .I /proc/sys/net/ipv4/tcp_window_scaling
956 must be set to a nonzero value (default).
958 .I max
959 The maximum size of the send buffer used by each TCP socket.
960 This value does not override the value in
961 .IR /proc/sys/net/core/wmem_max .
962 This is not used to limit the size of the send buffer declared using
963 .B SO_SNDBUF
964 on a socket.
965 The default value is calculated using the formula
967     max(65536, min(4MB, \fItcp_mem\fP[1]*PAGE_SIZE/128))
969 (On Linux 2.4, the default value is 128K bytes,
970 lowered 64K depending on low-memory systems.)
973 .IR tcp_workaround_signed_windows " (Boolean; default: disabled; since Linux 2.6.26)"
974 If enabled, assume that no receipt of a window-scaling option means that the
975 remote TCP is broken and treats the window as a signed quantity.
976 If disabled, assume that the remote TCP is not broken even if we do
977 not receive a window scaling option from it.
978 .SS Socket options
979 To set or get a TCP socket option, call
980 .BR getsockopt (2)
981 to read or
982 .BR setsockopt (2)
983 to write the option with the option level argument set to
984 .BR IPPROTO_TCP .
985 Unless otherwise noted,
986 .I optval
987 is a pointer to an
988 .IR int .
989 .\" or SOL_TCP on Linux
990 In addition,
991 most
992 .B IPPROTO_IP
993 socket options are valid on TCP sockets.
994 For more information see
995 .BR ip (7).
997 .BR TCP_CONGESTION " (since Linux 2.6.13)"
998 .\"         commit 5f8ef48d240963093451bcf83df89f1a1364f51d
999 .\"         Author: Stephen Hemminger <shemminger@osdl.org>
1000 The argument for this option is a string.
1001 This option allows the caller to set the TCP congestion control
1002 algorithm to be used, on a per-socket basis.
1003 Unprivileged processes are restricted to choosing one of the algorithms in
1004 .IR tcp_allowed_congestion_control
1005 (described above).
1006 Privileged processes
1007 .RB ( CAP_NET_ADMIN )
1008 can choose from any of the available congestion-control algorithms
1009 (see the description of
1010 .IR tcp_available_congestion_control
1011 above).
1013 .BR TCP_CORK " (since Linux 2.2)"
1014 .\" precisely: since 2.1.127
1015 If set, don't send out partial frames.
1016 All queued partial frames are sent when the option is cleared again.
1017 This is useful for prepending headers before calling
1018 .BR sendfile (2),
1019 or for throughput optimization.
1020 As currently implemented, there is a 200 millisecond ceiling on the time
1021 for which output is corked by
1022 .BR TCP_CORK .
1023 If this ceiling is reached, then queued data is automatically transmitted.
1024 This option can be combined with
1025 .B TCP_NODELAY
1026 only since Linux 2.5.71.
1027 This option should not be used in code intended to be portable.
1029 .BR TCP_DEFER_ACCEPT " (since Linux 2.4)"
1030 .\" Precisely: since 2.3.38
1031 .\" Useful references:
1032 .\" http://www.techrepublic.com/article/take-advantage-of-tcp-ip-options-to-optimize-data-transmission/
1033 .\" http://unix.stackexchange.com/questions/94104/real-world-use-of-tcp-defer-accept
1034 Allow a listener to be awakened only when data arrives on the socket.
1035 Takes an integer value (seconds), this can
1036 bound the maximum number of attempts TCP will make to
1037 complete the connection.
1038 This option should not be used in code intended to be portable.
1040 .BR TCP_INFO " (since Linux 2.4)"
1041 Used to collect information about this socket.
1042 The kernel returns a \fIstruct tcp_info\fP as defined in the file
1043 .IR /usr/include/linux/tcp.h .
1044 This option should not be used in code intended to be portable.
1046 .BR TCP_KEEPCNT " (since Linux 2.4)"
1047 .\" Precisely: since 2.3.18
1048 The maximum number of keepalive probes TCP should send
1049 before dropping the connection.
1050 This option should not be
1051 used in code intended to be portable.
1053 .BR TCP_KEEPIDLE " (since Linux 2.4)"
1054 .\" Precisely: since 2.3.18
1055 The time (in seconds) the connection needs to remain idle
1056 before TCP starts sending keepalive probes, if the socket
1057 option
1058 .B SO_KEEPALIVE
1059 has been set on this socket.
1060 This option should not be used in code intended to be portable.
1062 .BR TCP_KEEPINTVL " (since Linux 2.4)"
1063 .\" Precisely: since 2.3.18
1064 The time (in seconds) between individual keepalive probes.
1065 This option should not be used in code intended to be portable.
1067 .BR TCP_LINGER2 " (since Linux 2.4)"
1068 .\" Precisely: since 2.3.41
1069 The lifetime of orphaned FIN_WAIT2 state sockets.
1070 This option can be used to override the system-wide setting in the file
1071 .I /proc/sys/net/ipv4/tcp_fin_timeout
1072 for this socket.
1073 This is not to be confused with the
1074 .BR socket (7)
1075 level option
1076 .BR SO_LINGER .
1077 This option should not be used in code intended to be portable.
1079 .B TCP_MAXSEG
1080 .\" Present in Linux 1.0
1081 The maximum segment size for outgoing TCP packets.
1082 In Linux 2.2 and earlier, and in Linux 2.6.28 and later,
1083 if this option is set before connection establishment, it also
1084 changes the MSS value announced to the other end in the initial packet.
1085 Values greater than the (eventual) interface MTU have no effect.
1086 TCP will also impose
1087 its minimum and maximum bounds over the value provided.
1089 .B TCP_NODELAY
1090 .\" Present in Linux 1.0
1091 If set, disable the Nagle algorithm.
1092 This means that segments
1093 are always sent as soon as possible, even if there is only a
1094 small amount of data.
1095 When not set, data is buffered until there
1096 is a sufficient amount to send out, thereby avoiding the
1097 frequent sending of small packets, which results in poor
1098 utilization of the network.
1099 This option is overridden by
1100 .BR TCP_CORK ;
1101 however, setting this option forces an explicit flush of
1102 pending output, even if
1103 .B TCP_CORK
1104 is currently set.
1106 .BR TCP_QUICKACK " (since Linux 2.4.4)"
1107 Enable quickack mode if set or disable quickack
1108 mode if cleared.
1109 In quickack mode, acks are sent
1110 immediately, rather than delayed if needed in accordance
1111 to normal TCP operation.
1112 This flag is not permanent,
1113 it only enables a switch to or from quickack mode.
1114 Subsequent operation of the TCP protocol will
1115 once again enter/leave quickack mode depending on
1116 internal protocol processing and factors such as
1117 delayed ack timeouts occurring and data transfer.
1118 This option should not be used in code intended to be
1119 portable.
1121 .BR TCP_SYNCNT " (since Linux 2.4)"
1122 .\" Precisely: since 2.3.18
1123 Set the number of SYN retransmits that TCP should send before
1124 aborting the attempt to connect.
1125 It cannot exceed 255.
1126 This option should not be used in code intended to be portable.
1128 .BR TCP_USER_TIMEOUT " (since Linux 2.6.37)"
1129 .\"         commit dca43c75e7e545694a9dd6288553f55c53e2a3a3
1130 .\"         Author: Jerry Chu <hkchu@google.com>
1131 .\" The following text taken nearly verbatim from Jerry Chu's (excellent)
1132 .\" commit message.
1134 This option takes an
1135 .IR "unsigned int"
1136 as an argument.
1137 When the value is greater than 0,
1138 it specifies the maximum amount of time in milliseconds that transmitted
1139 data may remain unacknowledged before TCP will forcibly close the
1140 corresponding connection and return
1141 .B ETIMEDOUT
1142 to the application.
1143 If the option value is specified as 0,
1144 TCP will to use the system default.
1146 Increasing user timeouts allows a TCP connection to survive extended
1147 periods without end-to-end connectivity.
1148 Decreasing user timeouts
1149 allows applications to "fail fast", if so desired.
1150 Otherwise, failure may take up to 20 minutes with
1151 the current system defaults in a normal WAN environment.
1153 This option can be set during any state of a TCP connection,
1154 but is effective only during the synchronized states of a connection
1155 (ESTABLISHED, FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, and LAST-ACK).
1156 Moreover, when used with the TCP keepalive
1157 .RB ( SO_KEEPALIVE )
1158 option,
1159 .B TCP_USER_TIMEOUT
1160 will override keepalive to determine when to close a
1161 connection due to keepalive failure.
1163 The option has no effect on when TCP retransmits a packet,
1164 nor when a keepalive probe is sent.
1166 This option, like many others, will be inherited by the socket returned by
1167 .BR accept (2),
1168 if it was set on the listening socket.
1170 Further details on the user timeout feature can be found in
1171 RFC\ 793 and RFC\ 5482 ("TCP User Timeout Option").
1173 .BR TCP_WINDOW_CLAMP " (since Linux 2.4)"
1174 .\" Precisely: since 2.3.41
1175 Bound the size of the advertised window to this value.
1176 The kernel imposes a minimum size of SOCK_MIN_RCVBUF/2.
1177 This option should not be used in code intended to be
1178 portable.
1179 .SS Sockets API
1180 TCP provides limited support for out-of-band data,
1181 in the form of (a single byte of) urgent data.
1182 In Linux this means if the other end sends newer out-of-band
1183 data the older urgent data is inserted as normal data into
1184 the stream (even when
1185 .B SO_OOBINLINE
1186 is not set).
1187 This differs from BSD-based stacks.
1189 Linux uses the BSD compatible interpretation of the urgent
1190 pointer field by default.
1191 This violates RFC\ 1122, but is
1192 required for interoperability with other stacks.
1193 It can be changed via
1194 .IR /proc/sys/net/ipv4/tcp_stdurg .
1196 It is possible to peek at out-of-band data using the
1197 .BR recv (2)
1198 .B MSG_PEEK
1199 flag.
1201 Since version 2.4, Linux supports the use of
1202 .B MSG_TRUNC
1203 in the
1204 .I flags
1205 argument of
1206 .BR recv (2)
1207 (and
1208 .BR recvmsg (2)).
1209 This flag causes the received bytes of data to be discarded,
1210 rather than passed back in a caller-supplied buffer.
1211 Since Linux 2.4.4,
1212 .BR MSG_TRUNC
1213 also has this effect when used in conjunction with
1214 .BR MSG_OOB
1215 to receive out-of-band data.
1216 .SS Ioctls
1217 The following
1218 .BR ioctl (2)
1219 calls return information in
1220 .IR value .
1221 The correct syntax is:
1225 .BI int " value";
1226 .IB error " = ioctl(" tcp_socket ", " ioctl_type ", &" value ");"
1230 .I ioctl_type
1231 is one of the following:
1233 .B SIOCINQ
1234 Returns the amount of queued unread data in the receive buffer.
1235 The socket must not be in LISTEN state, otherwise an error
1236 .RB ( EINVAL )
1237 is returned.
1238 .B SIOCINQ
1239 is defined in
1240 .IR <linux/sockios.h> .
1241 .\" FIXME http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002,
1242 .\" filed 2010-09-10, may cause SIOCINQ to be defined in glibc headers
1243 Alternatively,
1244 you can use the synonymous
1245 .BR FIONREAD ,
1246 defined in
1247 .IR <sys/ioctl.h> .
1249 .B SIOCATMARK
1250 Returns true (i.e.,
1251 .I value
1252 is nonzero) if the inbound data stream is at the urgent mark.
1254 If the
1255 .B SO_OOBINLINE
1256 socket option is set, and
1257 .B SIOCATMARK
1258 returns true, then the
1259 next read from the socket will return the urgent data.
1260 If the
1261 .B SO_OOBINLINE
1262 socket option is not set, and
1263 .B SIOCATMARK
1264 returns true, then the
1265 next read from the socket will return the bytes following
1266 the urgent data (to actually read the urgent data requires the
1267 .B recv(MSG_OOB)
1268 flag).
1270 Note that a read never reads across the urgent mark.
1271 If an application is informed of the presence of urgent data via
1272 .BR select (2)
1273 (using the
1274 .I exceptfds
1275 argument) or through delivery of a
1276 .B SIGURG
1277 signal,
1278 then it can advance up to the mark using a loop which repeatedly tests
1279 .B SIOCATMARK
1280 and performs a read (requesting any number of bytes) as long as
1281 .B SIOCATMARK
1282 returns false.
1284 .B SIOCOUTQ
1285 Returns the amount of unsent data in the socket send queue.
1286 The socket must not be in LISTEN state, otherwise an error
1287 .RB ( EINVAL )
1288 is returned.
1289 .B SIOCOUTQ
1290 is defined in
1291 .IR <linux/sockios.h> .
1292 .\" FIXME . http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002,
1293 .\" filed 2010-09-10, may cause SIOCOUTQ to be defined in glibc headers
1294 Alternatively,
1295 you can use the synonymous
1296 .BR TIOCOUTQ ,
1297 defined in
1298 .IR <sys/ioctl.h> .
1299 .SS Error handling
1300 When a network error occurs, TCP tries to resend the packet.
1301 If it doesn't succeed after some time, either
1302 .B ETIMEDOUT
1303 or the last received error on this connection is reported.
1305 Some applications require a quicker error notification.
1306 This can be enabled with the
1307 .B IPPROTO_IP
1308 level
1309 .B IP_RECVERR
1310 socket option.
1311 When this option is enabled, all incoming
1312 errors are immediately passed to the user program.
1313 Use this option with care \(em it makes TCP less tolerant to routing
1314 changes and other normal network conditions.
1315 .SH ERRORS
1317 .B EAFNOTSUPPORT
1318 Passed socket address type in
1319 .I sin_family
1320 was not
1321 .BR AF_INET .
1323 .B EPIPE
1324 The other end closed the socket unexpectedly or a read is
1325 executed on a shut down socket.
1327 .B ETIMEDOUT
1328 The other end didn't acknowledge retransmitted data after some time.
1330 Any errors defined for
1331 .BR ip (7)
1332 or the generic socket layer may also be returned for TCP.
1333 .SH VERSIONS
1334 Support for Explicit Congestion Notification, zero-copy
1335 .BR sendfile (2),
1336 reordering support and some SACK extensions
1337 (DSACK) were introduced in 2.4.
1338 Support for forward acknowledgement (FACK), TIME_WAIT recycling,
1339 and per-connection keepalive socket options were introduced in 2.3.
1340 .SH BUGS
1341 Not all errors are documented.
1343 IPv6 is not described.
1344 .\" Only a single Linux kernel version is described
1345 .\" Info for 2.2 was lost. Should be added again,
1346 .\" or put into a separate page.
1347 .\" .SH AUTHORS
1348 .\" This man page was originally written by Andi Kleen.
1349 .\" It was updated for 2.4 by Nivedita Singhvi with input from
1350 .\" Alexey Kuznetsov's Documentation/networking/ip-sysctl.txt
1351 .\" document.
1352 .SH SEE ALSO
1353 .BR accept (2),
1354 .BR bind (2),
1355 .BR connect (2),
1356 .BR getsockopt (2),
1357 .BR listen (2),
1358 .BR recvmsg (2),
1359 .BR sendfile (2),
1360 .BR sendmsg (2),
1361 .BR socket (2),
1362 .BR ip (7),
1363 .BR socket (7)
1365 RFC\ 793 for the TCP specification.
1367 RFC\ 1122 for the TCP requirements and a description of the Nagle algorithm.
1369 RFC\ 1323 for TCP timestamp and window scaling options.
1371 RFC\ 1337 for a description of TIME_WAIT assassination hazards.
1373 RFC\ 3168 for a description of Explicit Congestion Notification.
1375 RFC\ 2581 for TCP congestion control algorithms.
1377 RFC\ 2018 and RFC\ 2883 for SACK and extensions to SACK.