cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 and LWIP settings for 2 simultaneous connections.

Muhammed Güler
Senior III

Hello to everyone,

I found LWIP settings working fine with 2 ports open at the same time. I want to share with you. I am working with the NUCLEO-H753ZI board.

in addition to the manual here.

I shifted the Ethernet and LWIP buffers to addresses 0x30000000 and 0x30004000. I installed the MPU in two ram regions of 64K and 256B starting from 0x30000000 as follows.

I got most settings from LwIP_HTTP_Server_Netconn_RTOS app. I increased some values ​​until it works stable.

I set MEMP_NUM_TCP_PCB to 10.

I set MEMP_NUM_UDP_PCB to 6.

Since it is not clear which setting will consume how much ram in the manuals, I set MEM_SIZE to 32768 bytes.

I set TCP_MSS to 1460 bytes.

I set PBUF_POOL_BUFSIZE to 1528 bytes.

I set TCP_WND and TCP_SND_BUF to 5840 bytes (4*TCP_MSS)

Cubemx set TCP_SND_QUEUELEN to 17 bytes.

I set MEMP_NUM_TCP_SEG to 24.

From advanced parameters;

I have enabled LWIP_TCPIP_TIMEOUT, LWIP_SO_SNDTIMEO, LWIP_SO_RCVTIMEO so that the ports can be closed if the connection is lost.

I know very little about LwIP. but with these settings, I can work from two different ports without losing packets.

I have written C# applications that query again for each port when the answer is received. In the scenario where I made a total of 5k queries per second from two applications, it worked for 2 days without any packet loss.

3 REPLIES 3
simosilva
Senior

Thanks for sharing!

NLong.1
Associate

Thank you so much for this! But can I ask some little questions cause I'm so new to LwIP. Have you ever tried to receive a packet that has a size larger than TCP_MSS yet? I can not receive the whole response from the server (2.75KB), I just received only 1440 Bytes. Are there any ways to receive full the response data? Can someone help me with this?

0693W00000GZ2oXQAT.png0693W00000GZ2vDQAT.jpg

Muhammed Güler
Senior III

My homepage is 2.5k in size, I am sending it with the code below.

I am using socket communication.

void BulkWrite(int conn,char *Buffer,int size)

{

  if(size<1400)

  {

    write(conn, Buffer, size);

  }

  else

  {

    write(conn, Buffer, 1400);

    BulkWrite(conn,&Buffer[1400],size-1400);

  }

}