Calculate network jitter as the variation in packet delay across a sample.
Jitter is the variation in packet delay over time, not the delay itself. The simplest measure is the average absolute difference between consecutive latency samples. RTP-based systems (VoIP, video) commonly use the RFC 3550 exponentially-smoothed estimator, J = J + (|D| − J)/16, where D is the difference between consecutive transit times, which reacts gradually to give a stable running estimate that's less sensitive to single outliers.
Simple average jitter
jitter = average(|latency[i] − latency[i-1]|) for consecutive samples
RFC 3550 smoothed jitter
J = J + (|D| − J) / 16
Latency is how long a single packet takes to arrive. Jitter is how much that delay varies from packet to packet. A link can have high latency but low jitter (consistently slow) or low latency but high jitter (usually fast, occasionally spikes).
Real-time audio/video is played out at a fixed rate. If packet delay varies too much, the playout buffer either runs dry (causing gaps/glitches) or overflows, so high jitter causes choppy audio and video even without any packet loss.
Under about 30ms of jitter is generally considered good for VoIP; above that, call quality noticeably degrades unless the jitter buffer is enlarged, which in turn adds more latency.
The RFC 3550 estimator weights recent samples more heavily and updates continuously, so it responds to real trends in network conditions without being thrown off by a single one-off delay spike the way a simple average of all samples can be.