Wednesday, April 30, 2014

OSPF Path Selection

Lessons Learned:
-----------------------------------------------------       
OSPF Path Selection
Once databases are synchronized, path selection begins.
Each router’s LSAs include a “cost” attribute for each described link
Best path to that link is the lowest end-to-end cost

Cisco’s implementation uses bandwidth based cost, But per RFC it is arbitrary.
--default cisco cost = 100Mbps / Link bandwidth
--reference bandwidth can be modified to accommodate higher speeds links (e.g Gigabit Ethernet)
This is with the reference bandwidth command under the process.
----------------------------------------------------- 

OSPF Path Selection Order:

Per RFC, OSPF path selection state machine prefers….
-intra area routes (O) – Will always choose these routes over all others, despite the cost of the link.
-Inter area routes (O IA)
-External Tyoe 1 (E1)
-External Type 2 (E2)
-NSSA Type 1 (N1)
-NSSA Type 2 (N2)
Cannot be modified with metric or distance – because we need to make sure all the devices come up with the same
Shorten path tree based on the link state database.

Note we will still use the longest match in the routing table to figure out where the traffic is going to go. If there is equal longest matches – one intra and one Inter area routes, OSPF will still always choose the Intra area. Regardless of metric or distance.


Path selection Topology:
-------------------------------------

















Sh ip ospf int bri
R2#sh ip ospf interface brief
Interface    PID   Area            IP Address/Mask    Cost  State Nbrs F/C
Gi0/0        10    0               192.168.24.2/24    1     DR    1/1
Fa1/0        10    0               192.168.12.2/24    1     BDR   1/1
Fa1/1        10    5               10.1.5.2/24        1     DR    1/1
R2#

We see here that I have 3 interfaces running OSPF. We can also see that int FA1/1 is in Are 5.
This means that  R2 is not an area border router. It should now be generating two separate router LSA’s.
One for area 5 and one for are 0.

Additionally any routes that are leaned in the are 5 links – those routes will be sent into Area 0 using the LSA Type 3 or Network summary LSA. This is considered a summary because we’re not summarizing  the NLRI – the actual prefixes – we are summarizing the topology information.

So when we do Intra area lookups, we’re going the run SPF for the destination. For Inter area lookups, between the area’s. we will use the OSPF cost derived to the are border router PLUS whatever values they are reporting in with the summary LSA.

Now let’s look at the Database.

============== 
R2#sh ip ospf database

            OSPF Router with ID (192.168.24.2) (Process ID 10) – For the part we can see all the routers in Area 0 and their respective links in area 0


                Router Link States (Area 0)

Link ID         ADV Router      Age         Seq#       Checksum Link count
10.1.11.1       10.1.11.1       434         0x80000009 0x0006E4 3
192.168.24.2    192.168.24.2    374         0x80000009 0x0021E5 3
192.168.34.3    192.168.34.3    426         0x80000008 0x00666E 3
192.168.34.4    192.168.34.4    366         0x80000007 0x00227C 4

                Net Link States (Area 0) If we did not see this link state – it would mean that there is no designated router on these segments (ex: all P2P links) These are the DR’s.

Link ID         ADV Router      Age         Seq#       Checksum
192.168.12.1    10.1.11.1       470         0x80000001 0x00EA27
192.168.13.1    10.1.11.1       434         0x80000001 0x007095
192.168.24.2    192.168.24.2    374         0x80000001 0x00AB74

                Summary Net Link States (Area 0) – These are the Inter area routes that are generated by the Area Border routers. These are the LSA type 3’s – they are used to describe the Inter are routes.

Link ID         ADV Router      Age         Seq#       Checksum
6.6.6.0         192.168.34.4    218         0x80000003 0x00ADE9
7.7.7.0         192.168.34.3    141         0x80000001 0x00EDA0
10.1.5.0        192.168.24.2    459         0x80000003 0x00099D
10.1.6.0        192.168.34.4    366         0x80000002 0x00ADEC
10.1.7.0        192.168.34.3    425         0x80000003 0x00018F

                Router Link States (Area 5)

Link ID         ADV Router      Age         Seq#       Checksum Link count
10.1.5.5        10.1.5.5        207         0x80000008 0x00D307 1
192.168.24.2    192.168.24.2    323         0x80000004 0x00C043 1

                Net Link States (Area 5)

