Data Communication and Networking

Chapter 8
Routing and Internetworking

Diploma in Computer Architecture and Networking
Data Communication and Networking   •   Diploma

Routing and Internetworking

Introduction

A computer network may contain many interconnected local networks rather than a single shared medium. Routing is the process of selecting a path for packets between different networks, while forwarding is the local action of sending a received packet through the appropriate interface toward its destination. Internetworking extends this idea by joining independent networks through routers that operate at the network layer.

Routing is essential because hosts normally know only their local network and a small set of gateways. Routers must therefore learn or be configured with reachability information. This chapter develops the principles of packet forwarding, static and default routing, and three important routing approaches: distance-vector routing, link-state routing, and path-vector routing. RIP, OSPF, and BGP provide practical examples of these approaches.

Learning Objectives

After studying this chapter, you should be able to:

  • distinguish forwarding from routing;
  • interpret routing tables and apply longest-prefix matching;
  • configure and verify static and default routes;
  • explain distance-vector, link-state, and path-vector routing;
  • compare RIP, OSPF, and BGP;
  • analyse routing failures, loops, convergence, and route security;
  • select appropriate routing methods for small, enterprise, and inter-domain networks.

1. Internetworking and the Role of a Router

A router connects separate IP networks. It receives a frame on one interface, removes the data-link header, examines the destination IP address in the packet, selects a next hop, decreases the packet's time-to-live (TTL), recalculates the IPv4 header checksum when applicable, encapsulates the packet in a new data-link frame, and transmits it through the selected interface.

A router does not normally forward a packet merely because it arrived on a particular interface. It consults a forwarding information base (FIB), usually derived from a routing information base (RIB). The RIB contains routes learned from connected interfaces, static configuration, or routing protocols. The FIB is optimized for rapid packet lookup.

A router's major functions are:

  1. Path determination: learning or calculating routes.
  2. Packet forwarding: selecting an outgoing interface and next hop.
  3. Packet lifetime control: decrementing TTL in IPv4 or Hop Limit in IPv6.
  4. Error reporting and control: often using ICMP messages.
  5. Policy enforcement: applying access controls, route filters, and quality-of-service decisions.

Switches primarily forward frames within a local network using MAC addresses. Routers forward packets between networks using network-layer addresses. In practice, multilayer switches may perform both functions.

2. Packet Forwarding and Routing Tables

A routing table commonly contains the destination prefix, prefix length, next-hop address, outgoing interface, route source, and metric. For example:

DestinationPrefix lengthNext hopInterfaceSource
192.168.10.0/24directly connectedG0/0Connected
10.20.0.0/16192.168.10.2G0/1Static
0.0.0.0/0192.168.10.1G0/1Static default

The destination prefix is written as an address followed by a slash and the number of network bits. A /24 IPv4 prefix, for example, has 24 network bits and 8 host bits.

Longest-Prefix Matching

A destination may match several routes. The router selects the matching route with the greatest prefix length, called the longest-prefix match. If a packet is addressed to 10.20.5.7 and the table includes 10.0.0.0/8, 10.20.0.0/16, and 10.20.5.0/24, the /24 route is selected because it is the most specific.

The general selection rule is:

Select route R such that R matches destination D and prefixlength(R) is maximal

This is a selection rule rather than a performance equation. It assumes that the routes are valid and that the forwarding system has no overriding policy or administrative decision.

If multiple routes have the same prefix length, the router may compare administrative distance, route preference, metric, or equal-cost multipath rules, depending on the implementation. Administrative distance compares route sources; a metric compares alternatives within a routing protocol. These concepts must not be confused.

Forwarding Example

Suppose a router has these routes:

  • 172.16.0.0/12 via interface A
  • 172.16.32.0/20 via interface B
  • 172.16.40.0/24 via interface C
  • 0.0.0.0/0 via interface D

A packet for 172.16.40.18 matches all three specific prefixes and the default route, but it is sent through interface C because /24 is the longest match. A packet for 172.16.50.9 matches the /12 and default route, so interface A is selected. A packet for 192.0.2.8 matches only the default route and is sent through interface D.

Packet forwarding through a router Incoming packetDestination IP RouterLongest-prefixlookup in FIBTTL − 1New frame Specific route172.16.40.0/24 Less specificor default route
Packet forwarding through a router using a routing table
Figure: Packet forwarding through a router using a routing table

