3

I am creating a server on a ST Cortex M3 device. I am using the lwip API and FreeRTOS. All is working, but the response time is way off. I am currently using lwip 1.3.2 and FreeRTOS 7.3.

A single client connects to the server and must have some time-critical data sent frequently. These packets are on the order of 6 or so bytes. Other times, I am sending upwards of 20K.

The problem I am having is that these smaller packets seem to be taking forever to be sent. I assume this is because lwip is waiting for more data to be enqueued to make more efficient transmissions. I cannot wait around for 2 or 3 seconds for the data to be sent; the client is expecting the data nominally in a few micro-seconds or milli-seconds.

I have tried using lwip_send and lwip_write. (I understand that one is the same as the other with a flag passed at the end. Just had to try...) I have tried setting TCP_NODELAY on the socket to no avail. I tried to set SO_SNDLOWAT to '1', but this always returned -1, so I do not think it is supported.

I do not want to redo all of my code using TCP RAW. Is there a way to invoke the tcp_output() function outside of TCP RAW mode? Is there any way to speed things up or is this just how slow lwip TCP with small packets is?

Any and all suggestions are welcome. Thanks.

--EDIT-- I would also like to add that once I am ready to transmit, I make sure that my TX task in FreeRTOS is at the highest priority. There are no other tasks running up to the point at which I call lwip_send/write.

4

1 回答 1

0

我对 xilinx 上的裸机 lwIP 相当有经验,而且 lwip 不会等待将内容发送出去。它将在基于以太网硬件确认您的中断时尽快将数据包抽出。我一直只使用UDP。不过,我想到的是,您的问题可能出在接收端。如果您正在使用 TCP,那么这些小数据包可能会迟到,因为您遇到了接收问题。您需要做的是在代码中找到以太网传输的最低级别点,在其上放置一个通用输出切换。然后在收到以太网数据包时打开通用输出开关。查看示波器上的信号。如果它证实了您的假设,则移动输出切换以缩小问题范围。清洗、冲洗并重复,直到找到问题所在。它' 粗略且耗时,但由于纯粹的决心,这种蛮力方法通常可以解决许多“不可能”的嵌入式软件问题。祝你好运!

于 2016-03-24T03:22:06.023 回答