Networking interview question · Most asked
Explain the OSI and TCP/IP models. Why do engineers still talk about 'layer 4' and 'layer 7'?
Summary
The TCP/IP model has four layers (link, internet, transport, application); the seven-layer OSI model is mostly used as vocabulary. 'Layer 4' means transport (TCP/UDP ports) and 'layer 7' means application (HTTP), so a layer 4 load balancer routes by IP and port while a layer 7 one can route by host, path or header.
Longer Answer
Each layer encapsulates the one above: an HTTP request inside a TCP segment, inside an IP packet, inside an Ethernet frame. Layer 3 is IP addressing and routing, layer 2 is MAC addresses and switches. Knowing the layer tells you which device or rule can affect a problem: security groups act on layers 3-4, a WAF on layer 7.
Key Points
- TCP/IP: link, internet, transport, application.
- OSI numbers are the common vocabulary.
- L4 = IP and port; L7 = HTTP content.
- Encapsulation adds a header per layer.
Deep dive: Networking Tutorial: OSI and TCP/IP Models
Explanation
What interviewers look for
Practical use of the models to reason about devices and rules, not memorised layer names.
More most-asked Networking questions
- What's the difference between TCP and UDP, and when would you choose UDP?
- How does NAT work, and what are its limits?
- What is CIDR notation? How many usable addresses are in a /26, and in an AWS /26 subnet?
- How does DNS resolution work, and what does a record's TTL control?
- What does TLS provide, and how does certificate validation work?
- What happens, at the network level, when you type a URL into a browser and press Enter?
- What do 502, 503 and 504 errors from a load balancer usually mean?
- What's the difference between stateful and stateless firewalls? Give cloud examples.