Figure: A router performs a forwarding-table lookup and sends the packet through the selected outgoing path.

3. Static and Default Routing

Static Routes

A static route is manually configured by an administrator. It identifies a destination prefix and either a next-hop address, an outgoing interface, or both. A generic IPv4 command on many Cisco IOS-like platforms is:

ip route destination-network subnet-mask next-hop-address

For example:

ip route 10.20.0.0 255.255.0.0 192.168.1.2

This tells the router that traffic for 10.20.0.0/16 should be sent to next hop 192.168.1.2. The next hop must be reachable through a directly connected network, unless the platform supports recursive resolution through another valid route.

A directly attached static route may be written as:

ip route 10.30.0.0 255.255.255.0 GigabitEthernet0/1

Point-to-point interfaces are well suited to an interface-only route. On multi-access Ethernet, specifying the next-hop address is usually safer because it avoids unnecessary ambiguity about frame delivery.

A static route is appropriate when the topology is small, stable, or intentionally controlled; for a stub network with one exit; for a backup route with a higher administrative preference; or when a security policy requires explicit paths. Its weaknesses are manual maintenance, poor scalability, and slow reaction to failures unless tracking mechanisms are added.

Default Routes

A default route matches every IPv4 destination not matched by a more specific route:

ip route 0.0.0.0 0.0.0.0 192.168.1.1

The equivalent IPv6 default route is ::/0. Default routes are common in branch offices and hosts with one upstream provider. They reduce table size but can conceal failures or create routing loops if the upstream path is not actually usable.

Verification and Troubleshooting

Useful verification tasks include:

  • inspect the routing table and confirm the route source;
  • test next-hop reachability with ping;
  • use traceroute or tracert to observe the forwarding path;
  • inspect the FIB where the platform distinguishes it from the RIB;
  • check interface status, subnet masks, and ARP or Neighbor Discovery;
  • examine route advertisements and administrative filters;
  • verify that return traffic has a valid route.

A route may appear in the table but still fail operationally because the next hop is down, an access-control list blocks the packet, the return route is missing, or a link-layer resolution process fails.

4. Routing Metrics, Convergence, and Administrative Preference

A routing protocol needs a method for comparing paths. Metrics may represent hop count, cost, bandwidth, delay, reliability, or a policy value. A lower metric is preferred in some protocols, but not all; BGP, for example, uses an ordered collection of attributes and policy decisions rather than a single universal distance value.

Convergence is the process by which routers reach a consistent view after a topology change. Fast convergence reduces disruption but may require more processing, bandwidth, and protocol complexity. During convergence, temporary loops, black holes, or inconsistent paths can occur.

A router may learn the same prefix from several sources. It first applies implementation-specific route preference, often called administrative distance in IPv4 teaching environments, and then compares metrics among routes from the selected source. Exact preference values are vendor-specific and should not be assumed to be universal.

5. Distance-Vector Routing and RIP

Distance-vector protocols tell neighbours the destinations a router can reach and the distance to those destinations. Each router does not possess a complete map of the topology. It relies on information received from neighbours and periodically improves its estimates.

The conceptual update rule is based on the Bellman–Ford principle:

dx(y) = minv ∈ N(x) [c(x,v) + dv(y)]

Here, dx(y) is router x's estimated distance to destination y; N(x) is the set of neighbours of x; c(x,v) is the cost from x to neighbour v; and dv(y) is neighbour v's advertised distance to y. The rule assumes additive path costs and information that is sufficiently current. It does not by itself prevent routing loops.

RIP is a classic distance-vector protocol. Important characteristics include:

  • metric based primarily on hop count;
  • maximum usable distance of 15 hops, with 16 representing infinity;
  • periodic route advertisements;
  • support for route timers and triggered updates;
  • use of split horizon, route poisoning, and hold-down techniques to reduce loops.

RIP is simple and useful for teaching and small legacy networks, but hop count is a weak measure of quality, convergence can be slow, and the 15-hop limit makes it unsuitable for large networks. RIPv2 supports classless routing and carries subnet-mask information; RIPv1 does not support classless advertisements in the same way.

The classic distance-vector problem is count to infinity. After a failure, neighbouring routers may incorrectly advertise routes to one another, gradually increasing the metric until an infinity value is reached. Split horizon prevents a router from advertising a route back through the interface from which it learned that route. Poison reverse advertises it back with an infinite metric, providing stronger information in some cases.

