Originally published on Code Beneath .
UDP packets vanish. Your application never sees them. The sender gets no error. Your monitoring shows traffic arrived on the interface, yet your receive loop pulls nothing from the socket. The culprit is often a UDP receive buffer overflow, where the OS kernel drops incoming datagrams because your application cannot consume them fast enough. Understanding how the kernel manages the UDP receive buffer, how to detect when it overflows, and how to tune SO_RCVBUF will save you hours of debugging and silent data loss. This article shows exactly what happens, with runnable code that demonstrates the problem and strace output that proves packets are being dropped at the OS level.
How UDP Receive Buffering Works
When a UDP packet arrives at a network interface, the kernel does not deliver it directly to your application. Instead, the packet lands in a socket receive buffer, a fixed-size ring buffer managed by the kernel.…