Am 03.02.2022 um 15:51 schrieb Matthias Paul:
Hello all,

I'm using lwip 2.1.2 in non-OS / non-threaded mode (main loop mode) with
raw API to send/receive TCP packets.

When sending packets with tcp_write() I'd like to use zero copy
mechanism. Therefore I need to keep the pbuf objects until the buffer
has been sent and acknowledged by the recipient. When acknowledged, my
callback registered by tcp_sent() is called:

static err_t

TCPSERVER_sentCallback(

         void                        * arg,

         struct tcp_pcb                * tcpPcb,

         uint16_t                    length) {

    // remove pbuf which are reported as "sent"
    ...
}

Is "length" always matching a single pbuf length or could it happen that
TCPSERVER_sentCallback() reports multiple pbuf objects at once?

Also, can I assume, that TCPSERVER_sentCallback() is called in the order
the packets have been sent?

You have to understand the tcp protocol to understand the sent callback:
a host acknowledges the bytes received from a the other side. It is free
to send an ACK for an arbitrary byte count between 1 and the maxiumum
outstanding bytes. But since tcp is a streaming protocol, you'll always
know when to free the next buffer from the from of your list when you
sum up the 'length' parameter of all 'sent' calls.

Regards,
Simon

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to