Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12599 Discussions

Standalone LwIP Raw API for TCP

Altera_Forum
Honored Contributor II
1,041 Views

Suppose my application enters a state in which it can temporarily no longer accept incoming TCP pbufs on an established connection. (for example : when my application incoming message queue is full) 

I am 'solving' the problem now by simply discarding incoming pbufs (using pbuf_free()) in the TCP Receive CallBack Function when this situation occurs. This works fine and very stable , but is not satisfactory because the remote host has no way of knowing that these messages have been discarded (because their reception has been acknowledged by LwIP). 

 

What would be the appropriate way to handle this situation without losing incoming pbufs? I can think of some solutions but I don't know if they are allowed by the LwIP library (due to the its limited documentation) : 

 

1. Not use the tcp_recved() function (for updating the TCP receive window) when the receive CallBack Function PLACES the pbuf on the application incoming message queue, but delaying this update to the moment when the application TAKES the incoming message from its incoming message queue. But does this guarantee me that there will be no more incoming pbufs when my application queue is full? I don't think so... 

 

2. Have the 'tcp_recv CallBack function' return with ERR_MEM without handling the pbuf. I am hoping this will tell LwIP that I didn't accept the pbuf and that it has to try again with the same pbuf later. I have tried this, but the LwIP Library became unstable... or maybe it was my apllication... But either way, I don't know really know what the effect is of returning an ERR_MEM from the Receive Callback Function. 

 

3. More drastic : Remove the 'tcp_recv CallBack function' from the TCP Protocol Control Block by replacing it with a NULL pointer. I'm supposing that when the receive Callback function is removed, LwIP will keep the incoming pbufs and deliver them later when receive Callback function is re-installed. 

 

4. Any other proposition...
0 Kudos
0 Replies
Reply