Sub topic 3
Link Costs and Path Metrics
This chapter assumes you know basic IP addressing, what a routing table is, and basic graph terms (nodes, edges, weights, shortest path). It builds on the weighted-graph model from the previous chapter.
What a metric is
A routing protocol needs a way to compare paths. It does this with a metric, a number attached to each link. The cost of a path is the sum of the link costs along it. The protocol installs the path with the lowest total. "Shortest" therefore means "lowest total metric", not "fewest links" or "least distance".
The metric a protocol uses is part of its design. Different protocols measure different things.
| Protocol | Metric | What it measures |
|---|---|---|
| RIP | Hop count | Number of routers crossed. Maximum usable value is 15; 16 means unreachable. |
| OSPF | Cost | Usually derived from interface bandwidth. Lower is better. |
| IS-IS | Default metric | An administratively set value per interface. |
| EIGRP | Composite | Bandwidth and delay by default. |
Hop count versus bandwidth-based cost
Hop count treats every link as equal. A path over two gigabit links ties with a path over two slow serial links. That is rarely what you want.
OSPF commonly computes interface cost as reference bandwidth divided by interface bandwidth. With the Cisco default reference of 100 Mb/s:
- 10 Mb/s Ethernet has cost 10.
- 100 Mb/s Fast Ethernet has cost 1.
- 1 Gb/s has cost 0.1, which rounds up to 1.
A worked example
Router A can reach network N by two paths.
- Path 1: A to B to N, over two links of cost 1 each. Total cost 2.
- Path 2: A to C to D to N, over three links of cost 1 each. Total cost 3.
With hop count and these costs, both metrics agree and path 1 wins. Now suppose the A to B link is a 10 Mb/s link with OSPF cost 10, and the others stay at cost 1. Path 1 costs 11 and path 2 costs 3. OSPF picks path 2, which has more hops. RIP still picks path 1, because it sees only two hops against three.
Properties a good metric needs
- Additive. Path cost must be the sum of link costs, so the algorithms in later chapters can build paths incrementally.
- Non-negative. Dijkstra's algorithm requires non-negative costs.
- Stable. A metric based on live load can change constantly and cause route flapping, where routes switch back and forth. Most protocols avoid load-based metrics for this reason.
Common errors
- Mismatched reference bandwidth between routers, which produces inconsistent costs and unexpected paths.
- Assuming the path with the fewest hops is the one OSPF or IS-IS chooses.
- Forgetting that equal-cost paths may both be installed, giving load sharing.
Exercise
A router has two routes to a network. Route 1 crosses two Gigabit links, each OSPF cost 1. Route 2 crosses one 10 Mb/s link with OSPF cost 10. Which does OSPF choose, and which does RIP choose?
Show answer
OSPF chooses route 1 (total cost 2 against 10). RIP chooses route 2, because it has one hop against two.
Exercise
Why can OSPF with a 100 Mb/s reference bandwidth choose badly on a network that mixes 1 Gb/s and 10 Gb/s links?
Show answer
Both link speeds round to cost 1, so OSPF sees them as equal and cannot prefer the faster path.