lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] lwIP malloc fail


From: Navcon - Pedro Paulo Santos
Subject: Re: [lwip-users] lwIP malloc fail
Date: Wed, 7 Apr 2010 14:31:27 -0300

Kieran,

Thanks for the valuable informations!

I ran my program and looked for the ACKs. I observed that in the correct part of my program (the HTTP server) all packages are alwayes acked, but when I begin to transfer the large file the unacked packages appear and the system run out of memory. The problem is: it seems that the ACK never comes. It's not about performance, the transfer doesn't work, even if I wait for minutes.

Using what you said I concluded that the lack of memory may occur because the microcontroller doesn't recognize the ACK that comes (and it really comes, because I can see it with Wireshark), and because of that, lwIP doesn't free segment memory and after some tranfers it doesn't find memory to alloc.

I'm going to look for the reason that it can't recognize the ACK.

If anyone have a suggestion I will accept it gladly.

About the NODELAY, I already use it.

I agree I won't have a high performance with low memory, but I also think that even with this issue, I have to be able to transfer data of large sizes (larger than the microcontroller internal memory), even if it takes long time.

Thanks,
Pedro Paulo.

----- Original Message ----- From: "Kieran Mansley" <address@hidden> To: "Navcon - Pedro Paulo Santos" <address@hidden>; "Mailing list for lwIP users" <address@hidden>
Sent: Wednesday, April 07, 2010 12:58 PM
Subject: Re: [lwip-users] lwIP malloc fail


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
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users


__________ Informação do ESET NOD32 Antivirus, versão da vacina 4628 (20091122) __________

A mensagem foi verificada pelo  ESET NOD32 Antivirus.

http://www.eset.com




__________ Informação do ESET NOD32 Antivirus, versão da vacina 4628 (20091122) 
__________

A mensagem foi verificada pelo  ESET NOD32 Antivirus.

http://www.eset.com







reply via email to

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