2

我正在为 TCP/IP 使用 LWIP 堆栈。

我的应用程序是服务器应用程序。它不断地向客户端发送数据包。客户端收到数据包没有任何延迟。但它在 200 毫秒后发送 ACK。

LWIP 堆栈总是在发送下一个数据包之前等待 ACK 数据包。

是否有任何配置使 LWIP 堆栈无需等待 ACK 数据包即可发送数据包,请告诉我们。

谢谢和问候, Hemanth Kumar PG

4

2 回答 2

4

检查您为堆栈的 TCP 设置配置的值。默认值位于include/lwip/opt.h您应该使用您自己的自定义值,这些值lwipopts.h包含在顶部,opt.h因此会覆盖任何默认值。

您应该对以下值感兴趣。他们有非常保守的默认设置,使 LwIP 在非常低的资源上运行:

/**
 * TCP_MSS: TCP Maximum segment size. (default is 536, a conservative default,
 * you might want to increase this.)
 * For the receive side, this MSS is advertised to the remote side
 * when opening a connection. For the transmit size, this MSS sets
 * an upper limit on the MSS advertised by the remote host.
 */
#ifndef TCP_MSS
#define TCP_MSS                         536
#endif

其他值大多是从这个计算出来的:

/**
 * TCP_WND: The size of a TCP window.  This must be at least 
 * (2 * TCP_MSS) for things to work well
 */
#ifndef TCP_WND
#define TCP_WND                         (4 * TCP_MSS)
#endif 

/**
 * TCP_SND_BUF: TCP sender buffer space (bytes).
 * To achieve good performance, this should be at least 2 * TCP_MSS.
 */
#ifndef TCP_SND_BUF
#define TCP_SND_BUF                     (2 * TCP_MSS)
#endif

/**
 * TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
 * as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work.
 */
#ifndef TCP_SND_QUEUELEN
#define TCP_SND_QUEUELEN                ((4 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))
#endif

您遇到的是 TCP 窗口太小,因此堆栈将等待 ACK 才能发送下一个数据包。

有关这方面的更多信息,请参见 LWIP wiki: http:
//lwip.wikia.com/wiki/Lwipopts.h
项目主页:
http
://savannah.nongnu.org/projects/lwip/ 或邮件列表:
https ://lists.nongnu.org/mailman/listinfo/lwip-users

于 2016-02-09T12:01:06.400 回答
0

这听起来您遇到了延迟 ACK 和 Nagle 算法之间的经典不良交互,您在延迟 ACK 计时器的持续时间内遇到临时死锁。这不是特定于 LwIP 的,应用程序可以通过传统的 IP 堆栈运行。有关此问题的更多信息,请参阅以下链接:

根据您的应用程序消息格式,您可以通过使用 TCP_NODELAY 套接字选项关闭 Nagle 算法或通过更改写入模式以不执行小于最大段大小的后续小写入来解决问题

于 2016-04-19T20:54:00.980 回答