OOPs HandbookOSI Model vs TCP/IP Model: All 7 Layers, Protocols and What Happens When You Open a Website
Computer NetworksBeginner
9 min read

OSI Model vs TCP/IP Model: All 7 Layers, Protocols and What Happens When You Open a Website

Each layer’s job and protocols, how the two models map, and the request journey interviewers ask you to explain.

TM
TestMeMan SDE Curriculum
Updated Sept 2026
Verified for FAANG Interviews
FROM TESTMEMAN•TestMeMan Campus

Coding problems with instant test-case feedback

Write Python, C++, C or JavaScript in your browser and see which hidden tests pass.

Sponsored Publisher Placement•
ID: ad-top-leaderboard
Executive Summary

Networking is built in layers. Each layer solves one problem and relies on the layer below it. The OSI model has seven layers and is mostly a teaching model; the TCP/IP model has four and describes how the internet actually works. You are expected to know both and how they line up.

1. The seven OSI layers#

From top (closest to the user) to bottom (the wire):

#LayerJobExamplesData unit
7ApplicationNetwork services for applicationsHTTP, DNS, SMTP, FTPData
6PresentationEncoding, encryption, compressionTLS, JPEG, UTF-8Data
5SessionOpen, manage and close sessionsRPC, session checkpointsData
4TransportEnd-to-end delivery between processes (ports)TCP, UDPSegment / datagram
3NetworkLogical addressing and routing between networksIP, ICMP, routersPacket
2Data linkDelivery on one link, MAC addresses, error detectionEthernet, Wi-Fi, switches, ARPFrame
1PhysicalBits as signals on a mediumCables, radio, hubsBit
Mnemonic

"Please Do Not Throw Sausage Pizza Away", from layer 1 up: Physical, Data link, Network, Transport, Session, Presentation, Application.

2. How OSI maps to TCP/IP#

The TCP/IP model merges OSI layers 5–7 into one Application layer and layers 1–2 into a Link (network access) layer.

TCP/IP layerOSI layersProtocols
Application7, 6, 5HTTP, HTTPS, DNS, SMTP, SSH
Transport4TCP, UDP
Internet3IP (v4, v6), ICMP
Link2, 1Ethernet, Wi-Fi, ARP
Sponsored ContentTestMeMan Campus

Practise placement aptitude on the real test pattern

TCS NQT, Infosys, Wipro, Accenture and Cognizant style mocks with section-wise analysis.

3. TCP vs UDP#

TCPUDP
ConnectionConnection-oriented (three-way handshake: SYN, SYN-ACK, ACK)Connectionless
ReliabilityRetransmits lost data, delivers in orderNo guarantee of delivery or order
Flow and congestion controlYesNo
Header size20–60 bytes8 bytes
Used forWeb pages, email, file transferDNS lookups, video calls, online games

4. What happens when you type a URL and press Enter#

This is one of the most common networking interview questions. A good answer walks down the layers:

  • DNS: the browser checks its cache, then asks a DNS resolver to turn the domain name into an IP address (usually over UDP port 53).
  • TCP: the browser opens a TCP connection to that IP on port 443 with the three-way handshake.
  • TLS: client and server agree on keys and the server proves its identity with a certificate, so the rest is encrypted.
  • HTTP: the browser sends GET / with headers; the server responds with status 200 and the HTML.
  • Below that, IP routes the packets hop by hop through routers, and on each link Ethernet or Wi-Fi delivers frames using MAC addresses found with ARP.
  • Rendering: the browser parses the HTML, requests CSS, JavaScript and images (often over the same connection) and paints the page.
Go one level deeper than asked

Mentioning DNS caching, the TLS handshake, or that HTTP/3 runs over QUIC on UDP shows you understand the stack rather than a memorised list.

Test Your Concept Mastery

Verify your retention on: OSI Model vs TCP/IP Model: All 7 Layers, Protocols and What Happens When You Open a Website

Diagnostic Check
Question 1 of 2
At which OSI layer do routers mainly operate?
Question 2 of 2
Which protocol does a typical DNS lookup use?
Ready for a full proctored assessment?

Take a free aptitude mock on a real company pattern, with a worked solution for every question.

Take an aptitude mock