Network Layer · Computer Networks

Data Delivery and Forwarding

Watch lectures
SVGVector Architecture Diagram (SVG)
COMPUTER NETWORKS · Module 3★ High PriorityData Delivery and ForwardingIT Sem 6 · Code 100602 · Direct, indirect, longest prefixMNEMONICSame network = direct (ARP), different network = indirect (via gateway, hop by hop).Routers pick the longest matching prefix; 0.0.0.0/0 is the default route.Core BreakdownDirectDestination is on the same network as the sender or last router.Resolve the destination MAC by ARP and send the frame straight out.TestCompute Dest IP AND own subnet mask and compare with own network ID.Equal means direct delivery; different means send to the gateway.IndirectDestination on a different network: go to the default gateway.Each router hops to the next, the last router delivers directly.Next-hopTable stores only the next router IP and outgoing interface.Not the whole path, so tables stay small.SpecificNetwork-specific: one entry per network, not per host.Host-specific /32 entry for one machine; default route 0.0.0.0/0.Longest /nIf several CIDR routes match, use the largest prefix length /n.A longer prefix is a more specific subnetwork.Diagram: Delivery and LookupDirect: same subnet (ARP, MAC)Host A.1.10Host B.1.50Indirect: via default gatewayHost AR1R2Host CDest AND mask = my network ? direct : gatewayNext-hopone routerNetwork-specificHost-spec/32Default0.0.0.0/0Dest 128.96.34.130 matches: 128.96.34.128/25 -> eth1 128.96.32.0/20 -> eth2Longest prefix /25 wins: eth1⚠️ Exam Traps & Viva Favorites① Direct or indirect?AND the destination IP with your own mask. If itequals your network ID use direct delivery, elsesend to the default gateway.② Longest prefix rule?When many routes match, the entry with the highest/n wins, because it is the most specific path tothe destination.③ What is the default route?Used when no entry matches. Written 0.0.0.0 withmask 0.0.0.0, i.e. 0.0.0.0/0. Usually points tothe ISP edge router.Tip: AND the mask, then longest /nMaster Revision Table(learn it row by row!)Destination networkMaskNext hopInterfaceMatch for 128.96.34.130?128.96.34.0255.255.255.128 (/25)Directeth0No: result 128.96.34.0128.96.34.128255.255.255.128 (/25)Directeth1Yes: 130 AND 128 = 128128.96.32.0255.255.240.0 (/20)192.168.1.1eth2Yes: 34 AND 240 = 320.0.0.00.0.0.0 (/0 default)203.0.113.1eth3Yes: matches everythingWinnerLongest prefix /25Direct deliveryeth1/25 beats /20 and /0No matchElseDefault gatewayeth3Fallback onlyQUICK FACTSDirect: Dest AND Mask = my Network ID, then ARP for the MAC and send the frameTechniques: next-hop, network-specific, host-specific (/32), default (0.0.0.0/0)130 = 10000010, mask 128 = 10000000, AND = 128 -> 128.96.34.128/25VERIFIED★ Golden rule: AND with the mask, thenforward by the longest prefix.

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:

MermaidDiagram
Rendering diagram…
MermaidDiagram
Rendering diagram…

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:
    1. The sender extracts the destination IP and applies its own subnet mask.
    2. If Dest IP AND Subnet Mask matches the sender's own Network ID, direct delivery is invoked.
    3. The sender queries its local ARP cache (or broadcasts an ARP request) to resolve the destination's MAC address.
    4. 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:

MermaidDiagram
Rendering diagram…
  1. 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 (RnextR_{\text{next}}) and the outbound interface.
  2. 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.
  3. Host-Specific Method: An explicit /32 route entry configured for a specific machine. Used for specialized security filtering or load balancing.
  4. 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 /n/n), 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:

  1. Check /25 entries (Mask 255.255.255.128):
    • Apply mask to IP 128.96.34.130:
      • 130=100000102130 = \mathbf{10000010}_2, Mask 128=100000002128 = \mathbf{10000000}_2.
      • Bitwise AND: 100000002=1281010000000_2 = 128_{10}.
    • Result = 128.96.34.128.
    • Matches Route 2 (128.96.34.128/25)!
  2. Check /20 entry (Mask 255.255.240.0):
    • 34=00100010234 = \mathbf{00100010}_2, Mask 240=111100002  ⟹  001000002=3210240 = \mathbf{11110000}_2 \implies 00100000_2 = 32_{10}.
    • Result = 128.96.32.0. Matches Route 3 (128.96.32.0/20).
  3. Selection:
    • Both /25 and /20 matched.
    • The Longest Prefix Match is /25 (25>2025 > 20).
    • Decision: Forward packet via interface eth1 (Direct Delivery).

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 /n/n) 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.

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.

← All Computer Networks modules