6. Link-State Routing and OSPF

A link-state protocol distributes information about links and their states to routers in a routing domain. Each router builds a link-state database (LSDB), conceptually a topology map, and independently calculates shortest paths. OSPF uses Dijkstra's shortest-path-first algorithm.

At a high level, Dijkstra's method is:

  1. place the local router in the confirmed set with distance zero;
  2. examine adjacent unconfirmed nodes;
  3. assign each the least currently known distance;
  4. confirm the unconfirmed node with the smallest distance;
  5. repeat until the required destinations are processed.

The path cost is additive:

C(path) = ∑ ci

where ci is the cost of link i and the sum applies to every link in the path. The calculation assumes that link costs are defined consistently and that the topology database is synchronized.

OSPF features include:

  • neighbour discovery using Hello messages;
  • link-state advertisements (LSAs);
  • a link-state database within an area;
  • shortest-path calculation;
  • hierarchical areas, with Area 0 acting as the backbone in conventional designs;
  • equal-cost multipath support;
  • authentication options and classless routing;
  • route summarization at suitable boundaries.

OSPF cost is commonly related to a reference bandwidth, but the precise formula and default reference value depend on the implementation and configuration. Administrators should explicitly verify cost settings rather than assume that a link's physical speed alone determines the route.

OSPF converges faster and scales better than RIP in enterprise networks, but it requires more memory, processing, planning, and operational expertise. A poorly designed area structure or inconsistent summarization can make troubleshooting difficult.

7. Path-Vector Routing and BGP

Path-vector routing advertises reachability together with path information and policy attributes. BGP is the principal inter-domain routing protocol and is used between autonomous systems (ASes), which are networks administered under a common routing policy.

BGP does not simply select the path with the fewest routers. It evaluates attributes according to policy and implementation rules. Common attributes include:

  • AS_PATH: sequence of autonomous systems traversed; also supports loop detection;
  • NEXT_HOP: next router used to reach the advertised prefix;
  • LOCAL_PREF: preference within an AS, commonly used to select an exit path;
  • MED: a suggestion about preferred entry into an AS, subject to policy;
  • COMMUNITY: a tag used to apply routing policy;
  • ORIGIN: information about how the route entered BGP.

BGP sessions use TCP, conventionally port 179. eBGP operates between autonomous systems, while iBGP distributes BGP information within one autonomous system. BGP's policy-driven design supports the global Internet but also means that configuration errors can have wide consequences.

BGP route selection is implementation-dependent, but a simplified decision process may consider highest local preference, shortest AS_PATH, preferred origin type, lowest MED under applicable conditions, eBGP over iBGP, and an internal tie-break sequence. This is a conceptual summary, not a substitute for the specific vendor's decision algorithm.

BGP's strengths are scalability, policy control, and inter-domain autonomy. Its weaknesses include configuration complexity, slower convergence than many interior protocols, and serious exposure to route leaks and prefix hijacking if advertisements are not validated.

8. Comparison of Routing Approaches

FeatureDistance-vectorLink-statePath-vector
Main knowledgeNeighbour reportsTopology databaseReachability plus path and policy
Typical algorithmBellman–Ford principleDijkstra SPFOrdered policy decisions
ExampleRIPOSPFBGP
Typical scopeSmall interior networksEnterprise interior networksInter-domain routing
Loop controlSplit horizon, timersConsistent LSDB and SPFAS_PATH and policy
StrengthSimplicityFast, structured convergenceScalability and policy
LimitationSlow convergence and hop limitGreater complexityPolicy complexity and security risk

The categories describe dominant behaviour, not every implementation detail. Modern protocols may include features associated with more than one conceptual category.

9. Applied Case: A Branch Network with Two Sites

This is an illustrative case. A college has a main campus and a small remote learning centre. The centre has one connection to the campus router and does not provide transit service to any other site. The campus uses OSPF internally, while the centre initially uses static routing.

Problem

The centre's staff can reach local services but cannot reach the campus learning-management system. The centre router has a connected route for its local LAN and no route for the campus network.

Analysis

The administrator identifies the campus LAN as 10.50.0.0/16 and the point-to-point next hop as 192.0.2.1. A static route is suitable because the centre is a stub with one stable exit. The campus router must also have a return route to the centre LAN, 10.60.10.0/24.

