Print this page
11554 Want TCP_CONGESTION socket option
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>


 246 .Xr read 2
 247 call, it is possible to
 248 advance to the urgent data in a simple loop which reads data, testing the
 249 socket with the
 250 .Dv SIOCATMARK
 251 .Fn ioctl
 252 request, until it reaches the mark.
 253 .Ss "Congestion Control"
 254 TCP follows the congestion control algorithm described in RFC 2581, and
 255 also supports the initial congestion window (cwnd) changes in RFC 3390.
 256 The initial cwnd calculation can be overridden by the socket option
 257 .Dv TCP_INIT_CWND .
 258 An application can use this option to set the initial cwnd to a
 259 specified number of TCP segments.
 260 This applies to the cases when the connection
 261 first starts and restarts after an idle period.
 262 The process must have the
 263 .Dv PRIV_SYS_NET_CONFIG
 264 privilege if it wants to specify a number greater than that
 265 calculated by RFC 3390.
















 266 .Ss "TCP Keep-Alive"
 267 Since TCP determines whether a remote peer is no longer reachable by timing out
 268 waiting for acknowledgements, a host that never sends any new data may never
 269 notice a peer that has gone away.
 270 While consumers can avoid this problem by sending their own periodic heartbeat
 271 messages (Transport Layer Security does this, for example),
 272 TCP describes an optional keep-alive mechanism in RFC 1122.
 273 Applications can enable it using the socket-level option
 274 .Dv SO_KEEPALIVE .
 275 When enabled, the first keep-alive probe is sent out after a TCP connection is
 276 idle for two hours.
 277 If the peer does not respond to the probe within eight minutes, the TCP
 278 connection is aborted.
 279 An application can alter the probe behavior using the following TCP-level
 280 socket options:
 281 .Bl -tag -offset indent -width 16m
 282 .It Dv TCP_KEEPALIVE_THRESHOLD
 283 Determines the interval for sending the first probe.
 284 The option value is specified as an unsigned integer in milliseconds.
 285 The system default is controlled by the TCP




 246 .Xr read 2
 247 call, it is possible to
 248 advance to the urgent data in a simple loop which reads data, testing the
 249 socket with the
 250 .Dv SIOCATMARK
 251 .Fn ioctl
 252 request, until it reaches the mark.
 253 .Ss "Congestion Control"
 254 TCP follows the congestion control algorithm described in RFC 2581, and
 255 also supports the initial congestion window (cwnd) changes in RFC 3390.
 256 The initial cwnd calculation can be overridden by the socket option
 257 .Dv TCP_INIT_CWND .
 258 An application can use this option to set the initial cwnd to a
 259 specified number of TCP segments.
 260 This applies to the cases when the connection
 261 first starts and restarts after an idle period.
 262 The process must have the
 263 .Dv PRIV_SYS_NET_CONFIG
 264 privilege if it wants to specify a number greater than that
 265 calculated by RFC 3390.
 266 .Pp
 267 The operating system also provides alternative algorithms that may be more
 268 appropriate for your application, including the CUBIC congestion control
 269 algorithm described in RFC 8312.
 270 These can be configured system-wide using
 271 .Xr ipadm 1M ,
 272 or on a per-connection basis with the TCP-level socket option
 273 .Dv TCP_CONGESTION ,
 274 whose argument is the name of the algorithm to use
 275 .Pq for example Dq cubic .
 276 If the requested algorithm does not exist, then
 277 .Fn setsockopt
 278 will fail, and
 279 .Va errno
 280 will be set to
 281 .Er ENOENT .
 282 .Ss "TCP Keep-Alive"
 283 Since TCP determines whether a remote peer is no longer reachable by timing out
 284 waiting for acknowledgements, a host that never sends any new data may never
 285 notice a peer that has gone away.
 286 While consumers can avoid this problem by sending their own periodic heartbeat
 287 messages (Transport Layer Security does this, for example),
 288 TCP describes an optional keep-alive mechanism in RFC 1122.
 289 Applications can enable it using the socket-level option
 290 .Dv SO_KEEPALIVE .
 291 When enabled, the first keep-alive probe is sent out after a TCP connection is
 292 idle for two hours.
 293 If the peer does not respond to the probe within eight minutes, the TCP
 294 connection is aborted.
 295 An application can alter the probe behavior using the following TCP-level
 296 socket options:
 297 .Bl -tag -offset indent -width 16m
 298 .It Dv TCP_KEEPALIVE_THRESHOLD
 299 Determines the interval for sending the first probe.
 300 The option value is specified as an unsigned integer in milliseconds.
 301 The system default is controlled by the TCP