Link ID         ADV Router      Age         Seq#       Checksum
10.1.5.2        192.168.24.2    323         0x80000001 0x007E8D

                Summary Net Link States (Area 5)

Link ID         ADV Router      Age         Seq#       Checksum
1.1.1.0         192.168.24.2    465         0x80000001 0x00B8FB
2.2.2.0         192.168.24.2    465         0x80000001 0x008A28
4.4.4.0         192.168.24.2    355         0x80000003 0x004861
6.6.6.0         192.168.24.2    220         0x80000001 0x000E96
7.7.7.0         192.168.24.2    135         0x80000001 0x00A8E5
10.1.6.0        192.168.24.2    355         0x80000003 0x00089C
10.1.7.0        192.168.24.2    415         0x80000003 0x00BBD4
192.168.12.0    192.168.24.2    466         0x80000001 0x009CA6
192.168.13.0    192.168.24.2    466         0x80000001 0x00F542
192.168.24.0    192.168.24.2    466         0x80000001 0x00181F
192.168.34.0    192.168.24.2    361         0x80000003 0x0028C2
R2#

So when a router wants to get to an Inter area route  - it will basically look in the database. Ex: the router will
Do a #sh ip ospf database summary 6.6.6.0 –

R2#sh ip ospf database summary 6.6.6.6

            OSPF Router with ID (192.168.24.2) (Process ID 10)
R2#sh ip ospf database summary 6.6.6.0

            OSPF Router with ID (192.168.24.2) (Process ID 10)

                Summary Net Link States (Area 0)

Note: we can see this route is being advertised by two routers R4 and R2.

  Routing Bit Set on this LSA
  LS age: 569
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 6.6.6.0 (summary Network Number)
  Advertising Router: 192.168.34.4 – Says’ this route is being originated by this router (R4)
  LS Seq Number: 80000003
  Checksum: 0xADE9
 Length: 28
  Network Mask: /24
        TOS: 0  Metric: 2  - this route has a metric of 2 to reach the destination


                Summary Net Link States (Area 5)

  LS age: 570
  Options: (No TOS-capability, DC, Upward)
  LS Type: Summary Links(Network)
  Link State ID: 6.6.6.0 (summary Network Number)
  Advertising Router: 192.168.24.2 Says’ this route is being originated by this router (R2)
  LS Seq Number: 80000001
  Checksum: 0xE96
  Length: 28
  Network Mask: /24
        TOS: 0  Metric: 3  this route has a metric of 3 to reach the destination

Based on this output we can’t determine which path we’re going to choose. We will then need to look at what is the SPF cost inside out own area in order to reach the ABR’s.

S we would look at our SFP cost to reach these routers then add that the metric these routers are advertising. This would be the total cost that would what get installed in the routing table.

So from each advertising router:

R2#sh ip route 6.6.6.0
Routing entry for 6.6.6.0/24
  Known via "ospf 10", distance 110, metric 3, type inter area – R2 is using a metric of “3”
  Last update from 192.168.24.4 on GigabitEthernet0/0, 00:18:34 ago
  Routing Descriptor Blocks:
  * 192.168.24.4, from 192.168.34.4, 00:18:34 ago, via GigabitEthernet0/0
      Route metric is 3, traffic share count is 1

------------------------------------------------------------------------------------------------ 

R4#sh ip route 6.6.6.0
Routing entry for 6.6.6.0/24
  Known via "ospf 10", distance 110, metric 2, type intra area R4 is using a metric of “2”
  Last update from 10.1.6.6 on FastEthernet2/0, 00:19:37 ago
  Routing Descriptor Blocks:
  * 10.1.6.6, from 10.1.6.6, 00:19:37 ago, via FastEthernet2/0
      Route metric is 2, traffic share count is 1


Note: So to truly figure out the cost to the route we need to add the cost of the advertising router and the summary cost.

Traffic Engineering –
If we wanted to them modify the path section – we could change the value the ABR is reporting in. Or we can change the local SPF cost in order to reach them. Again whatever is the lowest end-to-end cost will be the path.

Summary – the inter area lookups, the routers DO NOT know what’s going on in the topology beyond the ABR.
This adds to the stability of OSPF because the intra are feature will determine the flooding domain. So for example,
If there’s a change in one of the other areas’ the local area doesn't need to do anything, it just needs to know about the new Inter area metric. Etc.

