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
| Layer | Protocol | Adds |
|---|---|---|
| Application | HTTP, HTTPS | Method, path, headers |
| Transport | TCP, UDP | Port numbers, sequence numbers |
| Network | IP | Source/destination IP addresses |
| Link | Ethernet, WiFi | Source/destination MAC addresses |
| Physical | Cable, fiber, radio | Raw bits on the medium |
Encapsulation
The data grows at each layer as headers are added:
[ 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.
Stage 4: Link Layer (Ethernet/WiFi)
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.