Canonical: https://nitride.xyz/learn/packet-loss-and-jitter

# Packet loss and jitter

Where UDP packet loss happens (network path, NIC ring, kernel backlog, socket buffer, application), what jitter is, and the Linux counters that show each one.

UDP packet loss is any datagram that a sender transmits but the receiving program never reads. It can happen on the network path, in the network card, in the kernel or inside the application. Jitter is the variation in delay between packets of one stream, so they arrive unevenly spaced even when they were sent evenly.

## Why does UDP lose packets?
UDP was designed to carry a message with as little protocol as possible. RFC 768, its specification, says plainly that UDP does not promise delivery or protect against duplicates, and it points applications that need reliable ordered delivery to TCP.

So UDP has no acknowledgements, no retransmission and no flow control. A sender learns nothing when a datagram is dropped, and it does not slow down when the receiver falls behind. Every queue along the way, in a router, a switch, a network card or a socket, has a fixed size. When a queue is full, the next packet is discarded.

That design is also why UDP suits real-time data. Nothing waits for a lost packet to be resent, so a late packet never holds up the ones behind it. The cost is that the application has to detect gaps itself and decide what to do about them.

## Where does UDP packet loss happen?
Follow a datagram from the sender to your program and there are four places it can disappear.

**The network path.** Routers and switches queue packets when traffic arrives faster than an outgoing link can send it. A burst that fills the queue loses its tail. Rate limiters and policers drop traffic that exceeds a configured rate, and a damaged frame fails its checksum and is discarded. None of this is visible on your server. You only see the gap.

**The network card.** The card writes incoming frames into a ring of receive descriptors in memory, and the driver empties the ring. If the host does not keep up, the card has nowhere to put new frames. The kernel documentation counts these in `rx_missed_errors`, which it describes as packets dropped by the device for lack of buffer space, usually because the host is not keeping up with the receive rate. Some drivers report overflow in `rx_fifo_errors` or `rx_over_errors` instead.

**The kernel backlog.** After the driver hands a packet to the kernel, it may wait in a per-CPU input queue. The `netdev_max_backlog` sysctl caps that queue, which the kernel docs define as the number of packets queued on the input side when the interface receives faster than the kernel can process. Drops here appear in the second column of `/proc/net/softnet_stat`, one row per CPU.

**The socket buffer.** Each UDP socket has a receive buffer. When it is full, the kernel discards the datagram and, according to the UDP source code, increments both `RcvbufErrors` and `InErrors`. The buffer size comes from `SO_RCVBUF`, limited by `net.core.rmem_max`. The socket(7) man page notes that the kernel doubles the requested value to leave room for bookkeeping. Our guide to [Linux sockets and buffers](https://nitride.xyz/docs/receiver/linux-sockets) shows how to set it.

**The application.** A program that reads slowly, pauses for garbage collection or does heavy work on its receive thread lets the socket buffer fill, which turns into socket drops. A program that drops packets from its own internal queue leaves no trace in any kernel counter, so it needs its own count.

## How do I check for UDP drops on Linux?
Read each layer's counter twice, a minute apart, and compare. A counter that grows while your stream is running points to the layer that is losing packets.

```sh file="terminal"
# socket layer: system-wide UDP counters
nstat -az UdpInDatagrams UdpRcvbufErrors UdpInErrors

# one socket: rb is the buffer size, d is datagrams dropped on this socket
ss -u -a -m 'sport = :9000'

# kernel backlog: second column per CPU, in hex
cat /proc/net/softnet_stat

# network card: dropped and missed totals, then driver counters
ip -s link show dev eth0
ethtool -S eth0 | grep -i -E 'drop|miss|fifo|over'
```

Driver counter names in `ethtool -S` differ between vendors, so check your driver's documentation for the exact meaning. Loss on the network path shows up nowhere on the host. Only a gap in the data itself reveals it.

## What is jitter?
Jitter is the everyday name for packet delay variation. RFC 5481 prefers the longer term because "jitter" also has meanings outside networking, and it describes two common ways to measure it:

- **Inter-packet delay variation** compares each packet's delay with the packet before it.
- **Packet delay variation** compares every packet's delay with one reference, usually the packet with the lowest delay in the sample.

RFC 3550, the RTP specification, defines a running estimate many tools still use. For each pair of packets it takes the difference between their spacing at the receiver and their spacing at the sender, then smooths the absolute value: the new estimate equals the old one plus one sixteenth of the difference between that value and the old estimate.

Jitter comes from the same queues that cause loss. A packet that waits behind a burst in a router queue arrives late; the next one, finding the queue empty, does not. Interrupt handling, CPU scheduling and power saving on the receiving host add their own variation after the packet has arrived.

Measuring delay variation properly needs a timestamp from the sender. Without one you can still record arrival times and look at the gaps, but you cannot tell variation in sending from variation on the path. For delay itself, rather than its variation, see [where Solana latency comes from](https://nitride.xyz/learn/solana-latency).

## What do loss and jitter mean for a shred stream?
Solana shreds travel in UDP datagrams, so everything above applies to them. A lost data shred leaves a gap in a slot's index sequence. Coding shreds in the same set can often rebuild it, and a validator can ask its peers for what is still missing through the [repair protocol](https://nitride.xyz/learn/repair-protocol). A receiver that only reads a feed has neither option unless it implements recovery itself.

Jitter matters most when shreds arrive in bursts. Packets that bunch up on the path reach the receiver faster than it drains them, and the surplus waits in the socket buffer. A buffer sized for the average rate can overflow at the peaks.

Path loss and variation depend on the route between two machines. Some operators move latency-sensitive traffic onto dedicated links for that reason; the [DoubleZero page](https://nitride.xyz/learn/doublezero) describes one network used for Solana traffic.

## Questions

### What is an acceptable UDP packet loss rate?

It depends on the application. A stream with its own recovery, such as erasure coding, tolerates some loss; a stream without it loses data with every dropped packet. Measure the rate at each layer before deciding.

### Does a bigger receive buffer stop packet loss?

It stops loss at the socket only, and only for bursts the application can drain afterwards. It does nothing for drops on the network path or in the network card.

### Can I see packet loss on the network path from my server?

Not from kernel counters. Path loss shows up only as gaps in the data, so you need sequence numbers or another way to detect missing packets.
