In the ospf protocol, each interface has a cost value calculated by default formula based on its rate. The ospf protocol uses the cost value to determine the optimal path to the destination, if multiple paths reach the destination, the path with the lowest cost value is preferred. The Cost value is the sum of the cost values of all the interfaces that forward data along the destination. The following is an experiment to verify it.
The topology is as follows:
The route table on RT11 is as follows:
Rt11 # sh ip route
Codes: C-connected, S-static, R-RIP, M-mobile, B-BGP
D-OSPF, EX-VPN 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, su-IS summary, L1-IS-level-1, L2-IS level-2
Ia-IS inter area, *-candidate default, U-per-user static route
O-ODR, P-periodic downloaded static route
Gateway of last resort is not set
172.19.0.0/24 is subnetted, 1 subnets
O 172.19.10.0 [110/3] via 10.1.1.6, 00:00:12, FastEthernet2/0
10.0.0.0/30 is subnetted, 2 subnets
O 10.3.3.4 [110/2] via 10.1.1.6, 00:00:12, FastEthernet2/0
C 10.1.1.4 is directly connected, FastEthernet2/0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
The measurement value of 172.19.10.0 on this vro is 3. The calculation method is as follows:
Cost Value of f2/0 of the data forwarding interface of RT11 "1" + cost value of f2/0 of the data forwarding interface of RT12 "1" + cost value of vlan1 of the Target Interface of sw2 "1 ""= 3.
To prove that the cost value of the RT12 data inbound interface f0/0 is changed to 50, the cost value of the data forwarding interface f2/0 is changed to 60, and the cost value of the vlan1 of sw2 is changed to 70, let's take a look at the route table:
Rt11 # sh ip route
Codes: C-connected, S-static, R-RIP, M-mobile, B-BGP
D-OSPF, EX-VPN 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, su-IS summary, L1-IS-level-1, L2-IS level-2
Ia-IS inter area, *-candidate default, U-per-user static route
O-ODR, P-periodic downloaded static route
Gateway of last resort is not set
172.19.0.0/24 is subnetted, 1 subnets
O 172.19.10.0 [110/131] via 10.1.1.6, 00:00:00, FastEthernet2/0
10.0.0.0/30 is subnetted, 2 subnets
O 10.3.3.4 [110/61] via 10.1.1.6, 00:00:00, FastEthernet2/0
C 10.1.1.4 is directly connected, FastEthernet2/0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
The metric value of 172.19.10.0 is 131, which is calculated from 1 + 60 + 70. The cost value of the data inflow interface f0/0 on RT12 is not involved in the calculation.
Then let's look at the route table from SW1:
Sw2 # sh ip route
Codes: C-connected, S-static, R-RIP, M-mobile, B-BGP
D-OSPF, EX-VPN 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, su-IS summary, L1-IS-level-1, L2-IS level-2
Ia-IS inter area, *-candidate default, U-per-user static route
O-ODR, P-periodic downloaded static route
Gateway of last resort is not set
172.19.0.0/24 is subnetted, 1 subnets
C 172.19.10.0 is directly connected, Vlan1
10.0.0.0/30 is subnetted, 2 subnets
C 10.3.3.4 is directly connected, Vlan2
O 10.1.1.4 [110/51] via 10.3.3.5, 00:00:00, Vlan2
O 192.168.1.0/24 [110/52] via 10.3.3.5, 00:00:00, Vlan2
O 192.168.2.0/24 [110/52] via 10.3.3.5, 00:00:00, Vlan2
The calculation of the medium value of ospf protocol is verified from this route table. The measurement value from sw1 to 192.168.1.0 is calculated as follows:
The cost value of the Sw1 data forwarding interface vlan2 is "1" + the cost value of the RT12 data forwarding interface f0/0 is "50" + the cost value of the RT11 target interface is "1" = 52
In this case, how does one calculate the metric value for the re-release route? On RT11, change the two direct connection networks 192.168.1.0 and 192.168.2.0 to re-release:
Configuration command:
Access-list 10 permit 192.168.1.0
Access-list 20 permit 192.168.2.0
!
Route-map setmetric permit 10
Match ip address 10
Set metric 5
!
Route-map setmetric permit 20
Match ip address 20
Set metric 20
Router ospf 100
Log-adjacency-changes
Redistribute connected subnets route-map setmetric
In this way, change the measurement value of 192.168.1.0 to 5 and the measurement value of 192.168.2.0 to 20. view the route table on rt12 and SW1:
Rt12 # sh ip route
Codes: C-connected, S-static, R-RIP, M-mobile, B-BGP
D-OSPF, EX-VPN 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, su-IS summary, L1-IS-level-1, L2-IS level-2
Ia-IS inter area, *-candidate default, U-per-user static route
O-ODR, P-periodic downloaded static route
Gateway of last resort is not set
172.19.0.0/24 is subnetted, 1 subnets
O 172.19.10.0 [110/130] via 10.3.3.6, 00:04:08, FastEthernet2/0
10.0.0.0/30 is subnetted, 2 subnets
C 10.3.3.4 is directly connected, FastEthernet2/0
C 10.1.1.4 is directly connected, FastEthernet0/0
O E2 192.168.1.0/24 [110/5] via 10.1.1.5, 00:04:08, FastEthernet0/0
O E2 192.168.2.0/24 [110/20] via 10.1.1.5, 00:04:08, FastEthernet0/0
Sw2 # sh ip route
Codes: C-connected, S-static, R-RIP, M-mobile, B-BGP
D-OSPF, EX-VPN 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, su-IS summary, L1-IS-level-1, L2-IS level-2
Ia-IS inter area, *-candidate default, U-per-user static route
O-ODR, P-periodic downloaded static route
Gateway of last resort is not set
172.19.0.0/24 is subnetted, 1 subnets
C 172.19.10.0 is directly connected, Vlan1
10.0.0.0/30 is subnetted, 2 subnets
C 10.3.3.4 is directly connected, Vlan2
O 10.1.1.4 [110/51] via 10.3.3.5, 00:04:32, Vlan2
O E2 192.168.1.0/24 [110/5] via 10.3.3.5, 00:04:32, Vlan2
O E2 192.168.2.0/24 [110/20] via 10.3.3.5, 00:04:32, Vlan2
In the routing table of RT12 and SW1, the metric values that reach 192.168.1.0 and 192.168.2.0 are consistent with the metric values specified during republishing, it indicates that the metric value at the time of re-release is irrelevant to the cost value of the interface.
After learning about cost value calculation, you can modify the cost value in a redundant PATH environment to control the data forwarding path.
This article is from the "alive" blog