What is the Network Layer (OSI Layer 3)?
Learn what the OSI Network layer does, IP addressing, routing tables, ICMP, and how routers forward packets, with interview Q&A.
Expected Interview Answer
The Network layer is OSI Layer 3 — it is responsible for logical addressing (IP addresses) and routing, deciding the best path to move a packet from a source host to a destination host across multiple interconnected networks.
While the Data Link layer only handles delivery within a single local segment, the Network layer’s job is to get a packet across many segments to a host that may be on the other side of the world. Routers are the quintessential Layer 3 device: they inspect the destination IP address in each packet’s header and consult a routing table (built via static routes or dynamic protocols like OSPF or BGP) to decide the next hop. This layer also handles logical addressing and subnetting, packet fragmentation when a link’s MTU is smaller than the packet, and basic diagnostics via ICMP (used by tools like ping and traceroute). Unlike MAC addresses, which are flat and tied to hardware, IP addresses are hierarchical, which is what makes efficient, scalable internet-wide routing possible in the first place.
- Provides logical (IP) addressing independent of hardware
- Determines the best path across multiple networks via routing
- Enables fragmentation/reassembly to fit differing link MTUs
- Supports diagnostics (ICMP) like ping and traceroute
AI Mentor Explanation
The Network layer is like a national cricket board deciding which city’s stadium a touring team travels to next on a multi-leg tour — it does not care about seat numbers within a single ground (that is a local, Layer 2 concern), only about the best travel route between cities. A tour scheduler consulting a route table of flight connections between host cities mirrors a router consulting a routing table between networks. If a direct flight is unavailable, the scheduler picks a connecting route through another city, exactly like a router choosing an alternate hop when a link is down. This inter-city path planning is precisely the Network layer’s job.
Step-by-Step Explanation
Step 1
Logical addressing
Each host is assigned an IP address that identifies it hierarchically across networks.
Step 2
Route lookup
A router inspects the destination IP and consults its routing table for the best next hop.
Step 3
Forwarding
The packet is forwarded hop by hop through intermediate routers toward the destination network.
Step 4
Fragmentation if needed
If a link’s MTU is smaller than the packet, it is fragmented and reassembled at the destination.
What Interviewer Expects
- Clear definition: logical (IP) addressing and inter-network routing
- Distinguishes routers (Layer 3) from switches (Layer 2)
- Knows about routing tables and dynamic routing protocols (OSPF, BGP)
- Aware of ICMP’s role for diagnostics (ping, traceroute)
Common Mistakes
- Confusing routing (Layer 3, IP) with switching (Layer 2, MAC)
- Thinking a router only forwards, without decision logic (routing table lookup)
- Not knowing ICMP operates at this layer for diagnostics
- Forgetting that fragmentation happens at the Network layer, not Transport
Best Answer (HR Friendly)
“The Network layer is the layer responsible for getting your data from your device all the way to a destination possibly on the other side of the world, by figuring out the best path across many interconnected networks. This is where IP addresses live, and routers are the devices that read those addresses and decide, hop by hop, where to send your data next.”
Code Example
# Show the local routing table
ip route show
# Trace the Layer 3 hop-by-hop path to a destination
traceroute 8.8.8.8
# 1 192.168.1.1 1.2 ms
# 2 10.10.0.1 8.4 ms
# 3 8.8.8.8 14.1 msFollow-up Questions
- What is the difference between static and dynamic routing?
- How do OSPF and BGP differ in scope and purpose?
- What causes a router to fragment a packet and how is it reassembled?
- How does ICMP support tools like ping and traceroute?
MCQ Practice
1. What addressing scheme does the Network layer use?
The Network layer uses logical, hierarchical IP addresses to route across networks.
2. Which device makes forwarding decisions primarily at Layer 3?
Routers inspect destination IP addresses and use routing tables to forward packets.
3. What protocol is commonly used for network diagnostics like ping?
ICMP (Internet Control Message Protocol) underlies diagnostic tools like ping and traceroute.
Flash Cards
What is the Network layer? — OSI Layer 3 — handles logical (IP) addressing and routing across networks.
What device operates at Layer 3? — A router, which forwards packets based on destination IP and a routing table.
Two dynamic routing protocol examples? — OSPF (interior) and BGP (exterior/internet-wide).
What does ICMP support? — Network diagnostics, e.g. ping (echo request/reply) and traceroute.