1# TCP options 2 3# Copyright (c) 2016 Intel Corporation. 4# Copyright (c) 2021 Nordic Semiconductor 5# Copyright (c) 2023 Arm Limited (or its affiliates). All rights reserved. 6# SPDX-License-Identifier: Apache-2.0 7 8menuconfig NET_TCP 9 bool "TCP" 10 depends on NET_IP 11 help 12 The value depends on your network needs. 13 14if NET_TCP 15 16if NET_TCP 17module = NET_TCP 18module-dep = NET_LOG 19module-str = Log level for TCP 20module-help = Enables TCP handler output debug messages 21source "subsys/net/Kconfig.template.log_config.net" 22endif # NET_TCP 23 24config NET_TCP_WORKQ_STACK_SIZE 25 int "TCP work queue thread stack size" 26 default 1200 if X86 27 default 1024 28 depends on NET_TCP 29 help 30 Set the TCP work queue thread stack size in bytes. 31 32config NET_TCP_WORKER_PRIO 33 int "Priority of the TCP work queue" 34 default 2 35 depends on NET_TCP 36 help 37 Set the priority of the TCP worker queue, that handles all 38 transmission and maintenance within the TCP stack. 39 Value 0 = highest priortity. 40 When CONFIG_NET_TC_THREAD_COOPERATIVE = y, lowest priority is 41 CONFIG_NUM_COOP_PRIORITIES-1 else lowest priority is 42 CONFIG_NUM_PREEMPT_PRIORITIES-1. 43 Make sure the priority is lower than lower layer TX threads to 44 avoid the TCP stack consume all net_bufs before transferring 45 execution to the lower layer network stack, with a high risk of 46 running out of net_bufs. 47 48config NET_TCP_TIME_WAIT_DELAY 49 int "How long to wait in TIME_WAIT state (in milliseconds)" 50 depends on NET_TCP 51 default 1500 52 help 53 To avoid a (low-probability) issue when delayed packets from 54 previous connection get delivered to next connection reusing 55 the same local/remote ports, RFC 793 (TCP) suggests to keep 56 an old, closed connection in a special "TIME_WAIT" state for 57 the duration of 2*MSL (Maximum Segment Lifetime). The RFC 58 suggests to use MSL of 2 minutes, but notes "This is an 59 engineering choice, and may be changed if experience indicates 60 it is desirable to do so." For low-resource systems, having 61 large MSL may lead to quick resource exhaustion (and related 62 DoS attacks). At the same time, the issue of packet misdelivery 63 is largely alleviated in the modern TCP stacks by using random, 64 non-repeating port numbers and initial sequence numbers. Due 65 to this, Zephyr uses much lower value of 1500ms by default. 66 Value of 0 disables TIME_WAIT state completely. 67 68config NET_TCP_ACK_TIMEOUT 69 int "[DEPRECATED] How long to wait for ACK (in milliseconds)" 70 depends on NET_TCP 71 default 1000 72 range 1 $(INT32_MAX) 73 help 74 Deprecated. Use CONFIG_NET_TCP_INIT_RETRANSMISSION_TIMEOUT and 75 CONFIG_NET_TCP_RETRY_COUNT to control the total timeout at the TCP 76 level. 77 78config NET_TCP_INIT_RETRANSMISSION_TIMEOUT 79 int "Initial value of Retransmission Timeout (RTO) (in milliseconds)" 80 depends on NET_TCP 81 default 200 82 range 100 60000 83 help 84 This value affects the timeout between initial retransmission 85 of TCP data packets. The value is in milliseconds. 86 87config NET_TCP_RANDOMIZED_RTO 88 bool "Use a randomized retransmission time" 89 default y 90 depends on NET_TCP 91 help 92 It can happen that two similar stacks enter a retransmission cycle 93 due to a packet collision. If the transmission timeout is the same 94 both stacks will retry at the same moment resulting in another 95 collision. By introducing a randomized retry timeout, the chance of 96 a second collision is reduced and it reduces further the more 97 retransmissions occur. 98 99config NET_TCP_RETRY_COUNT 100 int "Maximum number of TCP segment retransmissions" 101 depends on NET_TCP 102 default 9 103 help 104 The following formula can be used to determine the time (in ms) 105 that a segment will be be buffered awaiting retransmission: 106 n=NET_TCP_RETRY_COUNT 107 Sum((1<<n) * NET_TCP_INIT_RETRANSMISSION_TIMEOUT) 108 n=0 109 With the default value of 9, the IP stack will try to 110 retransmit for up to 1:42 minutes. This is as close as possible 111 to the minimum value recommended by RFC1122 (1:40 minutes). 112 Only 5 bits are dedicated for the retransmission count, so accepted 113 values are in the 0-31 range. It's highly recommended to not go 114 below 9, though. 115 Should a retransmission timeout occur, the receive callback is 116 called with -ETIMEDOUT error code and the context is dereferenced. 117 118config NET_TCP_MAX_SEND_WINDOW_SIZE 119 int "Maximum sending window size to use" 120 depends on NET_TCP 121 default 0 122 range 0 $(UINT16_MAX) 123 help 124 This value affects how the TCP selects the maximum sending window 125 size. The default value 0 lets the TCP stack select the value 126 according to amount of network buffers configured in the system. 127 128config NET_TCP_MAX_RECV_WINDOW_SIZE 129 int "Maximum receive window size to use" 130 depends on NET_TCP 131 default 0 132 range 0 $(UINT16_MAX) 133 help 134 This value defines the maximum TCP receive window size. Increasing 135 this value can improve connection throughput, but requires more 136 receive buffers available in the system for efficient operation. 137 The default value 0 lets the TCP stack select the value 138 according to amount of network buffers configured in the system. 139 140config NET_TCP_RECV_QUEUE_TIMEOUT 141 int "How long to queue received data (in ms)" 142 depends on NET_TCP 143 default 2000 144 range 0 10000 145 help 146 If we receive out-of-order TCP data, we queue it. This value tells 147 how long the data is kept before it is discarded if we have not been 148 able to pass the data to the application. If set to 0, then receive 149 queueing is not enabled. The value is in milliseconds. 150 Note that we only queue data sequentially in current version i.e., 151 there should be no holes in the queue. For example, if we receive 152 SEQs 5,4,3,6 and are waiting SEQ 2, the data in segments 3,4,5,6 is 153 queued (in this order), and then given to application when we receive 154 SEQ 2. But if we receive SEQs 5,4,3,7 then the SEQ 7 is discarded 155 because the list would not be sequential as number 6 is be missing. 156 157config NET_TCP_PKT_ALLOC_TIMEOUT 158 int "How long to wait for a TCP packet allocation (in ms)" 159 depends on NET_TCP 160 default 100 161 range 10 1000 162 help 163 The TCP network stack allocates packets from the buffers and the 164 allocation can take some time depending on the situation. 165 This value indicates how long the stack should wait for the packet to 166 be allocated, before returning an internal error and trying again. 167 168config NET_TCP_CHECKSUM 169 bool "Check TCP checksum" 170 default y 171 depends on NET_TCP 172 help 173 Enables TCP handler to check TCP checksum. If the checksum is invalid, 174 then the packet is discarded. 175 176config NET_TCP_FAST_RETRANSMIT 177 bool "Fast-retry algorithm based on the number of duplicated ACKs" 178 depends on NET_TCP 179 default y 180 help 181 When a packet is lost, the receiver will keep acknowledging the 182 sequence number of the last correctly received byte. Upon reception 183 of a sequence of acknowledgements for the same sequence number, 184 this can be deduced as that the packet afterwards must have been lost. 185 In that case a retransmission is triggered to avoid having to wait for 186 the retransmit timer to elapse. 187 188config NET_TCP_CONGESTION_AVOIDANCE 189 bool "Implement a congestion avoidance algorithm in TCP" 190 depends on NET_TCP 191 default y 192 help 193 To avoid overstressing a link reduce the transmission rate as soon as 194 packets are starting to drop. 195 196config NET_TCP_KEEPALIVE 197 bool "TCP keep-alive support" 198 depends on NET_TCP 199 help 200 Enabling this option allows the TCP stack to send periodic TCP 201 keep-alive probes. Enables SO_KEEPALIVE, TCP_KEEPIDLE, TCP_KEEPINTVL 202 and TCP_KEEPCNT options processing. 203 204config NET_TCP_KEEPIDLE_DEFAULT 205 int "TCP_KEEPIDLE default value" 206 depends on NET_TCP_KEEPALIVE 207 default 7200 208 help 209 The time (in seconds) the connection needs to remain idle before TCP 210 starts sending keepalive probes, if the socket option SO_KEEPALIVE has 211 been set on this socket. 212 213config NET_TCP_KEEPINTVL_DEFAULT 214 int "TCP_KEEPINTVL default value" 215 depends on NET_TCP_KEEPALIVE 216 default 75 217 help 218 The time (in seconds) between individual keepalive probes. 219 220config NET_TCP_KEEPCNT_DEFAULT 221 int "TCP_KEEPCNT default value" 222 depends on NET_TCP_KEEPALIVE 223 default 9 224 help 225 The maximum number of keepalive probes TCP should send before dropping 226 the connection. 227 228config NET_TCP_ISN_RFC6528 229 bool "Use ISN algorithm from RFC 6528" 230 default y 231 depends on NET_TCP 232 depends on PSA_WANT_ALG_SHA_256 233 help 234 Implement Initial Sequence Number calculation as described in 235 RFC 6528 chapter 3. https://tools.ietf.org/html/rfc6528 236 If this is not set, then sys_rand32_get() is used for ISN value. 237 238config NET_TCP_REJECT_CONN_WITH_RST 239 bool "Reject connection attempts on unbound TCP ports with RST" 240 default y 241 help 242 If enabled, TCP stack will reject connection attempts on unbound ports 243 with TCP RST packet. 244 245config NET_TCP_IPV6_ND_REACHABILITY_HINT 246 bool "Provide a reachability hint for IPv6 Neighbor Discovery" 247 depends on NET_TCP 248 depends on NET_IPV6_ND 249 help 250 If enabled, TCP stack will inform the IPv6 Neighbor Discovery process 251 about the active link to a specific neighbor by signaling recent 252 "forward progress" event as described in RFC 4861. 253 254endif # NET_TCP 255