User Datagram Protocol (UDP) powers latency-critical network applications including DNS resolvers, NTP time synchronization, VoIP streaming, DHCP assignment, and modern QUIC/HTTP3 transport protocols. Because UDP is connectionless and does not employ TCP handshakes or persistent session states, tracking intermittent traffic bursts or locating which local process is receiving packets can be challenging with traditional tools like netstat or ss. The udpsnoop utility, part of the BPF Compiler Collection (BCC), dynamically traces kernel UDP transmit and receive events in real time using extended Berkeley Packet Filters (eBPF).
Why Trace UDP Traffic at the Kernel Boundary?
Unlike TCP streams where state machines track segments from SYN through ESTABLISHED to FIN, UDP is fire-and-forget. Traditional packet analysers such as tcpdump capture packet content over wire interfaces, but they incur significant CPU overhead under multi-gigabit traffic and cannot correlate packet events with specific user-space process IDs (PIDs) or thread command names.
The udpsnoop tool instruments internal kernel UDP send and receive paths (such as udp_sendmsg and udp_recvmsg). This reveals:
- Which applications and PIDs are generating high-frequency UDP packets.
- Transmission volume in bytes per datagram.
- Source and destination IP addresses alongside ephemeral port numbers.
- Whether packets flow via IPv4 or IPv6 stacks.
Installing the BCC Tools Suite
To run udpsnoop, install the BCC package and kernel development headers for your active kernel version.
On Debian, Ubuntu, and derivatives:
sudo apt update
sudo apt install bpfcc-tools linux-headers-$(uname -r)
On RHEL, Rocky Linux, or Fedora:
sudo dnf install bcc-tools kernel-devel-$(uname -r)
The binary is typically located at /usr/sbin/udpsnoop-bpfcc or /usr/share/bcc/tools/udpsnoop.
Running udpsnoop to Monitor UDP Activity
To begin tracing UDP events across the entire system, execute udpsnoop with root privileges:
sudo udpsnoop-bpfcc
When UDP packets are transmitted or received, udpsnoop streams tabular event lines:
TIME(s) PID COMM IP RADDR:RPORT BYTES
0.000000 1042 systemd-resolve 4 8.8.8.8:53 45
0.002140 1042 systemd-resolve 4 8.8.8.8:53 84
1.104210 3841 chronyd 4 192.168.1.1:123 48
2.451920 18920 chrome 4 142.250.190.46:443 1250
This output clearly illustrates DNS queries from systemd-resolve, NTP synchronization by chronyd, and QUIC/HTTP3 packets generated by web browsers.
Filtering UDP Output by Process ID
On busy production servers handling thousands of DNS queries per second, filtering output prevents console flooding and helps you focus on specific daemons:
# Trace UDP packets exclusively for a specific process (e.g. PID 3841)
sudo udpsnoop-bpfcc -p 3841
Tracing Specific IP Versions
To audit modern dual-stack environments and isolate IPv6 migration behaviour:
# Trace IPv6 UDP datagrams only
sudo udpsnoop-bpfcc -6
# Trace IPv4 UDP datagrams only
sudo udpsnoop-bpfcc -4
Correlating UDP Drops with Kernel Socket Buffers
If udpsnoop reveals heavy incoming UDP traffic but your application reports dropped messages, check whether the kernel UDP receive buffer is overflowing:
netstat -su | grep -E "buffer errors|receive errors"
When receive errors climb, increase socket buffer limits using sysctl:
sudo sysctl -w net.core.rmem_max=26214400
sudo sysctl -w net.core.rmem_default=26214400
By leveraging udpsnoop alongside socket buffer metrics, system administrators can resolve real-time packet loss across voice, video, DNS, and modern QUIC deployments.