AF_XDP, XSKMAP, NIC queues
C AF_XDP receiver for raw Solana shred datagrams
Start from the maintained AF_XDP C sample, then use a downloadable XDP filter for the shred source and verified UDP destination port.
Download the source
The working C receiver
Use the xdp-project AF_XDP example as the complete C userspace receiver and loader. Its xdpsock program creates UMEM and an AF_XDP socket, attaches the XDP path, and includes an RX-only mode. Download its GitHub archive above, build with the upstream instructions, and start the RX example on the queue carrying your UDP feed. The separate shred filter download is a focused BPF program to integrate with an AF_XDP loader; it is not a standalone receiver binary.
bash
git clone https://github.com/xdp-project/bpf-examples.gitcd bpf-examples./configuremakesudo ./AF_XDP-example/xdpsock -i eth0 -q 0 -rCheck the upstream README for the build command and installed dependencies on your host. Replace eth0 and queue 0 with the actual ingress interface and queue. A socket bound to one NIC queue cannot see packets delivered to another queue. Use the NIC's steering settings or one socket per relevant queue before judging packet coverage.
Adapt the XDP filter
The downloadable BPF source checks Ethernet, IPv4, UDP, source IP 203.23.178.228, destination UDP port 9000, and UDP payload length through 1,228 bytes before redirecting to xsks_map at the receive queue index. Edit DEST_PORT for your verified port. Your userspace loader must attach this program and populate xsks_map with the matching AF_XDP socket; simply compiling the filter does not attach it. Nonmatching traffic passes through the ordinary kernel path, including fragmented IPv4 packets that need reassembly.
On a Hetzner Frankfurt Linux server, inspect the actual ingress interface and RX queue with ip and ethtool before substituting values in the command. Do not assume the interface is named eth0. A C++ receiver can use the same AF_XDP C interface, but the linked example and the filter are written in C.
Zero-copy conditions
AF_XDP can avoid the ordinary socket receive path, but true zero-copy mode depends on NIC driver support and the AF_XDP bind mode. Do not label a deployment zero copy until it reports the selected mode and measurements. The 1,228-byte service payload normally fits unfragmented IPv4 at an effective MTU of at least 1,256 bytes; tunnels can lower the inner MTU. See MTU configuration.
Production boundary
The upstream RX benchmark drops packets after receipt. To parse shreds, replace its RX action with a bounded, source-filtered consumer that retains the payload length and validates with a pinned Agave implementation. Watch XDP redirect errors, fill-ring starvation, RX-ring occupancy, NIC drops, and parser rejects. Use the production checklist before promoting it to a trading path.