Thursday 17 March 2016

Best path selection in different OSPF process ID

Best Path Selection from different OSPF Process ID

When two OSPF processes are configured on a router and if same prefix is received on both OSPF process, it will be treated as like received from two different routing protocol and metric/LSA type will be ignored. Selection will be purely based on administrative distance. If the administrative distance is same, Router appears to select the best path based on lowest process ID.
The below topology has been configured to run OSPF process 1 and 100 on both R1 and R2.


The above statement has been tested by two test cases,
Test Case 1 :
Loopback 2 on R2 is redistributed into process 123 and configured with “network 22.22.22.0 0.0.0.255 area 0 “ into process 1.
R2#show run | sec ospf
router ospf 1
router-id 150.1.2.2
log-adjacency-changes
network 22.22.22.2 0.0.0.0 area 0
network 150.1.12.2 0.0.0.0 area 0
router ospf 123
router-id 2.2.2.2
log-adjacency-changes
redistribute connected subnets route-map CONN2OSPF
network 150.1.21.2 0.0.0.0 area 0
R2#
R2#route-map CONN2OSPF permit 10
match interface Loopback2
R2#
On R1, it can be confirmed that 22.22.22.0/24 is received as Type 1 LSA (router) via process 1 and Type 5 LSA (external) via process 123,

R1#show ip ospf database router 150.1.2.2 | inc Process|22.22
OSPF Router with ID (1.1.1.1) (Process ID 123)
OSPF Router with ID (150.1.1.1) (Process ID 1)
(Link ID) Network/subnet number: 22.22.22.2
R1#show ip ospf database external 22.22.22.0
OSPF Router with ID (1.1.1.1) (Process ID 123)
Type-5 AS External Link States
Routing Bit Set on this LSA
LS age: 1788
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 22.22.22.0 (External Network Number )
Advertising Router: 2.2.2.2
LS Seq Number: 80000001
Checksum: 0x90C5
Length: 36
Network Mask: /24
Metric Type: 2 (Larger than any link state path)
TOS: 0
Metric: 20
Forward Address: 0.0.0.0
External Route Tag: 0
OSPF Router with ID (150.1.1.1) (Process ID 1)
R1#
On R1, it is observed that route from process ID of numerically less number is preferred. In our case, Type 1 LSA from OSPF process 1 is selected and installed in routing table.
Clearing the routing table or clearing OSPF process doesn’t make any difference.

R1#show ip route 22.22.22.0
Routing entry for 22.22.22.0/24
Known via "ospf 1", distance 110, metric 11, type intra area
Last update from 150.1.12.2 on Ethernet0/0.12, 00:00:17 ago
Routing Descriptor Blocks:
* 150.1.12.2, from 150.1.2.2, 00:00:17 ago, via Ethernet0/0.12
Route metric is 11, traffic share count is 1
R1#
R1#clear ip route *
R1#clear ip ospf process
Reset ALL OSPF processes? [no]: yes
R1#show ip route 22.22.22.0
% Network not in table
R1#show ip route 22.22.22.0
Routing entry for 22.22.22.0/24
Known via "ospf 1", distance 110, metric 11, type intra area
Last update from 150.1.12.2 on Ethernet0/0.12, 00:00:03 ago
Routing Descriptor Blocks:
* 150.1.12.2, from 150.1.2.2, 00:00:03 ago, via Ethernet0/0.12
Route metric is 11, traffic share count is 1
R1#
Test Case 2:
Loopback 2 on R2 is redistributed into process 1 and configured with “network 22.22.22.0 0.0.0.255 area 0 “ into process 123.

R2#show run | sec ospf
router ospf 1
router-id 150.1.2.2
log-adjacency-changes
redistribute connected subnets route-map CONN2OSPF
network 150.1.12.2 0.0.0.0 area 0
router ospf 123
router-id 2.2.2.2
log-adjacency-changes
network 22.22.22.2 0.0.0.0 area 0
network 150.1.21.2 0.0.0.0 area 0
R2#
On R1, it can now be observed that 22.22.22.0/24 is received as Type 1 LSA (router) via OSPF process 123 and Type 5 LSA (external) via OSPF process 1 as below,

