Documentation
¶
Overview ¶
Command timestamps shows when packets actually arrived, using the time the device recorded for each one rather than the time this program got round to looking.
That difference is the whole point. Reading a clock in the receive loop measures the receive loop: if the loop is busy for a millisecond, every packet it then collects looks like it arrived at once. A timestamp taken by the NIC (or, on AF_PACKET, by the kernel as it fills the ring) was taken before any of this code ran, so the gaps between them are what happened on the wire.
sudo go run ./examples/timestamps -i eth0
It uses the AF_PACKET backend, so it needs no particular hardware. On a ConnectX the mlx5 backend reports the card's own 4 ns clock instead; the loop below does not change, only the Open call.