From 4f5a19482b930cd6ac00bfccd3ba8687b7013a79 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Fri, 18 Feb 2022 16:29:11 +0100 Subject: [PATCH] net: tcp: Make receive window size configurable Add Kconfig option to set the receive window size. Signed-off-by: Robert Lubos --- subsys/net/ip/Kconfig | 12 ++++++++++++ subsys/net/ip/tcp.c | 7 ++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/subsys/net/ip/Kconfig b/subsys/net/ip/Kconfig index 18dc37fe37d..516c9adc9b2 100644 --- a/subsys/net/ip/Kconfig +++ b/subsys/net/ip/Kconfig @@ -431,6 +431,18 @@ config NET_TCP_MAX_SEND_WINDOW_SIZE size. The default value 0 lets the TCP stack select the value according to amount of network buffers configured in the system. +config NET_TCP_MAX_RECV_WINDOW_SIZE + int "Maximum receive window size to use" + depends on NET_TCP + default 0 + range 0 65535 + help + This value defines the maximum TCP receive window size. Increasing + this value can improve connection throughput, but requires more + receive buffers avaialble in the system for efficient operation. + The default value 0 lets the TCP stack select the value + according to amount of network buffers configured in the system. + config NET_TCP_RECV_QUEUE_TIMEOUT int "How long to queue received data (in ms)" depends on NET_TCP diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index 7eefe46a5ee..da7d1f5266f 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -33,7 +33,12 @@ LOG_MODULE_REGISTER(net_tcp, CONFIG_NET_TCP_LOG_LEVEL); static int tcp_rto = CONFIG_NET_TCP_INIT_RETRANSMISSION_TIMEOUT; static int tcp_retries = CONFIG_NET_TCP_RETRY_COUNT; -static int tcp_window = NET_IPV6_MTU; +static int tcp_window = +#if (CONFIG_NET_TCP_MAX_RECV_WINDOW_SIZE != 0) + CONFIG_NET_TCP_MAX_RECV_WINDOW_SIZE; +#else + (CONFIG_NET_BUF_RX_COUNT * CONFIG_NET_BUF_DATA_SIZE) / 3; +#endif static sys_slist_t tcp_conns = SYS_SLIST_STATIC_INIT(&tcp_conns);