A Packet's Journey
Each layer page shows one layer on its own. This page follows a single HTTPS request from your browser down all seven layers, across the internet, and back up the stack on a web server. Watch each header get added on the way down, changed by routers in the middle, and removed on the way up.
The setup
You are on a desktop PC (192.168.1.20) plugged into your home router by an Ethernet cable. You click a link to https://osiexplain.com/index.html. The server lives at 203.0.113.10.
A few things have already happened before our story starts. DNS turned the name into an IP address. TCP's three-way handshake opened a connection. The TLS handshake agreed the encryption keys. We pick up the very next thing the browser sends: the request for the page.
Tip: use the โ and โ arrow keys to step through.
-
The browser writes an HTTP request
Your PC ยท Layer 7, Application
Everything starts as plain text. The browser builds an HTTP request asking the server for one file. The
Hostheader matters because one server often hosts many websites, and this is how it knows which one you want.GET /index.html HTTP/1.1 Host: osiexplain.com User-Agent: Mozilla/5.0 (X11; Linux x86_64) โฆ Accept: text/html Accept-Encoding: gzip, br Connection: keep-aliveAt this point there are no addresses or port numbers of any kind. The application layer just hands a block of data down and trusts the layers below to deliver it.
-
TLS encrypts the request
Your PC ยท Layer 6, Presentation
Because the link was
https://, the request is handed to TLS. Using the keys agreed during the handshake, TLS encrypts the request with AES-GCM and adds an authentication tag, so any tampering on the way will be detected. The result is wrapped in a small TLS record header.Content type 23(application data)Version 0x0303. TLS 1.3 still writes the TLS 1.2 number here so that old middleboxes keep working.Length Size of the encrypted payload, including the tag From here on, nothing between you and the server can read the HTTP request. Your ISP and every router on the path see only encrypted bytes.
-
The session layer addsโฆ nothing
Your PC ยท Layer 5, Session
This is the honest answer that textbooks often skip. The internet runs on TCP/IP, and TCP/IP has no separate session header. The OSI model's Layer 5 jobs are still being done, but by other parts of the stack:
- The TLS session ties this request to the keys from the earlier handshake, and can be resumed later without a full new handshake.
- HTTP keep-alive reuses the same TCP connection for the page's images and scripts.
So the data passes straight through. See OSI vs TCP/IP for why layers 5โ7 collapse into one in practice.
-
TCP turns it into a segment
Your PC ยท Layer 4, Transport
TCP adds its header, and the unit of data is now called a segment. Ports identify which program on each machine the data belongs to. Sequence numbers let the server put bytes back in order and spot anything missing.
Source port 51514, a random ephemeral port picked by your PCDestination port 443, HTTPSSequence number Position of the first byte of this segment in the stream Acknowledgement Next byte your PC expects from the server Flags PSH, ACKWindow How much more data your PC can buffer (flow control) -
IP turns it into a packet
Your PC ยท Layer 3, Network
The IP header carries the two addresses that stay the same for the whole trip, end to end (NAT is the exception, as step 8 shows). The unit is now a packet.
Source IP 192.168.1.20(your PC)Destination IP 203.0.113.10(the web server)TTL 64. Every router subtracts one, so a looping packet eventually dies.Protocol 6, meaning "the payload is TCP"Flags Don't Fragment set. Path MTU discovery handles packet size instead. Your PC now makes the key routing decision. Is
203.0.113.10on my own subnet (192.168.1.0/24)? No. So the packet must go to the default gateway, the home router at192.168.1.1. -
Ethernet turns it into a frame
Your PC ยท Layer 2, Data Link
A frame only travels across one link. So the destination MAC is not the web server's. It is the router's, the next hop. Your PC looked that MAC up with ARP, or found it already in its ARP cache.
Destination MAC 00:1a:2b:3c:4d:5e(home router's LAN port)Source MAC a4:5e:60:12:34:56(your PC's network card)EtherType 0x0800, meaning "the payload is IPv4"FCS (trailer) A 4-byte CRC-32 checksum over the whole frame, added at the end This is the only layer that adds a trailer as well as a header. The packet is now sandwiched between them.
-
The network card sends bits
Your PC ยท Layer 1, Physical
The network card puts a preamble in front of the frame: 7 bytes of
10101010, then a start frame delimiter,10101011. The alternating pattern lets the receiver lock on to the clock. Then every bit of the frame goes out as electrical signals. On gigabit Ethernet (1000BASE-T) that means PAM-5 voltage levels across all four twisted pairs at once.Layer 1 has no idea what any of these bits mean. It just moves them.
Encapsulation is complete: Data โ Segment โ Packet โ Frame โ Bits. On Wi-Fi the steps are the same, but Layer 2 uses an 802.11 frame and Layer 1 is radio.
-
Your home router: unwrap, decide, rewrap
Home router ยท Layers 1โ3
The router receives the bits (L1). It checks the FCS and sees the frame is addressed to its own MAC (L2), then throws the frame away to get at the packet. At Layer 3 it:
- Looks up
203.0.113.10in its routing table. The only match is the default route, out of the WAN port towards your ISP. - Decrements the TTL from 64 to 63, then recalculates the IP header checksum.
- Applies NAT. The private source
192.168.1.20:51514becomes the router's public address, for example198.51.100.7:40112. The router remembers this mapping so the reply can find its way back, and fixes up the TCP checksum, which also covers the IP addresses.
Then it builds a brand-new frame for the next link. The source MAC is now the router's WAN port, the destination MAC is the ISP's router, and the FCS is new.
A router never looks above Layer 3. It cannot see the TLS record or the HTTP request, and does not need to.
- Looks up
-
Across the internet, hop by hop
ISP and backbone routers ยท Layers 1โ3
The same thing repeats at every router on the path, typically 10โ20 of them. Each one strips the incoming frame, decrements the TTL, looks up the destination IP, and wraps the packet in a new frame for the next link. Some of those links are not Ethernet at all. A long-haul fibre run may use a different Layer 2 and Layer 1 entirely, and the packet does not care.
Field Changes at every hop? Source / destination MAC Yes. A new frame is built for every link. TTL Yes. Down by one each time; after 12 routers it reaches the server at 52. Source / destination IP No. Only NAT, at the edge, changed them. TCP ports and everything inside No. This is exactly what traceroute exploits. It sends packets with TTL 1, 2, 3โฆ and records which router sends back the "time exceeded" error each time.
-
The server's network card accepts the frame
Web server ยท Layers 1โ2
Now everything runs in reverse. This is de-encapsulation. The server's network card turns the signal back into bits (L1). Then at L2 it:
- Recalculates the CRC-32 and compares it with the FCS. If they differ, the frame was damaged on the last link and is silently dropped. TCP will notice the gap and resend.
- Checks that the destination MAC is its own. It is, because the last router addressed the frame to it.
- Reads the EtherType
0x0800, strips the header and trailer, and hands the packet to IPv4.
-
IP confirms the packet is for this server
Web server ยท Layer 3, Network
The destination IP
203.0.113.10matches one of the server's own addresses, and the header checksum is valid. The packet arrives with TTL 52. The Protocol field says6, so the IP header comes off and the segment goes to TCP.Notice the source IP the server sees:
198.51.100.7, your router's public address, not your PC's private one. That is NAT at work. The server replies to that address. -
TCP delivers the bytes to the right program
Web server ยท Layer 4, Transport
Destination port
443belongs to the web server process (nginx, say). TCP finds the existing connection from the source IP and port, checks that the sequence number is the next one it expected, and places the bytes in the receive buffer in order.TCP then sends an ACK back, so your PC knows it does not need to resend. That ACK is a whole tiny packet that makes the journey in the opposite direction.
-
TLS decrypts and verifies
Web server ยท Layers 5โ6, Session and Presentation
The connection belongs to an established TLS session, so the server already holds the matching keys. It decrypts the record and checks the authentication tag. If even one bit had been altered anywhere on the path, the check would fail and the connection would be torn down rather than trusted.
What comes out is the exact HTTP text your browser wrote in step 1.
-
The web server reads the request and replies
Web server ยท Layer 7, Application
The web server parses
GET /index.html, uses theHostheader to pick the right site, and builds a response:HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 Content-Encoding: br Content-Length: 6120 <!DOCTYPE html> โฆThat response now makes the same journey in reverse. It is encrypted, segmented, packeted and framed on the server, rebuilt hop by hop across the internet, un-NATed by your home router back to
192.168.1.20:51514, and unwrapped layer by layer on your PC. All of that usually takes tens of milliseconds.
The whole journey in one table
| Layer | Adds on the way down | PDU name | Who reads it |
|---|---|---|---|
| 7 Application | The HTTP request itself | Data | Browser and web server only |
| 6 Presentation | Encryption + TLS record header | Data | Browser and web server only |
| 5 Session | Nothing separate in TCP/IP | Data | โ |
| 4 Transport | TCP header: ports, sequence, ACK | Segment | The two end hosts (and firewalls) |
| 3 Network | IP header: IP addresses, TTL | Packet | Every router on the path |
| 2 Data Link | Ethernet header + FCS trailer | Frame | Only the two ends of each link |
| 1 Physical | Preamble, then signals | Bits | Network cards, cables, switches' ports |
To remember: MAC addresses describe the next hop and change at every router. IP addresses describe the whole journey and stay the same, except where NAT rewrites them at the edge.
Check your understanding — encapsulation
Five questions on how data moves through the whole stack.
-
Your PC sends a packet to a web server on the internet. What destination MAC address goes in the Ethernet frame it sends?
A frame only crosses one link. The server is on a different network, so your PC addresses the frame to the next hop, its default gateway, and the router builds a new frame for the next link.
-
Which header is completely replaced at every router hop?
Routers strip the incoming frame and build a new one for the outgoing link. They edit the IP header (TTL and checksum) but keep it. They do not touch anything above Layer 3, except when doing NAT.
-
What is the correct order of PDUs on the sending side, from the application down?
Layer 4 makes segments, Layer 3 packets, Layer 2 frames and Layer 1 bits. Option C is the receiving side, de-encapsulation, which runs in the opposite direction.
-
Which IP header field does every router decrement before forwarding?
TTL goes down by one per hop. At zero the packet is discarded and an ICMP "time exceeded" message goes back to the sender, which is how traceroute maps the path.
-
The routers along the path forward your HTTPS request but cannot read it. Why?
Encryption happened high in the stack on your PC. Everything below, and every device in the middle, only ever handles ciphertext. The routers also have no reason to look: they forward on the IP header alone.