I am going to write tool used for load/stress testing of VoIP application. Most of tested calls would be conference-like calls where one client speaks and all others in group listens. In such scenario server copies received UDP RTP audio packets to every listening client. In my load tool I will wait for these packets in epoll-based loop.
Problem: when UDP RTP packets arrives, I have to call recvfrom in order to receive it. In my case I do not want to process contents of this packet in most scenarios (packet count would be enough), so recvfrom unnecessary copies data from kernel to user space. For big groups this means a lot of unnecessary copying. Is it possible to ask kernel to remove this packet from receive buffer and do not pass it to user space? Or maybe somehow redirect it to /dev/null in kernel? Or ask kernel to remove all packets and return how many it removed?
Environment: Linux RedHat 6 (7 also would be acceptable), x86_64, gcc.
You can try to do it in user space:
MSG_TRUNC (since Linux 2.2) For raw (AF_PACKET), Internet datagram (since Linux 2.4.27/2.6.8), netlink (since Linux 2.6.22) and UNIX datagram (since Linux 3.4) sockets: return the real length of the packet or datagram, even when it was longer than the passed buffer. Not implemented for UNIX domain (unix(7)) sockets.
len = recvfrom(sock, buff, 0, MSG_TRUNC, ...);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With