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