Reorder RTP Packets in a Jitter Buffer With Wraparound

Last updated: November 29, 2026

Quick Overview

Implement a jitter buffer that accepts media packets tagged with 16-bit sequence numbers that can arrive late, duplicated or out of order, releases them strictly in sequence order, and skips a gap once more than K packets are waiting behind it.

Zoom
Coding & Algorithms
Software Engineer
Zoom
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Implement a jitter buffer that accepts media packets tagged with 16-bit sequence numbers that can arrive late, duplicated or out of order, releases them strictly in sequence order, and skips a gap once more than K packets are waiting behind it.

A media-team style coding question: Zoom clients receive audio and video over UDP where reordering and loss are normal. The interviewer is checking modular sequence arithmetic, a clear policy for giving up on a lost packet, and that the code would not stall playback forever.

What the Interviewer Expects
  • Compare sequence numbers modulo 2^16 using half-range logic
  • Drop duplicates and packets older than the playout point
  • Release a contiguous run as soon as the missing packet arrives
  • Bound memory with a capacity and count declared losses
  • Explain the latency versus loss trade-off of K
Key Topics to Cover
RTP sequence numbers
Modular arithmetic
Buffering
Real-time media
Hash map
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you switch from a packet-count bound to a time bound using RTP timestamps?
  • How would the buffer interact with NACK retransmission or FEC recovery?
  • How would you adapt K dynamically from measured jitter?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

push(seq, payload) returns the list of payloads that are now playable, in order. Sequence numbers are 16-bit and wrap from 65535 to 0. A packet behind the playout point (already played or already sk...

High-Level Design

Keep expected, the next sequence to play, and a dict of pending packets. The distance of a packet ahead of expected is (seq - expected) mod 65536; if that distance is at least 32768 the packet i...


Submit Your Answer
Markdown supported

Related Questions