kopia lustrzana https://github.com/espressif/esp-idf
lwip: Allow configuring/disabling some TCP options to save RAM
RAM savings are small, but may add up when running large numbers of sockets.pull/746/head
rodzic
8aa09aea10
commit
1c6510ed96
|
@ -68,6 +68,8 @@ config LWIP_IP_REASSEMBLY
|
|||
help
|
||||
Enabling this option allows reassemblying incoming fragmented IP packets.
|
||||
|
||||
menu "TCP"
|
||||
|
||||
config TCP_MAXRTX
|
||||
int "Maximum number of retransmissions of data segments"
|
||||
default 12
|
||||
|
@ -82,6 +84,79 @@ config TCP_SYNMAXRTX
|
|||
help
|
||||
Set maximum number of retransmissions of SYN segments.
|
||||
|
||||
config TCP_MSS
|
||||
int "Maximum Segment Size (MSS)"
|
||||
default 1436
|
||||
range 1220 1436
|
||||
help
|
||||
Set maximum segment size for TCP transmission.
|
||||
|
||||
Can be set lower to save RAM, the default value 1436 will give best throughput.
|
||||
|
||||
config TCP_SND_BUF_DEFAULT
|
||||
int "Default send buffer size"
|
||||
default 5744 # 4 * default MSS
|
||||
range 2440 65535
|
||||
help
|
||||
Set default send buffer size for new TCP sockets.
|
||||
|
||||
Per-socket send buffer size can be changed at runtime
|
||||
with lwip_setsockopt(s, TCP_SNDBUF, ...).
|
||||
|
||||
This value must be at least 2x the MSS size, and the default
|
||||
is 4x the default MSS size.
|
||||
|
||||
Setting a smaller default SNDBUF size can save some RAM, but
|
||||
will decrease performance.
|
||||
|
||||
config TCP_WND_DEFAULT
|
||||
int "Default receive window size"
|
||||
default 5744 # 4 * default MSS
|
||||
range 2440 65535
|
||||
help
|
||||
Set default TCP receive window size for new TCP sockets.
|
||||
|
||||
Per-socket receive window size can be changed at runtime
|
||||
with lwip_setsockopt(s, TCP_WINDOW, ...).
|
||||
|
||||
Setting a smaller default receive window size can save some RAM,
|
||||
but will significantly decrease performance.
|
||||
|
||||
config TCP_QUEUE_OOSEQ
|
||||
bool "Queue incoming out-of-order segments"
|
||||
default y
|
||||
help
|
||||
Queue incoming out-of-order segments for later use.
|
||||
|
||||
Disable this option to save some RAM during TCP sessions, at the expense
|
||||
of increased retransmissions if segments arrive out of order.
|
||||
|
||||
choice TCP_OVERSIZE
|
||||
prompt "Pre-allocate transmit PBUF size"
|
||||
default TCP_OVERSIZE_MSS
|
||||
help
|
||||
Allows enabling "oversize" allocation of TCP transmission pbufs ahead of time,
|
||||
which can reduce the length of pbuf chains used for transmission.
|
||||
|
||||
This will not make a difference to sockets where Nagle's algorithm
|
||||
is disabled.
|
||||
|
||||
Default value of MSS is fine for most applications, 25% MSS may save
|
||||
some RAM when only transmitting small amounts of data. Disabled will
|
||||
have worst performance and fragmentation characteristics, but uses
|
||||
least RAM overall.
|
||||
|
||||
config TCP_OVERSIZE_MSS
|
||||
bool "MSS"
|
||||
config TCP_OVERSIZE_QUARTER_MSS
|
||||
bool "25% MSS"
|
||||
config TCP_OVERSIZE_DISABLE
|
||||
bool "Disabled"
|
||||
|
||||
endchoice
|
||||
|
||||
endmenu # TCP
|
||||
|
||||
config LWIP_DHCP_DOES_ARP_CHECK
|
||||
bool "Enable an ARP check on the offered address"
|
||||
default y
|
||||
|
|
|
@ -69,7 +69,7 @@
|
|||
#include "lwip/memp.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
#if LWIP_TCP && TCP_QUEUE_OOSEQ
|
||||
#if LWIP_TCP && (TCP_QUEUE_OOSEQ || ESP_LWIP)
|
||||
#include "lwip/priv/tcp_priv.h"
|
||||
#endif
|
||||
#if LWIP_CHECKSUM_ON_COPY
|
||||
|
|
|
@ -284,7 +284,7 @@
|
|||
* TCP_QUEUE_OOSEQ==1: TCP will queue segments that arrive out of order.
|
||||
* Define to 0 if your device is low on memory.
|
||||
*/
|
||||
#define TCP_QUEUE_OOSEQ 1
|
||||
#define TCP_QUEUE_OOSEQ CONFIG_TCP_QUEUE_OOSEQ
|
||||
|
||||
/*
|
||||
* LWIP_EVENT_API==1: The user defines lwip_tcp_event() to receive all
|
||||
|
@ -292,7 +292,7 @@
|
|||
* LWIP_CALLBACK_API==1: The PCB callback function is called directly
|
||||
* for the event. This is the default.
|
||||
*/
|
||||
#define TCP_MSS 1460
|
||||
#define TCP_MSS CONFIG_TCP_MSS
|
||||
|
||||
/**
|
||||
* TCP_MAXRTX: Maximum number of retransmissions of data segments.
|
||||
|
@ -309,6 +309,24 @@
|
|||
*/
|
||||
#define TCP_LISTEN_BACKLOG 1
|
||||
|
||||
|
||||
/**
|
||||
* TCP_OVERSIZE: The maximum number of bytes that tcp_write may
|
||||
* allocate ahead of time
|
||||
*/
|
||||
#ifdef CONFIG_TCP_OVERSIZE_MSS
|
||||
#define TCP_OVERSIZE TCP_MSS
|
||||
#endif
|
||||
#ifdef CONFIG_TCP_OVERSIZE_QUARTER_MSS
|
||||
#define TCP_OVERSIZE (TCP_MSS/4)
|
||||
#endif
|
||||
#ifdef CONFIG_TCP_OVERSIZE_DISABLE
|
||||
#define TCP_OVERSIZE 0
|
||||
#endif
|
||||
#ifndef TCP_OVERSIZE
|
||||
#error "One of CONFIG_TCP_OVERSIZE_xxx options should be set by sdkconfig"
|
||||
#endif
|
||||
|
||||
/*
|
||||
----------------------------------
|
||||
---------- Pbuf options ----------
|
||||
|
@ -673,8 +691,8 @@
|
|||
#define ESP_DHCP_TIMER 1
|
||||
#define ESP_LWIP_LOGI(...) ESP_LOGI("lwip", __VA_ARGS__)
|
||||
|
||||
#define TCP_WND_DEFAULT (4*TCP_MSS)
|
||||
#define TCP_SND_BUF_DEFAULT (4*TCP_MSS)
|
||||
#define TCP_WND_DEFAULT CONFIG_TCP_WND_DEFAULT
|
||||
#define TCP_SND_BUF_DEFAULT CONFIG_TCP_SND_BUF_DEFAULT
|
||||
|
||||
#if ESP_PERF
|
||||
#define DBG_PERF_PATH_SET(dir, point)
|
||||
|
|
|
@ -110,9 +110,11 @@ static void dbg_lwip_tcp_pcb_one_show(struct tcp_pcb* pcb)
|
|||
seg = pcb->unacked;
|
||||
DBG_LWIP_SEG_SHOW(seg);
|
||||
|
||||
ESP_LWIP_LOGI("ooseg semengts:");
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
ESP_LWIP_LOGI("ooseq semengts:");
|
||||
seg = pcb->ooseq;
|
||||
DBG_LWIP_SEG_SHOW(seg);
|
||||
#endif
|
||||
|
||||
ESP_LWIP_LOGI("refused data=%p", pcb->refused_data);
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue