lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Again confused about tcp_recved() and pbuf_free()


From: address@hidden
Subject: Re: [lwip-users] Again confused about tcp_recved() and pbuf_free()
Date: Mon, 25 Feb 2019 20:23:36 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0

Am 23.02.2019 um 10:20 schrieb Giuseppe Modugno:
I know, this is a hot topic and many times this was explaied in the list and in doc/rawapi.txt, however now I'm in trouble understanding this.

tcp_recved() is related to the TCP window size of the receiver: "The purpose is to advertise a larger window when the data has been processed.". Isn't the TCP window size fixed to TCP_WND macro? Does it mean that the window size increases every time tcp_recved() is called from the application? I don't think, otherwise the window size increases continuously during a connection.

The window has a more or less fixed total size. But it changes with each segment sent: for every byte sent (and ACKed), it decrease. The receiver is responsible to "reopen" the window by sending an appropriate window size with its ACK segments. lwIP does this for you, but you have to tell it when you are ready to accept more data. This is what 'tcp_recved()' does.

What are the situations when it should be better to not call tcp_recved() in recv() callback()? Here the application has the received data, can process and free the pbufs or can avoid freeing the pbufs to wait for additional data. In both cases I think the application should call tcp_recved().

If you need to process the received data further at slower speed, it's better to not call tcp_recved() right away. For example if you're programming into slow flash, calling tcp_recved after the bytes are programmed ensures the client does not send faster than you can program.

Regards,
Simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]