Data Delivery and Forwarding in the Network Layer
1. Direct vs. Indirect Packet Delivery
The network layer supervises the transmission of packets across interconnected networks. Handling of a packet by the network layer falls into two fundamental categories:
1. Direct Delivery
- Occurs when the destination host resides on the same physical network as the delivering entity (either the original source host or the final intermediate router).
- Process:
- The sender extracts the destination IP and applies its own subnet mask.
- If
Dest IP AND Subnet Maskmatches the sender's own Network ID, direct delivery is invoked. - The sender queries its local ARP cache (or broadcasts an ARP request) to resolve the destination's MAC address.
- The packet is encapsulated into a Data Link frame with the destination's physical MAC address and transmitted directly onto the wire.
2. Indirect Delivery
- Occurs when the destination host is on a different network.
- The packet must travel hop-by-hop through one or more intermediate Routers.
- The sender transmits the packet directly to its Default Gateway (Router).
- Each intermediate router performs an indirect delivery to the next-hop router until the final router delivers the packet directly to the destination host.
3. Forwarding Techniques in Routers
To manage massive routing tables efficiently, routers employ four fundamental forwarding optimizations:
- Next-Hop Method: Instead of storing the complete list of intermediate routers along the entire path from source to destination, the routing table stores only the IP address of the immediate next-hop router () and the outbound interface.
- Network-Specific Method: Instead of maintaining an entry for every individual host computer on the Internet (which would require billions of table rows), the table maintains one single entry for each destination Network ID.
- Host-Specific Method: An explicit
/32route entry configured for a specific machine. Used for specialized security filtering or load balancing. - Default Route Method (
0.0.0.0/0): If a destination IP does not match any specific network in the table, the packet is forwarded to the Default Gateway (e.g., the ISP edge router), preventing table explosion.
4. The Longest Prefix Match Algorithm
When Classless Inter-Domain Routing (CIDR) is utilized, a destination IP address might match multiple overlapping routes in the routing table.
Principle:
Routers evaluate all matching routes and forward the packet using the route entry that possesses the Longest Subnet Mask (Largest prefix length ), because a longer prefix represents a more specific subnetwork.
Solved Numerical Example:
A router has the following CIDR routing table:
| Destination Network | Subnet Mask | Next Hop Router | Interface |
|---|---|---|---|
128.96.34.0 |
255.255.255.128 (/25) |
Direct | eth0 |
128.96.34.128 |
255.255.255.128 (/25) |
Direct | eth1 |
128.96.32.0 |
255.255.240.0 (/20) |
192.168.1.1 |
eth2 |
0.0.0.0 |
0.0.0.0 (/0 - Default) |
203.0.113.1 |
eth3 |
- Incoming Packet Destination IP:
128.96.34.130
Lookup Steps:
- Check
/25entries (Mask255.255.255.128):- Apply mask to IP
128.96.34.130:- , Mask .
- Bitwise AND: .
- Result =
128.96.34.128. - Matches Route 2 (
128.96.34.128/25)!
- Apply mask to IP
- Check
/20entry (Mask255.255.240.0):- , Mask .
- Result =
128.96.32.0. Matches Route 3 (128.96.32.0/20).
- Selection:
- Both
/25and/20matched. - The Longest Prefix Match is
/25(). - Decision: Forward packet via interface
eth1(Direct Delivery).
- Both
Frequently Asked Questions
QHow does a host know whether to use Direct or Indirect delivery?
The host performs a bitwise AND between the destination IP address and its own subnet mask. If the resulting network address matches its own local network address, it uses Direct Delivery. If the addresses differ, it uses Indirect Delivery and forwards to the default gateway.
QExplain the Longest Prefix Match rule.
In CIDR routing, when an incoming packet's destination IP matches more than one network prefix in the routing table, the router selects the entry with the longest prefix (highest mask length ) because it represents the most specific and accurate destination path.
QWhat is the Default Route and what address represents it?
The default route handles all destination packets that have no explicit matching entry in the routing table. It is represented by destination prefix 0.0.0.0 with mask 0.0.0.0 (0.0.0.0/0).
QWhat is the next-hop method in routing tables?
Instead of storing the whole path to a destination, the table stores only the IP of the immediate next-hop router and the outgoing interface, which keeps the tables small.