|
From: | address@hidden |
Subject: | Re: [lwip-users] tcp_sent() callback: Called once per sent packet or for multiple packets at once? |
Date: | Thu, 3 Feb 2022 17:57:19 +0100 |
User-agent: | Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |