TRT
Sign in

Network Layers in a Request

Visualize the four network layers (application, transport, network, link, physical) and how each adds a header as a request travels to a server.

The Runtime Theory Team05 stages

trace / request.md

APPLICATION LAYERTRANSPORTLAYER (TCP/UDP)NETWORKLAYER (IP)LINK LAYER(ETHERNET/WIFI)PHYSICAL LAYER(CABLE/FIBER/RADIO)

readyThe browser creates an HTTP request with method, path, headers, and body.

Network Layers in a Request

This diagram shows how each layer of the network stack adds its own header to data as it travels from a client to a server.

The Five Layers

LayerProtocolAdds
ApplicationHTTP, HTTPSMethod, path, headers
TransportTCP, UDPPort numbers, sequence numbers
NetworkIPSource/destination IP addresses
LinkEthernet, WiFiSource/destination MAC addresses
PhysicalCable, fiber, radioRaw bits on the medium

Encapsulation

The data grows at each layer as headers are added:

plaintext
[ HTTP headers + body ]
  [ TCP header + HTTP data ]
    [ IP header + TCP data ]
      [ Ethernet header + IP data ]
        [ bits on wire ]

Trace a packet through these layers · Read: IP Addresses and Routing

Stage-by-stage execution walkthrough

This request flow decomposes Network Layers in a Request into 5 sequential stages so you can trace where latency accumulates, which state transitions are irreversible, and where production failure modes occur.

Stage 1: Application Layer

The browser creates an HTTP request with method, path, headers, and body. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 2: Transport Layer (TCP/UDP)

TCP wraps the data in a segment with source and destination port numbers and a sequence number. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 3: Network Layer (IP)

IP wraps the segment in a packet with source and destination IP addresses. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Ethernet wraps the packet in a frame with source and destination MAC addresses. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Stage 5: Physical Layer (Cable/Fiber/Radio)

Bits are transmitted as electrical signals, light pulses, or radio waves over the medium. During this transition, the runtime enforces strict state invariants before handing control to the next stage: inputs are validated at the boundary, state mutations are ordered deterministically, and latency/resource costs are bounded so downstream consumers never observe a torn or partially initialized state.

Production invariants and failure modes

Each layer encapsulates the data from the layer above by prepending its own header (and sometimes trailer). On the receiving side, each layer strips its header and passes the payload up. This encapsulation lets each layer evolve independently — IP can run over Ethernet, WiFi, fiber, or any other link-layer technology. When debugging or capacity-planning this flow in production, instrument each stage boundary separately (measuring both p50 median and p99.9 tail latency), verify what happens when an intermediate stage times out or drops packets, and ensure retry or fallback paths preserve end-to-end idempotency.

Not started

Sign in to save your learning progress.

Sign in to save