Skip to content
Tech Interview Prep
Technical interview guide

OSI & TCP/IP Models

The layered models networking is reasoned about in, physical up to application, and where common protocols and problems live.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v5
Editorial status
Reviewed

Scope: Current IETF host, IPv4, IPv6, ARP, NDP, TCP, UDP, port, ICMP, PMTUD, TLS 1.3, QUIC, and Wireshark references reviewed 2026-09-04.

Overview

Curated: · Written: · Reviewed:

OSI & TCP/IP Models

In one line

Each layer is a service contract with a narrow scope. Use the model to decide which contract a symptom violates and which capture proves it. OSI has seven layers, but the deployed stack is TCP/IP: link, internet, transport, application. Reach for it when a request fails somewhere between the application and the wire and you need to pick where to look first.

Key definitions

  • Encapsulation: each layer wraps the one above in its own header, and the receiver unwraps in reverse.
  • PDU names: frame (link), packet (IP), segment (TCP) or datagram (UDP).
  • Best effort: IP gives no guarantee of order, single delivery or arrival.
  • Four-tuple: source IP, source port, destination IP, destination port. It identifies a TCP connection, not the listening port alone.
  • PMTUD: finding the smallest MTU on a path using ICMP Fragmentation Needed (IPv4, DF set) or Packet Too Big (IPv6).
  • ARP / NDP: resolve an IP address to a MAC address on the local link.

Formulas and complexity

MSSIPv4=MTU−40MSSIPv6=MTU−60\text{MSS}_{IPv4} = \text{MTU} - 40 \qquad \text{MSS}_{IPv6} = \text{MTU} - 60 Throughput≤windowRTT\text{Throughput} \le \frac{\text{window}}{\text{RTT}}

Worked example, labelled hypothetical: a 64 KiB window over a 40 ms RTT caps throughput at about 13.1 Mbit/s, whatever the link speed.

How it works

An off-subnet send is handled hop by hop:

HTTP data TCP segment: ports, seq IP packet: src and dst IP, TTL Ethernet frame: src and dst MAC, FCS Router R1: strips frame, decrements TTL New frame: new MACs, same IPs
  • The host ARPs for its default gateway. The frame's destination MAC is the gateway's; the IP destination stays the final host.
  • Each router rewrites the link-layer addresses and decrements TTL (Hop Limit in IPv6). IPv4 also recomputes the header checksum.
  • IPv6 routers never fragment. The source host owns Path MTU Discovery.
  • A TCP byte stream has no message boundaries. Applications must frame their own records.

When to use and when not to

NeedChooseReason
Every byte, in orderTCP or QUICTransport guarantees retransmission and ordering
Freshness over completenessUDPNo retransmission; drop stale data in the application
Many streams, no cross-stream stallQUICPer-stream ordering
Tunnels, QUIC, VXLANNeither layer aloneThey span layers; discuss the contracts instead

Do not use the model to assign performance blame. Loss at layer 2 shows up as retransmissions at layer 4.

Traps interviewers probe

  1. "TCP preserves messages." It preserves byte order only. Fix: length-prefix records, handle partial reads, and treat uncertain outcomes on retried requests.
  2. "Blocking ICMP is safer." It breaks PMTUD, and on IPv6 it breaks neighbor discovery. Fix: permit Fragmentation Needed and Packet Too Big, or clamp MSS at the tunnel.
  3. "DNS resolved, so the service is reachable." A resolved name says nothing about reachability. Fix: RST means nothing is listening (ECONNREFUSED); a timeout means filtered or dropped.
  4. "A star in traceroute means that hop is down." Many routers rate-limit ICMP Time Exceeded. Fix: check whether later hops answer.
  5. "Switches and routers forward the same way." Switches forward by MAC within a broadcast domain and keep the frame. Routers forward by prefix, rewrite MACs, and decrement TTL.

Interview tips

Opening: "Layers are contracts. I'd locate the symptom by the contract it violates, then name the capture that proves it."

Expect these follow-ups:

  • Where QUIC fits: transport over UDP, with per-stream ordering. Packet loss still stalls every stream that shares the connection's congestion control.
  • Why a connection works from one subnet and not another: check subnet mask, gateway, ARP, firewall, and MTU.
  • Why a TCP connection succeeds but the application fails: TLS and application semantics sit above the byte stream.
  • Which layer a load balancer operates at: it depends on whether it inspects L4 flows or L7 content.

30-second outline:

  1. Name the layers the symptom touches.
  2. State the contract that is violated.
  3. Give the evidence: packet sizes, DF bit, RST or timeout, ARP entry.
  4. Give the fix and the check that proves it. Name the capture point, because a host capture can miss what the wire carried.

The Overview is now longer than the first draft and sits within the 600-900 word range.

Feedback on this overview

Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.