Search This Blog

Thursday, November 4, 2010

OSPF Cost

Cost is the OSPF metric, expressed as an unsigned 16-bit integer in the range of 1 to 65535. Cisco uses a default cost of 100,000,000/BW (in bps), expressed in whole numbers. For example the cost of a serial link 1.5Mbps will be= 100,000,000\1,540,000=64, a cost of a Fast Ethernet link will be= 100,000,000\100,000,000=1.

The default reference bandwidth for OSPF is 10^8 bps or 100Mbit. Increasing the reference-bandwidth allows a more granular OSPF design. If changed it should be changed on all routers in the OSPF domain.

Link costs for individual intra-area LSAs are represented by a 16 bit unsigned integer which gives an upper bound of 2^16-1 (65535). The OSPF standard poses no limit on intra-area total path metric, though metrics of inter-area summary and external paths are limited by space in those LSAs of 24 bits, giving you max metric 2^24-1(16,777,215). Most implementations (including JunOS and IOS) are using 32 bit unsigned for total path cost, which gives you 2^32-1 (4,294,967,295)

Autocost

Due to the fact that IOS router uses 100mbps as a reference for cost calculation, a problem can occur when connecting giga-ethernet interfaces, for this particular reason we can change the reference to 1000mbps by using the command:

R1(config-router)#auto-cost reference-bandwidth 1000

The reference value is presented in Mbps units, so the default reference value is 100.

Reference= Cost X Bandwidth

Cost = Reference_BW/ Interface_BW

Cost can be modified by:

Interface bandwidth

Interface ip ospf cost

Process auto-cost

Process neighbor w.x.y.z cost

OSPF calculate loopback interface as 8Gb interface with a cost of 1.

OSPF Uses bandwidth based cost, calculating each link cost and then runs SPF over the tree in order to choose the Shortest-path from the root (the router itself) to the destination. Calculating the total cost for each link occurs from top to down.

Using the following LAB:

R1 will sees 2 equal path to R4:

R1#sh ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2

i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

ia - IS-IS inter area, * - candidate default, U - per-user static route

o - ODR, P - periodic downloaded static route


Gateway of last resort is not set


1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/32 is subnetted, 1 subnets

O 2.2.2.2 [110/2] via 10.1.123.2, 00:16:56, FastEthernet0/0

O 192.168.44.0/24 [110/3] via 10.1.123.3, 00:16:56, FastEthernet0/0

[110/3] via 10.1.123.2, 00:16:56, FastEthernet0/0

3.0.0.0/32 is subnetted, 1 subnets

O 3.3.3.3 [110/2] via 10.1.123.3, 00:16:56, FastEthernet0/0

4.0.0.0/24 is subnetted, 1 subnets

O 4.4.4.0 [110/3] via 10.1.123.3, 00:16:56, FastEthernet0/0

[110/3] via 10.1.123.2, 00:16:56, FastEthernet0/0

C 192.168.11.0/24 is directly connected, Loopback2

O 192.168.4.0/24 [110/3] via 10.1.123.3, 00:16:56, FastEthernet0/0

[110/3] via 10.1.123.2, 00:16:56, FastEthernet0/0

10.0.0.0/24 is subnetted, 3 subnets

O 10.1.24.0 [110/2] via 10.1.123.2, 00:16:57, FastEthernet0/0

O 10.1.34.0 [110/2] via 10.1.123.3, 00:16:57, FastEthernet0/0

C 10.1.123.0 is directly connected, FastEthernet0/0

C 192.168.1.0/24 is directly connected, Loopback1

When I configured R2(config-if)#ip ospf cost 5 on R2 interface f0/0 (represented by Link B), R4 routing table has changed and now had only 1 route to R1 networks while R1 still had 2 equal cost paths to R4 networks.

The way R1 is calculating the cost to R4 includes Links A,D,C and E while R4 calculates F,E,C and B. Changing the cost is local significant to the configured router only and doesn't affect other routers calculations.


1 comment: