camzabriskie.com

Primers › Networking

The OSI model

01 / 10 updated Oct 5, 2026
On this page
  1. Why layers
  2. The seven layers
    1. Addresses at layers 2, 3, and 4
  3. The model the internet actually uses
    1. TLS isn’t the transport layer, despite its name
  4. One request, from start to finish
    1. Before the first byte of the page
    2. Down the stack: encapsulation
    3. Across the internet: hop by hop
    4. Back up the stack at the server
    5. ARP: from an IP address to a MAC address
    6. DHCP: how a device gets its settings
  5. Where the things in the other primers sit
  6. Using the layers to troubleshoot
  7. References

Networking people describe almost everything by layer. A Network Load Balancer is “layer 4,” an Application Load Balancer is “layer 7,” a router is “layer 3,” and a problem gets narrowed down by asking which layer it’s at. Those numbers come from the OSI model (Open Systems Interconnection), a reference model that splits the job of getting data from one program to another into seven layers [1]. Every other primer in this topic uses its vocabulary, so it’s the place to start.

Why layers

Getting a web page from a server to your browser involves a lot of separate problems: turning bits into electrical or radio signals, getting data to the next device on the same network, finding a path across many networks, getting it to the right program on the far end without losing anything, and finally what the data actually means. Layering gives each problem to one layer:

So your browser doesn’t care whether you’re on Wi-Fi or a cable, and the cable doesn’t care whether it’s carrying a web page or a video call. You can swap out one layer (move from Wi-Fi to Ethernet, or from HTTP/1.1 to HTTP/2) without touching the others.

The seven layers

Layers are numbered from the bottom up, starting with the physical signal. Each one has its own kind of address and its own name for a chunk of data:

#LayerIts jobExamplesAddressed byA chunk is called
7ApplicationWhat the data means to the programHTTP, DNS, SSH, SMTPURLs, hostnamesa message
6PresentationHow data is represented: encoding, compression, encryptionCharacter encodings, formats like JSON
5SessionSetting up and keeping track of an ongoing conversationMostly folded into apps today
4TransportGetting data to the right program on a machine, reliably or notTCP, UDP (and QUIC, on top of UDP)Portsa segment (TCP) or datagram (UDP)
3NetworkGetting data across many networks, hop by hopIP, ICMPIP addressesa packet
2Data linkGetting data to the next device on the same local networkEthernet, Wi-FiMAC addressesa frame
1PhysicalTurning bits into signalsCopper cable, fiber, radiobits

If you need a way to remember the order from layer 1 up, the classic mnemonic is “Please Do Not Throw Sausage Pizza Away” (Physical, Data link, Network, Transport, Session, Presentation, Application).

Addresses at layers 2, 3, and 4

Three of those layers have their own kind of address, and each one narrows things down further:

The model the internet actually uses

The OSI model is a way of describing networking, not how the internet’s protocols were actually designed. The internet’s own model, usually called the TCP/IP model, has four layers [4]:

TCP/IP layerRoughly OSI layersExamples
Application5, 6, 7HTTP, DNS, TLS, SSH
Transport4TCP, UDP
Internet3IP, ICMP
Link1, 2Ethernet, Wi-Fi

Layers 5 and 6 never really became separate pieces in practice. Applications and libraries do that work themselves. So in day-to-day use, the numbers people actually say are 1, 2, 3, 4, and 7, and the OSI numbering survives mostly as shared vocabulary. When a product says it works “at layer 7,” it means it understands the application protocol, and “layer 4” means it only sees connections and ports.

TLS isn’t the transport layer, despite its name

Real protocols don’t always fit the model neatly (the internet’s own standards call strict layering “an imperfect model” [4]), and TLS is the usual example. It sits on top of TCP and underneath HTTP, encrypting everything above it, so it gets described as layer 6, layer 4.5, or “part of the application,” depending on who you ask. The model is a map, and maps simplify.

Its name makes it more confusing. TLS stands for Transport Layer Security, which makes it sound like it belongs at layer 4 or replaced something there. It didn’t. TLS replaced SSL, an older encryption protocol (TLS 1.0 was built from SSL 3.0 [5]), which is why people still say “SSL certificate” for what’s now a TLS certificate. It never replaced TCP. TLS runs on top of TCP, and the transport layer is still TCP and UDP.

QUIC blurs the line more. It’s a newer transport protocol that runs on top of UDP and has TLS 1.3 built into it [6], [7], and HTTP/3 uses it instead of TCP [8]. So the two stacks for a web request look like this:

