As stated on asio-users mailing list (
https://sourceforge.net/p/asio/mailman/asio-users/thread/CADfydx%2BDF1kvqchV...
), I wrote a patch that enables sendmmsg / recvmmsg on supported operating
systems (Linux, [Free/Net/Open]BDS, AIX, Blackberry QNXNeutrino).
The syscalls are implemented in reactive_socket_service backend (the
io_uring backend on Linux does not support sendmmsg / recvmmsg yet, so no
recvmmsg / sendmmsg when using newest support for io_uring on asio).
The config.hpp has macros for forcible disable those calls, and detect
supported operating system compiler macros.
New methods were developed for (send/send_to/receive/receive_from) suffixed
with '_multiple_buffer_sequence' that accepts a multiple_buffer_sequence
class (backed by asio::detail::array or
std::vector) and a
multiple_buffer_sequence_adapter that convert ops to struct mmsghdr* for
sendmmsg/recvmmsg.
The multiple_buffer_sequence implementations are basically a collection of
multiple_buffer_sequence_op instances that represents each socket operation
.
It defines the objects needed to perform fill on mmsghdr structures
buffer_sequence_type buffer_sequence_;
buffer_sequence_adapter_type buffer_sequence_adapter_;
endpoint_type endpoint_;
bool completed_;
socket_base::message_flags flags_;
std::size_t bytes_transferred_;
asio::error_code error_code_;
The multiple_buffer_sequence implementations has full container support,
iterators, and support Mutable and Const buffer sequences.
I finished the first version of the patch. It's able to send and receive
1million packet / second on my box at same time (an intel i9 9900k / ubuntu
22.04 lts low latency kernel) using packet sizes of 64 / 1430 bytes without
packet loss (using 64mb udp socket buffers)
A little running demo is able to being watched at
https://www.youtube.com/watch?v=Q3hqe6ntM3w. I need to write some automatic
tests for (async_)[send/receive]_multiple_buffer_sequence calls[_to/_from]
and push a pure ASIO example in examples repository
I made the code available for review, scrutiny and suggestions.
The source code is in my github repo (
https://github.com/virgiliofornazin/asio ),on branch
feature/multiple_datagram_buffers_sequence-io-sendmmsg-recvmmsg
( the full URL of patch diff is
https://github.com/chriskohlhoff/asio/compare/master...virgiliofornazin:asio...
).