OpenFastPath / ofp

OpenFastPath project
BSD 3-Clause "New" or "Revised" License
349 stars 126 forks source link

How to determine when a packet has been sent #292

Open stockxiay opened 8 months ago

stockxiay commented 8 months ago

Before I call ofp_send, how do I determine whether the current descriptor is writable and how do I confirm that the data packet is sent?

JereLeppanen commented 8 months ago

With a TCP socket, you should be able to use the OFP_MSG_NBIO (non-blocking I/O) flag with ofp_send().

To confirm that packet is sent, you might find the packet counters returned by ofp_get_packet_statistics() useful.

bogdanPricope commented 8 months ago

Hi @stockxiay,

If you have considered using ofp_epoll or ofp_select() to determine if a descriptor is writable.... it will not work. Current OFP version does not support this functionality.

However you may try this version that provide it: https://github.com/NetInoSoftware/nfp

bogdanPricope commented 8 months ago

ofp_send() do return the number of bytes sent or -1 on error. However, even if the bytes are reported as 'sent', OFP may store them (a small number of packets, store per thread) to favor burst sending. The size of the burst is configurable (default 1).

Application can force the sending of the stored packets with ofp_send_pending_pkt().