R1#show ip ospf database router | inc Process|22.22.
OSPF Router with ID (1.1.1.1) (Process ID 123)
(Link ID) Network/subnet number: 22.22.22.0
OSPF Router with ID (150.1.1.1) (Process ID 1)
OSPF Router with ID (10.1.14.1) (Process ID 45)
R1#
R1#show ip ospf database external 22.22.22.0
OSPF Router with ID (1.1.1.1) (Process ID 123)
OSPF Router with ID (150.1.1.1) (Process ID 1)
Type-5 AS External Link States
Routing Bit Set on this LSA
LS age: 117
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 22.22.22.0 (External Network Number )
Advertising Router: 150.1.2.2
LS Seq Number: 80000001
Checksum: 0x5F63
Length: 36
Network Mask: /24
Metric Type: 2 (Larger than any link state path)
TOS: 0
Metric: 20
Forward Address: 0.0.0.0
External Route Tag: 0
OSPF Router with ID (10.1.14.1) (Process ID 45)
R1#
On R1, it is observed that route from process ID of numerically less number is preferred. In our case, Type 5 LSA from OSPF process 1 is selected and installed in routing table.

Clearing the routing table or clearing OSPF process doesn’t make any difference.

R1#show ip route 22.22.22.0
Routing entry for 22.22.22.0/24
Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10
Last update from 150.1.12.2 on Ethernet0/0.12, 00:03:17 ago
Routing Descriptor Blocks:
* 150.1.12.2, from 150.1.2.2, 00:03:17 ago, via Ethernet0/0.12
Route metric is 20, traffic share count is 1
R1#
R1#clear ip route *
R1#clear ip ospf pro
Reset ALL OSPF processes? [no]: yes
R1#
R1#show ip route 22.22.22.0
% Network not in table
R1#show ip route 22.22.22.0
% Network not in table
R1#show ip route 22.22.22.0
Routing entry for 22.22.22.0/24
Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10
Last update from 150.1.12.2 on Ethernet0/0.12, 00:00:00 ago
Routing Descriptor Blocks:
* 150.1.12.2, from 150.1.2.2, 00:00:00 ago, via Ethernet0/0.12
Route metric is 20, traffic share count is 1
R1#
Testcase 3:
Now let us try test case 2 setup, but allow route received from Process ID 123 to be installed in routing table and then advertise same prefix via OSPF process 1.
I have shut the interface connected & Configured for OSPF Process 1 and receive route 22.22.22.0/24 only from Process 123.

R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int e0/0.12
R1(config-subif)#shut
R1(config-subif)#
R1(config-subif)#do sh ip ospf data router | in Proce|22.22.22.
OSPF Router with ID (150.1.1.1) (Process ID 123)
(Link ID) Network/subnet number: 22.22.22.0
OSPF Router with ID (1.1.1.1) (Process ID 1)
OSPF Router with ID (10.1.14.1) (Process ID 45)
R1(config-subif)#do sh ip ospf data external 22.22.22.0
OSPF Router with ID (150.1.1.1) (Process ID 123)
OSPF Router with ID (1.1.1.1) (Process ID 1)
OSPF Router with ID (10.1.14.1) (Process ID 45)
R1(config-subif)#do show ip route 22.22.22.2
Routing entry for 22.22.22.0/24
Known via "ospf 123", distance 110, metric 2, type intra area
Last update from 150.1.21.2 on Ethernet0/0.21, 00:02:55 ago
Routing Descriptor Blocks:
* 150.1.21.2, from 2.2.2.2, 00:02:55 ago, via Ethernet0/0.21
Route metric is 2, traffic share count is 1
R1(config-subif)#
Now, I will un shut the interface and receive route 22.22.22.0/24 from Process 1.

