xref: /xnu-8792.61.2/bsd/netinet/tcp_sysctls.c (revision 42e220869062b56f8d7d0726fd4c88954f87902c)
1*42e22086SApple OSS Distributions /*
2*42e22086SApple OSS Distributions  * Copyright (c) 2000-2021 Apple Inc. All rights reserved.
3*42e22086SApple OSS Distributions  *
4*42e22086SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*42e22086SApple OSS Distributions  *
6*42e22086SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*42e22086SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*42e22086SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*42e22086SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*42e22086SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*42e22086SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*42e22086SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*42e22086SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*42e22086SApple OSS Distributions  *
15*42e22086SApple OSS Distributions  * Please obtain a copy of the License at
16*42e22086SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*42e22086SApple OSS Distributions  *
18*42e22086SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*42e22086SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*42e22086SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*42e22086SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*42e22086SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*42e22086SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*42e22086SApple OSS Distributions  * limitations under the License.
25*42e22086SApple OSS Distributions  *
26*42e22086SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*42e22086SApple OSS Distributions  */
28*42e22086SApple OSS Distributions 
29*42e22086SApple OSS Distributions #include "tcp_includes.h"
30*42e22086SApple OSS Distributions 
31*42e22086SApple OSS Distributions #include <netinet/tcp_sysctls.h>
32*42e22086SApple OSS Distributions #include <netinet/tcp_var.h>
33*42e22086SApple OSS Distributions 
34*42e22086SApple OSS Distributions #include <sys/sysctl.h>
35*42e22086SApple OSS Distributions 
36*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_tcp_friendliness, CTLFLAG_RW | CTLFLAG_LOCKED,
37*42e22086SApple OSS Distributions     int, tcp_cubic_tcp_friendliness, 0, "Enable TCP friendliness");
38*42e22086SApple OSS Distributions 
39*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_fast_convergence, CTLFLAG_RW | CTLFLAG_LOCKED,
40*42e22086SApple OSS Distributions     int, tcp_cubic_fast_convergence, 0, "Enable fast convergence");
41*42e22086SApple OSS Distributions 
42*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_use_minrtt, CTLFLAG_RW | CTLFLAG_LOCKED,
43*42e22086SApple OSS Distributions     int, tcp_cubic_use_minrtt, 0, "use a min of 5 sec rtt");
44*42e22086SApple OSS Distributions 
45*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_minor_fixes, CTLFLAG_RW | CTLFLAG_LOCKED,
46*42e22086SApple OSS Distributions     int, tcp_cubic_minor_fixes, 1, "Minor fixes to TCP Cubic");
47*42e22086SApple OSS Distributions 
48*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_rfc_compliant, CTLFLAG_RW | CTLFLAG_LOCKED,
49*42e22086SApple OSS Distributions     int, tcp_cubic_rfc_compliant, 1, "RFC Compliance for TCP Cubic");
50*42e22086SApple OSS Distributions 
51*42e22086SApple OSS Distributions /* Target queuing delay in milliseconds. This includes the processing
52*42e22086SApple OSS Distributions  * and scheduling delay on both of the end-hosts. A LEDBAT sender tries
53*42e22086SApple OSS Distributions  * to keep queuing delay below this limit. When the queuing delay
54*42e22086SApple OSS Distributions  * goes above this limit, a LEDBAT sender will start reducing the
55*42e22086SApple OSS Distributions  * congestion window.
56*42e22086SApple OSS Distributions  *
57*42e22086SApple OSS Distributions  * The LEDBAT draft says that target queue delay MUST be 100 ms for
58*42e22086SApple OSS Distributions  * inter-operability.
59*42e22086SApple OSS Distributions  * As we are enabling LEDBAT++ by default, we are updating the target
60*42e22086SApple OSS Distributions  * queuing delay to 60ms as recommended by the draft.
61*42e22086SApple OSS Distributions  */
62*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, bg_target_qdelay, CTLFLAG_RW | CTLFLAG_LOCKED,
63*42e22086SApple OSS Distributions     int, target_qdelay, 40, "Target queuing delay");
64*42e22086SApple OSS Distributions 
65*42e22086SApple OSS Distributions /* Allowed increase and tether are used to place an upper bound on
66*42e22086SApple OSS Distributions  * congestion window based on the amount of data that is outstanding.
67*42e22086SApple OSS Distributions  * This will limit the congestion window when the amount of data in
68*42e22086SApple OSS Distributions  * flight is little because the application is writing to the socket
69*42e22086SApple OSS Distributions  * intermittently and is preventing the connection from becoming idle .
70*42e22086SApple OSS Distributions  *
71*42e22086SApple OSS Distributions  * max_allowed_cwnd = allowed_increase + (tether * flight_size)
72*42e22086SApple OSS Distributions  * cwnd = min(cwnd, max_allowed_cwnd)
73*42e22086SApple OSS Distributions  *
74*42e22086SApple OSS Distributions  * 'Allowed_increase' parameter is set to 8. If the flight size is zero, then
75*42e22086SApple OSS Distributions  * we want the congestion window to be at least 8 packets to reduce the
76*42e22086SApple OSS Distributions  * delay induced by delayed ack. This helps when the receiver is acking
77*42e22086SApple OSS Distributions  * more than 2 packets at a time (stretching acks for better performance).
78*42e22086SApple OSS Distributions  *
79*42e22086SApple OSS Distributions  * 'Tether' is also set to 2. We do not want this to limit the growth of cwnd
80*42e22086SApple OSS Distributions  * during slow-start.
81*42e22086SApple OSS Distributions  */
82*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, bg_allowed_increase, CTLFLAG_RW | CTLFLAG_LOCKED,
83*42e22086SApple OSS Distributions     int, tcp_ledbat_allowed_increase, 8,
84*42e22086SApple OSS Distributions     "Additive constant used to calculate max allowed congestion window");
85*42e22086SApple OSS Distributions 
86*42e22086SApple OSS Distributions /* Left shift for cwnd to get tether value of 2 */
87*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, bg_tether_shift, CTLFLAG_RW | CTLFLAG_LOCKED,
88*42e22086SApple OSS Distributions     int, tcp_ledbat_tether_shift, 1, "Tether shift for max allowed congestion window");
89*42e22086SApple OSS Distributions 
90*42e22086SApple OSS Distributions /* Start with an initial window of 2. This will help to get more accurate
91*42e22086SApple OSS Distributions  * minimum RTT measurement in the beginning. It will help to probe
92*42e22086SApple OSS Distributions  * the path slowly and will not add to the existing delay if the path is
93*42e22086SApple OSS Distributions  * already congested. Using 2 packets will reduce the delay induced by delayed-ack.
94*42e22086SApple OSS Distributions  */
95*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, bg_ss_fltsz, CTLFLAG_RW | CTLFLAG_LOCKED,
96*42e22086SApple OSS Distributions     uint32_t, bg_ss_fltsz, 2, "Initial congestion window for background transport");
97*42e22086SApple OSS Distributions 
98*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, ledbat_plus_plus, CTLFLAG_RW | CTLFLAG_LOCKED,
99*42e22086SApple OSS Distributions     int, tcp_ledbat_plus_plus, 1, "Use LEDBAT++");
100*42e22086SApple OSS Distributions 
101*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, rledbat, CTLFLAG_RW | CTLFLAG_LOCKED,
102*42e22086SApple OSS Distributions     int, tcp_rledbat, 1, "Use Receive LEDBAT");
103*42e22086SApple OSS Distributions 
104*42e22086SApple OSS Distributions int tcp_cc_debug;
105*42e22086SApple OSS Distributions SYSCTL_INT(_net_inet_tcp, OID_AUTO, cc_debug, CTLFLAG_RW | CTLFLAG_LOCKED,
106*42e22086SApple OSS Distributions     &tcp_cc_debug, 0, "Enable debug data collection");
107*42e22086SApple OSS Distributions 
108*42e22086SApple OSS Distributions extern struct tcp_cc_algo tcp_cc_newreno;
109*42e22086SApple OSS Distributions SYSCTL_INT(_net_inet_tcp, OID_AUTO, newreno_sockets,
110*42e22086SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, &tcp_cc_newreno.num_sockets,
111*42e22086SApple OSS Distributions     0, "Number of sockets using newreno");
112*42e22086SApple OSS Distributions 
113*42e22086SApple OSS Distributions extern struct tcp_cc_algo tcp_cc_ledbat;
114*42e22086SApple OSS Distributions SYSCTL_INT(_net_inet_tcp, OID_AUTO, background_sockets,
115*42e22086SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, &tcp_cc_ledbat.num_sockets,
116*42e22086SApple OSS Distributions     0, "Number of sockets using background transport");
117*42e22086SApple OSS Distributions 
118*42e22086SApple OSS Distributions #if (DEVELOPMENT || DEBUG)
119*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, use_ledbat,
120*42e22086SApple OSS Distributions     CTLFLAG_RW | CTLFLAG_LOCKED, int, tcp_use_ledbat, 0,
121*42e22086SApple OSS Distributions     "Use TCP LEDBAT for testing");
122*42e22086SApple OSS Distributions #else
123*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, use_ledbat,
124*42e22086SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, int, tcp_use_ledbat, 0,
125*42e22086SApple OSS Distributions     "Use TCP LEDBAT for testing");
126*42e22086SApple OSS Distributions #endif /* (DEVELOPMENT || DEBUG) */
127*42e22086SApple OSS Distributions 
128*42e22086SApple OSS Distributions extern struct tcp_cc_algo tcp_cc_cubic;
129*42e22086SApple OSS Distributions SYSCTL_INT(_net_inet_tcp, OID_AUTO, cubic_sockets,
130*42e22086SApple OSS Distributions     CTLFLAG_RD | CTLFLAG_LOCKED, &tcp_cc_cubic.num_sockets,
131*42e22086SApple OSS Distributions     0, "Number of sockets using cubic");
132*42e22086SApple OSS Distributions 
133*42e22086SApple OSS Distributions SYSCTL_SKMEM_TCP_INT(OID_AUTO, use_newreno,
134*42e22086SApple OSS Distributions     CTLFLAG_RW | CTLFLAG_LOCKED, int, tcp_use_newreno, 0,
135*42e22086SApple OSS Distributions     "Use TCP NewReno by default");
136