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