Modifying OSPF Path Selection:

OSPF uses bandwidth based cost
--COST = Reference _ BW / Interface BW – if we change the bandwidth, it will change the cost. 
The only issue is the Bandwidth statement can affect other operations in the network.

Cost can be modified with
-interface bandwidth                
                   
-Interface ip ospf cost - would be the best way to change the cost. 

-Process auto-cost - This will change the reference bandwidth, EX; i the REF bandwidth is 100Mbps and th einterface bandwidth is 100Mbps a second. The result would be a cost of 1. 

Process neighbor (address) cost

More examples: lets say we want to change the cost of a 10Gig link. The Cost of that link will be a cost of 5. 
You can use the Show commands on the router to help figure this out. Or remember the formula of how OSPF does the calculation. #Cost = reference
 BW / Interface BW. This is why the default 100 Mbps OSPF cost and a 100MB link are a cost of =1. 

Ex: if I were to go to my router 4 in the topology and change the bandwidth on my FastEthernet2/0 Link to 10 GB - and we can see the result of the cost is. 

R4(config)#interface fastEthernet 2/0
R4(config-if)#bandwidth 10000000

R4#sh ip ospf interface fa2/0 | in Cost
  Process ID 10, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 1

The Cost value is set at one. That is because anytime we go over 100Mbps everything is going to be a cost of 1. 

So we would then need to go under the OSPF process and cahge the auto-cost reference bandwidth. 
EX:
R4(config)#router ospf 10
R4(config-router)#au
R4(config-router)#auto-cost re
R4(config-router)#auto-cost reference-bandwidth ?
  <1-4294967>  The reference bandwidth in terms of Mbits per second

R4(config-router)#auto-cost reference-bandwidth 4294967 - I set this to the maximum to see what the new cost of the link would be --

R4#sh ip ospf interface fa2/0 | in Cost
  Process ID 10, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 429
R4#

So if i want the cost the link to be "5", I will need to change / find the auto-cost ref bandwidth. 
By trial and error a ref bandwicth of 50000 set the cost of the link to "5"

R4(config)#router ospf 10                    
R4(config-router)#auto-cost reference-bandwidth 50000

R4#sh ip ospf interface fa2/0 | in Cost
  Process ID 10, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 5
R4#

Note: if you change the auto cost - you will need to change it everywhere of you will have errors in the calculation. Typically in today's network you would want to change the auto-cost ref, because otherwise anything over 100Mb will be a cost of 1. 

FastEthernet2/0 is up, line protocol is up 
  Internet Address 10.1.6.4/24, Area 6 
  Process ID 10, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 5 - We can see the link i changes has thecost we wanted of 5 

Serial1/0 is up, line protocol is up 
  Internet Address 192.168.34.4/24, Area 0 
  Process ID 10, Router ID 4.4.4.4, Network Type POINT_TO_POINT, Cost: 32383 - But because we didn't change the reference bandwidth everywhere we can see the cost of the other links has dramatically changed. 

GigabitEthernet0/0 is up, line protocol is up 
  Internet Address 192.168.24.4/24, Area 0 
  Process ID 10, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 50

Note: if bandwidth is Kilobits. a bandwidth - so 2000 would equal a 2MB connection. 
The more 0's we ad the higher the BANDWIDTH
EX: 
2000 - 2 mb
20000 - 20 mb
200000 - 200 mb
2000000 - 2 GB
20000000 - 20 GB 

 Compared to EIGRP the patch selections straight forward. We simply add the cost value on a hop-by-hop basis

Note: Remember though, if its a different type of router there's no was we can change that. EX:
Intra area Vs Inter area. the "O" or intra will always win over the "O IA" routes. 

2 comments:

  1. this is wrong, RFC3101:

    Takes the “N” routes out over “E” routes (if Type-7 LSA with the P-bit set). RFC1587 was the old way to do it when “E” routes were preferred over “N” routes.

    ReplyDelete
  2. OSPF Path Selection:

    1. Intra-Area routes - Lowest OSPF Process ID (PID) takes precedence if you have the same intra area route via two paths.
    2. Inter-Area routes
    3. N1
    4. E1
    5. N2
    6. E2

    **If both N1 and E1 routes are identical with different FAs, the lower cost will be chosen**

    ReplyDelete