Reorder Out-of-Order UDP Packets in a Live Audio Jitter Buffer
Last updated: November 29, 2026
Quick Overview
Packets of a Douyin live voice chat arrive over UDP with sequence numbers, possibly late, duplicated or lost; implement a jitter buffer that releases payloads in order, drops duplicates and late arrivals, and skips a missing packet after a bounded wait.
ByteDance
November 29, 20260
0
0 solved
Packets of a Douyin live voice chat arrive over UDP with sequence numbers, possibly late, duplicated or lost; implement a jitter buffer that releases payloads in order, drops duplicates and late arrivals, and skips a missing packet after a bounded wait.
Real-time audio in Douyin live rooms and co-host battles runs over UDP-based transport, and networking fundamentals questions at ByteDance often ask why and how to cope with UDP's lack of ordering. The interviewer checks your grasp of TCP versus UDP trade-offs and a correct reordering structure.
What the Interviewer Expects
- Explain why live audio prefers UDP: head-of-line blocking and retransmit delay in TCP
- Buffer packets by sequence number and release contiguous runs
- Drop duplicates and packets older than the playout point
- Skip a gap after a time budget rather than stalling forever
- Mention sequence wraparound and adaptive buffer depth
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you handle 16-bit sequence number wraparound?
- Choose the wait budget adaptively from measured jitter.
- Where do FEC and NACK-based retransmission fit, and when is each worth it?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
push(seq, payload) adds a packet and returns any payloads now playable in order. tick() is called each playout interval; if the next expected packet is still missing after max_wait ticks, skip ahead t...
High-Level Design
Keep next_seq, the sequence the player needs next, and a dict of buffered packets. Whenever next_seq is present, pop it and advance, releasing contiguous runs. TCP would retransmit and block everythin...