2
votes

I am using LWIP stack for TCP/IP.

My application is the server application. It sends packet continuously to the client. Client receives the packet without any delay .But it sends the ACK after 200ms.

LWIP stack always waits for ACK packet before it sends the next packet.

Is there any configuration which makes the LWIP stack to send packet without waiting for the ACK packet please let us know.

Thanks and Regards, Hemanth Kumar PG

2

2 Answers

4
votes

Check what values you configured for the TCP settings of the stack. The default values are located in include/lwip/opt.h you should customize them with your own lwipopts.hwhich get included at the top of opt.hand thus overwrites any default values.

The following values should be interesting for you. They have very conservative default settings to make LwIP run on very low ressources:

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

the other values are mostly calculated from this one:

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

What you are experiencing is that the TCP window is too small and so the stack will wait for ACKs befor being able to send the next packet(s).

More info on this can be found in the LWIP wiki:
http://lwip.wikia.com/wiki/Lwipopts.h
the project homepage:
http://savannah.nongnu.org/projects/lwip/
or on the mailing list:
https://lists.nongnu.org/mailman/listinfo/lwip-users

0
votes

This sounds you're running into the classic bad interaction between Delayed ACK's and Nagle's algorithm where you get a temporary deadlock the duration of the delayed ACK timer. This isn't specific to LwIP and applications can run into this with traditional IP stacks. See the below links for more information on this problem:

Depending on your application message format, you can resolve the issue by turning off Nagle's algorithm with the TCP_NODELAY socket option or by changing your write pattern to not perform subsequent small writes less than a maximum segment size