OSI Model: 7 Layers

The OSI (Open Systems Interconnection) model is a conceptual framework with seven layers: Physical, Data Link, Network, Transport, Session, Presentation, and Application. It helps understand how data moves through a network and how different protocols interact.

OSI Model

The OSI model is the conceptual framework that describes how data travels across a network from one device to another. It divides the complex process of network communication into seven distinct layers, each with a specific responsibility. Understanding the OSI model gives you a mental map for reasoning about networking protocols, diagnosing connectivity problems, and understanding where different technologies fit in the broader picture of how networks work.

What Is the OSI Model

The OSI model, which stands for Open Systems Interconnection model, is a conceptual framework developed by the International Organization for Standardization (ISO) in 1984 to standardise how different computer systems communicate over a network. It defines seven layers of abstraction, each responsible for a specific aspect of network communication, from the physical transmission of electrical signals up through the application-level interactions that users experience directly.

The model was created to solve a real problem that existed in the early days of networking: different vendors built networking equipment and software that could only communicate with other products from the same vendor. The OSI model provided a vendor-neutral reference framework that defined clear boundaries between different functions, allowing hardware and software from different manufacturers to interoperate as long as each component conformed to the specifications for its layer.

It is important to understand that the OSI model is a reference model, not a strict implementation specification. The real-world internet runs on the TCP/IP protocol suite, which maps roughly but not precisely to the OSI layers. The OSI model remains invaluable as a teaching and troubleshooting framework because it gives network engineers and developers a common vocabulary and a structured way to reason about where in the communication stack a problem might be occurring. When a network engineer says a problem is at layer 3, everyone immediately understands they are talking about IP routing rather than physical cabling or application logic.

The Seven Layers of the OSI Model

Each of the seven layers in the OSI model has a specific, well-defined responsibility. Data passes down through the layers on the sending side, with each layer adding its own header or processing, and then passes up through the layers on the receiving side, with each layer stripping and processing the information added by its counterpart on the sender. This process is called encapsulation on the way down and decapsulation on the way up.

Layer Name Responsibility Example Protocols and Technologies
7ApplicationProvides network services directly to end-user applications and handles high-level protocols for data exchangeHTTP, HTTPS, FTP, SMTP, DNS, SSH
6PresentationTranslates data between the application layer and the network, handling encoding, encryption, and compressionTLS/SSL, JPEG, MPEG, ASCII, Unicode
5SessionEstablishes, manages, and terminates sessions between applications on different devicesNetBIOS, RPC, SQL sessions, NFS
4TransportProvides end-to-end communication between applications, handling segmentation, flow control, and error correctionTCP, UDP, SCTP
3NetworkHandles logical addressing and routing of packets across multiple networks from source to destinationIP, ICMP, OSPF, BGP, routers
2Data LinkProvides reliable node-to-node data transfer within a single network segment and handles MAC addressing and error detectionEthernet, Wi-Fi (802.11), ARP, switches, bridges
1PhysicalTransmits raw bits over a physical medium, defining electrical, optical, and radio signal specificationsEthernet cables, fibre optic, radio waves, hubs, repeaters

A common mnemonic for remembering the layers from top to bottom is "All People Seem To Need Data Processing" and from bottom to top "Please Do Not Throw Sausage Pizza Away." The layers are numbered from 1 at the bottom to 7 at the top, and when engineers refer to a layer by number, layer 1 always means the physical layer and layer 7 always means the application layer.

Layer 1: Physical Layer

The physical layer is the foundation of the OSI model and is responsible for the actual transmission of raw bits over a physical medium. It defines the electrical, optical, mechanical, and procedural characteristics of the hardware interface between devices. At this layer, data exists only as ones and zeros encoded as voltage levels, light pulses, or radio waves.

The physical layer specifies everything about how signals are transmitted: the type of cable or wireless medium used, the connector types, the voltage levels that represent a one or zero, the data rate in bits per second, and whether communication is simplex, half-duplex, or full-duplex. Ethernet cables, fibre optic cables, coaxial cables, and the radio spectrum used for Wi-Fi are all physical layer concerns. Hubs and repeaters operate at the physical layer, simply amplifying and retransmitting signals without any understanding of the data they carry.

Physical layer problems are among the most common sources of network connectivity failures. A damaged cable, a loose connector, a failing network interface card, interference on a wireless channel, or a mismatched duplex setting are all physical layer issues. When troubleshooting a network problem, verifying that the physical layer is functioning correctly is always the first step.

Layer 2: Data Link Layer

The data link layer is responsible for reliable data transfer between two directly connected nodes on the same network segment. It takes the raw bit stream from the physical layer and organises it into frames, which are structured units of data with a defined beginning and end. It also handles error detection to identify frames that were corrupted in transit and manages access to the shared physical medium so that multiple devices can communicate without their signals colliding.

The data link layer uses MAC addresses, which are hardware addresses burned into every network interface, to identify devices within a local network segment. Unlike IP addresses which are logical and can be changed, MAC addresses are tied to the physical hardware. When a frame needs to be delivered to a device on the same local network, the data link layer uses the destination MAC address to identify which device should receive it.

The data link layer is divided into two sublayers in the IEEE model. The Media Access Control sublayer handles how devices share access to the physical medium, including collision detection and avoidance in Ethernet and Wi-Fi networks. The Logical Link Control sublayer handles flow control and error checking between adjacent nodes. Network switches operate at the data link layer, reading MAC addresses in frame headers to forward frames only to the correct port rather than broadcasting them to every device on the network.

Layer 3: Network Layer

The network layer is responsible for logical addressing and routing, enabling packets to travel from a source device to a destination device across multiple interconnected networks. While the data link layer handles communication within a single network segment, the network layer handles communication across the boundaries between different networks, which is what makes the internet possible.

IP, the Internet Protocol, is the primary protocol operating at the network layer. Every device on the internet has an IP address, and the network layer uses these addresses to determine the path a packet should take from its source to its destination. Routers operate at the network layer, examining the destination IP address of each incoming packet and forwarding it toward the destination based on their routing tables.

The network layer also handles packet fragmentation when a packet is too large to traverse a network segment with a smaller maximum transmission unit, and reassembly of fragmented packets at the destination. ICMP, the protocol used by ping and traceroute, operates at the network layer to provide diagnostic and error reporting functions for IP networks.

Layer 4: Transport Layer

The transport layer provides end-to-end communication services between applications running on different hosts. While the network layer gets a packet from one machine to another, the transport layer ensures the data is delivered to the correct application on that machine and, depending on the protocol, provides reliability guarantees like ordered delivery and retransmission of lost segments.

TCP, the Transmission Control Protocol, and UDP, the User Datagram Protocol, are the two primary transport layer protocols. TCP provides reliable, ordered, and error-checked delivery through a connection-oriented handshake, acknowledgements, and retransmission. UDP provides a simpler, faster connectionless service that does not guarantee delivery or ordering, leaving those concerns to the application if needed. Port numbers live at the transport layer, identifying which application on a host should receive incoming data.

The transport layer is also responsible for segmentation, breaking large messages from the application layer into smaller segments suitable for transmission, and reassembly, reconstructing those segments into the original message at the destination. Flow control mechanisms at the transport layer ensure the sender does not overwhelm a receiver that cannot keep up with incoming data, and congestion control mechanisms prevent the sender from overwhelming the network itself.

Layer 5: Session Layer

The session layer is responsible for establishing, managing, and terminating communication sessions between applications on different devices. A session is a logical connection that persists for the duration of an exchange, providing mechanisms to open and close dialogues between applications in an orderly way, synchronise data exchange with checkpoints, and resume interrupted sessions without starting from the beginning.

In practice, the session layer is one of the least distinct layers in real-world implementations. Many modern protocols handle session management within the application layer rather than relying on a separate session layer. However, protocols like NetBIOS, Remote Procedure Call (RPC), and the session establishment aspects of SQL database connections conceptually correspond to session layer functionality. The TLS handshake that establishes an encrypted connection before HTTPS data flows also has session layer characteristics, though TLS is typically mapped to the presentation layer.

Layer 6: Presentation Layer

The presentation layer is responsible for translating data between the format used by the application layer and the format suitable for network transmission. It handles three main concerns: data translation between different character encodings and data formats, encryption and decryption for secure transmission, and compression and decompression to reduce the volume of data that needs to be transmitted.

Concrete examples of presentation layer concerns include character encoding standards like ASCII and Unicode that define how text characters are represented as bytes, image and video compression formats like JPEG and MPEG that reduce file sizes for efficient transmission, and TLS encryption that protects data in transit from interception. When a browser and server negotiate an HTTPS connection, the TLS negotiation that establishes the encryption algorithms and keys is a presentation layer function, even though in the TCP/IP model it is typically considered part of the application or transport layer.

Layer 7: Application Layer

The application layer is the topmost layer of the OSI model and the one closest to the end user. It provides the interface between the network and the applications that use it, defining the protocols and data formats that applications use to communicate over the network. This layer does not refer to the applications themselves, such as a web browser or an email client, but rather to the network protocols those applications use.

HTTP and HTTPS define how web browsers and servers exchange web content. SMTP and IMAP define how email clients and servers send and retrieve messages. DNS defines how domain names are resolved to IP addresses. SSH defines how encrypted remote terminal sessions are established. FTP defines how files are transferred between systems. All of these are application layer protocols because they define the high-level rules for a specific type of networked application interaction, sitting on top of the transport, network, and lower layers that handle the actual delivery of data.

Data Encapsulation and Decapsulation

When an application sends data across a network, that data passes down through all seven layers on the sending device, with each layer wrapping it in its own header containing the information that layer needs to do its job. This process is called encapsulation. At the physical layer, the data exits as a stream of bits on the physical medium.

Encapsulation as data travels down the OSI layers:
Layer 7 - Application:   [ HTTP Data                              ]
Layer 6 - Presentation:  [ TLS Header  | HTTP Data                ]
Layer 5 - Session:       [ Session Header | TLS | HTTP Data       ]
Layer 4 - Transport:     [ TCP Header | Session | TLS | HTTP Data ]
Layer 3 - Network:       [ IP Header  | TCP | Session | TLS | HTTP]
Layer 2 - Data Link:     [ Frame Header | IP | TCP | ... | Trailer]
Layer 1 - Physical:      101010110101001010110100101010110100...

On the receiving device, the process reverses. Each layer reads and strips its own header, passing the remaining data up to the next layer. The data link layer reads the frame header and trailer, verifies the MAC address and checks for errors, then strips the frame and passes the IP packet up to the network layer. The network layer reads the IP header, verifies the destination address, strips the IP header, and passes the TCP segment to the transport layer. This continues up through all layers until the application receives the original HTTP data that the sender's application layer produced.

OSI Model vs TCP/IP Model

The TCP/IP model, also called the Internet model, is the practical model that describes how the internet actually works. It predates the OSI model and was developed specifically for the ARPANET, which became the foundation of the internet. The two models cover the same ground but organise the layers differently, which causes confusion when people familiar with one try to map concepts from the other.

OSI Model TCP/IP Model Key Protocols
Layer 7 - ApplicationApplication LayerHTTP, HTTPS, FTP, DNS, SMTP, SSH
Layer 6 - PresentationTLS/SSL, JPEG, ASCII
Layer 5 - SessionNetBIOS, RPC
Layer 4 - TransportTransport LayerTCP, UDP
Layer 3 - NetworkInternet LayerIP, ICMP, BGP, OSPF
Layer 2 - Data LinkNetwork Access LayerEthernet, Wi-Fi, ARP
Layer 1 - PhysicalCables, radio waves, fibre optic

The TCP/IP model collapses the OSI model's application, presentation, and session layers into a single application layer, and combines the data link and physical layers into a single network access layer. The transport and internet layers in TCP/IP correspond directly to the transport and network layers in OSI. Neither model is more correct than the other. The OSI model is more useful as a teaching and troubleshooting framework because of its finer granularity. The TCP/IP model is more useful as a description of how the internet actually works in practice.

Using the OSI Model for Troubleshooting

One of the most practical applications of the OSI model is as a structured framework for network troubleshooting. By working systematically through the layers from bottom to top, you can quickly narrow down where a problem is occurring and avoid wasting time investigating layers that are functioning correctly.

  • Layer 1 check: Are cables plugged in correctly? Are link lights on the network interface and switch port? Is the wireless signal strong enough? Physical layer problems are the most common and the easiest to overlook.
  • Layer 2 check: Is the device getting a MAC address on the network? Are there duplicate MAC addresses causing conflicts? Is the correct VLAN configured on the switch port?
  • Layer 3 check: Does the device have a valid IP address? Is the subnet mask correct? Can it ping its default gateway? Are routing tables correct on intermediate routers?
  • Layer 4 check: Is the correct port open on the destination host? Is a firewall blocking TCP or UDP traffic on the required port? Run a port scan or check firewall rules.
  • Layer 5 to 7 check: Is the application configured correctly? Is TLS negotiation succeeding? Is the server returning the expected response? Are DNS records pointing to the correct servers?

