A jitter buffer schedules against a media clock while absorbing bounded arrival variation
Separate RTP timestamps, arrival variation, clock drift, and playout deadlines while measuring the latency and late-loss costs of buffer policy.
On this page
The question for today
What you’ll understand
- Convert Opus RTP timestamp increments without confusing them with decoder sample counts.
- Calculate one RFC-style interarrival jitter update.
- Explain buffer delay, late arrivals, burst pressure, and clock-mismatch corrections as separate mechanisms.
Network audio arrives in packets, but a speaker must consume a continuous timed waveform. A jitter buffer reorders and schedules media before its deadlines, trading additional delay for tolerance of arrival variation. It cannot eliminate every loss, repair a permanently mismatched clock by waiting forever, or infer the best latency target from one jitter statistic. Track the media time domain, arrival timing, occupancy, and late-loss policy separately so a larger queue does not merely hide one failure while making conversation slower.
Transport sequence, media timestamp, and decoded samples differ
RTP sequence numbers help identify packet ordering and losses, while RTP timestamps represent media sampling time in the payload's declared clock. A packet can contain several codec frames, and gaps or reordered arrivals require explicit handling. RFC 7587 specifies a forty-eight-kilohertz RTP clock for Opus even when the audio representation or decoder output uses another supported rate. Thus a twenty-millisecond media interval advances the timestamp by 960 ticks, not necessarily by the count of samples returned by a sixteen-kilohertz decoder. Handle timestamp wrap and stream restarts under a defined unwrapping policy.
Map the source media timeline into the receiver's playout clock using an origin and rate estimate. A fixed schedule needs a starting cushion, while an adaptive schedule can adjust timing through an explicit policy. Source and sink clock mismatch gradually changes occupancy even on a network with constant delay. Reordering can fix packet order but cannot itself correct that rate mismatch. Long sessions need clock-aware adaptation, such as a suitable time-scale or resampling strategy, with quality and latency measurements rather than arbitrary repeated sample drops.
Interarrival jitter is not a complete buffer-delay prescription
RFC 3550 defines an interarrival-jitter estimator based on changes in relative transit time, with arrival and media differences expressed in compatible units. It smooths variation; it does not measure an absolute one-way delay or directly prescribe a playout target. A burst, a heavy delay tail, and a gradual clock offset can need different responses even when a recent average statistic looks similar. Evaluate deadline misses and occupancy distributions under realistic traces rather than selecting a buffer solely as a fixed multiple of one smoothed number.
Packets arriving after their useful playout deadline may be discarded, concealed, or handled by another codec-specific policy; waiting for every missing packet can make delay grow without bound. Loss concealment can maintain continuity without reconstructing the exact missing speech. A larger target cushion often reduces late loss while increasing conversational latency, and an overflow policy can create another loss mode during bursts. Measure startup delay, steady-state delay, late discard, concealment, and underflow separately so an average packet-loss statistic cannot hide avoidable interaction stalls.
Test bursts and clocks in addition to average packet rates
Replay controlled traces with reordered packets, isolated losses, long bursts, timestamp wrap, clock drift, and a route change. Preserve the original source timestamps when measuring outcomes. Compare actual audible delay and deadline loss, including startup and adaptation periods, and test the consequences for endpoint detection and interruption. Buffer targets that work for prerecorded playback can feel poor in conversation. A correct packet counter alone cannot reveal duplicated decoded frames, discontinuities after concealment, or a buffer that slowly accumulates latency over a long call.
The queue lab isolates a constant-rate mismatch rather than network jitter. Reset, explicitly set BOTH λ=3 and μ=3, predict q(2)=4 from the initial backlog four, then Play or Step four times. Reset and re-set BOTH λ=3.5 and μ=3; predict q(2)=5. Edits retain t and recompute the original fluid trajectory. This model has no packet timestamps, bursts, finite capacity, deadlines, or concealment. A constant mismatch can grow occupancy even with smooth arrivals; actual jitter-buffer behavior needs the richer trace tests just described.
Work it through
Use the correct timestamp unit and interpret a jitter update
An Opus stream carries twenty-millisecond media intervals and is decoded at sixteen kilohertz. In a separate RFC-style update, previous jitter is 192 RTP ticks and the new absolute transit-difference magnitude is 960 ticks. Assume a fixed sixty-millisecond lateness cushion for one illustrative deadline comparison.
The RTP increment is 48000×0.020=960 ticks, while the sixteen-kilohertz decoded interval has 16000×0.020=320 samples. The two counts describe different clocks.
Jitter becomes 192+(960−192)/16=240 ticks, or 240/48000=0.005 seconds. Five milliseconds of smoothed variation is not automatically the correct playout delay.
If a packet is seventy milliseconds late relative to the baseline media-arrival schedule while only sixty milliseconds of cushion was assigned, it misses that illustrative deadline by ten milliseconds. The policy must handle the miss rather than infer that the five-millisecond jitter estimate guaranteed safety.
Clock units, smoothed variation, and actual deadlines are separate quantities in a timed playout system.
The living notebook
Explore the model
Interactive lab · queue
Rate mismatch can grow occupancy without packet bursts
For EACH run Reset, set BOTH λ and μ, predict, then Play or Step four times to t=2. Initial q=4 stays 4 at (3,3) and becomes 5 at (3.5,3). Edits retain t/recompute the original constant-rate trajectory. This fluid model has no RTP clock, bursts, bounded jitter buffer, deadlines, or concealment.
- Fluid backlog
- 4
- Net rate · λ − μ
- −1 /s
- M/M/1 mean residence
- 1 s
Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forA jitter buffer needs clock and deadline policies in addition to enough average service capacity.
Pause & reason
Check your understanding
Your turn
Try it yourself
An RFC-style jitter estimate is 480 ticks at a forty-eight-kilohertz clock. A new absolute transit-difference magnitude is zero. Calculate the updated jitter in ticks and milliseconds. Does a zero difference prove there is no absolute network delay?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
Apply the one-sixteenth smoothing step; variation and absolute delay differ.
Compare with the solution
Updated jitter is 480+(0−480)/16=450 ticks, or 450/48000×1000=9.375 milliseconds. A zero relative-transit change can occur with a constant large network delay, so it does not establish zero absolute latency.
Keep the idea
Take it with you
- RTP media clocks, packet sequence numbers, and decoded sample rates have different roles.
- Smoothed interarrival variation does not prescribe a complete playout delay or guarantee deadlines.
- Burst tests, clock adaptation, and late-loss policy determine the latency-quality tradeoff.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.