lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] LWIP LPCWare Example: Questions on Transmit PBUF Usage


From: JR
Subject: Re: [lwip-users] LWIP LPCWare Example: Questions on Transmit PBUF Usage
Date: Wed, 27 May 2015 14:36:18 -0700 (MST)

Sergio R. Caprile wrote
> Justin,
> I will assume you are using the raw API:
> you should check the wiki for the documentation on the proper way to do
> things lwIP:
> http://lwip.wikia.com/wiki/Raw/TCP ;
> t


Sergio / All,

Yes, I am using the raw API - that document doesn't link to anything
describing allocation/use of transmit pbufs. It only describes how to call
tcp_write, etc. I can provide some more details about what I've done since
the post above. 

My code uses pre-allocated (at init) receive pbufs, which are queued into
available RX DMA descriptors in RAM - I am able to receive TCP/IP data
successfully and pass it to my application callback, and RX pbufs are freed
successfully when I am done with them (queued back into DMA RX descriptors).
If I leave my TCP connection open and don't send any data, I can see basic
network traffic allocating and freeing pbufs in the heap forever. I have
*0x6000* (24.7k) of heap, and I see my RX pbufs in the 0x2000 - 0x4000 range
upon allocation. My RX pbufs are 1536 bytes in size to avoid chaining. I
receive and respond to one message per second.

Once I've received my data and prepared a response, I call the following:

t = pbuf_alloc(PBUF_RAW, (u16_t) tx_data_len, PBUF_RAM);
pbuf_take(t, XmtData, tx_data_len);
tcp_write(tpcb, t->payload, t->len, 1);
pbuf_free(t);
tcp_recved(tpcb, p->len)    //p is my receive pbuf that hasn't yet been
free'd

This successfully allocates TX pbuf's on the first 3 function calls, but
each allocation is more and more successive in the heap (first at 0x4BB0,
last (third) at 0x5B92). These first three messages are transmitted
successfully. Upon the fourth allocation, there is no more room in the heap
going upward, and pbuf_alloc returns NULL, killing the response.

The problem is, I see these TX pbuf's being freed - the value of 'p' goes
from 0x4BB0 (for example) to 0x0000 after pbuf_free(). Upon failure of the
4th pbuf_alloc, I'm seeing enough free heap space there, but it's trying to
allocate it way up at 0x5B92 for a 1300 byte packet instead of the
previously used space that's already been freed.

Could anyone venture a guess as to why, and is there anything unusual /
wrong with my dynamic allocation / freeing of transmit pbufs? I'm completely
open to any changes. 



--
View this message in context: 
http://lwip.100.n7.nabble.com/LWIP-LPCWare-Example-Questions-on-Transmit-PBUF-Usage-tp24467p24529.html
Sent from the lwip-users mailing list archive at Nabble.com.



reply via email to

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