On 6 Apr 2010, at 16:38, Navcon - Pedro Paulo Santos wrote: > Hi all! > > I'm having a problem in trying to make a system with lwIP that sends a large > file with TCP from an external serial Flash memory. > > I use the following logic: read certain amont of data from the external > memory, send over TCP with tcp_write (), read more data, send again, and > there goes on. I made a function to handle lack of memory because of Nagle's > algoritm (because I have little memory and can't prepare a large TCP > message), and use tcp_output () to force the send of the amont of data. The > problem is that after some transfers (no more than 15 tcp transfers) the > program doesn't find memory to alloc in the following lines of tcp_enqueue () > function:
TCP won't free the segments until it has finished with them, which means waiting for an ACK from the other end. This could take some time. You should be able to disable Nagle's algorithm, and so avoid having to work around it, by setting the NODELAY flag on the PCB. If you can address the memory in your flash directly then the most efficient way to deal with this would be to use a PBUF_ROM type pbuf, which will just reference the flash directly and avoiding having to copy the data into a separate buffer. If that's not an option then you will need to do as you are and wait for buffers to be freed when ACKs arrive. To get ACKs more quickly I would suggest using a small TCP_MSS value. If you don't have much memory you're never going to get high performance, so the tradeoff in this case is probably worth it. Kieran _______________________________________________ lwip-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
