c2cedge
LibraryCS Fundamentals › Ch 11
CS Fundamentals · C — Computer Networks

Network Models: OSI & TCP/IP

Networking is taught in layers. Knowing the OSI and TCP/IP models, and which protocol lives where, is the foundation of every networking interview.

Test weight: Very highAsked by: TCS, Infosys, WiproDifficulty: Easy–Medium

Networks are designed in layers so each layer handles one concern and talks only to the layers next to it. The OSI model has 7 layers (a teaching reference); the TCP/IP model has 4 (what the internet actually uses). Interviews expect you to name the layers and place common protocols correctly.

Why layering

Layering gives separation of concerns: the application doesn't worry about cables, and the wire doesn't worry about web pages. Each layer adds its own header (encapsulation) as data goes down the sender's stack and is stripped going up the receiver's stack.

The OSI 7 layers (top to bottom)

LayerJobExample
Applicationuser-facing servicesHTTP, DNS, SMTP
Presentationformat, encrypt, compressTLS, JPEG
Sessionmanage sessionssockets
Transportend-to-end deliveryTCP, UDP
Networkrouting across networksIP, routers
Data Linknode-to-node framesEthernet, MAC, switches
Physicalraw bits on the mediumcables, signals
⚡ The edge
  • A mnemonic for OSI top-to-bottom: All People Seem To Need Data Processing (Application, Presentation, Session, Transport, Network, Data Link, Physical).
  • Place the protocols: HTTP/DNS = Application; TCP/UDP = Transport; IP = Network; Ethernet/MAC = Data Link. That mapping answers a large share of networking questions.
Worked example
'What is the difference between the OSI and TCP/IP models?'
  1. OSI is a 7-layer conceptual/reference model; TCP/IP is the 4-layer model the internet actually runs on.
  2. TCP/IP collapses OSI's top three (Application, Presentation, Session) into one Application layer, and the bottom two into a Network Access layer.
  3. So OSI is for teaching/standardising; TCP/IP is practical and protocol-driven.
Worked example
'What happens when you type a URL and press Enter?' (layered view)
  1. DNS (Application) resolves the domain to an IP; a TCP connection (Transport) is set up to that IP.
  2. IP (Network) routes the packets across routers; Data Link/Physical carry the frames hop to hop.
  3. The HTTP request travels up the server's stack, the response comes back, and the browser renders it.
⚠ Watch out
  • Switches operate at the Data Link layer (MAC addresses); routers at the Network layer (IP) — don't swap them.
  • TCP and UDP are Transport layer; IP is Network layer — a very common mix-up.
  • OSI is a reference model; the internet doesn't literally implement all 7 layers separately.
Practice this — take a timed mock →
1,300+ questions, scored, with a weak-area report.
Know who's ready. Not who finished.
HomeLibraryPrivacyTerms