Computer Networking › Section B · The application layer › Topic B.7

Video streaming and content distribution networks

Streaming services deliver films smoothly to millions of screens over a network that promises nothing about throughput. They manage it with ordinary HTTP, a buffer in the player, many versions of every video, and servers placed as close to viewers as possible.

Streaming stored video over HTTP

On-demand video, such as films and recorded lectures, is stored on servers and sent as the viewer watches. Today almost all of it travels over HTTP: on HTTP/1.1 or HTTP/2 over TCP, or HTTP/3 over QUIC. HTTP passes through firewalls and NAT boxes that block unusual protocols, and ordinary web servers, caches and content distribution networks can serve it. The player simply requests the video piece by piece with GET requests. Older dedicated streaming protocols, such as RTMP, now survive mainly for uploading live video into platforms.

The playout buffer

Throughput across the internet rises and falls, so a player never shows video the moment it arrives. It downloads ahead into a playout buffer and plays from that buffer at a steady rate. Playback starts after a short startup delay, once enough video is stored. If throughput briefly drops below the video's bit rate, playback carries on from the buffer, which shrinks. If the buffer empties, the picture freezes while it refills: a stall, or rebuffering event, the problem viewers dislike most. A bigger buffer rides out longer dips but cannot help if throughput stays too low.

Adaptive streaming: DASH and HLS

A single bit rate is either too high for slow connections or too low for fast ones. Adaptive bit rate streaming solves this. Each video is encoded at several quality levels, a bit-rate ladder, perhaps from under 1 Mbit/s for a small phone image to 15 Mbit/s or more for 4K, and each version is cut into chunks of a few seconds. A manifest file lists every version and chunk with its URL. The client fetches the manifest, then chooses a version for each chunk, so quality can change mid-film. The two main standards are MPEG-DASH, Dynamic Adaptive Streaming over HTTP, and Apple's HTTP Live Streaming (HLS).

How the player chooses a rate

The intelligence sits in the client, not the server. Throughput-based players estimate the available rate from how long recent chunks took to download and pick the highest version safely below the estimate, often leaving a margin. Buffer-based players, such as those using the BOLA algorithm, choose from how full the buffer is: a nearly full buffer allows a higher rate, a draining one forces a lower rate. Many real players combine both signals. Good adaptation balances three goals that pull against each other: high average quality, few or no stalls, and few abrupt quality switches.

Worked example: choosing from a ladder

A service's ladder offers 0.8, 1.8, 3, 4.5 and 8 Mbit/s. The player uses 80% of its throughput estimate as a safety margin. 1. Estimate 10 Mbit/s: the limit is \(0.8 \times 10 = 8\) Mbit/s, so it picks the 8 Mbit/s version. 2. The estimate falls to 5 Mbit/s: the limit is 4 Mbit/s, so 4.5 is too high and it picks 3 Mbit/s. 3. The estimate falls to 2.5 Mbit/s: the limit is 2 Mbit/s, so it picks 1.8 Mbit/s. Check: each choice is the largest rung not above the limit. The margin matters because estimates are noisy, and overshooting drains the buffer.

Worked example: a draining buffer

A player holds 24 s of video and is playing the 8 Mbit/s version in 4 s chunks when throughput falls to 4 Mbit/s. 1. One chunk is \(8 \times 4 = 32\) Mbit, which now takes \(32 \div 4 = 8\) s to download. 2. During those 8 s, 4 s of new video arrives while 8 s is played, so the buffer shrinks by 4 s per chunk. 3. It would empty after \(24 \div 4 = 6\) chunks, about 48 s. 4. Switching to 3 Mbit/s makes a chunk 12 Mbit, downloaded in 3 s, so the buffer grows by 1 s per chunk. Check: any version below the 4 Mbit/s throughput refills the buffer, and any above it drains it.

Content distribution networks

