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 36 SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_tcp_friendliness, CTLFLAG_RW | CTLFLAG_LOCKED, 37 int, tcp_cubic_tcp_friendliness, 0, "Enable TCP friendliness"); 38 39 SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_fast_convergence, CTLFLAG_RW | CTLFLAG_LOCKED, 40 int, tcp_cubic_fast_convergence, 0, "Enable fast convergence"); 41 42 SYSCTL_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 45 /* TODO - remove once uTCP stops using it */ 46 SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_minor_fixes, CTLFLAG_RW | CTLFLAG_LOCKED, 47 int, tcp_cubic_minor_fixes, 1, "Minor fixes to TCP Cubic"); 48 49 /* TODO - remove once uTCP stops using it */ 50 SYSCTL_SKMEM_TCP_INT(OID_AUTO, cubic_rfc_compliant, CTLFLAG_RW | CTLFLAG_LOCKED, 51 int, tcp_cubic_rfc_compliant, 1, "RFC Compliance for TCP Cubic"); 52 53 SYSCTL_SKMEM_TCP_INT(OID_AUTO, rack, CTLFLAG_RW | CTLFLAG_LOCKED, 54 int, tcp_rack, 1, "TCP RACK"); 55 /* Target queuing delay in milliseconds. This includes the processing 56 * and scheduling delay on both of the end-hosts. A LEDBAT sender tries 57 * to keep queuing delay below this limit. When the queuing delay 58 * goes above this limit, a LEDBAT sender will start reducing the 59 * congestion window. 60 * 61 * The LEDBAT draft says that target queue delay MUST be 100 ms for 62 * inter-operability. 63 * As we are enabling LEDBAT++ by default, we are updating the target 64 * queuing delay to 60ms as recommended by the draft. 65 */ 66 SYSCTL_SKMEM_TCP_INT(OID_AUTO, bg_target_qdelay, CTLFLAG_RW | CTLFLAG_LOCKED, 67 int, target_qdelay, 40, "Target queuing delay"); 68 69 /* Allowed increase and tether are used to place an upper bound on 70 * congestion window based on the amount of data that is outstanding. 71 * This will limit the congestion window when the amount of data in 72 * flight is little because the application is writing to the socket 73 * intermittently and is preventing the connection from becoming idle . 74 * 75 * max_allowed_cwnd = allowed_increase + (tether * flight_size) 76 * cwnd = min(cwnd, max_allowed_cwnd) 77 * 78 * 'Allowed_increase' parameter is set to 8. If the flight size is zero, then 79 * we want the congestion window to be at least 8 packets to reduce the 80 * delay induced by delayed ack. This helps when the receiver is acking 81 * more than 2 packets at a time. 82 * 83 * 'Tether' is also set to 2. We do not want this to limit the growth of cwnd 84 * during slow-start. 85 */ 86 SYSCTL_SKMEM_TCP_INT(OID_AUTO, bg_allowed_increase, CTLFLAG_RW | CTLFLAG_LOCKED, 87 int, tcp_ledbat_allowed_increase, 8, 88 "Additive constant used to calculate max allowed congestion window"); 89 90 /* Left shift for cwnd to get tether value of 2 */ 91 SYSCTL_SKMEM_TCP_INT(OID_AUTO, bg_tether_shift, CTLFLAG_RW | CTLFLAG_LOCKED, 92 int, tcp_ledbat_tether_shift, 1, "Tether shift for max allowed congestion window"); 93 94 /* Start with an initial window of 2. This will help to get more accurate 95 * minimum RTT measurement in the beginning. It will help to probe 96 * the path slowly and will not add to the existing delay if the path is 97 * already congested. Using 2 packets will reduce the delay induced by delayed-ack. 98 */ 99 SYSCTL_SKMEM_TCP_INT(OID_AUTO, bg_ss_fltsz, CTLFLAG_RW | CTLFLAG_LOCKED, 100 uint32_t, bg_ss_fltsz, 2, "Initial congestion window for background transport"); 101 102 SYSCTL_SKMEM_TCP_INT(OID_AUTO, ledbat_plus_plus, CTLFLAG_RW | CTLFLAG_LOCKED, 103 int, tcp_ledbat_plus_plus, 1, "Use LEDBAT++"); 104 105 SYSCTL_SKMEM_TCP_INT(OID_AUTO, rledbat, CTLFLAG_RW | CTLFLAG_LOCKED, 106 int, tcp_rledbat, 1, "Use Receive LEDBAT"); 107 108 int tcp_cc_debug; 109 SYSCTL_INT(_net_inet_tcp, OID_AUTO, cc_debug, CTLFLAG_RW | CTLFLAG_LOCKED, 110 &tcp_cc_debug, 0, "Enable debug data collection"); 111 112 extern struct tcp_cc_algo tcp_cc_newreno; 113 SYSCTL_INT(_net_inet_tcp, OID_AUTO, newreno_sockets, 114 CTLFLAG_RD | CTLFLAG_LOCKED, &tcp_cc_newreno.num_sockets, 115 0, "Number of sockets using newreno"); 116 117 extern struct tcp_cc_algo tcp_cc_ledbat; 118 SYSCTL_INT(_net_inet_tcp, OID_AUTO, background_sockets, 119 CTLFLAG_RD | CTLFLAG_LOCKED, &tcp_cc_ledbat.num_sockets, 120 0, "Number of sockets using background transport"); 121 122 #if (DEVELOPMENT || DEBUG) 123 SYSCTL_SKMEM_TCP_INT(OID_AUTO, use_ledbat, 124 CTLFLAG_RW | CTLFLAG_LOCKED, int, tcp_use_ledbat, 0, 125 "Use TCP LEDBAT for testing"); 126 #else 127 SYSCTL_SKMEM_TCP_INT(OID_AUTO, use_ledbat, 128 CTLFLAG_RD | CTLFLAG_LOCKED, int, tcp_use_ledbat, 0, 129 "Use TCP LEDBAT for testing"); 130 #endif /* (DEVELOPMENT || DEBUG) */ 131 132 extern struct tcp_cc_algo tcp_cc_cubic; 133 SYSCTL_INT(_net_inet_tcp, OID_AUTO, cubic_sockets, 134 CTLFLAG_RD | CTLFLAG_LOCKED, &tcp_cc_cubic.num_sockets, 135 0, "Number of sockets using cubic"); 136 137 SYSCTL_SKMEM_TCP_INT(OID_AUTO, use_newreno, 138 CTLFLAG_RW | CTLFLAG_LOCKED, int, tcp_use_newreno, 0, 139 "Use TCP NewReno by default"); 140