cancel
Showing results for 
Search instead for 
Did you mean: 

Low TCP/IP Data Transfer Rate Using LWIP

Chao
Senior II

Edited by a ST moderator to be comliant with the ST community rules. In next time please use </> button to paste your code. Please review How to insert source code.

Hi,

I have a video application using F767 with LWIP and without RTOS. The custmized board has an SDRAM of 512MB. When receiving data, the pbuf.len is always 1460 bytes while the other side sends 40KB each time. Comparing to the data transfer rate can reach over 20Mbit/s, it's extremely slow in a video application, there must be fundamental issues in buffer configuration in my application.

The options in lwipopts.h that I think they would be relevant to the data transfer rate are:

#define MEM_ALIGNMENT 4

#define MEM_SIZE (30*1024)

#define MEMP_NUM_PBUF 25

#define MEMP_NUM_UDP_PCB 4

#define MEMP_NUM_TCP_PCB 4

#define MEMP_NUM_TCP_PCB_LISTEN 2

#define MEMP_NUM_TCP_SEG 150

#define MEMP_NUM_SYS_TIMEOUT 6

#define PBUF_POOL_SIZE 20

#define PBUF_POOL_BUFSIZE LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)

#define LWIP_TCP 1

#define TCP_TTL 255

#define TCP_QUEUE_OOSEQ 0

#define TCP_MSS (1500 - 40) /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */

#define TCP_SND_BUF (11*TCP_MSS)

#define TCP_SND_QUEUELEN (8* TCP_SND_BUF/TCP_MSS)

#define TCP_WND (20*TCP_MSS)

 

In stm32f7xx_hal_conf.h:

/* Definition of the Ethernet driver buffers size and count */

#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */

#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */

#define ETH_RXBUFNB ((uint32_t)5) /* 5 Rx buffers of size ETH_RX_BUF_SIZE */

#define ETH_TXBUFNB ((uint32_t)5) /* 5 Tx buffers of size ETH_TX_BUF_SIZE */

 

In stm32f7xx_hal_eth.h:

#define ETH_MAX_PACKET_SIZE ((uint32_t)1524U) /*!< ETH_HEADER + ETH_EXTRA + ETH_VLAN_TAG + ETH_MAX_ETH_PAYLOAD + ETH_CRC */

#define ETH_HEADER ((uint32_t)14U) /*!< 6 byte Dest addr, 6 byte Src addr, 2 byte length/type */

#define ETH_CRC ((uint32_t)4U) /*!< Ethernet CRC */

#define ETH_EXTRA ((uint32_t)2U) /*!< Extra bytes in some cases */

#define ETH_VLAN_TAG ((uint32_t)4U) /*!< optional 802.1q VLAN Tag */

#define ETH_MIN_ETH_PAYLOAD ((uint32_t)46U) /*!< Minimum Ethernet payload size */

#define ETH_MAX_ETH_PAYLOAD ((uint32_t)1500U) /*!< Maximum Ethernet payload size */

#define ETH_JUMBO_FRAME_PAYLOAD ((uint32_t)9000U) /*!< Jumbo frame payload size */

Any suggestions would be highly appreciated.

Regards

Chao

6 REPLIES 6
Pavel A.
Super User

Use wireshark to understand if there are retransmissions or other anomalies- and why.

 

LCE
Principal II

Only 5 RX buffers at ETH_MAX_PACKET_SIZE don't make sense when expecting 40 kB packets.

Same for jumbo frame payload, why only 9k?

But I might be wrong here, I have no experience with big packet handling in LWIP. I told my software colleagues they may not send any packets larger than max TCP packet size. :D

Ozone
Principal II

And how about profiling you application ?

Pavel A.
Super User

Jumbo frame size is a L2 hardware (MAC) limit, documented in the RM (or DS). Max TCP packet size can be large, if fragmentation is allowed. LwIP can handle fragmentation, wireshark can show if this indeed happens and how successfully.

 

Hi Pavel,

Thanks for the suggestion, the following is a snapshot of the wireshark capture, please find the capture file attached:

Chao_0-1762958168255.png

There are three main issues in this application:

1. there are too many [TCP window FULL] reports which I don't know how to deal with

2. the maximal packet size is 19020 bytes sent from a server running from a PC, but the F767 client receives packets all at 1460 bytes, is there a way to increase it ?

3. the client application with F767 and LWIP causes network failure every 30 seconds

the server reports 10060 error "The connection has been dropped because of a network failure or because the peer system failed to respond" every 30 seconds

Regards

Chao

Hi LCE,

Sorry, I have no experience with LWIP configurations at all, and don't know which parameters should be  modified, according to your comments, I tested ETH_MAX_PACKET_SIZE from 10 to 500 with transferring a frame of picture (960*540 in BGR565, about 1MB), the data transfer time improved from 1 minute to 5 seconds, which is a big jump, thanks a lot!  With jumbo frame payload set to 38912 bytes, the performance was a bit better. Are there anything else I could do to improve the performance?

Regards

Chao