Starting at layer 1 and working upward prevents the common mistake of spending time debugging application configuration when the real problem is a loose cable or an incorrect IP address. Each layer depends on the layers below it functioning correctly, so confirming each layer before moving to the next ensures you are not building on a faulty foundation.

Frequently Asked Questions

  1. Do real networks actually implement all seven OSI layers?
    Not as distinct separate components. The OSI model is a conceptual reference framework, not a strict implementation blueprint. Real networks run on the TCP/IP protocol suite, which maps loosely to OSI but collapses the seven layers into four. The OSI model remains widely used as a teaching tool and a shared vocabulary for discussing networking because its seven-layer structure provides useful granularity for understanding where different functions occur. When a network engineer says a problem is at layer 2, they are using OSI terminology to communicate precisely, even though the underlying implementation follows TCP/IP.
  2. What is the difference between layer 2 and layer 3 switches?
    A layer 2 switch operates at the data link layer and makes forwarding decisions based on MAC addresses. It forwards frames within the same network segment but cannot route traffic between different IP subnets. A layer 3 switch adds routing capabilities, making forwarding decisions based on IP addresses in addition to MAC addresses. This allows it to route traffic between different subnets without requiring a separate dedicated router. Layer 3 switches are common in enterprise networks where inter-VLAN routing is needed at high speed within a data centre or campus network.
  3. Why are there seven layers specifically?
    The seven-layer structure was the result of the ISO's analysis of what distinct functions needed to be separated to allow interoperable networking components from different vendors. Each boundary between layers was chosen to isolate a specific set of concerns so that changes in one layer would not require changes in adjacent layers. The number seven was not arbitrary but reflected a judgement about the right level of granularity. Some argue the OSI model over-divided certain areas, particularly in separating session and presentation from application, which is why the TCP/IP model collapses them into one layer.
  4. What layer does a firewall operate on?
    It depends on the type of firewall. A simple packet filtering firewall operates at layer 3, the network layer, inspecting source and destination IP addresses and making allow or deny decisions based on those addresses. A stateful firewall adds layer 4 awareness, tracking TCP connection state and port numbers. An application layer firewall or next-generation firewall operates at layer 7, inspecting the content of application-level protocols like HTTP, DNS, and SMTP to make more sophisticated filtering decisions. Most modern firewalls are stateful and operate across multiple layers simultaneously.
  5. Where does TLS fit in the OSI model?
    TLS sits between the application layer and the transport layer and is most commonly mapped to layer 6, the presentation layer, because it handles encryption and decryption of data, which is a presentation layer concern. However, TLS also has session layer characteristics because it establishes and tears down encrypted sessions. In the TCP/IP model, TLS is typically considered part of the application layer because it sits above TCP. The placement varies depending on which model is being used and the exact aspect of TLS being discussed. The practical answer is that TLS spans the boundary between session, presentation, and application layers in OSI terms.
  6. What does it mean when someone says a protocol operates at a specific layer?
    Saying a protocol operates at a specific OSI layer means that protocol's primary function corresponds to the responsibilities defined for that layer. IP operates at layer 3 because its primary job is logical addressing and routing between networks, which is the network layer's role. TCP operates at layer 4 because it provides end-to-end reliable transport between applications, which is the transport layer's role. HTTP operates at layer 7 because it defines how applications exchange web content, which is an application layer function. Most protocols interact with multiple layers to some degree, so the layer assignment represents the primary function rather than the exclusive scope of a protocol's operation.

Conclusion

The OSI model is one of the most enduring and useful frameworks in all of networking. By dividing the complexity of network communication into seven well-defined layers, each with a specific responsibility and a clear boundary with the layers above and below it, it gives every person working with networks a common language and a structured mental model for understanding how data flows from one application to another across any network. Whether you are diagnosing a connectivity problem by working systematically from physical layer cabling up through application configuration, designing a network architecture by reasoning about where routing, switching, and security functions belong, or learning how a new protocol works by identifying which layer it operates at, the OSI model provides the organising framework that makes these tasks tractable. To go deeper, explore TCP vs UDP, HTTP vs HTTPS, Network Address Translation, and how routing works.