Approach

On the centre router:

ip route 10.50.0.0 255.255.0.0 192.0.2.1

On the campus router:

ip route 10.60.10.0 255.255.255.0 192.0.2.2

The administrator verifies interface status, pings the next hop, tests the remote destination, and uses traceroute. If the campus already advertises 10.60.10.0/24 through OSPF, the manually configured return route might be unnecessary; however, route preference and redistribution must be checked before removing it.

Outcome

Traffic reaches the campus after the forward route is installed, and return traffic reaches the centre after the reverse route is installed. Later, a second campus connection is added. At that point, static routing becomes less attractive, and OSPF or tracked floating static routes may provide better resilience.

Learning Points

A route must exist in both directions for ordinary bidirectional communication. Static routing is effective for simple stable topologies, but growth and redundancy justify dynamic routing. Verification must test the complete path, not only the presence of a routing-table entry.

10. Design, Security, and Operational Issues

Good routing design begins with an accurate addressing plan, clear ownership of prefixes, and deliberate redundancy. Summarization reduces table size and limits the spread of instability, but an incorrect summary can attract traffic to a router that cannot deliver it. Default routes should be used only where their forwarding meaning is understood.

Routing security requires authentication where supported, strict route filtering, prefix limits, maximum-prefix protection, and monitoring for unexpected changes. BGP deployments should use route-origin validation based on the Resource Public Key Infrastructure (RPKI) where available. Operators should distinguish route-origin validation from complete path validation: a valid origin authorization does not prove that every AS_PATH hop is correct.

Ethically and operationally, administrators should avoid announcements that intentionally or negligently misdirect traffic, expose private data, or create denial-of-service conditions. Logs and routing telemetry may reveal organizational relationships and traffic patterns, so access to them should be controlled. Change management, documented rollback procedures, and least-privilege administration reduce the effect of mistakes.

Contemporary networks often combine protocols: OSPF or another interior gateway protocol within an organization, BGP at provider or interconnection boundaries, and static or default routes at simple edges. Software-defined networking may separate the control plane from forwarding devices, but the fundamental ideas—reachability, next hops, policy, and failure handling—remain applicable. Automation can improve consistency, yet an incorrect template can distribute an error rapidly; automated validation and staged deployment are therefore essential.

Best-Practice Checklist

  • Use clear, non-overlapping address plans.
  • Prefer the most specific valid route through longest-prefix matching.
  • Use static routes for stable, simple, or intentionally controlled paths.
  • Use dynamic routing when topology size or change makes manual configuration unsafe.
  • Document next hops, route ownership, and summarization boundaries.
  • Verify both forward and return paths.
  • Apply authentication, filtering, prefix limits, and monitoring.
  • Test failure and recovery behaviour, not only normal operation.
  • Match protocol complexity to operational capability.

Chapter Summary

Routing determines paths between networks, while forwarding applies a routing decision to each packet. Routers use forwarding tables and longest-prefix matching, with more specific prefixes preferred over less specific prefixes and the default route used only when no more specific match exists. Static routes provide precise manual control, and default routes efficiently represent a single upstream path, but both require careful verification and maintenance.

Distance-vector protocols such as RIP exchange destination distances with neighbours and are simple but limited by convergence behaviour and hop count. Link-state protocols such as OSPF distribute topology information and calculate shortest paths, providing stronger scalability within an autonomous system. Path-vector BGP carries reachability, AS paths, and policy attributes between autonomous systems, enabling Internet-scale interconnection but requiring disciplined security and policy management. Effective routing practice combines sound addressing, appropriate protocol selection, redundancy, filtering, monitoring, and two-way path verification.

Key Terms

Autonomous system: A network under a common administrative routing policy.

BGP: A path-vector protocol used primarily for inter-domain routing.

Convergence: The process by which routers reach consistent routing information after a change.

Default route: A route, such as 0.0.0.0/0, used when no more specific route matches.

Distance-vector: A routing approach based on neighbour-advertised distances to destinations.

FIB: Forwarding Information Base used for rapid packet forwarding.

Forwarding: The local act of sending a packet through a selected interface and next hop.

Inter-networking: Connecting distinct networks so that they can exchange packets.

Link-state: A routing approach in which routers build a topology database from link information.

