[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Using netbufs
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] Using netbufs |
Date: |
Thu, 18 Feb 2010 07:25:27 +0100 |
Joe Dupre wrote:
> I have a simple application that sends out a UDP packet every few seconds.
> When using the raw API, I created a raw pbuf in ram, filled the payload,
> and then had udp_send() send that same pbuf over and over from my lwip
> task.
This is only valid when you don't have a DMA-enabled MAC. Or in other words you
may only re-use the pbufs (after udp_send returns), when their reference
coutner (p->ref) is 1 (which means noone else is using it). With a DMA-enabled
MAC, the driver calls pbuf_ref (p->ref++) and enqueues the packet for sending,
which means udp_send can return before the packet is sent. If you then pass the
pbuf to udp_send again, the IP and ethernet headers (which are in the same
pbuf!) get changed and the previous packet may get corrupted while sending
through DMA.
> Now with the Netconn API, I've created separate task to do this. I create
> a netbuf, fill the payload, and call netconn_sendto(). The first time the
> packet is sent as expected, but when netconn_sendto() returns, the length
> of my netbuf has changed, and the payload is in a different location.
>
> I see that as the netbuf's pbuf gets passed toward the interface, headers
> get added to the payload. But after the packet is sent the headers are not
> removed and the netbuf I get back is no longer the netbuf that I started
> with.
>
> Are netbufs only designed to be used once and then thrown away?
I think they are. Probably noone has bothered to try this yet, for the problems
I listed above (for the raw API) are of course true for the netconn API as well
(as it uses the raw API an netbufs are mainly wrappers around pbufs).
In general, what you do is a good thing to measure throughput, but isn't often
used in real applications.
Simon
--
Sicherer, schneller und einfacher. Die aktuellen Internet-Browser -
jetzt kostenlos herunterladen! http://portal.gmx.net/de/go/chbrowser