Shortest Path Tree SPF and the OSPF Metric Cost

When the LS database is synchronized within an area, the Dijkstra algorithm is run against it in two passes to form the shortest-path (SPF) tree. The first pass against the SPF database forms the branches, or router adjacencies within the area. The second pass adds all leaves or stub networks to the tree. When OSPF builds the tree, it determines the shortest path to each destination based on the sum cost to the destination. The lower the cost is, the more preferred the route is. The cost of a route is the sum of all costs of outgoing interfaces to that destination. Oddly enough, RFC 2328 offers no specific values for cost. Nortel Networks, for example, implements OSPF under RFC 2328 and uses the same formula to generate cost as Cisco Systems. In multivendor environments, take the extra time to see how cost is calculated because it will help OSPF have a consistent view of the entire internetwork.

Cisco routers calculate OSPF cost as (108/BW) rounded down, where BW is the configured or default bandwidth of the interface. Table 12-1 lists the common default OSPF cost settings.

Table 12-1. Default OSPF Interface Cost

Interface Type

Default Cost (108/ BW)

FDDI, ATM, Fast Ethernet, Gigabit Ethernet (> 100 Mbps)


HSSI (45 Mps)


16-Mbps Token Ring


10-Mbps Ethernet


4-Mbps Token Ring


T1 (1.544 Mbps)


DS-0 (64 kbps)


56 kbps


Tunnel (9 kbps)


The default cost values can be overridden with the ip ospf cost 1-65535 interface command. The cost for a route can be viewed with the show ip route command. Recall that the variable behind the administrative distance is the metric cost for the router. Figure 12-5 shows a quick example of how cost is calculated. The route table of the echo router lists the cost for network to be 70. The bandwidth of the T1 plus the 16-MB Token Ring equals 70; 64 + 6 = 70. The route to the Ethernet network has a cost of 80; 64 + 6 + 10.

Figure 12-5. OSPF Cost Calculation

Figure 12-5. OSPF Cost Calculation

Directed Broadcast

Was this article helpful?

0 0

Post a comment