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.\" 36.Dd June 29, 2023 37.Dt TCP 4 38.Os 39.Sh NAME 40.Nm tcp 41.Nd Internet Transmission Control Protocol 42.Sh SYNOPSIS 43.In sys/types.h 44.In sys/socket.h 45.In netinet/in.h 46.In netinet/tcp.h 47.Ft int 48.Fn socket AF_INET SOCK_STREAM 0 49.Sh DESCRIPTION 50The 51.Tn TCP 52protocol provides reliable, flow-controlled, two-way 53transmission of data. 54It is a byte-stream protocol used to 55support the 56.Dv SOCK_STREAM 57abstraction. 58.Tn TCP 59uses the standard 60Internet address format and, in addition, provides a per-host 61collection of 62.Dq "port addresses" . 63Thus, each address is composed 64of an Internet address specifying the host and network, 65with a specific 66.Tn TCP 67port on the host identifying the peer entity. 68.Pp 69Sockets utilizing the 70.Tn TCP 71protocol are either 72.Dq active 73or 74.Dq passive . 75Active sockets initiate connections to passive 76sockets. 77By default, 78.Tn TCP 79sockets are created active; to create a 80passive socket, the 81.Xr listen 2 82system call must be used 83after binding the socket with the 84.Xr bind 2 85system call. 86Only passive sockets may use the 87.Xr accept 2 88call to accept incoming connections. 89Only active sockets may use the 90.Xr connect 2 91call to initiate connections. 92.Pp 93Passive sockets may 94.Dq underspecify 95their location to match 96incoming connection requests from multiple networks. 97This technique, termed 98.Dq "wildcard addressing" , 99allows a single 100server to provide service to clients on multiple networks. 101To create a socket which listens on all networks, the Internet 102address 103.Dv INADDR_ANY 104must be bound. 105The 106.Tn TCP 107port may still be specified 108at this time; if the port is not specified, the system will assign one. 109Once a connection has been established, the socket's address is 110fixed by the peer entity's location. 111The address assigned to the 112socket is the address associated with the network interface 113through which packets are being transmitted and received. 114Normally, this address corresponds to the peer entity's network. 115.Pp 116.Tn TCP 117supports a number of socket options which can be set with 118.Xr setsockopt 2 119and tested with 120.Xr getsockopt 2 : 121.Bl -tag -width ".Dv TCP_FUNCTION_BLK" 122.It Dv TCP_INFO 123Information about a socket's underlying TCP session may be retrieved 124by passing the read-only option 125.Dv TCP_INFO 126to 127.Xr getsockopt 2 . 128It accepts a single argument: a pointer to an instance of 129.Vt "struct tcp_info" . 130.Pp 131This API is subject to change; consult the source to determine 132which fields are currently filled out by this option. 133.Fx 134specific additions include 135send window size, 136receive window size, 137and 138bandwidth-controlled window space. 139.It Dv TCP_CCALGOOPT 140Set or query congestion control algorithm specific parameters. 141See 142.Xr mod_cc 4 143for details. 144.It Dv TCP_CONGESTION 145Select or query the congestion control algorithm that TCP will use for the 146connection. 147See 148.Xr mod_cc 4 149for details. 150.It Dv TCP_FASTOPEN 151Enable or disable TCP Fast Open (TFO). 152To use this option, the kernel must be built with the 153.Dv TCP_RFC7413 154option. 155.Pp 156This option can be set on the socket either before or after the 157.Xr listen 2 158is invoked. 159Clearing this option on a listen socket after it has been set has no effect on 160existing TFO connections or TFO connections in progress; it only prevents new 161TFO connections from being established. 162.Pp 163For passively-created sockets, the 164.Dv TCP_FASTOPEN 165socket option can be queried to determine whether the connection was established 166using TFO. 167Note that connections that are established via a TFO 168.Tn SYN , 169but that fall back to using a non-TFO 170.Tn SYN|ACK 171will have the 172.Dv TCP_FASTOPEN 173socket option set. 174.Pp 175In addition to the facilities defined in RFC7413, this implementation supports a 176pre-shared key (PSK) mode of operation in which the TFO server requires the 177client to be in posession of a shared secret in order for the client to be able 178to successfully open TFO connections with the server. 179This is useful, for example, in environments where TFO servers are exposed to 180both internal and external clients and only wish to allow TFO connections from 181internal clients. 182.Pp 183In the PSK mode of operation, the server generates and sends TFO cookies to 184requesting clients as usual. 185However, when validating cookies received in TFO SYNs from clients, the server 186requires the client-supplied cookie to equal 187.Bd -literal -offset left 188SipHash24(key=\fI16-byte-psk\fP, msg=\fIcookie-sent-to-client\fP) 189.Ed 190.Pp 191Multiple concurrent valid pre-shared keys are supported so that time-based 192rolling PSK invalidation policies can be implemented in the system. 193The default number of concurrent pre-shared keys is 2. 194.Pp 195This can be adjusted with the 196.Dv TCP_RFC7413_MAX_PSKS 197kernel option. 198.It Dv TCP_FUNCTION_BLK 199Select or query the set of functions that TCP will use for this connection. 200This allows a user to select an alternate TCP stack. 201The alternate TCP stack must already be loaded in the kernel. 202To list the available TCP stacks, see 203.Va functions_available 204in the 205.Sx MIB (sysctl) Variables 206section further down. 207To list the default TCP stack, see 208.Va functions_default 209in the 210.Sx MIB (sysctl) Variables 211section. 212.It Dv TCP_KEEPINIT 213This 214.Xr setsockopt 2 215option accepts a per-socket timeout argument of 216.Vt "u_int" 217in seconds, for new, non-established 218.Tn TCP 219connections. 220For the global default in milliseconds see 221.Va keepinit 222in the 223.Sx MIB (sysctl) Variables 224section further down. 225.It Dv TCP_KEEPIDLE 226This 227.Xr setsockopt 2 228option accepts an argument of 229.Vt "u_int" 230for the amount of time, in seconds, that the connection must be idle 231before keepalive probes (if enabled) are sent for the connection of this 232socket. 233If set on a listening socket, the value is inherited by the newly created 234socket upon 235.Xr accept 2 . 236For the global default in milliseconds see 237.Va keepidle 238in the 239.Sx MIB (sysctl) Variables 240section further down. 241.It Dv TCP_KEEPINTVL 242This 243.Xr setsockopt 2 244option accepts an argument of 245.Vt "u_int" 246to set the per-socket interval, in seconds, between keepalive probes sent 247to a peer. 248If set on a listening socket, the value is inherited by the newly created 249socket upon 250.Xr accept 2 . 251For the global default in milliseconds see 252.Va keepintvl 253in the 254.Sx MIB (sysctl) Variables 255section further down. 256.It Dv TCP_KEEPCNT 257This 258.Xr setsockopt 2 259option accepts an argument of 260.Vt "u_int" 261and allows a per-socket tuning of the number of probes sent, with no response, 262before the connection will be dropped. 263If set on a listening socket, the value is inherited by the newly created 264socket upon 265.Xr accept 2 . 266For the global default see the 267.Va keepcnt 268in the 269.Sx MIB (sysctl) Variables 270section further down. 271.It Dv TCP_NODELAY 272Under most circumstances, 273.Tn TCP 274sends data when it is presented; 275when outstanding data has not yet been acknowledged, it gathers 276small amounts of output to be sent in a single packet once 277an acknowledgement is received. 278For a small number of clients, such as window systems 279that send a stream of mouse events which receive no replies, 280this packetization may cause significant delays. 281The boolean option 282.Dv TCP_NODELAY 283defeats this algorithm. 284 285.It Dv TCP_MAXSEG 286By default, a sender- and 287.No receiver- Ns Tn TCP 288will negotiate among themselves to determine the maximum segment size 289to be used for each connection. 290The 291.Dv TCP_MAXSEG 292option allows the user to determine the result of this negotiation, 293and to reduce it if desired. 294.It Dv TCP_MAXUNACKTIME 295This 296.Xr setsockopt 2 297option accepts an argument of 298.Vt "u_int" 299to set the per-socket interval, in seconds, in which the connection must 300make progress. Progress is defined by at least 1 byte being acknowledged within 301the set time period. If a connection fails to make progress, then the 302.Tn TCP 303stack will terminate the connection with a reset. Note that the default 304value for this is zero which indicates no progress checks should be made. 305.It Dv TCP_NOOPT 306.Tn TCP 307usually sends a number of options in each packet, corresponding to 308various 309.Tn TCP 310extensions which are provided in this implementation. 311The boolean option 312.Dv TCP_NOOPT 313is provided to disable 314.Tn TCP 315option use on a per-connection basis. 316.It Dv TCP_NOPUSH 317By convention, the 318.No sender- Ns Tn TCP 319will set the 320.Dq push 321bit, and begin transmission immediately (if permitted) at the end of 322every user call to 323.Xr write 2 324or 325.Xr writev 2 . 326When this option is set to a non-zero value, 327.Tn TCP 328will delay sending any data at all until either the socket is closed, 329or the internal send buffer is filled. 330.It Dv TCP_MD5SIG 331This option enables the use of MD5 digests (also known as TCP-MD5) 332on writes to the specified socket. 333Outgoing traffic is digested; 334digests on incoming traffic are verified. 335When this option is enabled on a socket, all inbound and outgoing 336TCP segments must be signed with MD5 digests. 337.Pp 338One common use for this in a 339.Fx 340router deployment is to enable 341based routers to interwork with Cisco equipment at peering points. 342Support for this feature conforms to RFC 2385. 343.Pp 344In order for this option to function correctly, it is necessary for the 345administrator to add a tcp-md5 key entry to the system's security 346associations database (SADB) using the 347.Xr setkey 8 348utility. 349This entry can only be specified on a per-host basis at this time. 350.Pp 351If an SADB entry cannot be found for the destination, 352the system does not send any outgoing segments and drops any inbound segments. 353However, during connection negotiation, a non-signed segment will be accepted if 354an SADB entry does not exist between hosts. 355When a non-signed segment is accepted, the established connection is not 356protected with MD5 digests. 357.It Dv TCP_STATS 358Manage collection of connection level statistics using the 359.Xr stats 3 360framework. 361.Pp 362Each dropped segment is taken into account in the TCP protocol statistics. 363.It Dv TCP_TXTLS_ENABLE 364Enable in-kernel Transport Layer Security (TLS) for data written to this 365socket. 366See 367.Xr ktls 4 368for more details. 369.It Dv TCP_TXTLS_MODE 370The integer argument can be used to get or set the current TLS transmit mode 371of a socket. 372See 373.Xr ktls 4 374for more details. 375.It Dv TCP_RXTLS_ENABLE 376Enable in-kernel TLS for data read from this socket. 377See 378.Xr ktls 4 379for more details. 380.It Dv TCP_REUSPORT_LB_NUMA 381Changes NUMA affinity filtering for an established TCP listen 382socket. 383This option takes a single integer argument which specifies 384the NUMA domain to filter on for this listen socket. 385The argument can also have the follwing special values: 386.Bl -tag -width "Dv TCP_REUSPORT_LB_NUMA" 387.It Dv TCP_REUSPORT_LB_NUMA_NODOM 388Remove NUMA filtering for this listen socket. 389.It Dv TCP_REUSPORT_LB_NUMA_CURDOM 390Filter traffic associated with the domain where the calling thread is 391currently executing. 392This is typically used after a process or thread inherits a listen 393socket from its parent, and sets its CPU affinity to a particular core. 394.El 395.It Dv TCP_REMOTE_UDP_ENCAPS_PORT 396Set and get the remote UDP encapsulation port. 397It can only be set on a closed TCP socket. 398.El 399.Pp 400The option level for the 401.Xr setsockopt 2 402call is the protocol number for 403.Tn TCP , 404available from 405.Xr getprotobyname 3 , 406or 407.Dv IPPROTO_TCP . 408All options are declared in 409.In netinet/tcp.h . 410.Pp 411Options at the 412.Tn IP 413transport level may be used with 414.Tn TCP ; 415see 416.Xr ip 4 . 417Incoming connection requests that are source-routed are noted, 418and the reverse source route is used in responding. 419.Pp 420The default congestion control algorithm for 421.Tn TCP 422is 423.Xr cc_newreno 4 . 424Other congestion control algorithms can be made available using the 425.Xr mod_cc 4 426framework. 427.Ss MIB (sysctl) Variables 428The 429.Tn TCP 430protocol implements a number of variables in the 431.Va net.inet.tcp 432branch of the 433.Xr sysctl 3 434MIB, which can also be read or modified with 435.Xr sysctl 8 . 436.Bl -tag -width ".Va v6pmtud_blackhole_mss" 437.It Va always_keepalive 438Assume that 439.Dv SO_KEEPALIVE 440is set on all 441.Tn TCP 442connections, the kernel will 443periodically send a packet to the remote host to verify the connection 444is still up. 445.It Va blackhole 446If enabled, disable sending of RST when a connection is attempted 447to a port where there is no socket accepting connections. 448See 449.Xr blackhole 4 . 450.It Va blackhole_local 451See 452.Xr blackhole 4 . 453.It Va cc 454A number of variables for congestion control are under the 455.Va net.inet.tcp.cc 456node. 457See 458.Xr mod_cc 4 . 459.It Va cc.newreno 460Variables for NewReno congestion control are under the 461.Va net.inet.tcp.cc.newreno 462node. 463See 464.Xr cc_newreno 4 . 465.It Va delacktime 466Maximum amount of time, in milliseconds, before a delayed ACK is sent. 467.It Va delayed_ack 468Delay ACK to try and piggyback it onto a data packet or another ACK. 469.It Va do_lrd 470Enable Lost Retransmission Detection for SACK-enabled sessions, disabled by 471default. 472Under severe congestion, a retransmission can be lost which then leads to a 473mandatory Retransmission Timeout (RTO), followed by slow-start. 474LRD will try to resend the repeatedly lost packet, preventing the time-consuming 475RTO and performance reducing slow-start. 476.It Va do_prr 477Perform SACK loss recovery using the Proportional Rate Reduction (PRR) algorithm 478described in RFC6937. 479This improves the effectiveness of retransmissions particular in environments 480with ACK thinning or burst loss events, as chances to run out of the ACK clock 481are reduced, preventing lengthy and performance reducing RTO based loss recovery 482(default is true). 483.It Va do_prr_conservative 484While doing Proportional Rate Reduction, remain strictly in a packet conserving 485mode, sending only one new packet for each ACK received. 486Helpful when a misconfigured token bucket traffic policer causes persistent 487high losses leading to RTO, but reduces PRR effectiveness in more common settings 488(default is false). 489.It Va do_tcpdrain 490Flush packets in the 491.Tn TCP 492reassembly queue if the system is low on mbufs. 493.It Va drop_synfin 494Drop TCP packets with both SYN and FIN set. 495.It Va ecn.enable 496Enable support for TCP Explicit Congestion Notification (ECN). 497ECN allows a TCP sender to reduce the transmission rate in order to 498avoid packet drops. 499.Bl -tag -compact 500.It 0 501Disable ECN. 502.It 1 503Allow incoming connections to request ECN. 504Outgoing connections will request ECN. 505.It 2 506Allow incoming connections to request ECN. 507Outgoing connections will not request ECN. 508(default) 509.It 3 510Negotiate on incoming connection for Accurate ECN, ECN, or no ECN. 511Outgoing connections will request Accurate ECN and fall back to 512ECN depending on the capabilities of the server. 513.It 4 514Negotiate on incoming connection for Accurate ECN, ECN, or no ECN. 515Outgoing connections will not request ECN. 516.El 517.It Va ecn.maxretries 518Number of retries (SYN or SYN/ACK retransmits) before disabling ECN on a 519specific connection. 520This is needed to help with connection establishment 521when a broken firewall is in the network path. 522.It Va fast_finwait2_recycle 523Recycle 524.Tn TCP 525.Dv FIN_WAIT_2 526connections faster when the socket is marked as 527.Dv SBS_CANTRCVMORE 528(no user process has the socket open, data received on 529the socket cannot be read). 530The timeout used here is 531.Va finwait2_timeout . 532.It Va fastopen.acceptany 533When non-zero, all client-supplied TFO cookies will be considered to be valid. 534The default is 0. 535.It Va fastopen.autokey 536When this and 537.Va net.inet.tcp.fastopen.server_enable 538are non-zero, a new key will be automatically generated after this specified 539seconds. 540The default is 120. 541.It Va fastopen.ccache_bucket_limit 542The maximum number of entries in a client cookie cache bucket. 543The default value can be tuned with the 544.Dv TCP_FASTOPEN_CCACHE_BUCKET_LIMIT_DEFAULT 545kernel option or by setting 546.Va net.inet.tcp.fastopen_ccache_bucket_limit 547in the 548.Xr loader 8 . 549.It Va fastopen.ccache_buckets 550The number of client cookie cache buckets. 551Read-only. 552The value can be tuned with the 553.Dv TCP_FASTOPEN_CCACHE_BUCKETS_DEFAULT 554kernel option or by setting 555.Va fastopen.ccache_buckets 556in the 557.Xr loader 8 . 558.It Va fastopen.ccache_list 559Print the client cookie cache. 560Read-only. 561.It Va fastopen.client_enable 562When zero, no new active (i.e., client) TFO connections can be created. 563On the transition from enabled to disabled, the client cookie cache is cleared 564and disabled. 565The transition from enabled to disabled does not affect any active TFO 566connections in progress; it only prevents new ones from being established. 567The default is 0. 568.It Va fastopen.keylen 569The key length in bytes. 570Read-only. 571.It Va fastopen.maxkeys 572The maximum number of keys supported. 573Read-only, 574.It Va fastopen.maxpsks 575The maximum number of pre-shared keys supported. 576Read-only. 577.It Va fastopen.numkeys 578The current number of keys installed. 579Read-only. 580.It Va fastopen.numpsks 581The current number of pre-shared keys installed. 582Read-only. 583.It Va fastopen.path_disable_time 584When a failure occurs while trying to create a new active (i.e., client) TFO 585connection, new active connections on the same path, as determined by the tuple 586.Brq client_ip, server_ip, server_port , 587will be forced to be non-TFO for this many seconds. 588Note that the path disable mechanism relies on state stored in client cookie 589cache entries, so it is possible for the disable time for a given path to be 590reduced if the corresponding client cookie cache entry is reused due to resource 591pressure before the disable period has elapsed. 592The default is 593.Dv TCP_FASTOPEN_PATH_DISABLE_TIME_DEFAULT . 594.It Va fastopen.psk_enable 595When non-zero, pre-shared key (PSK) mode is enabled for all TFO servers. 596On the transition from enabled to disabled, all installed pre-shared keys are 597removed. 598The default is 0. 599.It Va fastopen.server_enable 600When zero, no new passive (i.e., server) TFO connections can be created. 601On the transition from enabled to disabled, all installed keys and pre-shared 602keys are removed. 603On the transition from disabled to enabled, if 604.Va fastopen.autokey 605is non-zero and there are no keys installed, a new key will be generated 606immediately. 607The transition from enabled to disabled does not affect any passive TFO 608connections in progress; it only prevents new ones from being established. 609The default is 0. 610.It Va fastopen.setkey 611Install a new key by writing 612.Va net.inet.tcp.fastopen.keylen 613bytes to this sysctl. 614.It Va fastopen.setpsk 615Install a new pre-shared key by writing 616.Va net.inet.tcp.fastopen.keylen 617bytes to this sysctl. 618.It Va finwait2_timeout 619Timeout to use for fast recycling of 620.Tn TCP 621.Dv FIN_WAIT_2 622connections 623.Pq Va fast_finwait2_recycle . 624Defaults to 60 seconds. 625.It Va functions_available 626List of available TCP function blocks (TCP stacks). 627.It Va functions_default 628The default TCP function block (TCP stack). 629.It Va functions_inherit_listen_socket_stack 630Determines whether to inherit listen socket's TCP stack or use the current 631system default TCP stack, as defined by 632.Va functions_default . 633Default is true. 634.It Va hostcache 635The TCP host cache is used to cache connection details and metrics to 636improve future performance of connections between the same hosts. 637At the completion of a TCP connection, a host will cache information 638for the connection for some defined period of time. 639There are a number of 640.Va hostcache 641variables under this node. 642See 643.Va hostcache.enable . 644.It Va hostcache.bucketlimit 645The maximum number of entries for the same hash. 646Defaults to 30. 647.It Va hostcache.cachelimit 648Overall entry limit for hostcache. 649Defaults to 650.Va hashsize 651* 652.Va bucketlimit . 653.It Va hostcache.count 654The current number of entries in the host cache. 655.It Va hostcache.enable 656Enable/disable the host cache: 657.Bl -tag -compact 658.It 0 659Disable the host cache. 660.It 1 661Enable the host cache. (default) 662.El 663.It Va hostcache.expire 664Time in seconds, how long a entry should be kept in the 665host cache since last accessed. 666Defaults to 3600 (1 hour). 667.It Va hostcache.hashsize 668Size of TCP hostcache hashtable. 669This number has to be a power of two, or will be rejected. 670Defaults to 512. 671.It Va hostcache.histo 672Provide a Histogram of the hostcache hash utilization. 673.It Va hostcache.list 674Provide a complete list of all current entries in the host 675cache. 676.It Va hostcache.prune 677Time in seconds between pruning expired host cache entries. 678Defaults to 300 (5 minutes). 679.It Va hostcache.purge 680Expire all entires on next pruning of host cache entries. 681Any non-zero setting will be reset to zero, once the purge 682is running. 683.Bl -tag -compact 684.It 0 685Do not purge all entries when pruning the host cache (default). 686.It 1 687Purge all entries when doing the next pruning. 688.It 2 689Purge all entries and also reseed the hash salt. 690.El 691.It Va hostcache.purgenow 692Immediately purge all entries once set to any value. 693Setting this to 2 will also reseed the hash salt. 694.It Va icmp_may_rst 695Certain 696.Tn ICMP 697unreachable messages may abort connections in 698.Tn SYN-SENT 699state. 700.It Va initcwnd_segments 701Enable the ability to specify initial congestion window in number of segments. 702The default value is 10 as suggested by RFC 6928. 703Changing the value on the fly would not affect connections 704using congestion window from the hostcache. 705Caution: 706This regulates the burst of packets allowed to be sent in the first RTT. 707The value should be relative to the link capacity. 708Start with small values for lower-capacity links. 709Large bursts can cause buffer overruns and packet drops if routers have small 710buffers or the link is experiencing congestion. 711.It Va insecure_rst 712Use criteria defined in RFC793 instead of RFC5961 for accepting RST segments. 713Default is false. 714.It Va insecure_syn 715Use criteria defined in RFC793 instead of RFC5961 for accepting SYN segments. 716Default is false. 717.It Va isn_reseed_interval 718The interval (in seconds) specifying how often the secret data used in 719RFC 1948 initial sequence number calculations should be reseeded. 720By default, this variable is set to zero, indicating that 721no reseeding will occur. 722Reseeding should not be necessary, and will break 723.Dv TIME_WAIT 724recycling for a few minutes. 725.It Va keepcnt 726Number of keepalive probes sent, with no response, before a connection 727is dropped. 728The default is 8 packets. 729.It Va keepidle 730Amount of time, in milliseconds, that the connection must be idle 731before sending keepalive probes (if enabled). 732The default is 7200000 msec (7.2M msec, 2 hours). 733.It Va keepinit 734Timeout, in milliseconds, for new, non-established 735.Tn TCP 736connections. 737The default is 75000 msec (75K msec, 75 sec). 738.It Va keepintvl 739The interval, in milliseconds, between keepalive probes sent to remote 740machines, when no response is received on a 741.Va keepidle 742probe. 743The default is 75000 msec (75K msec, 75 sec). 744.It Va log_in_vain 745Log any connection attempts to ports where there is no socket 746accepting connections. 747The value of 1 limits the logging to 748.Tn SYN 749(connection establishment) packets only. 750A value of 2 results in any 751.Tn TCP 752packets to closed ports being logged. 753Any value not listed above disables the logging 754(default is 0, i.e., the logging is disabled). 755.It Va minmss 756Minimum TCP Maximum Segment Size; used to prevent a denial of service attack 757from an unreasonably low MSS. 758.It Va msl 759The Maximum Segment Lifetime, in milliseconds, for a packet. 760.It Va mssdflt 761The default value used for the TCP Maximum Segment Size 762.Pq Dq MSS 763for IPv4 when no advice to the contrary is received from MSS negotiation. 764.It Va newcwd 765Enable the New Congestion Window Validation mechanism as described in RFC 7661. 766This gently reduces the congestion window during periods, where TCP is 767application limited and the network bandwidth is not utilized completely. 768That prevents self-inflicted packet losses once the application starts to 769transmit data at a higher speed. 770.It Va nolocaltimewait 771Suppress creation of TCP 772.Dv TIME_WAIT 773states for connections in 774which both endpoints are local. 775.It Va path_mtu_discovery 776Enable Path MTU Discovery. 777.It Va pcbcount 778Number of active protocol control blocks 779(read-only). 780.It Va perconn_stats_enable 781Controls the default collection of statistics for all connections using the 782.Xr stats 3 783framework. 7840 disables, 1 enables, 2 enables random sampling across log id connection 785groups with all connections in a group receiving the same setting. 786.It Va perconn_stats_sample_rates 787A CSV list of template_spec=percent key-value pairs which controls the per 788template sampling rates when 789.Xr stats 3 790sampling is enabled. 791.It Va persmax 792Maximum persistence interval, msec. 793.It Va persmin 794Minimum persistence interval, msec. 795.It Va pmtud_blackhole_detection 796Enable automatic path MTU blackhole detection. 797In case of retransmits of MSS sized segments, 798the OS will lower the MSS to check if it's an MTU problem. 799If the current MSS is greater than the configured value to try 800.Po Va net.inet.tcp.pmtud_blackhole_mss 801and 802.Va net.inet.tcp.v6pmtud_blackhole_mss 803.Pc , 804it will be set to this value, otherwise, 805the MSS will be set to the default values 806.Po Va net.inet.tcp.mssdflt 807and 808.Va net.inet.tcp.v6mssdflt 809.Pc . 810Settings: 811.Bl -tag -compact 812.It 0 813Disable path MTU blackhole detection. 814.It 1 815Enable path MTU blackhole detection for IPv4 and IPv6. 816.It 2 817Enable path MTU blackhole detection only for IPv4. 818.It 3 819Enable path MTU blackhole detection only for IPv6. 820.El 821.It Va pmtud_blackhole_mss 822MSS to try for IPv4 if PMTU blackhole detection is turned on. 823.It Va reass.cursegments 824The current total number of segments present in all reassembly queues. 825.It Va reass.maxqueuelen 826The maximum number of segments allowed in each reassembly queue. 827By default, the system chooses a limit based on each TCP connection's 828receive buffer size and maximum segment size (MSS). 829The actual limit applied to a session's reassembly queue will be the lower of 830the system-calculated automatic limit and the user-specified 831.Va reass.maxqueuelen 832limit. 833.It Va reass.maxsegments 834The maximum limit on the total number of segments across all reassembly 835queues. 836The limit can be adjusted as a tunable. 837.It Va recvbuf_auto 838Enable automatic receive buffer sizing as a connection progresses. 839.It Va recvbuf_max 840Maximum size of automatic receive buffer. 841.It Va recvspace 842Initial 843.Tn TCP 844receive window (buffer size). 845.It Va retries 846Maximum number of consecutive timer based retransmits sent after a data 847segment is lost (default and maximum is 12). 848.It Va rexmit_drop_options 849Drop TCP options from third and later retransmitted SYN segments 850of a connection. 851.It Va rexmit_initial , rexmit_min , rexmit_slop 852Adjust the retransmit timer calculation for 853.Tn TCP . 854The slop is 855typically added to the raw calculation to take into account 856occasional variances that the 857.Tn SRTT 858(smoothed round-trip time) 859is unable to accommodate, while the minimum specifies an 860absolute minimum. 861While a number of 862.Tn TCP 863RFCs suggest a 1 864second minimum, these RFCs tend to focus on streaming behavior, 865and fail to deal with the fact that a 1 second minimum has severe 866detrimental effects over lossy interactive connections, such 867as a 802.11b wireless link, and over very fast but lossy 868connections for those cases not covered by the fast retransmit 869code. 870For this reason, we use 200ms of slop and a near-0 871minimum, which gives us an effective minimum of 200ms (similar to 872.Tn Linux ) . 873The initial value is used before an RTT measurement has been performed. 874.It Va rfc1323 875Implement the window scaling and timestamp options of RFC 1323/RFC 7323 876(default is 1). 877Settings: 878.Bl -tag -compact 879.It 0 880Disable window scaling and timestamp option. 881.It 1 882Enable window scaling and timestamp option. 883.It 2 884Enable only window scaling. 885.It 3 886Enable only timestamp option. 887.El 888.It Va rfc3042 889Enable the Limited Transmit algorithm as described in RFC 3042. 890It helps avoid timeouts on lossy links and also when the congestion window 891is small, as happens on short transfers. 892.It Va rfc3390 893Enable support for RFC 3390, which allows for a variable-sized 894starting congestion window on new connections, depending on the 895maximum segment size. 896This helps throughput in general, but 897particularly affects short transfers and high-bandwidth large 898propagation-delay connections. 899.It Va rfc6675_pipe 900Deprecated and superseded by 901.Va sack.revised 902.It Va sack.enable 903Enable support for RFC 2018, TCP Selective Acknowledgment option, 904which allows the receiver to inform the sender about all successfully 905arrived segments, allowing the sender to retransmit the missing segments 906only. 907.It Va sack.globalholes 908Global number of TCP SACK holes currently allocated. 909.It Va sack.globalmaxholes 910Maximum number of SACK holes per system, across all connections. 911Defaults to 65536. 912.It Va sack.maxholes 913Maximum number of SACK holes per connection. 914Defaults to 128. 915.It Va sack.revised 916Enables three updated mechanisms from RFC6675 (default is true). 917Calculate the bytes in flight using the algorithm described in RFC 6675, and 918is also an improvement when Proportional Rate Reduction is enabled. 919Next, Rescue Retransmission helps timely loss recovery, when the trailing segments 920of a transmission are lost, while no additional data is ready to be sent. 921In case a partial ACK without a SACK block is received during SACK loss 922recovery, the trailing segment is immediately resent, rather than waiting 923for a Retransmission timeout. 924Finally, SACK loss recovery is also engaged, once two segments plus one byte are 925SACKed - even if no traditional duplicate ACKs were observed. 926.It Va sendbuf_auto 927Enable automatic send buffer sizing. 928.It Va sendbuf_auto_lowat 929Modify threshold for auto send buffer growth to account for 930.Dv SO_SNDLOWAT . 931.It Va sendbuf_inc 932Incrementor step size of automatic send buffer. 933.It Va sendbuf_max 934Maximum size of automatic send buffer. 935.It Va sendspace 936Initial 937.Tn TCP 938send window (buffer size). 939.It Va syncache 940Variables under the 941.Va net.inet.tcp.syncache 942node are documented in 943.Xr syncache 4 . 944.It Va syncookies 945Determines whether or not 946.Tn SYN 947cookies should be generated for outbound 948.Tn SYN-ACK 949packets. 950.Tn SYN 951cookies are a great help during 952.Tn SYN 953flood attacks, and are enabled by default. 954(See 955.Xr syncookies 4 . ) 956.It Va syncookies_only 957See 958.Xr syncookies 4 . 959.It Va tcbhashsize 960Size of the 961.Tn TCP 962control-block hash table 963(read-only). 964This is tuned using the kernel option 965.Dv TCBHASHSIZE 966or by setting 967.Va net.inet.tcp.tcbhashsize 968in the 969.Xr loader 8 . 970.It Va tolerate_missing_ts 971Tolerate the missing of timestamps (RFC 1323/RFC 7323) for 972.Tn TCP 973segments belonging to 974.Tn TCP 975connections for which support of 976.Tn TCP 977timestamps has been negotiated. 978As of June 2021, several TCP stacks are known to violate RFC 7323, including 979modern widely deployed ones. 980Therefore the default is 1, i.e., the missing of timestamps is tolerated. 981.It Va ts_offset_per_conn 982When initializing the TCP timestamps, use a per connection offset instead of a 983per host pair offset. 984Default is to use per connection offsets as recommended in RFC 7323. 985.It Va tso 986Enable TCP Segmentation Offload. 987.It Va udp_tunneling_overhead 988The overhead taken into account when using UDP encapsulation. 989Since MSS clamping by middleboxes will most likely not work, values larger than 9908 (the size of the UDP header) are also supported. 991Supported values are between 8 and 1024. 992The default is 8. 993.It Va udp_tunneling_port 994The local UDP encapsulation port. 995A value of 0 indicates that UDP encapsulation is disabled. 996The default is 0. 997.It Va v6mssdflt 998The default value used for the TCP Maximum Segment Size 999.Pq Dq MSS 1000for IPv6 when no advice to the contrary is received from MSS negotiation. 1001.It Va v6pmtud_blackhole_mss 1002MSS to try for IPv6 if PMTU blackhole detection is turned on. 1003See 1004.Va pmtud_blackhole_detection . 1005.El 1006.Sh ERRORS 1007A socket operation may fail with one of the following errors returned: 1008.Bl -tag -width Er 1009.It Bq Er EISCONN 1010when trying to establish a connection on a socket which 1011already has one; 1012.It Bo Er ENOBUFS Bc or Bo Er ENOMEM Bc 1013when the system runs out of memory for 1014an internal data structure; 1015.It Bq Er ETIMEDOUT 1016when a connection was dropped 1017due to excessive retransmissions; 1018.It Bq Er ECONNRESET 1019when the remote peer 1020forces the connection to be closed; 1021.It Bq Er ECONNREFUSED 1022when the remote 1023peer actively refuses connection establishment (usually because 1024no process is listening to the port); 1025.It Bq Er EADDRINUSE 1026when an attempt 1027is made to create a socket with a port which has already been 1028allocated; 1029.It Bq Er EADDRNOTAVAIL 1030when an attempt is made to create a 1031socket with a network address for which no network interface 1032exists; 1033.It Bq Er EAFNOSUPPORT 1034when an attempt is made to bind or connect a socket to a multicast 1035address. 1036.It Bq Er EINVAL 1037when trying to change TCP function blocks at an invalid point in the session; 1038.It Bq Er ENOENT 1039when trying to use a TCP function block that is not available; 1040.El 1041.Sh SEE ALSO 1042.Xr getsockopt 2 , 1043.Xr socket 2 , 1044.Xr stats 3 , 1045.Xr sysctl 3 , 1046.Xr blackhole 4 , 1047.Xr inet 4 , 1048.Xr intro 4 , 1049.Xr ip 4 , 1050.Xr ktls 4 , 1051.Xr mod_cc 4 , 1052.Xr siftr 4 , 1053.Xr syncache 4 , 1054.Xr tcp_bbr 4 , 1055.Xr tcp_rack 4 , 1056.Xr setkey 8 , 1057.Xr sysctl 8 , 1058.Xr tcp_functions 9 1059.Rs 1060.%A "V. Jacobson" 1061.%A "B. Braden" 1062.%A "D. Borman" 1063.%T "TCP Extensions for High Performance" 1064.%O "RFC 1323" 1065.Re 1066.Rs 1067.%A "D. Borman" 1068.%A "B. Braden" 1069.%A "V. Jacobson" 1070.%A "R. Scheffenegger" 1071.%T "TCP Extensions for High Performance" 1072.%O "RFC 7323" 1073.Re 1074.Rs 1075.%A "A. Heffernan" 1076.%T "Protection of BGP Sessions via the TCP MD5 Signature Option" 1077.%O "RFC 2385" 1078.Re 1079.Rs 1080.%A "K. Ramakrishnan" 1081.%A "S. Floyd" 1082.%A "D. Black" 1083.%T "The Addition of Explicit Congestion Notification (ECN) to IP" 1084.%O "RFC 3168" 1085.Re 1086.Sh HISTORY 1087The 1088.Tn TCP 1089protocol appeared in 1090.Bx 4.2 . 1091The RFC 1323 extensions for window scaling and timestamps were added 1092in 1093.Bx 4.4 . 1094The 1095.Dv TCP_INFO 1096option was introduced in 1097.Tn Linux 2.6 1098and is 1099.Em subject to change . 1100