Introduction
The network layer is Layer 3 of the OSI model, sitting above the data link layer and below the transport layer. Its core job is to move packets from a source host to a destination host, possibly across many intermediate networks, using logical addressing (IP addresses) rather than the physical (MAC) addressing used within a single local network segment.
Cricket analogy: The network layer is like the ICC's fixture-routing system that gets a player's transfer paperwork from their home board to a destination board across multiple intermediary boards, using the board's official registration number rather than the player's jersey number used on a single ground.
Explanation
While the data link layer only knows how to deliver frames between two directly connected devices on the same physical link using MAC addresses, the network layer provides end-to-end logical addressing and routing so that data can travel across multiple, interconnected networks. Three responsibilities define this layer: logical addressing (assigning and interpreting IP addresses that identify a host's network and host portion), packet forwarding (routers examine a packet's destination IP address and forward it out the correct interface toward its destination, hop by hop), and fragmentation and reassembly (when a packet is larger than the maximum transmission unit, MTU, of an outgoing link, the network layer may split it into smaller fragments, which the destination host reassembles). Devices called routers operate at this layer, maintaining routing tables and making forwarding decisions independently for each packet.
Cricket analogy: While a single ground's PA only reaches the players on that field, the ICC's registration system handles three jobs: assigning each player a board and squad ID, forwarding transfer paperwork hop by hop through each board, and splitting a huge documentation bundle into smaller filings that get reassembled at the destination board — all managed by boards that keep independent transfer registers.
Example
# Conceptual view of network-layer forwarding at a router
packet = {
"source_ip": "192.168.1.10",
"dest_ip": "203.0.113.50",
"ttl": 64,
"payload_size_bytes": 1500,
}
def forward_packet(packet, mtu=1492):
packet["ttl"] -= 1 # each router hop decrements TTL
if packet["ttl"] <= 0:
return "drop: TTL expired"
if packet["payload_size_bytes"] > mtu:
return "fragment before forwarding"
return f"forward toward {packet['dest_ip']} out best-match interface"
print(forward_packet(packet))
# forward toward 203.0.113.50 out best-match interfaceAnalysis
The distinction between this layer and the data link layer is important: MAC addresses only have meaning within a single local segment and change at every hop, while the source and destination IP addresses in a packet stay the same end-to-end (barring NAT). Each router along the path decrements the packet's Time To Live (TTL) field, and if TTL reaches zero the packet is discarded to prevent routing loops from circulating packets forever. Fragmentation adds overhead and can hurt performance, which is why modern networks favor Path MTU Discovery to avoid fragmentation whenever possible.
Cricket analogy: A player's shirt number changes at every new franchise they join within a season, but their official board registration ID stays the same throughout, and each franchise the transfer paperwork passes through counts down a validity window, discarding stale documents to stop paperwork looping between boards forever — similar to TTL decrementing at each router hop.
Key Takeaways
- The network layer (Layer 3) provides logical addressing and end-to-end packet delivery across interconnected networks.
- Routers forward packets hop by hop based on destination IP address, unlike switches which forward frames based on MAC address within one segment.
- Fragmentation splits packets larger than a link's MTU; the destination reassembles them.
- TTL prevents packets from looping forever by being decremented at each router hop.
Practice what you learned
1. Which OSI layer is primarily responsible for logical addressing and routing packets across networks?
2. What happens when a packet's TTL field reaches zero?
3. Which addressing type stays the same end-to-end across a multi-hop path, unlike per-hop addressing?
4. Why does a router fragment a packet?
Was this page helpful?
You May Also Like
The OSI Model
Understand the 7 layers of the OSI reference model, their responsibilities, and example protocols at each layer.
IP Addressing and Subnetting
Master IPv4 addressing and CIDR subnetting with a fully worked, hand-verified example.
Routing Fundamentals
Understand how routers use routing tables and longest prefix match to forward packets, and the difference between static and dynamic routing.
Data Link Layer Basics
How raw bits are organized into frames for reliable node-to-node delivery on the same network segment.