Computer Networks

Unit 7: Presentation Layer (Layer 6)

Encoding, encryption, and compression — from JSON and Protobuf to TLS, JPEG, and Netflix's encoding ladder.

What is the presentation layer?

The Presentation Layer is the translator of the OSI model. It makes sure that data sent by the application on one system can be understood by the application on the other system, regardless of differences in encoding, formats, or character sets.

It also handles encryption / decryption and compression / decompression.

Unit of data: data

Responsibilities

  • Translation — converting between different data representations (e.g. ASCII ↔ EBCDIC, little-endian ↔ big-endian).
  • Encoding — defining how complex data structures are serialised (JSON, XML, Protobuf, Avro).
  • Encryption / decryption — securing data in transit using TLS/SSL.
  • Compression / decompression — reducing the size of data (gzip, Brotli) so it transmits faster.

Common formats and standards

CategoryExamples
TextASCII, UTF-8, UTF-16
ImagesJPEG, PNG, WebP, AVIF
AudioMP3, AAC, Opus
VideoH.264, H.265 (HEVC), VP9, AV1
DataJSON, XML, Protobuf, Avro, MessagePack
EncryptionSSL, TLS 1.2, TLS 1.3
Compressiongzip, deflate, Brotli, Zstandard

Example — sending JSON over HTTPS

When you call an API like GET https://api.github.com/users/torvalds:

  1. The server takes a database row and encodes it as a JSON string.
  2. It optionally compresses the response with gzip or Brotli.
  3. It encrypts the response with TLS before pushing it through the socket.
  4. On your machine, the browser decrypts the bytes, decompresses them, and decodes the JSON into a JavaScript object.

All four operations — encoding, compression, encryption, decryption — belong conceptually to the Presentation Layer.

Real-world scenarios

Google’s Protocol Buffers and gRPC

Internally, Google sends trillions of messages per day between services using Protocol Buffers (Protobuf) instead of JSON. Protobuf is a binary encoding that is ~3–10× smaller than JSON and much faster to parse — a huge Presentation-Layer win at Google’s scale. gRPC (built on Protobuf + HTTP/2) is now used by Netflix, Square, Spotify, and many others.

TLS 1.3 everywhere

Every visit to a https:// site involves TLS doing presentation-layer work: negotiating encryption ciphers, exchanging keys, and then encrypting/decrypting every byte. Let’s Encrypt has issued free TLS certificates for over a billion domains, making HTTPS the default across the web.

Netflix’s encoding ladder

Netflix re-encodes every show into dozens of versions at different resolutions and bitrates (240p → 4K HDR) using codecs like H.264, VP9, and AV1. Their adaptive bitrate (ABR) system picks the right version on the fly based on your connection — a massive presentation-layer pipeline that has been credited with saving Netflix billions in bandwidth costs.

Spotify’s audio codecs

Spotify streams music using Ogg Vorbis and increasingly AAC, choosing the bit rate based on whether you’re on free or premium, and adapting on the fly to mobile data conditions. The user just hears music; the codec work is invisible Presentation-Layer magic.

WhatsApp end-to-end encryption

WhatsApp uses the Signal protocol for end-to-end encryption. Even though messages travel through WhatsApp’s servers, only the sender and receiver can decrypt them — a strong presentation-layer guarantee that even Meta cannot read your messages.

Compression at Cloudflare

Cloudflare automatically applies Brotli compression to text-based responses (HTML, CSS, JS, JSON) for websites behind their CDN. This typically reduces transfer sizes by 15–25% over gzip — saving bandwidth for billions of requests every day.

Common presentation-layer problems

  • Character-encoding mismatch (UTF-8 vs Latin-1) showing ”?” or ”□” characters.
  • Expired or invalid TLS certificate.
  • Wrong gzip negotiation causing garbled responses.
  • Incompatible Protobuf schema versions between services.
  • Video codec not supported by the user’s device (e.g. AV1 on older browsers).