hn.today

What's inside one voice packet

mainlog.dev5 points0 comments
Screenshot of What's inside one voice packet

A real-time voice call is presented as a stream of small, time-sensitive packets, rather than as one continuous audio file. A typical packet carries 20 milliseconds of sound, sent 50 times per second. At 48 kHz, that slice contains 960 audio samples: 1,920 bytes as raw PCM, compressed by Opus to 80 bytes at a constant 32 kb/s. IPv4, UDP and RTP add another 40 bytes, making a 120-byte packet. The walkthrough decodes a sample packet layer by layer: IP identifies the destination machine, UDP selects the receiving program, and RTP identifies the audio stream, codec, packet order and sampling time. RTP’s timestamp advances by 960 for each 20 ms slice.

The central argument is that audio packets have deadlines, so reliable delivery is not always useful. A receiver buffers packets briefly to smooth out jitter, then plays each at a fixed time; a packet arriving after its playout deadline is effectively lost, even if it reached the machine. UDP does not resend missing data or enforce ordering, allowing later audio to continue. RTP sequence numbers reveal gaps, and the decoder can fill them with an approximation. TCP, which carries WebSockets, instead guarantees ordered delivery: if one packet is lost, later bytes wait behind it until retransmission succeeds. This head-of-line blocking can make several audio packets late, turning one network loss into a longer interruption. A deterministic example models 20 ms frames, a 30 ms one-way trip and a 40 ms jitter buffer to illustrate the timing.

Read on mainlog.dev0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Web

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.