R1(config)#int e0/0.12
R1(config-subif)#no shut
R1(config-subif)#do sh ip ospf data router | inc Proce|22.22.22.
OSPF Router with ID (150.1.1.1) (Process ID 123)
(Link ID) Network/subnet number: 22.22.22.0
OSPF Router with ID (1.1.1.1) (Process ID 1)
OSPF Router with ID (10.1.14.1) (Process ID 45)
R1(config-subif)#do sh ip ospf database external 22.22.22.0
OSPF Router with ID (150.1.1.1) (Process ID 123)
OSPF Router with ID (1.1.1.1) (Process ID 1)
Type-5 AS External Link States
Routing Bit Set on this LSA
LS age: 510
Options: (No TOS-capability, DC)
LS Type: AS External Link
Link State ID: 22.22.22.0 (External Network Number )
Advertising Router: 150.1.2.2
LS Seq Number: 80000013
Checksum: 0x3B75
Length: 36
Network Mask: /24
Metric Type: 2 (Larger than any link state path)
TOS: 0
Metric: 20
Forward Address: 0.0.0.0
External Route Tag: 0
OSPF Router with ID (10.1.14.1) (Process ID 45)
R1(config-subif)#
It still can be observed that OSPF route from Process 123 is not preempted by route from Process 1.

When routing table is cleared, route from Process 1 will be installed.

R1#show ip route 22.22.22.2
Routing entry for 22.22.22.0/24
Known via "ospf 123", distance 110, metric 2, type intra area
Last update from 150.1.21.2 on Ethernet0/0.21, 00:07:18 ago
Routing Descriptor Blocks:
* 150.1.21.2, from 2.2.2.2, 00:07:18 ago, via Ethernet0/0.21
Route metric is 2, traffic share count is 1
R1#clear ip route *
R1#show ip route 22.22.22.2
Routing entry for 22.22.22.0/24
Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 10
Last update from 150.1.12.2 on Ethernet0/0.12, 00:00:01 ago
Routing Descriptor Blocks:
* 150.1.12.2, from 150.1.2.2, 00:00:01 ago, via Ethernet0/0.12
Route metric is 20, traffic share count is 1
R1#
Tried with modifying the router-id and it still it appears to select the route based on lowest process ID.

Conclusion:
The above testing appears that when a router running 2 OSPF processes receives same prefix from different process, it will ignore metric/LSA Type and will only check the Administrative Distance (AD). If both are same, it will install based on lowest process ID.

In case, we receive the prefix via highest process ID and already installed in routing table, it will not be preempted by the lowest process ID until you clear the routing table

If we have for example OSPF, this is how a route gets selected to the RIB(global).
The routers exchange LSAs with each other. Within an area every router has the same
view of the network. These LSAs populate the LSDB. If there are multiple paths to
a destination they will compete with each other unless they are of same type and equal
cost. Intra area is preferred first, then inter and finally external routes. There is no
way of modifying this behaviour. The best route then goes to the OSPF RIB, could be several
if they are equal. From there this route will compete with other routing protocols and the
AD will decide which one is installed. If the OSPF one is best then that one goes to the global
RIB. Then finally the RIB populates FIB with this information and forwarding can ensue.
This is a picture I made that describes the process.
Route_selection

IP switching per-packet and per-destination

IP switching is the internal mechanism used by Cisco IOS to forward packets through a router. Available mechanisms include process switching, fast switching, and Cisco Express Forwarding. Depending on which of the three mechanisms is used to switch the majority of packets, the overall system performance and load balancing is affected.
IP switching mechanisms support two general modes, per-packet and per-destination. The following table outlines the advantages and disadvantages of both modes.
Per-Destination Per-Packet
IP Switching Mechanism Fast switching and Cisco Express Forwarding per-destination. Process switching and Cisco Express Forwarding per-packet.
Advantages With fast switching, packets for a given destination are guaranteed to take the same path even if multiple paths are available. With Cisco Express Forwarding switching, packets for a given source-destination host pair are guaranteed to take the same path, even if multiple paths are available. Traffic destined for different pairs tend to take different paths. Path utilization with per-packet load balancing is good because per-packet load balancing allows the router to send successive data packets over paths without regard to individual hosts or user sessions. It uses the round-robin method to determine which path each packet takes to the destination
Disadvantages With fast switching, per destination switching may result in unequal load sharing because packets to one destination always follow the same path. Cisco Express Forwarding switching may result in unequal distribution with a small number of source-destination pairs. Per-destination load balancing depends on the statistical distribution of traffic; load sharing becomes more effective as the number of source-destination pairs increase. Packets for a given source-destination host pair might take different paths, which could introduce reordering of packets. This is not recommended for Voice over IP (VoIP) and other flows that require in-sequence delivery.