]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/tcp.4
awk: Merge 20210729 from One True Awk upstream (0592de4a)
[FreeBSD/FreeBSD.git] / share / man / man4 / tcp.4
1 .\" Copyright (c) 1983, 1991, 1993
2 .\"     The Regents of the University of California.
3 .\" Copyright (c) 2010-2011 The FreeBSD Foundation
4 .\" All rights reserved.
5 .\"
6 .\" Portions of this documentation were written at the Centre for Advanced
7 .\" Internet Architectures, Swinburne University of Technology, Melbourne,
8 .\" Australia by David Hayes under sponsorship from the FreeBSD Foundation.
9 .\"
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
12 .\" are met:
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\"    notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\"    notice, this list of conditions and the following disclaimer in the
17 .\"    documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the University nor the names of its contributors
19 .\"    may be used to endorse or promote products derived from this software
20 .\"    without specific prior written permission.
21 .\"
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" SUCH DAMAGE.
33 .\"
34 .\"     From: @(#)tcp.4 8.1 (Berkeley) 6/5/93
35 .\" $FreeBSD$
36 .\"
37 .Dd June 27, 2021
38 .Dt TCP 4
39 .Os
40 .Sh NAME
41 .Nm tcp
42 .Nd Internet Transmission Control Protocol
43 .Sh SYNOPSIS
44 .In sys/types.h
45 .In sys/socket.h
46 .In netinet/in.h
47 .In netinet/tcp.h
48 .Ft int
49 .Fn socket AF_INET SOCK_STREAM 0
50 .Sh DESCRIPTION
51 The
52 .Tn TCP
53 protocol provides reliable, flow-controlled, two-way
54 transmission of data.
55 It is a byte-stream protocol used to
56 support the
57 .Dv SOCK_STREAM
58 abstraction.
59 .Tn TCP
60 uses the standard
61 Internet address format and, in addition, provides a per-host
62 collection of
63 .Dq "port addresses" .
64 Thus, each address is composed
65 of an Internet address specifying the host and network,
66 with a specific
67 .Tn TCP
68 port on the host identifying the peer entity.
69 .Pp
70 Sockets utilizing the
71 .Tn TCP
72 protocol are either
73 .Dq active
74 or
75 .Dq passive .
76 Active sockets initiate connections to passive
77 sockets.
78 By default,
79 .Tn TCP
80 sockets are created active; to create a
81 passive socket, the
82 .Xr listen 2
83 system call must be used
84 after binding the socket with the
85 .Xr bind 2
86 system call.
87 Only passive sockets may use the
88 .Xr accept 2
89 call to accept incoming connections.
90 Only active sockets may use the
91 .Xr connect 2
92 call to initiate connections.
93 .Pp
94 Passive sockets may
95 .Dq underspecify
96 their location to match
97 incoming connection requests from multiple networks.
98 This technique, termed
99 .Dq "wildcard addressing" ,
100 allows a single
101 server to provide service to clients on multiple networks.
102 To create a socket which listens on all networks, the Internet
103 address
104 .Dv INADDR_ANY
105 must be bound.
106 The
107 .Tn TCP
108 port may still be specified
109 at this time; if the port is not specified, the system will assign one.
110 Once a connection has been established, the socket's address is
111 fixed by the peer entity's location.
112 The address assigned to the
113 socket is the address associated with the network interface
114 through which packets are being transmitted and received.
115 Normally, this address corresponds to the peer entity's network.
116 .Pp
117 .Tn TCP
118 supports a number of socket options which can be set with
119 .Xr setsockopt 2
120 and tested with
121 .Xr getsockopt 2 :
122 .Bl -tag -width ".Dv TCP_FUNCTION_BLK"
123 .It Dv TCP_INFO
124 Information about a socket's underlying TCP session may be retrieved
125 by passing the read-only option
126 .Dv TCP_INFO
127 to
128 .Xr getsockopt 2 .
129 It accepts a single argument: a pointer to an instance of
130 .Vt "struct tcp_info" .
131 .Pp
132 This API is subject to change; consult the source to determine
133 which fields are currently filled out by this option.
134 .Fx
135 specific additions include
136 send window size,
137 receive window size,
138 and
139 bandwidth-controlled window space.
140 .It Dv TCP_CCALGOOPT
141 Set or query congestion control algorithm specific parameters.
142 See
143 .Xr mod_cc 4
144 for details.
145 .It Dv TCP_CONGESTION
146 Select or query the congestion control algorithm that TCP will use for the
147 connection.
148 See
149 .Xr mod_cc 4
150 for details.
151 .It Dv TCP_FUNCTION_BLK
152 Select or query the set of functions that TCP will use for this connection.
153 This allows a user to select an alternate TCP stack.
154 The alternate TCP stack must already be loaded in the kernel.
155 To list the available TCP stacks, see
156 .Va functions_available
157 in the
158 .Sx MIB Variables
159 section further down.
160 To list the default TCP stack, see
161 .Va functions_default
162 in the
163 .Sx MIB Variables
164 section.
165 .It Dv TCP_KEEPINIT
166 This
167 .Xr setsockopt 2
168 option accepts a per-socket timeout argument of
169 .Vt "u_int"
170 in seconds, for new, non-established
171 .Tn TCP
172 connections.
173 For the global default in milliseconds see
174 .Va keepinit
175 in the
176 .Sx MIB Variables
177 section further down.
178 .It Dv TCP_KEEPIDLE
179 This
180 .Xr setsockopt 2
181 option accepts an argument of
182 .Vt "u_int"
183 for the amount of time, in seconds, that the connection must be idle
184 before keepalive probes (if enabled) are sent for the connection of this
185 socket.
186 If set on a listening socket, the value is inherited by the newly created
187 socket upon
188 .Xr accept 2 .
189 For the global default in milliseconds see
190 .Va keepidle
191 in the
192 .Sx MIB Variables
193 section further down.
194 .It Dv TCP_KEEPINTVL
195 This
196 .Xr setsockopt 2
197 option accepts an argument of
198 .Vt "u_int"
199 to set the per-socket interval, in seconds, between keepalive probes sent
200 to a peer.
201 If set on a listening socket, the value is inherited by the newly created
202 socket upon
203 .Xr accept 2 .
204 For the global default in milliseconds see
205 .Va keepintvl
206 in the
207 .Sx MIB Variables
208 section further down.
209 .It Dv TCP_KEEPCNT
210 This
211 .Xr setsockopt 2
212 option accepts an argument of
213 .Vt "u_int"
214 and allows a per-socket tuning of the number of probes sent, with no response,
215 before the connection will be dropped.
216 If set on a listening socket, the value is inherited by the newly created
217 socket upon
218 .Xr accept 2 .
219 For the global default see the
220 .Va keepcnt
221 in the
222 .Sx MIB Variables
223 section further down.
224 .It Dv TCP_NODELAY
225 Under most circumstances,
226 .Tn TCP
227 sends data when it is presented;
228 when outstanding data has not yet been acknowledged, it gathers
229 small amounts of output to be sent in a single packet once
230 an acknowledgement is received.
231 For a small number of clients, such as window systems
232 that send a stream of mouse events which receive no replies,
233 this packetization may cause significant delays.
234 The boolean option
235 .Dv TCP_NODELAY
236 defeats this algorithm.
237 .It Dv TCP_MAXSEG
238 By default, a sender- and
239 .No receiver- Ns Tn TCP
240 will negotiate among themselves to determine the maximum segment size
241 to be used for each connection.
242 The
243 .Dv TCP_MAXSEG
244 option allows the user to determine the result of this negotiation,
245 and to reduce it if desired.
246 .It Dv TCP_NOOPT
247 .Tn TCP
248 usually sends a number of options in each packet, corresponding to
249 various
250 .Tn TCP
251 extensions which are provided in this implementation.
252 The boolean option
253 .Dv TCP_NOOPT
254 is provided to disable
255 .Tn TCP
256 option use on a per-connection basis.
257 .It Dv TCP_NOPUSH
258 By convention, the
259 .No sender- Ns Tn TCP
260 will set the
261 .Dq push
262 bit, and begin transmission immediately (if permitted) at the end of
263 every user call to
264 .Xr write 2
265 or
266 .Xr writev 2 .
267 When this option is set to a non-zero value,
268 .Tn TCP
269 will delay sending any data at all until either the socket is closed,
270 or the internal send buffer is filled.
271 .It Dv TCP_MD5SIG
272 This option enables the use of MD5 digests (also known as TCP-MD5)
273 on writes to the specified socket.
274 Outgoing traffic is digested;
275 digests on incoming traffic are verified.
276 When this option is enabled on a socket, all inbound and outgoing
277 TCP segments must be signed with MD5 digests.
278 .Pp
279 One common use for this in a
280 .Fx
281 router deployment is to enable
282 based routers to interwork with Cisco equipment at peering points.
283 Support for this feature conforms to RFC 2385.
284 .Pp
285 In order for this option to function correctly, it is necessary for the
286 administrator to add a tcp-md5 key entry to the system's security
287 associations database (SADB) using the
288 .Xr setkey 8
289 utility.
290 This entry can only be specified on a per-host basis at this time.
291 .Pp
292 If an SADB entry cannot be found for the destination,
293 the system does not send any outgoing segments and drops any inbound segments.
294 .It Dv TCP_STATS
295 Manage collection of connection level statistics using the
296 .Xr stats 3
297 framework.
298 .Pp
299 Each dropped segment is taken into account in the TCP protocol statistics.
300 .It Dv TCP_TXTLS_ENABLE
301 Enable in-kernel Transport Layer Security (TLS) for data written to this
302 socket.
303 See
304 .Xr ktls 4
305 for more details.
306 .It Dv TCP_TXTLS_MODE
307 The integer argument can be used to get or set the current TLS transmit mode
308 of a socket.
309 See
310 .Xr ktls 4
311 for more details.
312 .It Dv TCP_RXTLS_ENABLE
313 Enable in-kernel TLS for data read from this socket.
314 See
315 .Xr ktls 4
316 for more details.
317 .It Dv TCP_REUSPORT_LB_NUMA
318 Changes NUMA affinity filtering for an established TCP listen
319 socket.
320 This option takes a single integer argument which specifies
321 the NUMA domain to filter on for this listen socket.
322 The argument can also have the follwing special values:
323 .Bl -tag -width "Dv TCP_REUSPORT_LB_NUMA"
324 .It Dv TCP_REUSPORT_LB_NUMA_NODOM
325 Remove NUMA filtering for this listen socket.
326 .It Dv TCP_REUSPORT_LB_NUMA_CURDOM
327 Filter traffic associated with the domain where the calling thread is
328 currently executing.
329 This is typically used after a process or thread inherits a listen
330 socket from its parent, and sets its CPU affinity to a particular core.
331 .El
332 .It Dv TCP_REMOTE_UDP_ENCAPS_PORT
333 Set and get the remote UDP encapsulation port.
334 It can only be set on a closed TCP socket.
335 .El
336 .Pp
337 The option level for the
338 .Xr setsockopt 2
339 call is the protocol number for
340 .Tn TCP ,
341 available from
342 .Xr getprotobyname 3 ,
343 or
344 .Dv IPPROTO_TCP .
345 All options are declared in
346 .In netinet/tcp.h .
347 .Pp
348 Options at the
349 .Tn IP
350 transport level may be used with
351 .Tn TCP ;
352 see
353 .Xr ip 4 .
354 Incoming connection requests that are source-routed are noted,
355 and the reverse source route is used in responding.
356 .Pp
357 The default congestion control algorithm for
358 .Tn TCP
359 is
360 .Xr cc_newreno 4 .
361 Other congestion control algorithms can be made available using the
362 .Xr mod_cc 4
363 framework.
364 .Ss MIB Variables
365 The
366 .Tn TCP
367 protocol implements a number of variables in the
368 .Va net.inet.tcp
369 branch of the
370 .Xr sysctl 3
371 MIB.
372 .Bl -tag -width ".Va TCPCTL_DO_RFC1323"
373 .It Dv TCPCTL_DO_RFC1323
374 .Pq Va rfc1323
375 Implement the window scaling and timestamp options of RFC 1323/RFC 7323
376 (default is true).
377 .It Va tolerate_missing_ts
378 Tolerate the missing of timestamps (RFC 1323/RFC 7323) for
379 .Tn TCP
380 segments belonging to
381 .Tn TCP
382 connections for which support of
383 .Tn TCP
384 timestamps has been negotiated.
385 As of June 2021, several TCP stacks are known to violate RFC 7323, including
386 modern widely deployed ones.
387 Therefore the default is 1, i.e., the missing of timestamps is tolerated.
388 .It Dv TCPCTL_MSSDFLT
389 .Pq Va mssdflt
390 The default value used for the maximum segment size
391 .Pq Dq MSS
392 when no advice to the contrary is received from MSS negotiation.
393 .It Dv TCPCTL_SENDSPACE
394 .Pq Va sendspace
395 Maximum
396 .Tn TCP
397 send window.
398 .It Dv TCPCTL_RECVSPACE
399 .Pq Va recvspace
400 Maximum
401 .Tn TCP
402 receive window.
403 .It Va log_in_vain
404 Log any connection attempts to ports where there is not a socket
405 accepting connections.
406 The value of 1 limits the logging to
407 .Tn SYN
408 (connection establishment) packets only.
409 That of 2 results in any
410 .Tn TCP
411 packets to closed ports being logged.
412 Any value unlisted above disables the logging
413 (default is 0, i.e., the logging is disabled).
414 .It Va msl
415 The Maximum Segment Lifetime, in milliseconds, for a packet.
416 .It Va keepinit
417 Timeout, in milliseconds, for new, non-established
418 .Tn TCP
419 connections.
420 The default is 75000 msec.
421 .It Va keepidle
422 Amount of time, in milliseconds, that the connection must be idle
423 before keepalive probes (if enabled) are sent.
424 The default is 7200000 msec (2 hours).
425 .It Va keepintvl
426 The interval, in milliseconds, between keepalive probes sent to remote
427 machines, when no response is received on a
428 .Va keepidle
429 probe.
430 The default is 75000 msec.
431 .It Va keepcnt
432 Number of probes sent, with no response, before a connection
433 is dropped.
434 The default is 8 packets.
435 .It Va always_keepalive
436 Assume that
437 .Dv SO_KEEPALIVE
438 is set on all
439 .Tn TCP
440 connections, the kernel will
441 periodically send a packet to the remote host to verify the connection
442 is still up.
443 .It Va icmp_may_rst
444 Certain
445 .Tn ICMP
446 unreachable messages may abort connections in
447 .Tn SYN-SENT
448 state.
449 .It Va do_tcpdrain
450 Flush packets in the
451 .Tn TCP
452 reassembly queue if the system is low on mbufs.
453 .It Va blackhole
454 If enabled, disable sending of RST when a connection is attempted
455 to a port where there is not a socket accepting connections.
456 See
457 .Xr blackhole 4 .
458 .It Va delayed_ack
459 Delay ACK to try and piggyback it onto a data packet.
460 .It Va delacktime
461 Maximum amount of time, in milliseconds, before a delayed ACK is sent.
462 .It Va path_mtu_discovery
463 Enable Path MTU Discovery.
464 .It Va tcbhashsize
465 Size of the
466 .Tn TCP
467 control-block hash table
468 (read-only).
469 This may be tuned using the kernel option
470 .Dv TCBHASHSIZE
471 or by setting
472 .Va net.inet.tcp.tcbhashsize
473 in the
474 .Xr loader 8 .
475 .It Va pcbcount
476 Number of active process control blocks
477 (read-only).
478 .It Va syncookies
479 Determines whether or not
480 .Tn SYN
481 cookies should be generated for outbound
482 .Tn SYN-ACK
483 packets.
484 .Tn SYN
485 cookies are a great help during
486 .Tn SYN
487 flood attacks, and are enabled by default.
488 (See
489 .Xr syncookies 4 . )
490 .It Va isn_reseed_interval
491 The interval (in seconds) specifying how often the secret data used in
492 RFC 1948 initial sequence number calculations should be reseeded.
493 By default, this variable is set to zero, indicating that
494 no reseeding will occur.
495 Reseeding should not be necessary, and will break
496 .Dv TIME_WAIT
497 recycling for a few minutes.
498 .It Va reass.cursegments
499 The current total number of segments present in all reassembly queues.
500 .It Va reass.maxsegments
501 The maximum limit on the total number of segments across all reassembly
502 queues.
503 The limit can be adjusted as a tunable.
504 .It Va reass.maxqueuelen
505 The maximum number of segments allowed in each reassembly queue.
506 By default, the system chooses a limit based on each TCP connection's
507 receive buffer size and maximum segment size (MSS).
508 The actual limit applied to a session's reassembly queue will be the lower of
509 the system-calculated automatic limit and the user-specified
510 .Va reass.maxqueuelen
511 limit.
512 .It Va rexmit_initial , rexmit_min , rexmit_slop
513 Adjust the retransmit timer calculation for
514 .Tn TCP .
515 The slop is
516 typically added to the raw calculation to take into account
517 occasional variances that the
518 .Tn SRTT
519 (smoothed round-trip time)
520 is unable to accommodate, while the minimum specifies an
521 absolute minimum.
522 While a number of
523 .Tn TCP
524 RFCs suggest a 1
525 second minimum, these RFCs tend to focus on streaming behavior,
526 and fail to deal with the fact that a 1 second minimum has severe
527 detrimental effects over lossy interactive connections, such
528 as a 802.11b wireless link, and over very fast but lossy
529 connections for those cases not covered by the fast retransmit
530 code.
531 For this reason, we use 200ms of slop and a near-0
532 minimum, which gives us an effective minimum of 200ms (similar to
533 .Tn Linux ) .
534 The initial value is used before an RTT measurement has been performed.
535 .It Va initcwnd_segments
536 Enable the ability to specify initial congestion window in number of segments.
537 The default value is 10 as suggested by RFC 6928.
538 Changing the value on fly would not affect connections using congestion window
539 from the hostcache.
540 Caution:
541 This regulates the burst of packets allowed to be sent in the first RTT.
542 The value should be relative to the link capacity.
543 Start with small values for lower-capacity links.
544 Large bursts can cause buffer overruns and packet drops if routers have small
545 buffers or the link is experiencing congestion.
546 .It Va newcwd
547 Enable the New Congestion Window Validation mechanism as described in RFC 7661.
548 This gently reduces the congestion window during periods, where TCP is
549 application limited and the network bandwidth is not utilized completely.
550 That prevents self-inflicted packet losses once the application starts to
551 transmit data at a higher speed.
552 .It Va do_lrd
553 Enable Lost Retransmission Detection for SACK-enabled sessions, disabled by
554 default.
555 Under severe congestion, a retransmission can be lost which then leads to a
556 mandatory Retransmission Timeout (RTO), followed by slow-start.
557 LRD will try to resend the repeatedly lost packet, preventing the time-consuming
558 RTO and performance reducing slow-start.
559 .It Va do_prr
560 Perform SACK loss recovery using the Proportional Rate Reduction (PRR) algorithm
561 described in RFC6937.
562 This improves the effectiveness of retransmissions particular in environments
563 with ACK thinning or burst loss events, as chances to run out of the ACK clock
564 are reduced, preventing lengthy and performance reducing RTO based loss recovery
565 (default is true).
566 .It Va do_prr_conservative
567 While doing Proportional Rate Reduction, remain strictly in a packet conserving
568 mode, sending only one new packet for each ACK received.
569 Helpful when a misconfigured token bucket traffic policer causes persistent
570 high losses leading to RTO, but reduces PRR effectiveness in more common settings
571 (default is false).
572 .It Va rfc6675_pipe
573 Deprecated and superseded by
574 .Va sack.revised
575 .It Va rfc3042
576 Enable the Limited Transmit algorithm as described in RFC 3042.
577 It helps avoid timeouts on lossy links and also when the congestion window
578 is small, as happens on short transfers.
579 .It Va rfc3390
580 Enable support for RFC 3390, which allows for a variable-sized
581 starting congestion window on new connections, depending on the
582 maximum segment size.
583 This helps throughput in general, but
584 particularly affects short transfers and high-bandwidth large
585 propagation-delay connections.
586 .It Va sack.enable
587 Enable support for RFC 2018, TCP Selective Acknowledgment option,
588 which allows the receiver to inform the sender about all successfully
589 arrived segments, allowing the sender to retransmit the missing segments
590 only.
591 .It Va sack.revised
592 Enables three updated mechanisms from RFC6675 (default is true).
593 Calculate the bytes in flight using the algorithm described in RFC 6675, and
594 is also an improvement when Proportional Rate Reduction is enabled.
595 Next, Rescue Retransmission helps timely loss recovery, when the trailing segments
596 of a transmission are lost, while no additional data is ready to be sent.
597 In case a partial ACK without a SACK block is received during SACK loss
598 recovery, the trailing segment is immediately resent, rather than waiting
599 for a Retransmission timeout.
600 Finally, SACK loss recovery is also engaged, once two segments plus one byte are
601 SACKed - even if no traditional duplicate ACKs were observed.
602 .It Va sack.maxholes
603 Maximum number of SACK holes per connection.
604 Defaults to 128.
605 .It Va sack.globalmaxholes
606 Maximum number of SACK holes per system, across all connections.
607 Defaults to 65536.
608 .It Va maxtcptw
609 When a TCP connection enters the
610 .Dv TIME_WAIT
611 state, its associated socket structure is freed, since it is of
612 negligible size and use, and a new structure is allocated to contain a
613 minimal amount of information necessary for sustaining a connection in
614 this state, called the compressed TCP TIME_WAIT state.
615 Since this structure is smaller than a socket structure, it can save
616 a significant amount of system memory.
617 The
618 .Va net.inet.tcp.maxtcptw
619 MIB variable controls the maximum number of these structures allocated.
620 By default, it is initialized to
621 .Va kern.ipc.maxsockets
622 / 5.
623 .It Va nolocaltimewait
624 Suppress creating of compressed TCP TIME_WAIT states for connections in
625 which both endpoints are local.
626 .It Va fast_finwait2_recycle
627 Recycle
628 .Tn TCP
629 .Dv FIN_WAIT_2
630 connections faster when the socket is marked as
631 .Dv SBS_CANTRCVMORE
632 (no user process has the socket open, data received on
633 the socket cannot be read).
634 The timeout used here is
635 .Va finwait2_timeout .
636 .It Va finwait2_timeout
637 Timeout to use for fast recycling of
638 .Tn TCP
639 .Dv FIN_WAIT_2
640 connections.
641 Defaults to 60 seconds.
642 .It Va ecn.enable
643 Enable support for TCP Explicit Congestion Notification (ECN).
644 ECN allows a TCP sender to reduce the transmission rate in order to
645 avoid packet drops.
646 .Bl -tag -compact
647 .It 0
648 Disable ECN.
649 .It 1
650 Allow incoming connections to request ECN.
651 Outgoing connections will request ECN.
652 .It 2
653 Allow incoming connections to request ECN.
654 Outgoing connections will not request ECN.
655 (default)
656 .El
657 .It Va ecn.maxretries
658 Number of retries (SYN or SYN/ACK retransmits) before disabling ECN on a
659 specific connection.
660 This is needed to help with connection establishment
661 when a broken firewall is in the network path.
662 .It Va pmtud_blackhole_detection
663 Enable automatic path MTU blackhole detection.
664 In case of retransmits of MSS sized segments,
665 the OS will lower the MSS to check if it's an MTU problem.
666 If the current MSS is greater than the configured value to try
667 .Po Va net.inet.tcp.pmtud_blackhole_mss
668 and
669 .Va net.inet.tcp.v6pmtud_blackhole_mss
670 .Pc ,
671 it will be set to this value, otherwise,
672 the MSS will be set to the default values
673 .Po Va net.inet.tcp.mssdflt
674 and
675 .Va net.inet.tcp.v6mssdflt
676 .Pc .
677 Settings:
678 .Bl -tag -compact
679 .It 0
680 Disable path MTU blackhole detection.
681 .It 1
682 Enable path MTU blackhole detection for IPv4 and IPv6.
683 .It 2
684 Enable path MTU blackhole detection only for IPv4.
685 .It 3
686 Enable path MTU blackhole detection only for IPv6.
687 .El
688 .It Va pmtud_blackhole_mss
689 MSS to try for IPv4 if PMTU blackhole detection is turned on.
690 .It Va v6pmtud_blackhole_mss
691 MSS to try for IPv6 if PMTU blackhole detection is turned on.
692 .It Va hostcache.enable
693 The TCP host cache is used to cache connection details and metrics to
694 improve future performance of connections between the same hosts.
695 At the completion of a TCP connection, a host will cache information
696 for the connection for some defined period of time.
697 .Bl -tag -compact
698 .It 0
699 Disable the host cache.
700 .It 1
701 Enable the host cache. (default)
702 .El
703 .It Va hostcache.purgenow
704 Immediately purge all entries once set to any value.
705 Setting this to 2 will also reseed the hash salt.
706 .It Va hostcache.purge
707 Expire all entires on next pruning of host cache entries.
708 Any non-zero setting will be reset to zero, once the pruge
709 is running.
710 .Bl -tag -compact
711 .It 0
712 Do not purge all entries when pruning the host cache. (default)
713 .It 1
714 Purge all entries when doing the next pruning.
715 .It 2
716 Purge all entries, and also reseed the hash salt.
717 .El
718 .It Va hostcache.prune
719 Time in seconds between pruning expired host cache entries.
720 Defaults to 300 (5 minutes).
721 .It Va hostcache.expire
722 Time in seconds, how long a entry should be kept in the
723 host cache since last accessed.
724 Defaults to 3600 (1 hour).
725 .It Va hostcache.count
726 The current number of entries in the host cache.
727 .It Va hostcache.bucketlimit
728 The maximum number of entries for the same hash.
729 Defaults to 30.
730 .It Va hostcache.hashsize
731 Size of TCP hostcache hashtable.
732 This number has to be a power of two, or will be rejected.
733 Defaults to 512.
734 .It Va hostcache.cachelimit
735 Overall entry limit for hostcache.
736 Defaults to hashsize * bucketlimit.
737 .It Va hostcache.histo
738 Provide a Histogram of the hostcache hash utilization.
739 .It Va hostcache.list
740 Provide a complete list of all current entries in the host
741 cache.
742 .It Va functions_available
743 List of available TCP function blocks (TCP stacks).
744 .It Va functions_default
745 The default TCP function block (TCP stack).
746 .It Va functions_inherit_listen_socket_stack
747 Determines whether to inherit listen socket's tcp stack or use the current
748 system default tcp stack, as defined by
749 .Va functions_default .
750 Default is true.
751 .It Va insecure_rst
752 Use criteria defined in RFC793 instead of RFC5961 for accepting RST segments.
753 Default is false.
754 .It Va insecure_syn
755 Use criteria defined in RFC793 instead of RFC5961 for accepting SYN segments.
756 Default is false.
757 .It Va ts_offset_per_conn
758 When initializing the TCP timestamps, use a per connection offset instead of a
759 per host pair offset.
760 Default is to use per connection offsets as recommended in RFC 7323.
761 .It Va perconn_stats_enable
762 Controls the default collection of statistics for all connections using the
763 .Xr stats 3
764 framework.
765 0 disables, 1 enables, 2 enables random sampling across log id connection
766 groups with all connections in a group receiving the same setting.
767 .It Va perconn_stats_sample_rates
768 A CSV list of template_spec=percent key-value pairs which controls the per
769 template sampling rates when
770 .Xr stats 3
771 sampling is enabled.
772 .It Va udp_tunneling_port
773 The local UDP encapsulation port.
774 A value of 0 indicates that UDP encapsulation is disabled.
775 The default is 0.
776 .It Va udp_tunneling_overhead
777 The overhead taken into account when using UDP encapsulation.
778 Since MSS clamping by middleboxes will most likely not work, values larger than
779 8 (the size of the UDP header) are also supported.
780 Supported values are between 8 and 1024.
781 The default is 8.
782 .El
783 .Sh ERRORS
784 A socket operation may fail with one of the following errors returned:
785 .Bl -tag -width Er
786 .It Bq Er EISCONN
787 when trying to establish a connection on a socket which
788 already has one;
789 .It Bo Er ENOBUFS Bc or Bo Er ENOMEM Bc
790 when the system runs out of memory for
791 an internal data structure;
792 .It Bq Er ETIMEDOUT
793 when a connection was dropped
794 due to excessive retransmissions;
795 .It Bq Er ECONNRESET
796 when the remote peer
797 forces the connection to be closed;
798 .It Bq Er ECONNREFUSED
799 when the remote
800 peer actively refuses connection establishment (usually because
801 no process is listening to the port);
802 .It Bq Er EADDRINUSE
803 when an attempt
804 is made to create a socket with a port which has already been
805 allocated;
806 .It Bq Er EADDRNOTAVAIL
807 when an attempt is made to create a
808 socket with a network address for which no network interface
809 exists;
810 .It Bq Er EAFNOSUPPORT
811 when an attempt is made to bind or connect a socket to a multicast
812 address.
813 .It Bq Er EINVAL
814 when trying to change TCP function blocks at an invalid point in the session;
815 .It Bq Er ENOENT
816 when trying to use a TCP function block that is not available;
817 .El
818 .Sh SEE ALSO
819 .Xr getsockopt 2 ,
820 .Xr socket 2 ,
821 .Xr stats 3 ,
822 .Xr sysctl 3 ,
823 .Xr blackhole 4 ,
824 .Xr inet 4 ,
825 .Xr intro 4 ,
826 .Xr ip 4 ,
827 .Xr ktls 4 ,
828 .Xr mod_cc 4 ,
829 .Xr siftr 4 ,
830 .Xr syncache 4 ,
831 .Xr tcp_bbr 4 ,
832 .Xr setkey 8 ,
833 .Xr tcp_functions 9
834 .Rs
835 .%A "V. Jacobson"
836 .%A "B. Braden"
837 .%A "D. Borman"
838 .%T "TCP Extensions for High Performance"
839 .%O "RFC 1323"
840 .Re
841 .Rs
842 .%A "D. Borman"
843 .%A "B. Braden"
844 .%A "V. Jacobson"
845 .%A "R. Scheffenegger"
846 .%T "TCP Extensions for High Performance"
847 .%O "RFC 7323"
848 .Re
849 .Rs
850 .%A "A. Heffernan"
851 .%T "Protection of BGP Sessions via the TCP MD5 Signature Option"
852 .%O "RFC 2385"
853 .Re
854 .Rs
855 .%A "K. Ramakrishnan"
856 .%A "S. Floyd"
857 .%A "D. Black"
858 .%T "The Addition of Explicit Congestion Notification (ECN) to IP"
859 .%O "RFC 3168"
860 .Re
861 .Sh HISTORY
862 The
863 .Tn TCP
864 protocol appeared in
865 .Bx 4.2 .
866 The RFC 1323 extensions for window scaling and timestamps were added
867 in
868 .Bx 4.4 .
869 The
870 .Dv TCP_INFO
871 option was introduced in
872 .Tn Linux 2.6
873 and is
874 .Em subject to change .