net.ListenConfig, SO_REUSEPORT
Receive raw Solana shreds in Go with SO_REUSEPORT
A downloadable Go UDP receiver using net.ListenConfig, Linux SO_REUSEPORT, a large receive buffer, source filtering, and one-second counters.
Download the source
What this implementation does
The Go program sets Linux SO_REUSEPORT in net.ListenConfig.Control before bind, then asks for an 8 MiB socket receive buffer. It reads each UDP datagram into a 2,048-byte slice, checks the documented 1,228-byte maximum, accepts only source IP 203.23.178.228, prints the verification challenge, and reports stream packet and byte counts once per second. It samples the 83-byte common header and prints variant, slot, index, version, and FEC-set index as little-endian fields.
Run on Linux
bash
go run main.go 9000Use the verified destination port. A second process can bind the same port because SO_REUSEPORT is enabled. Run one process first, then compare per-process counters if you add another. A single stable UDP flow can land entirely on one process; SO_REUSEPORT alone is not a sharding plan.
Parsing Solana shreds in Go
The sampled common header is useful for commissioning, but it does not validate the shred signature or Merkle proof. Read the packet format and header parsing guides before extending the parser. Treat those fields as untrusted until a release-matched Agave parser sanitizes the shred and verifies its leader signature. Do not infer completeness from arrival order: UDP can reorder and drop datagrams without resend.
Production boundary
Measure UdpRcvbufErrors and per-socket drops on the Linux host. Keep the receive loop short, avoid per-packet logging, and move decoding into a bounded queue. The socket setup and production checklist describe the remaining work.