Skip to main content
DBurr
Senior
April 13, 2021
Solved

How to tune LwIP to receive more incoming connections?

  • April 13, 2021
  • 1 reply
  • 2994 views

Hi, I've got FreeRTOS and LwIP running on an STM32F746. The application has a TCP socket listening for incoming connections. Incoming connections are coming from multiple sources and unfortunately I'm seeing some of the connections get an ECONNRESET error. I've tried turning up the number of TCP connections but this only seems to make the time between these ECONNRESETs greater and does not get rid of them completely. I'm wondering what other LwIP parameters I can tweak to help resolve this?

I was able to track down why the ECONNRESETs are happening. I've traced it to the "tcp_abandon" function getting called. The documentation indicates this function "Abandons a connection and optionally sends a RST to the remote host. Delete the local protocol control block. This is done when a connection is killed because of shortage of memory." I've tried tweaking the memory settings for LwIP but to no avail. Can anyone suggest settings to help with this?

Thanks,

Doug Burrell

This topic has been closed for replies.
Best answer by Walid ZRELLI

Hello @DBurr​ ,

You can refer to the following link for lwIP internal memory pool management : http://www.nongnu.org/lwip/2_0_x/group__lwip__opts__memp.html.

By tweaking the options in lwipopts.h, it should be possible to receive more incoming connections: MEMP_NUM_TCP_PCB, MEMP_NUM_TCP_PCB_LISTEN, MEMP_NUM_NETCONN, etc...

Best regards,

Walid

1 reply

Walid ZRELLI
Walid ZRELLIBest answer
Visitor II
May 19, 2021

Hello @DBurr​ ,

You can refer to the following link for lwIP internal memory pool management : http://www.nongnu.org/lwip/2_0_x/group__lwip__opts__memp.html.

By tweaking the options in lwipopts.h, it should be possible to receive more incoming connections: MEMP_NUM_TCP_PCB, MEMP_NUM_TCP_PCB_LISTEN, MEMP_NUM_NETCONN, etc...

Best regards,

Walid

DBurr
DBurrAuthor
Senior
May 19, 2021

Thanks, Walid, I ended up increasing MEMP_NUM_NETCONN and this has solved my problem.

Regards,

Doug Burrell