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