870 likes | 880 Views
Learn how to receive and play audio packets using socket communication, manage playout buffer, handle issues like packet ordering and loss, and handle delay jitter. Explore different algorithms for adapting the playout delay and choose the most suitable one based on your requirements.
E N D
Encoder Decoder Middlebox Receiver Sender Network You are Here
How to recv and play? open socket while not done if socket is readable read packet from socket remove RTP header decode play back
What’s Wrong? • packet ordering • packet loss • next packet arrive in-time? Especially bad for audio applications
Audio Compression • Normally uncompressed • Telephone quality: • 8-bit audio • 8Khz • 20-30ms per packet
Common Technique • Silence Detection • No need to send if there is no sound at the input • Talkspurt • Sequence of consecutive audio packets (in between silence)
Detecting Talkspurt in RTP • Marker bit • Not reliable as packet with marker bit could be lost • Deduce from timestamp and sequence number
What causes Jitter? • Network delay = Propagation Delay (fixed) + Queueing Delay (variable) • Delay jitter is caused by variable queueing delay
Delay Jitter Transit Time small jitter large jitter Time
Spike Transit Time Time
If Zero Jitter Time
With Jitter Time LOSS
With Jitter + Buffer Buffer Size Time Playout Delay
Adapting Playout Delay • When jitter is low, reduce delay • When jitter is high, increase delay
Fundamental Trade-off Latency vs Packet Loss
Playout Delay • Once you set the playout delay, cannot change! • NOT true: can change at beginning of talkspurt
Adapting Playout Delay SEND RECV PLAY
Variables and Notations Tnet(i) Tbuffer(i) Tarrive(i) Tplay(i) Tdelay(i) Tsend(i)
First Packet in the Talkspurt Tdelay(i) = Enet(i) + 4 Vnet(i) Tplay(i) = Tsend(i) + Tdelay(i) Tbuffer(i) Tnet(i) Tarrive(i) Tplay(i) Tdelay(i) Tsend(i)
Subsequent Packets Tplay(j) = Tplay(i) + Tsend(j) – Tsend(i) Tbuffer(i) Tnet(i) Tarrive(i) Tplay(i) Tdelay(i) Tsend(i)
Algorithm 1 (Jacobson’s) Enet(i) = aEnet(i-1) + (1-a)Tnet(i)
Algorithm 2 if Tnet(i) > Enet(i) Enet(i) = bEnet(i-1) + (1-b)Tnet(i) else Enet(i) = aEnet(i-1) + (1-a)Tnet(i)
Algorithm 3 Enet(i) = min { Tnet(j) } (over all packets in previous talkspurt)
Algorithm 4 (Ramjee’s) • Ramjee’s Proposal • Observation: Algorithm 1-3 take too long to react to spike.
Ramjee’s Idea Works in 2 modes SPIKE NORMAL
Three Questions • When to switch from normal to spike mode? • When to switch from spike back to normal? • How to estimate during spike mode?
Normal to Spike • if difference in delays is large
Normal to Spike • if difference in delays is large • difference in delays: Tnet(i) – Tnet(i-1) • large: 800 + 2Vnet(i)
Another View of Spike (ZOOM) Tnet(i) Tarrive(i)
Spike to Normal • slope = slope/2 + |2Tnet(i) – Tnet(i-1) – Tnet(i-2)|/8 • if slope < 64 switch to normal
Estimation in Spike Mode Enet(i) = Enet(i-1) + Tnet(i) – Tnet(i-1)
First Packet in the Talkspurt Tdelay(i) = Enet(i) + 4 Vnet(i) Tplay(i) = Tsend(i) + Tdelay(i)
Tprop(i) Tq(i) Tbuffer(i) Tarrive(i) Tplay(i) Tnet(i) Tdelay(i) Tsend(i) First Packet in the Talkspurt Tdelay(i) = Enet(i) + 4 Vnet(i) Tplay(i) = Tsend(i) + Tdelay(i)
Variation of Delay • Vnet(i) = aVnet(i-1) + (1-a)|Enet(i) – Tnet(i)|
Playout Delay vs Loss Rate Loss Rate Tdelay(i)
Problems of Existing Algorithms • Jacobson’s react too slowly • Ramjee’s follow the delay too closely
Moon’s Idea • Collect statistics on packets that have arrived • Find t such that q% of last w packets has Tnet(i) < t • Tdelay(i) = t
Example (w =50, q = 90%) num of packets 1 2 3 4 5 6 7 8 9 10 11 12 delay
Spike Mode • Tdelay(i) = Enet(1) SPIKE NORMAL