Longest-prefix match: Selection of the matching route with the greatest prefix length.

LSA: Link-State Advertisement used by OSPF to distribute topology information.

Metric: A value or attribute used to compare routes.

Next hop: The immediate router or interface to which a packet is sent.

OSPF: A link-state interior gateway protocol using shortest-path computation.

Path-vector: A routing approach that advertises reachability together with path and policy information.

RIB: Routing Information Base containing learned and configured routes.

RIP: A distance-vector protocol using hop count as its principal metric.

Route summarization: Representing multiple specific prefixes with a larger aggregate prefix.

TTL: IPv4 time-to-live field that limits packet lifetime in hops.

Review Questions

Short Answer Questions

  1. What is the difference between routing and forwarding?
  2. What does longest-prefix matching mean?
  3. State one suitable use and one limitation of a static route.
  4. What is the maximum usable hop-count metric in traditional RIP?
  5. Name two important BGP path or policy attributes.

Long Answer Questions

  1. Explain the steps a router performs when forwarding an IPv4 packet.
  2. Compare distance-vector and link-state routing in terms of knowledge, algorithms, convergence, and scalability.
  3. Explain how static routes and default routes can be configured and verified in a branch network.
  4. Describe OSPF areas, LSAs, the LSDB, and shortest-path calculation.
  5. Explain why BGP is appropriate for inter-domain routing and why it requires strong policy controls.

Analytical / Application Questions

  1. A table contains routes 10.0.0.0/8, 10.20.0.0/16, and 10.20.5.0/24. Which route forwards a packet to 10.20.5.9, and why?
  2. A branch has one WAN connection today but will receive a second connection next year. Recommend a routing approach for each stage and justify the transition.
  3. A BGP router receives a more-specific prefix from an unexpected neighbour. Identify two operational or security checks that should occur before accepting the route.

Multiple Choice Questions with Answers

Question 1

A router has routes 10.0.0.0/8, 10.20.0.0/16, and 10.20.5.0/24. Which route is selected for destination 10.20.5.9?

A. 10.0.0.0/8

B. 10.20.0.0/16

C. 10.20.5.0/24

D. The default route

Correct Answer: C. 10.20.5.0/24

Question 2

What is the primary function of a forwarding information base (FIB)?

A. Store user passwords

B. Provide optimized packet lookup information

C. Assign MAC addresses to hosts

D. Encrypt every packet

Correct Answer: B. Provide optimized packet lookup information

Question 3

Which command represents an IPv4 default static route to next hop 192.168.1.1?

A. ip route 255.255.255.255 0.0.0.0 192.168.1.1

B. ip route 0.0.0.0 0.0.0.0 192.168.1.1

C. ip default-network 255.255.255.255

D. route ip 192.168.1.1 default

Correct Answer: B. ip route 0.0.0.0 0.0.0.0 192.168.1.1

Question 4

Which protocol is a classic distance-vector protocol?

A. RIP

B. OSPF

C. BGP

D. Ethernet

Correct Answer: A. RIP

Question 5

What is the traditional maximum usable hop-count metric in RIP?

A. 8

B. 15

C. 16

D. 255

Correct Answer: B. 15

Question 6

Which database is central to OSPF's view of network topology?

A. ARP cache

B. MAC address table

C. Link-state database

D. DNS zone file

Correct Answer: C. Link-state database

Question 7

Which BGP attribute helps detect routing loops between autonomous systems?

A. AS_PATH

B. TTL

C. Subnet mask

D. ARP opcode

Correct Answer: A. AS_PATH

Question 8

What does convergence describe in routing?

A. Encrypting a packet payload

B. Routers reaching consistent information after a change

C. Increasing Ethernet frame size

D. Assigning hostnames to interfaces

Correct Answer: B. Routers reaching consistent information after a change

Question 9

A branch has one stable upstream connection and no transit role. Which solution is generally simplest?

A. A static route or default route

B. A full-mesh BGP design

C. An OSPF backbone with many areas

D. A separate link-state database for every host

Correct Answer: A. A static route or default route

Question 10

Why must a routing design normally include a return route?

A. Packets cannot contain destination addresses

B. Bidirectional communication requires the response to reach the source

C. Routers forward only broadcast frames

D. A return route increases TTL

Correct Answer: B. Bidirectional communication requires the response to reach the source

Data Communication and Networking
Chapter 8 of 14