Serving every stream from one data centre would use long, congested paths. A content distribution network (CDN) keeps copies of content on many servers spread across the world. Some CDNs enter deep, placing small server clusters inside many access ISPs, close to viewers. Others bring home, building fewer but larger clusters at internet exchange points, which are easier to manage. Commercial CDNs such as Akamai and Cloudflare serve many customers, while large platforms such as Netflix and Google run private CDNs of their own. A cluster that lacks a requested video fetches it from a central copy and keeps it.

Steering each request to a server

A CDN often intercepts the request with DNS. 1. The player is given a URL whose host name belongs to the CDN, perhaps through a CNAME. 2. The viewer's resolver queries the CDN's authoritative DNS servers. 3. Those servers pick a suitable cluster and return the address of a server in it. 4. The player then sends its HTTP requests straight to that server. Choosing the cluster is the hard part: the geographically closest one is not always fastest, so CDNs also use measurements of delay and load. Some CDNs instead announce the same IP address from every site using anycast, so routing carries each request to a nearby site.

Case studies: Netflix and YouTube

Netflix runs its own CDN, Open Connect. It offers ISPs dedicated caching servers to install inside their networks or at exchange points, and fills them during quiet night-time hours with the titles it expects people to watch, an approach called push caching. Viewers' players then fetch chunks from those nearby servers, while account, search and recommendation services run in the cloud. YouTube relies on Google's private CDN, with caches in many ISPs, and largely pulls videos into caches when they are first requested. Both encode every video into many versions and codecs and use adaptive streaming.

Measuring the viewer's experience

Services judge streaming by quality of experience (QoE) rather than raw throughput: startup delay, how often and how long playback stalls, average bit rate, and how often quality switches. Viewers are more likely to abandon a video as startup delay grows, and stalls do more harm than slightly lower resolution, so players usually favour safety over peak quality. Live streaming adds one more measure, how far viewers lag behind the real event. Ordinary chunks can put viewers tens of seconds behind; low-latency versions of HLS and DASH deliver partial chunks to cut that to a few seconds.

Common mistakes to avoid

First, thinking the server decides the bit rate; in DASH and HLS the client chooses each chunk. Second, assuming a bigger buffer cures a link that is permanently too slow; only a lower bit rate does. Third, comparing chunk size in megabits with throughput in megabytes per second without converting. Fourth, picking a version exactly equal to the throughput estimate with no margin. Fifth, assuming the nearest CDN server is always the best one. Sixth, believing streaming needs a special protocol; it runs over plain HTTP.

Key takeaways

Stored video is streamed over HTTP, on TCP or QUIC, so it crosses firewalls and uses web caches and CDNs. A playout buffer absorbs throughput dips; an empty buffer means a stall. Adaptive streaming, with MPEG-DASH or HLS, encodes a ladder of versions in short chunks listed in a manifest, and the client picks each chunk's rate from throughput estimates and buffer levels. A version above the throughput drains the buffer; one below refills it. CDNs place copies near viewers, entering deep in ISPs or bringing home to exchange points, and steer requests by DNS or anycast. QoE counts startup delay, stalls, bit rate and switches.

Flashcards

Flashcard

Streaming over HTTP

Video fetched chunk by chunk with GET requests

Passes firewalls, uses CDNs.

Test your understanding

Question 1 of 5

A player plays a 6 Mbit/s version in 2 s chunks while throughput is 4 Mbit/s. By how much does the buffer change with each chunk?

Question 2 of 5

In DASH or HLS, who decides which quality version of the next chunk is fetched?

Question 3 of 5

A ladder offers 1, 2.5, 4 and 6 Mbit/s. The player picks the highest rung no more than 80% of its 5 Mbit/s throughput estimate. Which does it choose?

Question 4 of 5

How does a DNS-based CDN direct a viewer to a nearby server?

Question 5 of 5

A viewer's connection stays at 2 Mbit/s for an hour while the video is encoded only at 5 Mbit/s. What would prevent stalls?

← Previous topicNext topic →