[Top][All Lists]
[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: |
Tue, 13 Apr 2010 18:20:43 -0300 |
Hi to all,
Excuse for the delay.
Finally I could do the large download from the external serial flash memory,
and I'll post here in the case someone have the same problem I had.
The main mistake I did was that I tried to send all the data in the recv
callback function. As I realized, lwIP received the ACK, but didn't freed
the memory because it does so in other handler (unknown for me) different
from recv. And this isn't done while the program remained in recv function
(I think that the callback functions can't be interrupted by lwIP itself,
correct me if I'm wrong).
So I had to create a global struct where I could "register" files to be
transfered (I write a pointer to the data, the number of bytes, and a
pointer to a next tranfer struct) that is included in the argument struct.
In the recv callback function I just "register" the files I want to download
and the tcp_write itself is done outside in the poll callback function. In
this struct I have, also, a status where I set if there is a transfer
running or not, and this status changes from "TRANSFER_RUNNING" to
"NO_TRANSFER" in the sent callback function. This way I can transfer files
of almost any size I want (only limited by the size of the linked list
created for the "registers").
Of course this solution causes high latency, but the performance can be
improve by the correct configuration of the timer used by lwIP if we
stablish a fixed size for each TCP transfer (but this only make sense in my
case where I have to make large transfers that always use a lot of TCP
packages). The latency can be improve for really small tranfers by sending
in the recv function, but I would not suggest this.
To complete, my program runs fine. If I said anything wrong about lwIP
engine, please correct me, my conclusions were born in my atempting to
implement my program, but I didn't find any documentation that explains lwIP
from the basics.
Thanks to all.
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 4:01 PM
Subject: Re: [lwip-users] lwIP malloc fail
On 7 Apr 2010, at 18:31, Navcon - Pedro Paulo Santos wrote:
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.
The most simple explanation would be that you've used all the available TCP
segments by queueing data to send, and there are none left to process the
received packet, so it gets dropped. If you set the TCP_SND_QUEUELEN (or
something similar - can't remember the exact name) smaller than the number
of TCP segments then you shouldn't be able to exhaust them by queueing data
to send.
Kieran
__________ 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