ApplicationEncryptionTransportNetwork
HTTP/1.1 and HTTP/2HTTPTLSTCPIP
HTTP/3HTTP/3TLS 1.3, inside QUICQUIC over UDPIP

One request, from start to finish

Here’s a laptop on a home network loading https://www.example.com, which lives on a server at 203.0.113.10.

Before the first byte of the page

Loading a page takes more than one request. Here’s everything that happens, in order, the first time:

  1. Join the network. When the laptop connects, DHCP gives it an address (192.168.1.20), the home router’s address as its default gateway (192.168.1.1), and a DNS server to use.
  2. Find the router. To send anything off the local network, the laptop needs the router’s MAC address, so it asks with ARP. The answer gets cached and reused for everything after.
  3. Look up the name. The laptop asks DNS for www.example.com and gets 203.0.113.10 (How DNS resolution works covers that lookup step by step).
  4. Open a connection. TCP sets up a connection with the server in a three-way handshake: the laptop sends a SYN (“let’s talk”), the server answers SYN-ACK (“okay”), and the laptop sends an ACK (“okay, starting”) [9].
  5. Agree on encryption. TLS does its own handshake over that connection. The server shows its certificate, the laptop checks it, and they agree on keys [10].
  6. Send the request. Now the browser can finally send GET /, which is what the next section follows down the stack.

Steps 1 and 2 happen once and get reused. Steps 3 through 5 happen for each new server, which is part of why the first visit to a site feels slower than the second.

Down the stack: encapsulation

On the way down, each layer wraps the data from the layer above in its own envelope, with its own addresses on the outside. That’s called encapsulation:

  1. Layer 7: the browser writes an HTTP request: GET / for host www.example.com [11].
  2. TLS encrypts it, so nothing below it can read the request.
  3. Layer 4: TCP puts the encrypted data in a segment from the laptop’s ephemeral port (say 51544) to port 443 on the server. TCP numbers what it sends and resends anything that doesn’t get acknowledged [9].
  4. Layer 3: IP puts the segment in a packet from 192.168.1.20 to 203.0.113.10 [12].
  5. Layer 2: Wi-Fi puts the packet in a frame addressed to the home router’s MAC address, not the server’s, because layer 2 only ever reaches the next device on the local network.
  6. Layer 1: the frame goes out as radio signals.

Read the result from the outside in, and each layer’s header only holds what that layer needs:

Each layer wraps the one above it. A router only opens the outer two boxes, a load balancer at layer 4 opens three, and only the server (or something terminating TLS) can see the request itself.

Across the internet: hop by hop

A hop is one trip between two devices on the same local network, like the laptop to the home router, or one router to the next. At each router, only the bottom layers get unwrapped: the router strips off the layer 2 frame, reads the layer 3 destination address, looks it up in its route table to pick the next hop, and wraps the packet in a fresh layer 2 frame addressed to that next device. That’s the same idea as a route table’s target being the next hop: the packet carries its final destination, and each router just picks the next step.

So the layer 2 addresses change on every hop, and the layer 3 addresses stay the same, with one exception: the home router does NAT (network address translation). Private addresses like 192.168.1.20 can’t be used on the internet, so as the packet leaves the home network, the router swaps the private source address (and usually the port) for the home’s one public address and remembers the swap so it can undo it on the reply [13].

HopLayer 2: from → toLayer 3: from → to
Laptop → home routerlaptop’s MAC → home router’s MAC192.168.1.20 → 203.0.113.10
Home router → ISP’s routerhome router’s MAC → ISP router’s MAC198.51.100.7 → 203.0.113.10 (NAT swapped the source)
More routers across the interneteach router’s MAC → the next one’s198.51.100.7 → 203.0.113.10
Last router → serverlast router’s MAC → server’s MAC198.51.100.7 → 203.0.113.10

The reply makes the same trip backwards, from 203.0.113.10 to 198.51.100.7, and the home router swaps the destination back to 192.168.1.20 before handing it to the laptop.

Back up the stack at the server

At the server it goes back up: layer 2 checks the frame was for it, layer 3 checks the packet was for its address, layer 4 hands the data to whatever program is listening on port 443, TLS decrypts it, and the web server reads the HTTP request. The response goes through the same process in reverse.

ARP: from an IP address to a MAC address

