FAQ-How Do I Calculate the Cost of an IGP Route

Publication Date:  2015-05-05 Views:  490 Downloads:  0
Issue Description
How Do I Calculate the Cost of an IGP Route?
Solution
IGP protocols include RIP, IS-IS, and OSPF.

Calculating the Cost of a RIP Route

RIP measures the distance from the local end to the destination by hop count. The hop count is also called the metric. RIP defines that the hop count from a router to a directly connected network is 0, and the hop count from a router to a network that can be reached through another router is 1. The hop count increases with the number of routers between the local router and the destination network. To limit the convergence time, RIP defines that the hop count must be an integer ranging from 0 to 15. A hop count of 16 or greater is defined as infinite. That is, the destination network or host is unreachable.

An interface does not add the cost to RIP routes to be sent, but increases the cost by 1 for the received RIP routes. You can run the following commands to change the cost of routes:
  • After you run the rip metricin command, the AR150&AR160&AR200&AR1200&AR2200&AR3200 adds an additional metric to a received route, and then adds the route to the routing table. Then the metric of the route changes in the routing table. This command affects route selection on the local device and other devices.
  • After you run the rip metricout command, the AR150&AR160&AR200&AR1200&AR2200&AR3200 adds an additional metric to a route when advertising the route. The metric of the route, however, does not change in the routing table. This command does not affect route selection on the local device, but affects route selection on other devices.
NOTE:
You can run one of the following commands to set the metric of the imported routes. The following commands are listed in descending order of priority:
  • Run the apply cost command to set the route cost.
  • Run the import-route (RIP) command to set the cost for imported routes.
  • Run the default-cost (RIP) command to set the cost for default routes.
Calculating the Cost of an IS-IS Route
On an IS-IS network, the default cost of an IS-IS interface is 10. The cost of an IS-IS route is the sum of costs of all links between the source device and the destination device.

The link cost of an IS-IS interface can be calculated in the following modes in descending order of priority:
  • Run the isis cost command to set the link cost for a specified IS-IS interface.
  • Run the circuit-cost command to set the link cost for all IS-IS interfaces.
  • Run the auto-cost enable command to enable automatic calculation of the link cost of an interface.
Before using the auto-cost enable command, run the bandwidth-reference command to set the bandwidth reference value. By default, the bandwidth reference value is 100 Mbit/s. The bandwidth reference value takes effect only when the cost type is wide or wide-compatible. The cost of each interface is calculated as follows:
  • Cost of each interface = (Bandwidth reference value/Interface bandwidth) x 10
If the cost type is narrow, narrow-compatible, or compatible, the cost of each interface can be obtained from Table 1.

Table 1 Relationship between the IS-IS interface cost and interface bandwidth 



NOTE:
A Level-1 router in the Level-1 area must communicate with a router outside the Level-1 area through the default route generated on the Level-1-2 router. Therefore, the cost of the route from the Level-1 router to the router outside the Level-1 area is the cost of the route from the Level-1 router to the closest Level-1-2 router.
IS-IS can be configured to specify the cost for the imported route or retain the original cost of the imported route.

Calculating the Cost of the OSPF Route

Similar to the cost of an IS-IS route, the cost of an OSPF route is the sum of costs of all links along the route. By default, the link cost of an OSPF interface is 1.

You can run the ospf cost command to set the cost for a specified OSPF interface. If no interface cost is configured, the system calculates the interface cost using the following formula:
  • Cost of each interface = Bandwidth reference value/Interface bandwidth
The integer portion of the calculation result is taken as the cost of the interface. If the value is smaller than 1, OSPF takes 1 as the interface cost. By default, the bandwidth reference value is 100 Mbit/s. You can change the cost of an OSPF interface by running the bandwidth-reference command to change the bandwidth reference value.

NOTE:
Packets between the stub router or total stub router and a router outside the AS are forwarded through the default route generated on the ABR. Therefore, the cost of the route from the stub router or total stub router to the router outside the AS is the cost of the route from the outside the stub router or total stub router to the closest ABR. Similarly, the cost of the route from the NSSA router to a router in another area or AS is the cost of the route from the NSSA router to the closest ABR or ASBR.

END