skip to content

In the OSI reference model, what are the seven layers from L1 to L7, and what is each one responsible for?

level: juniorimportance: must knowfreq 82%

answer

  1. from signals up to services
  2. one link, many networks, two processes
  3. Please Do Not Throw Sausage Pizza Away
  4. dialogue control, then data representation

basics

~20 s

The OSI model's seven layers, bottom up: Physical (bits on a medium), Data Link (frames between neighbours), Network (addressing and routing across networks), Transport (end-to-end delivery between processes), Session (dialogue control), Presentation (data representation), Application (network services to programs).

solid answer

~50 s

Bottom up: **L1 Physical** moves raw bits as signals over a medium: voltages, light or radio. **L2 Data Link** groups bits into frames and delivers them between two nodes on the same link, with hardware addresses and error detection. **L3 Network** gives hosts logical addresses and routes packets across many links. **L4 Transport** delivers data end to end between processes on two hosts, adding ports and, depending on the protocol, reliability, ordering and flow control. **L5 Session** manages the dialogue: opening, synchronising and closing an exchange. **L6 Presentation** agrees how data is represented, its encoding and syntax. **L7 Application** is the protocol a program speaks to the network, such as HTTP or DNS. 'Please Do Not Throw Sausage Pizza Away' fixes the order; the substance is that each layer serves the one above and relies on the one below.

go deeper

for a junior

Recall all seven names in order with their numbers, and give each a one-phrase job. The mnemonic gets you the order; the job per layer is what is being tested.

for a middle

Explain the service relationship: each layer uses the one below and serves the one above, and peers talk through their own control information. Show that L1-L2 work per link, L3 across networks, L4 and above only at the endpoints.

for a senior

Use the layers to reason about real systems: say which layer a symptom or a component belongs to and why, and admit where real protocols straddle the boxes.

for a principal

Be ready to argue where the layered model helps and where it hurts, citing the RFC 3439 critique that strict layering hides information lower layers could use.

## What the OSI model is The **Open Systems Interconnection (OSI) reference model**, published by ISO, splits the job of moving data between two programs on two machines into **seven layers**. It is a *reference model*: it names functions and where they belong, not a protocol you can install. The Internet protocol suite was designed separately and describes its own layers (RFC 1122 lists link, internet, transport and application), so real protocols fit the seven boxes only approximately. The model survives because it gives engineers a shared vocabulary: "that is a Layer 2 problem" instantly says *which part of the system* to look at. ## The seven layers at a glance | # | Layer | Responsible for | Unit of data | Scope | |---|---|---|---|---| | 7 | **Application** | the protocol a program uses to talk to the network | data / message | end to end | | 6 | **Presentation** | representation: encoding, syntax, format conversion | data | end to end | | 5 | **Session** | dialogue: opening, synchronising, closing an exchange | data | end to end | | 4 | **Transport** | delivery between processes; ports, optionally reliability and order | segment (TCP) / datagram (UDP) | end to end | | 3 | **Network** | logical addressing and routing across networks | packet | host to host, across many links | | 2 | **Data Link** | framing, hardware addressing, error detection on one link | frame | node to node, one link | | 1 | **Physical** | turning bits into signals on a medium and back | bits | one medium | ## Layer by layer - **L1 Physical**: cables, fibre, radio, connectors, voltages, light pulses and bit timing. It knows nothing about addresses or meaning; it moves bits. - **L2 Data Link**: packs bits into **frames**, marks where each frame starts and ends, addresses it to a neighbour by **hardware address**, and **detects** corrupted frames. Its reach is one link or one broadcast domain. - **L3 Network**: gives every host a **logical address** that works across networks and chooses a path through intermediate routers. This is what makes an *internetwork* out of many separate links. - **L4 Transport**: the first layer that, in the model, exists only in the **two end hosts** (middleboxes aside). It adds **ports** so data reaches the right process, and, depending on the protocol, **reliability, ordering and flow control**. RFC 1122 describes TCP as reliable and connection-oriented and UDP as connectionless ("datagram"). - **L5 Session**: manages the **dialogue** between two applications: who talks when, checkpoints to resume from, and orderly close. - **L6 Presentation**: makes sure both ends **interpret the bytes the same way**: character encoding, data syntax, format conversion. Textbooks also list compression and encryption here. - **L7 Application**: the **network-facing protocol** of a program, such as HTTP for the web or DNS for names. It is not the program's user interface. ## How the layers relate 1. **Service upward**: each layer offers a service to the layer above (L3 offers "get this to that host"; L4 turns it into "get this to that process"). 2. **Reliance downward**: each layer uses only the service of the layer below and does not need to know how it is provided. 3. **Peer conversation**: each layer adds its own control information that only the **same layer** on the far side reads. L4 logically talks to L4, while the bits physically travel down to L1, across the medium, and back up. How those pieces of control information nest is its own subject. The payoff is **substitution**: a new physical medium or link technology can arrive without rewriting a single application, because the layers above depend on the service, not on the medium. ## Where the model stops being literal - Few real protocols map one-to-one onto a single box; placing a protocol with a reason is a separate skill from reciting the list. - RFC 1122 says the Internet suite's single application layer combines the functions of OSI's Presentation and Application layers. - RFC 3439 has a section titled "Layering Considered Harmful": strict layering means each layer finishes its work before handing on, which hides information lower layers could use for optimisation. So use the layers to **reason**, not as a sorting quiz. ## Remembering the order - Bottom up: **P**lease **D**o **N**ot **T**hrow **S**ausage **P**izza **A**way (Physical, Data Link, Network, Transport, Session, Presentation, Application). - Top down: **A**ll **P**eople **S**eem **T**o **N**eed **D**ata **P**rocessing. An interviewer who hears the mnemonic will ask the follow-up at once: *what does Layer 3 do, and what does Layer 4 add on top?* A good answer gives each layer's job in one phrase and shows the pattern: **L1-L2 work per link, L3 works across the network, L4-L7 work only at the endpoints.**

  • In the OSI model, why do layers 1 to 3 run in every router on a path while layers 4 to 7 run only on the end hosts?
    Forwarding needs only the medium, the frame and the logical destination address, so a router needs L1-L3. Delivery to a process, dialogue, representation and the application protocol matter only to the two endpoints, so they live there. Keeping conversation state at the edges also lets a router fail and traffic reroute through another path without losing it, the fate-sharing idea RFC 1958 describes. Middleboxes that inspect higher layers are a deliberate exception.
  • In the OSI model, what does it mean that a layer talks to its peer on the other host?
    Each layer adds control information that only the same layer on the far side reads, so Transport logically converses with Transport and Network with Network. Physically, the data goes down the sender's stack to the medium and back up the receiver's. That separation is why one layer can change without the others noticing.

saying these in an interview costs you the question

  • Layer 2 is the network layer and routes between networks
  • The Presentation layer draws the application's user interface
  • Layer 7 is the user's whole program, not the protocol it speaks
  • Transport routes packets while the network layer is end to end
  • Reciting the mnemonic but unable to state any layer's job
  • The OSI model is the exact specification Internet protocols implement