The OSI Model Explained
A clear explanation of the OSI model's seven layers, what each layer actually does, and how real-world protocols like HTTP, TCP, and Ethernet map onto them.
Introduction
The OSI (Open Systems Interconnection) model breaks network communication into seven distinct layers, each responsible for a specific part of getting data from one machine to another. It is not a protocol you install or a piece of software you run — it is a conceptual framework, and one of the most useful vocabulary tools you will ever learn for talking precisely about networking. This guide walks through each layer, bottom to top, with real protocols mapped to each one.
Why a Layered Model at All?
Splitting networking into layers means each layer only needs to solve one problem and trust the layers below it to handle theirs. The physical layer does not need to know anything about HTTP, and HTTP does not need to know anything about how electrical signals travel across a cable. This separation is what lets you swap Wi-Fi for Ethernet without changing a single line of application code — the layers above simply do not need to know or care.
Layer 1: Physical
The Physical layer deals with the actual transmission of raw bits over a physical medium — electrical signals over copper cable, light pulses over fiber optics, or radio waves for Wi-Fi. It defines things like voltage levels, cable types, and connector shapes. There is no concept of "data" here yet, only raw signal.
Layer 2: Data Link
The Data Link layer organizes raw bits into frames and handles communication between devices on the same local network segment, using physical (MAC) addresses. Ethernet and Wi-Fi (802.11) both operate at this layer, along with switches, which use MAC addresses to decide which physical port to forward a frame out of.
Frame: [ Destination MAC | Source MAC | Payload | Error Check ]
Layer 3: Network
The Network layer is responsible for routing data between different networks, using logical addressing — IP addresses — rather than physical MAC addresses. Routers operate here, examining a packet's destination IP address to decide which path it should take toward its destination, potentially across many intermediate networks.
Packet: [ Source IP | Destination IP | Payload ]
Layer 4: Transport
The Transport layer manages end-to-end communication between the actual sending and receiving applications, handling things like reliability, ordering, and flow control. The two protocols you have almost certainly heard of live here:
- TCP (Transmission Control Protocol) — reliable, ordered, connection-based. Guarantees delivery and correct ordering, retransmitting lost data automatically. Used for HTTP, email, file transfer — anywhere correctness matters more than raw speed.
- UDP (User Datagram Protocol) — fast, connectionless, no delivery guarantees. Used for video streaming, online gaming, and DNS — anywhere low latency matters more than guaranteed delivery of every single packet.
TCP: establishes a connection (handshake), guarantees ordered delivery, retransmits lost data
UDP: sends packets immediately, no handshake, no guarantee of delivery or order
Layer 5: Session
The Session layer manages and maintains connections between two machines — opening, coordinating, and closing a "session" of communication. In practice, this layer's responsibilities are often absorbed into the Transport layer or application-level session management (like a login session tracked with a cookie), which is part of why it is one of the least distinctly implemented layers in real-world networking.
Layer 6: Presentation
The Presentation layer is responsible for translating data between the format an application uses and the format suitable for network transmission — encryption, compression, and character encoding conversions conceptually live here. TLS/SSL encryption is often associated with this layer, though in practice it is frequently discussed alongside the Transport or Application layers instead.
Layer 7: Application
The Application layer is the one developers interact with directly — it defines the protocols that applications actually use to communicate: HTTP for web traffic, SMTP for email, DNS for name resolution, FTP for file transfer. When you make a fetch() call or an HTTP request in any language, you are working entirely at this layer, with everything below it handled transparently by the operating system and network hardware.
Mapping Real Protocols to the Model
Layer 7 (Application): HTTP, HTTPS, DNS, SMTP, FTP
Layer 6 (Presentation): TLS/SSL encryption, data encoding
Layer 5 (Session): Session management (often merged into Layer 4/7 in practice)
Layer 4 (Transport): TCP, UDP
Layer 3 (Network): IP, routers
Layer 2 (Data Link): Ethernet, Wi-Fi (802.11), switches
Layer 1 (Physical): Cables, radio signals, physical connectors
Tracing a Web Request Through the Layers
When your browser loads a webpage, data conceptually travels down through every layer on your machine, across the network, and back up through every layer on the server:
Your browser: builds an HTTP request (Layer 7)
-> TLS encrypts it (Layer 6)
-> TCP breaks it into segments,
establishes a connection (Layer 4)
-> IP addresses and routes the packets (Layer 3)
-> Ethernet/Wi-Fi frames the packets
for the physical network (Layer 2)
-> Signals travel over the wire/air (Layer 1)
Server: reverses this process, layer by layer, back up to Layer 7
Why This Model Is Still Useful
Even though real systems mostly follow the simpler four-layer TCP/IP model rather than a strict seven-layer implementation, OSI terminology remains the common language for network troubleshooting: "it's a Layer 2 issue" (something wrong with the local network hardware/switching) versus "it's a Layer 7 issue" (something wrong with the application protocol itself) immediately communicates where to start looking.
Best Practices
- Use OSI layer terminology to communicate precisely about where a networking problem or feature lives, especially in cross-team discussions.
- Remember that real-world implementations blend layers 5 and 6 into layers 4 and 7 far more than the strict seven-layer model suggests.
- When debugging connectivity issues, work from the bottom up: confirm the physical connection, then addressing, then transport, then the application protocol itself.
- Map any new networking technology you learn about back onto this model — it almost always clarifies what problem that technology is actually solving.
Common Mistakes to Avoid
- Assuming every real networking stack implements all seven layers distinctly — most practical stacks compress session and presentation concerns into adjacent layers.
- Confusing MAC addresses (Layer 2, local network) with IP addresses (Layer 3, routable across networks) when troubleshooting connectivity.
- Assuming TLS is "just" one specific layer — in practice, its role spans concepts from both the Transport and Presentation layers depending on how you look at it.
- Treating the OSI model as a strict implementation guide rather than the conceptual/vocabulary tool it is intended to be.
OSI Versus the Real-World TCP/IP Model
A common point of confusion is that the protocols the internet actually runs on were not designed around the OSI model at all — they follow the older, simpler four-layer TCP/IP model (Link, Internet, Transport, Application), which predates OSI's seven-layer model. The two are usually taught side by side, with rough correspondences drawn between them:
OSI (7 layers) TCP/IP (4 layers)
Application ---\
Presentation ---+---> Application
Session ---/
Transport -------> Transport
Network -------> Internet
Data Link ---\
Physical ---+---> Link
OSI's Application, Presentation, and Session layers all collapse into a single "Application" layer in the practical TCP/IP model, because in real protocol design, concerns like data formatting and session management are typically handled within the application protocol itself (HTTP headers, TLS session resumption) rather than as cleanly separated protocol layers. This is exactly why the OSI model is best understood as a conceptual teaching tool rather than a literal description of how the internet is built: it gives precise vocabulary for discussing networking concerns in isolation, even though no widely deployed protocol stack implements all seven layers as distinctly separate. When someone says "that's a layer 7 problem" in a real conversation, they are using OSI's vocabulary to describe an application-level concern, even though the actual software stack handling it follows the simpler four-layer TCP/IP model underneath.
Conclusion
The OSI model's real value is not as a blueprint for building networking software — it is a shared vocabulary that lets you describe exactly where, in the long chain from raw electrical signals to a rendered webpage, a particular protocol or problem lives. Once you can map HTTP, TCP, IP, and Ethernet onto their respective layers, a huge amount of networking discussion becomes far easier to follow.
Article FAQ
References
Comments
Comments are coming soon. Meanwhile, share your feedback via our contact page.
Related Articles
View allHTTP and HTTPS Deep Dive
A deep dive into how HTTP and HTTPS work, covering request/response structure, methods, status codes, headers, and how TLS secures HTTP traffic today.
Memory Management Basics in Operating Systems
Learn the fundamentals of operating system memory management, including virtual memory, paging, the stack versus the heap, and how memory leaks occur.
Load Balancing Basics for System Design
Learn the fundamentals of load balancing in system design, including load balancing algorithms, health checks, layer 4 vs layer 7 balancing, and common failu...
Closures in JavaScript: A Complete Guide
A complete guide to JavaScript closures explaining lexical scope, the scope chain, and how closures power data privacy, memoization, and function factories.