I am using the NWConnection in UDP mode, however it is considerably slower than NWUDPSession when used with NEPacketTunnelProvider.
The reason is that while NWUDPSession will pass an array of datagrams to the callback function, that allows for a fast batch processing of the entire array and then batch write into the packetFlow.
The callback of NWConnection will only pass a single datagram, which means we have to process one packet at a time, and then write one packet into the packetFlow. The result is 2 times slower, whereas NWConnection is supposed to be faster.
Is there an efficient way to aggregate several callbacks and get a single array of packets, without expensive syncrhonization in user space?