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