A frame needs a MAC address and a packet needs an IP address, and something has to connect the two. That something is ARP, the Address Resolution Protocol [14]. It answers one question on the local network: “which MAC address has this IP address?” It’s a lot like DNS, just lower down: DNS turns a name into an IP address, and ARP turns an IP address into a MAC address.

Here’s step 2 of the timeline above, the first time the laptop needs to send something off the local network:

  1. The laptop decides who’s next. 203.0.113.10 isn’t in the laptop’s own subnet, 192.168.1.0/24 (what a subnet is), so the packet has to go through the default gateway, the home router at 192.168.1.1, which DHCP told it about.
  2. It checks its ARP cache for 192.168.1.1. If it’s there from a recent conversation, it’s done.
  3. If not, it broadcasts an ARP request, sent to the special broadcast address ff:ff:ff:ff:ff:ff so every device on the local network hears it: “Who has 192.168.1.1? Tell 192.168.1.20.”
  4. The router replies directly to the laptop: “192.168.1.1 is at 00:00:5e:00:53:01.”
  5. The laptop caches the answer and addresses its frames to that MAC address.

A few things follow from how that works:

DHCP: how a device gets its settings

A device joining a network needs a few settings before it can do anything: its own IP address, the size of the subnet it’s on, the default gateway’s address, and which DNS servers to use. Typing those in by hand on every phone and laptop would be miserable, so almost every network hands them out automatically with DHCP, the Dynamic Host Configuration Protocol [16]. On a home network the router is usually the DHCP server too.

When the laptop joins, it has no address yet, so the exchange starts with a broadcast [16]:

  1. Discover. The laptop broadcasts “is there a DHCP server out there?”
  2. Offer. The router offers an address (192.168.1.20) along with the other settings.
  3. Request. The laptop asks to use that offer. (This step exists because more than one server might have answered.)
  4. Acknowledge. The router confirms, and the laptop configures itself.

The other settings travel as numbered DHCP options: one for the subnet mask, one for the default gateway (DHCP calls it the “router” option), one for the DNS servers, and so on [17]. That’s also how the laptop knows which recursive resolver to ask.

The address is a lease, not a permanent assignment. The laptop has to renew it before it runs out, and if it leaves the network the address eventually goes back into the pool. That’s why a device’s IP address on a home network can change from one day to the next, and why servers usually get a fixed address or a reservation instead.

Where the things in the other primers sit

ThingLayerWhat it can see
Switch2MAC addresses
Router, route table3IP addresses
NAT gateway, home router doing NAT3–4Addresses and ports, which it rewrites
Security group, NACL3–4Addresses, protocols, ports
Site-to-site VPN (IPsec)3Whole packets, which it encrypts
AWS Gateway Load Balancer3Packets [18]
Network Load Balancer4Connections and ports [19]
Application Load Balancer [20], WAF, CDN7Full HTTP requests: paths, headers, cookies
DNS7An application protocol, carried over UDP or TCP port 53

The higher a device works, the more of the envelope it opens, so the more it can see and the smarter its decisions can be. It also has to understand the protocol, which is why a layer 7 load balancer can route by URL path but only for HTTP, and a layer 4 one can carry anything but can’t look inside.

Using the layers to troubleshoot

When something can’t connect, working through the same order as the timeline keeps you from guessing. Each step has its own check:

LayerQuestionCheck
1–2Is the machine connected to its network, with an address?Is the link up, ip addr or ifconfig
NameDoes the name resolve, to the right address?dig <name> (watching DNS)
3Can packets reach the other address?ping, traceroute, the route tables
4Is anything listening on the port, and does the firewall allow it?nc -vz <host> <port>, security groups, NACLs
TLSDoes the certificate check out?openssl s_client (Certificates and Trust)
7Does the application answer correctly?curl -v, the HTTP status code, the app’s logs

Two catches:

UDP gets less of this help, since it has no connection to set up and no delivery checks [22]. A UDP request that gets no answer looks the same whether it was blocked, lost, or ignored.

References

