[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Managing pbufs for sending UDP
From: |
Sergio R. Caprile |
Subject: |
Re: [lwip-users] Managing pbufs for sending UDP |
Date: |
Fri, 9 Jun 2017 10:34:49 -0300 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 |
struct pbuf* p;
if((p = pbuf_alloc(PBUF_TRANSPORT, MSG_LEN, PBUF_RAM)) == NULL){
oops...
}
// do your stuff on p
udp_send(pcb, p) or udp_sendto(pcb, p, &ipaddr, DEST_PORT);
pbuf_free(p);
If you send from static memory, you could use PBUF_ROM
You will use PBUF_POOL on your netif. As far as I understand from the
docs, fragmentation is "avoided" by using fixed size pbufs that are
chained when needed to form a bigger pbuf.
As for PBUF_RAM, it is alloced from an lwIP RAM area, it won't mess with
the rest of the system but I guess it might get fragmented.
Perhaps Simon or one of the developers can shine a light on this.
The docs (they are good friends) recommend you don't use PBUF_POOL for
tx:
http://www.nongnu.org/lwip/2_0_x/group__pbuf.html#ggab7e0e32fcc292c0d7107721766ed92fbac9b6ba960fdea6f2e8f35c8313b77e4e