LWIP堆栈配置

时间:2015-12-29 23:47:16

标签: lwip

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

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

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

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

谢谢和问候, Hemanth Kumar PG

2 个答案:

答案 0 :(得分:2)

检查您为堆栈的TCP设置配置的值。 默认值位于include/lwip/opt.h,您应该使用自己的lwipopts.h自定义它们,这些opt.h会包含在/** * 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 的顶部,从而覆盖任何默认值。

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

/**
 * 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

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

ItemNumber    CountRows
xxxxxxxx        12
yyyyyyyy        18
xxxxxxxxx       10
yyyyyyyyy       9

您遇到的是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

答案 1 :(得分:0)

这听起来你正在遇到延迟ACK和Nagle算法之间的经典不良交互,在这种算法中,你会在延迟的ACK定时器的持续时间内遇到暂时的死锁。这并不是LwIP特有的,应用程序可以使用传统的IP堆栈来解决这个问题。有关此问题的详细信息,请参阅以下链接:

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

相关问题