Instead, they use routing tables and routing protocols to determine efficient paths.
Several factors influence routing decisions.
Longest Prefix Match
The most specific route usually wins.
For example:
192.168.1.0/24
is more specific than:
192.168.0.0/16
Routers prefer more specific routes whenever possible.
Routing Metrics
Routes may also be selected based on:
- Hop count
- Bandwidth
- Delay
- Reliability
- Cost
Different routing protocols evaluate these metrics differently.
Dynamic Routing Protocols
Large networks rely on routing protocols to exchange route information automatically.
Common examples include:
| Protocol |
Purpose |
| RIP |
Simple distance-vector routing |
| OSPF |
Link-state routing inside organizations |
| BGP |
Internet-wide routing between providers |
BGP, in particular, powers global internet routing.
Without it, large-scale internet communication would collapse.
A Real Example of Packet Routing
Suppose you visit a website hosted in another country.
Your packet may travel through:
- Your laptop
- Your home router
- Your ISP
- Regional backbone routers
- International internet exchanges
- Data center routers
- The destination server
At every step, routers analyze the destination IP address and forward the packet closer to its destination.
Remarkably, this entire process often takes only milliseconds.
Layer 3 vs Layer 2
A common beginner confusion is understanding the difference between MAC addresses and IP addresses.
Layer 2 (Data Link Layer)
Uses:
- MAC addresses
- Local delivery
- Frames
- Switches
Focuses on communication inside the local network.
Layer 3 (Network Layer)
Uses:
- IP addresses
- Routing
- Packets
- Routers
Focuses on communication between networks.
Both layers work together during every network transmission.
Fragmentation and MTU
Not all networks support the same maximum packet size.
This limit is called the:
Maximum Transmission Unit (MTU)
If a packet is too large for a network segment, fragmentation may occur.
The packet is divided into smaller pieces that are later reassembled at the destination.
Although fragmentation helps compatibility, excessive fragmentation can reduce performance.
Visualizing Routing in the OSI Model Simulator
Routing and IP addressing become much easier to understand when you can see them visually.
The Roboticela OSI Model Simulator allows you to enter custom:
- Source IP addresses
- Destination IP addresses
and then observe how the Network Layer inserts those values into packet headers during encapsulation.
Watching packets gain their IP identity helps make Layer 3 concepts significantly more intuitive.
Landing Page:
Launch Simulator:
Try entering different IP addresses and observe how the packet structure changes at the Network Layer.
Key Takeaways
- The Network Layer handles communication between networks.
- IP addresses provide logical identification for devices.
- IPv4 uses 32-bit addresses, while IPv6 uses 128-bit addresses.
- Routers examine destination IP addresses to forward packets.
- Routing protocols help networks dynamically exchange route information.
- Layer 3 transforms segments into packets during encapsulation.
Conclusion
The Network Layer is what transforms isolated local networks into a globally connected internet.
By introducing logical addressing and intelligent routing, Layer 3 allows packets to travel across cities, countries, oceans, and continents until they finally reach their destinations.
Every website you visit and every online service you use depends on routers making millions of Layer 3 decisions every second.
In the next article, we'll move higher into the communication stack and explore Layer 4: the Transport Layer, where TCP and UDP determine how data is delivered reliably—or as quickly as possible.