Interview Q&A / Computer Networks

BeginnerIn-depth4 min readUpdated 2 Oct 2026

What is the OSI model, and how is it different from the TCP/IP model?

SHORT ANSWER

The OSI model is a 7-layer reference model (Physical, Data Link, Network, Transport, Session, Presentation, Application) used to explain and troubleshoot networks. The TCP/IP model is the 4-layer model the internet actually runs on (Link, Internet, Transport, Application), which folds OSI's top three layers into one.

Explain it simply

Sending data is like sending a Diwali gift to a cousin in another city. You write a card and put the gift in a box (application). The courier puts it in a labelled packet with a tracking number (transport). The sorting hub decides which city it goes to (network). A van carries it to the next hub on a specific road (data link). The road itself is the physical layer. Each person only cares about their own job and trusts the layer below to do theirs.

The OSI model and the TCP/IP model are two ways of drawing those jobs. OSI is the detailed textbook diagram. TCP/IP is the shorter version the real internet was built on.

Example

OSI layerWhat it doesExamplesTCP/IP layer
7 ApplicationServices the user's app talks toHTTP, DNS, SMTP, SSHApplication
6 PresentationData format, encoding, encryptionTLS, JSON, UTF-8, JPEGApplication
5 SessionOpening and managing conversationsSession setup, checkpointsApplication
4 TransportProcess-to-process delivery, portsTCP, UDPTransport
3 NetworkAddressing and routing across networksIP, ICMPInternet
2 Data LinkDelivery to the next device on the same link, MAC addressesEthernet, Wi-Fi (802.11), ARPLink
1 PhysicalBits as signals on a mediumCables, fibre, radioLink

A common way to remember OSI from layer 1 up: "Please Do Not Throw Sausage Pizza Away".

Devices are also described by layer: a hub works at layer 1, a switch at layer 2 (it forwards by MAC address), and a router at layer 3 (it forwards by IP address).

How it works

When you send data, each layer adds its own header around the data from the layer above. This is called encapsulation. Your HTTP request becomes a TCP segment (with ports), which goes inside an IP packet (with source and destination IP), which goes inside an Ethernet or Wi-Fi frame (with MAC addresses), which is sent as bits. At each router, the frame is unwrapped up to layer 3, the router reads the IP address, picks the next hop and wraps it in a new frame. At the destination, the layers peel off their headers in reverse until the app gets the original request.

The name of the data unit changes by layer: bits at layer 1, frames at layer 2, packets at layer 3, segments (TCP) or datagrams (UDP) at layer 4, and simply data or messages above that.

OSI was designed by ISO as a general standard. TCP/IP came from real ARPANET work and won in practice, so real protocols do not fit OSI's session and presentation layers neatly. TLS, for example, is described differently in different books. Some textbooks also show TCP/IP as 5 layers by splitting Link into Data Link and Physical.

Real-world use

Engineers use layer numbers as shorthand every day. "It's a layer 1 problem" means a loose cable. A "layer 4 load balancer" routes by IP and port, while a "layer 7 load balancer" can route by URL path or header. Troubleshooting often goes bottom up: is the link up, do I have an IP, can I ping the gateway, can I open the port, does the app respond?

Common mistakes

  • Saying the internet uses the OSI model. It uses TCP/IP; OSI is the reference for explaining it.
  • Putting IP at the transport layer or TCP at the network layer.
  • Thinking MAC addresses travel end to end. They change at every hop; IP addresses stay the same (apart from NAT).
  • Forgetting that the TCP/IP application layer covers OSI layers 5, 6 and 7.

What to say in the interview

"The OSI model has seven layers: physical, data link, network, transport, session, presentation and application. It is a conceptual reference for how communication is split into responsibilities. The TCP/IP model is the practical model the internet uses, with four layers: link, internet, transport and application. The main difference is that TCP/IP merges OSI's session, presentation and application layers into one application layer, and merges physical and data link into the link layer. As data moves down the stack each layer encapsulates it with its own header, like TCP ports, then IP addresses, then MAC addresses."

Follow-up questions

  • At which layer do a switch and a router work?
  • What is encapsulation?
  • Which layer does TLS belong to?
  • What is the difference between a layer 4 and a layer 7 load balancer?

Go deeper

Read these once the basics above feel easy.

ARP sits between layers 2 and 3: a host knows the destination IP of its gateway but needs its MAC address to build the frame, so it broadcasts "who has this IP?" on the local network. ICMP, used by ping and traceroute, is carried inside IP but is treated as part of the network layer because it reports network-level errors such as "destination unreachable" or "time exceeded".

#networking#osi-model#tcp-ip#layers

Related questions

Practise more Computer Networks questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Computer Networks quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.