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_INIT_RETRANSMISSION_TIMEOUT
69	int "Initial value of Retransmission Timeout (RTO) (in milliseconds)"
70	depends on NET_TCP
71	default 200
72	range 100 60000
73	help
74	  This value affects the timeout between initial retransmission
75	  of TCP data packets. The value is in milliseconds.
76
77config NET_TCP_RANDOMIZED_RTO
78	bool "Use a randomized retransmission time"
79	default y
80	depends on NET_TCP
81	help
82	  It can happen that two similar stacks enter a retransmission cycle
83	  due to a packet collision. If the transmission timeout is the same
84	  both stacks will retry at the same moment resulting in another
85	  collision. By introducing a randomized retry timeout, the chance of
86	  a second collision is reduced and it reduces further the more
87	  retransmissions occur.
88
89config NET_TCP_RETRY_COUNT
90	int "Maximum number of TCP segment retransmissions"
91	depends on NET_TCP
92	default 9
93	help
94	  The following formula can be used to determine the time (in ms)
95	  that a segment will be be buffered awaiting retransmission:
96	  n=NET_TCP_RETRY_COUNT
97	  Sum((1<<n) * NET_TCP_INIT_RETRANSMISSION_TIMEOUT)
98	  n=0
99	  With the default value of 9, the IP stack will try to
100	  retransmit for up to 1:42 minutes.  This is as close as possible
101	  to the minimum value recommended by RFC1122 (1:40 minutes).
102	  Only 5 bits are dedicated for the retransmission count, so accepted
103	  values are in the 0-31 range.  It's highly recommended to not go
104	  below 9, though.
105	  Should a retransmission timeout occur, the receive callback is
106	  called with -ETIMEDOUT error code and the context is dereferenced.
107
108config NET_TCP_MAX_SEND_WINDOW_SIZE
109	int "Maximum sending window size to use"
110	depends on NET_TCP
111	default 0
112	range 0 $(UINT16_MAX)
113	help
114	  This value affects how the TCP selects the maximum sending window
115	  size. The default value 0 lets the TCP stack select the value
116	  according to amount of network buffers configured in the system.
117
118config NET_TCP_MAX_RECV_WINDOW_SIZE
119	int "Maximum receive window size to use"
120	depends on NET_TCP
121	default 0
122	range 0 $(UINT16_MAX)
123	help
124	  This value defines the maximum TCP receive window size. Increasing
125	  this value can improve connection throughput, but requires more
126	  receive buffers available in the system for efficient operation.
127	  The default value 0 lets the TCP stack select the value
128	  according to amount of network buffers configured in the system.
129
130config NET_TCP_RECV_QUEUE_TIMEOUT
131	int "How long to queue received data (in ms)"
132	depends on NET_TCP
133	default 2000
134	range 0 10000
135	help
136	  If we receive out-of-order TCP data, we queue it. This value tells
137	  how long the data is kept before it is discarded if we have not been
138	  able to pass the data to the application. If set to 0, then receive
139	  queueing is not enabled. The value is in milliseconds.
140	  Note that we only queue data sequentially in current version i.e.,
141	  there should be no holes in the queue. For example, if we receive
142	  SEQs 5,4,3,6 and are waiting SEQ 2, the data in segments 3,4,5,6 is
143	  queued (in this order), and then given to application when we receive
144	  SEQ 2. But if we receive SEQs 5,4,3,7 then the SEQ 7 is discarded
145	  because the list would not be sequential as number 6 is be missing.
146
147config NET_TCP_PKT_ALLOC_TIMEOUT
148	int "How long to wait for a TCP packet allocation (in ms)"
149	depends on NET_TCP
150	default 100
151	range 10 1000
152	help
153	  The TCP network stack allocates packets from the buffers and the
154	  allocation can take some time depending on the situation.
155	  This value indicates how long the stack should wait for the packet to
156	  be allocated, before returning an internal error and trying again.
157
158config NET_TCP_CHECKSUM
159	bool "Check TCP checksum"
160	default y
161	depends on NET_TCP
162	help
163	  Enables TCP handler to check TCP checksum. If the checksum is invalid,
164	  then the packet is discarded.
165
166config NET_TCP_FAST_RETRANSMIT
167	bool "Fast-retry algorithm based on the number of duplicated ACKs"
168	depends on NET_TCP
169	default y
170	help
171	  When a packet is lost, the receiver will keep acknowledging the
172	  sequence number of the last correctly received byte. Upon reception
173	  of a sequence of acknowledgements for the same sequence number,
174	  this can be deduced as that the packet afterwards must have been lost.
175	  In that case a retransmission is triggered to avoid having to wait for
176	  the retransmit timer to elapse.
177
178config NET_TCP_CONGESTION_AVOIDANCE
179	bool "Implement a congestion avoidance algorithm in TCP"
180	depends on NET_TCP
181	default y
182	help
183	  To avoid overstressing a link reduce the transmission rate as soon as
184	  packets are starting to drop.
185
186config NET_TCP_KEEPALIVE
187	bool "TCP keep-alive support"
188	depends on NET_TCP
189	help
190	  Enabling this option allows the TCP stack to send periodic TCP
191	  keep-alive probes. Enables SO_KEEPALIVE, TCP_KEEPIDLE, TCP_KEEPINTVL
192	  and TCP_KEEPCNT options processing.
193
194config NET_TCP_KEEPIDLE_DEFAULT
195	int "TCP_KEEPIDLE default value"
196	depends on NET_TCP_KEEPALIVE
197	default 7200
198	help
199	  The time (in seconds) the connection needs to remain idle before TCP
200	  starts sending keepalive probes, if the socket option SO_KEEPALIVE has
201	  been set on this socket.
202
203config NET_TCP_KEEPINTVL_DEFAULT
204	int "TCP_KEEPINTVL default value"
205	depends on NET_TCP_KEEPALIVE
206	default 75
207	help
208	  The time (in seconds) between individual keepalive probes.
209
210config NET_TCP_KEEPCNT_DEFAULT
211	int "TCP_KEEPCNT default value"
212	depends on NET_TCP_KEEPALIVE
213	default 9
214	help
215	  The maximum number of keepalive probes TCP should send before dropping
216	  the connection.
217
218config NET_TCP_ISN_RFC6528
219	bool "Use ISN algorithm from RFC 6528"
220	default y
221	depends on NET_TCP
222	depends on PSA_WANT_ALG_SHA_256
223	help
224	  Implement Initial Sequence Number calculation as described in
225	  RFC 6528 chapter 3. https://tools.ietf.org/html/rfc6528
226	  If this is not set, then sys_rand32_get() is used for ISN value.
227
228config NET_TCP_REJECT_CONN_WITH_RST
229	bool "Reject connection attempts on unbound TCP ports with RST"
230	default y
231	help
232	  If enabled, TCP stack will reject connection attempts on unbound ports
233	  with TCP RST packet.
234
235config NET_TCP_IPV6_ND_REACHABILITY_HINT
236	bool "Provide a reachability hint for IPv6 Neighbor Discovery"
237	depends on NET_TCP
238	depends on NET_IPV6_ND
239	help
240	  If enabled, TCP stack will inform the IPv6 Neighbor Discovery process
241	  about the active link to a specific neighbor by signaling recent
242	  "forward progress" event as described in RFC 4861.
243
244endif # NET_TCP
245