Show all 22 sourcesHide sources
  1. [1] ↩ ITU-T, “Information technology - Open Systems Interconnection - Basic Reference Model: The basic model,” ITU-T Recommendation X.200, International Telecommunication Union, Jul. 1994. Accessed: Oct. 5, 2026. [Online]. Available: https://www.itu.int/rec/T-REC-X.200-199407-I/en
  2. [2] ↩ D. Eastlake 3rd, J. Abley, and Y. Li, “IANA Considerations and IETF Protocol and Documentation Usage for IEEE 802 Parameters,” RFC 9542, Internet Engineering Task Force, Apr. 2024. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc9542
  3. [3] ↩ Internet Assigned Numbers Authority, “Service Name and Transport Protocol Port Number Registry.” Accessed: Oct. 5, 2026. [Online]. Available: https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
  4. [4] ↩ a b R. Braden, Ed., “Requirements for Internet Hosts - Communication Layers,” RFC 1122, Internet Engineering Task Force, Oct. 1989. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc1122
  5. [5] ↩ T. Dierks and C. Allen, “The TLS Protocol Version 1.0,” RFC 2246, Internet Engineering Task Force, Jan. 1999. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc2246
  6. [6] ↩ J. Iyengar, Ed. and M. Thomson, Ed., “QUIC: A UDP-Based Multiplexed and Secure Transport,” RFC 9000, Internet Engineering Task Force, May 2021. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc9000
  7. [7] ↩ M. Thomson, Ed. and S. Turner, Ed., “Using TLS to Secure QUIC,” RFC 9001, Internet Engineering Task Force, May 2021. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc9001
  8. [8] ↩ M. Bishop, Ed., “HTTP/3,” RFC 9114, Internet Engineering Task Force, Jun. 2022. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc9114
  9. [9] ↩ a b W. Eddy, Ed., “Transmission Control Protocol (TCP),” RFC 9293, Internet Engineering Task Force, Aug. 2022. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc9293
  10. [10] ↩ E. Rescorla, “The Transport Layer Security (TLS) Protocol Version 1.3,” RFC 9846, Internet Engineering Task Force, Jul. 2026. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc9846
  11. [11] ↩ R. Fielding, Ed., M. Nottingham, Ed., and J. Reschke, Ed., “HTTP Semantics,” RFC 9110, Internet Engineering Task Force, Jun. 2022. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc9110
  12. [12] ↩ J. Postel, “Internet Protocol,” RFC 791, Internet Engineering Task Force, Sep. 1981. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc791
  13. [13] ↩ P. Srisuresh and K. Egevang, “Traditional IP Network Address Translator (Traditional NAT),” RFC 3022, Internet Engineering Task Force, Jan. 2001. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc3022
  14. [14] ↩ D. Plummer, “An Ethernet Address Resolution Protocol: Or Converting Network Protocol Addresses to 48.bit Ethernet Address for Transmission on Ethernet Hardware,” RFC 826, Internet Engineering Task Force, Nov. 1982. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc826
  15. [15] ↩ T. Narten, E. Nordmark, W. Simpson, and H. Soliman, “Neighbor Discovery for IP version 6 (IPv6),” RFC 4861, Internet Engineering Task Force, Sep. 2007. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc4861
  16. [16] ↩ a b R. Droms, “Dynamic Host Configuration Protocol,” RFC 2131, Internet Engineering Task Force, Mar. 1997. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc2131
  17. [17] ↩ S. Alexander and R. Droms, “DHCP Options and BOOTP Vendor Extensions,” RFC 2132, Internet Engineering Task Force, Mar. 1997. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc2132
  18. [18] ↩ Amazon Web Services, “What is a Gateway Load Balancer?” Elastic Load Balancing User Guide for Gateway Load Balancers. Accessed: Oct. 5, 2026. [Online]. Available: https://docs.aws.amazon.com/elasticloadbalancing/latest/gateway/introduction.html
  19. [19] ↩ Amazon Web Services, “What is a Network Load Balancer?” Elastic Load Balancing User Guide for Network Load Balancers. Accessed: Oct. 5, 2026. [Online]. Available: https://docs.aws.amazon.com/elasticloadbalancing/latest/network/introduction.html
  20. [20] ↩ Amazon Web Services, “What is an Application Load Balancer?” Elastic Load Balancing User Guide for Application Load Balancers. Accessed: Oct. 5, 2026. [Online]. Available: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html
  21. [21] ↩ J. Postel, “Internet Control Message Protocol,” RFC 792, Internet Engineering Task Force, Sep. 1981. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc792
  22. [22] ↩ J. Postel, “User Datagram Protocol,” RFC 768, Internet Engineering Task Force, Aug. 1980. Accessed: Oct. 5, 2026. [Online]. Available: https://www.rfc-editor.org/rfc/rfc768

Every source cited across the primers is collected on one page.