To calculate the best path to a route, first the router builds an LSDB that is then run against the SPF Algorithm, which then comes up with its best paths to subnets.
Ultimately what makes it into the IP Route Table is decided by CEF, which views all protocols different tables to decide the best path to a destination, but for the OSPF Route Table it uses the SPF Algorithm and its LSDB.
Cost is OSPF’s Metric, and it is calculated by the available Bandwidth on a link, which the higher the bandwidth speed the lower the cost will be – Lowest cost is always preferred.
Cost is determined by the “egress” interface or the interface the data will be taking outbound from a router, and to see that interfaces cost you can type “sh ip ospf int X”
Intra-Area routes
As said cost is derived by OSPF calculating the cost of every single link, along every single path, to the destination network. So if you are asked to find the cost of a path, you always start with the first hops interface cost, and end with the last interfaces hop to that network. Also if you don’t know, and you should, Intra-Area means within your Area and Inter-Area means from other Areas into your Area.
Speaking of Costs, here is a quick breakdown of them:
- 10Gig/1Gig/FastEthernet (100mbps) = 1
- Ethernet = 10
- Serial = 64
There are other serial speeds that cost more, but they are not worth committing to memory, if you remember those 3 you should be good. The 10G/1G/100MBPS all equaling 1 I believe was due to the fact that when this algorithm was created, it was not thought that speeds would ever exceed FastEthernet, much like we never thought we’d need more storage space than a Floppy Disk provided 🙂
Inter-Area routes
Intra-Area routes can be manually calculated easily because we (or OSPF) has the link speeds and can quickly find the least cost path, whereas Inter-Area routes are learned from Type 3 LSA’s with do not provide link types / speeds in its Topology information.
That is essentially with Type 3 LSA’s are referred to as a Summary LSA, because the ABR is basically flooding the routes into the other Area, only telling them they can reach a specific route through them and that’s it for information.
This give the ABR a LOT of control over telling routers in one Area how to get to routes in another Area. This also gives the network administrator the ability to manipulate the costs from one Area into another, if you prefer that perhaps a less used but slower link is preferred for your Daily Backups of a Server while you prefer the faster link for work load data transmission.
So essentially the Cost from one Area is passed down to an ABR, which makes a Type 3 LSA, and the Intra-Area has to decide its best path via Cost to that ABR and trust the ABR does truly have the lowest Cost preferred path.
Metric Fine Tuning
Before we fine tune any paths, we better know the order they are preferred:
- Intra-Area
- Inter-Area
- External
Type 1 and 2 LSA’s mean a route is an Intra-Area Route, a type 3 LSA indicates an Inter-Area Route, and type 5 LSA’s (or type 7 in NSSA Areas) indicate a route has been Redistributed from another protocol, or routing domain such as a connected or static route.
Type 1 and 2 LSA’s trigger a recalculation within the entire Area of its SPF Tree for best Paths to a route, whereas a change in a Type 3 LSA does not, because they don’t describe the Topology or Tree in this Area – They have their own Area to do all that calculation in!
To see the # of SPF calculations in the local routers Areas that it is connected to, and a lot of other good info I’ll highlight, use the command “sh ip ospf” :
R1#sh ip ospf
Routing Process “ospf 1” with ID 1.1.1.1
Start time: 00:00:18.784, Time elapsed: 06:04:12.980
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Supports area transit capability
Event-log enabled, Maximum number of events: 1000, Mode: cyclic
It is an area border router
Router is not originating router-LSAs with maximum metric
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Maximum wait time between two consecutive SPFs 10000 msecs
Incremental-SPF disabled
Minimum LSA interval 5 secs
Minimum LSA arrival 1000 msecs
LSA group pacing timer 240 secs
Interface flood pacing timer 33 msecs
Retransmission pacing timer 66 msecs
Number of external LSA 0. Checksum Sum 0x000000
Number of opaque AS LSA 0. Checksum Sum 0x000000
Number of DCbitless external and opaque AS LSA 0
Number of DoNotAge external and opaque AS LSA 0
Number of areas in this router is 3. 3 normal 0 stub 0 nssa
Number of areas transit capable is 0
External flood list length 0
IETF NSF helper support enabled
Cisco NSF helper support enabled
Reference bandwidth unit is 100 mbps
Area BACKBONE(0)
Number of interfaces in this area is 1
Area has no authentication
SPF algorithm last executed 04:14:00.828 ago
SPF algorithm executed 6 times
Area ranges are
Number of LSA 9. Checksum Sum 0x05AC1E
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0
Area 1
Number of interfaces in this area is 1 (1 loopback)
Area has no authentication
SPF algorithm last executed 04:14:00.828 ago
SPF algorithm executed 4 times
Area ranges are
Number of LSA 6. Checksum Sum 0x0267B6
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0
Area 15
Number of interfaces in this area is 1
Area has no authentication
SPF algorithm last executed 03:35:46.956 ago
SPF algorithm executed 6 times
Area ranges are
Number of LSA 8. Checksum Sum 0x027C73
Number of opaque link LSA 0. Checksum Sum 0x000000
Number of DCbitless LSA 0
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0
R1#
It’s hard not to highlight a majority of the information, I shut down a lot of Areas to make the output readable at full length, but as an ABR this shows how long its been since SPF Calculation / SPF executions / Authentication / # of LSA’s / # of interfaces in Area (How many interfaces this local router has in that Area) / It’s RID / Its route type / What types of Areas it knows of and how many.
TLDR – “sh ip ospf” has a lot of good information.
Back to changing the Metric, there are 3 ways to accomplish this configuration:
- Changing the reference bandwidth (configured in OSPF router config mode)
- Setting the bandwidth on the interface
- Configuring the cost directly (on the interface)
The default “reference bandwidth” for OSPF is 100MBPS, which is why 10gig/1gig/FastEthernet(100mbps) all cost 1, because whoever originally came up with this thought we would never see speeds beyond 100MBPS, so that is the lowest cost that can be assigned for an interface – Fortunately this is only by default.
Lets change things up since I’m running the lab anyways, and see how to do it this way:
R1(config)#router ospf 1
R1(config-router)#auto
R1(config-router)#auto-cost ref
R1(config-router)#auto-cost reference-bandwidth ?
<1-4294967> The reference bandwidth in terms of Mbits per second
This is locally significant only, but should be adjusted across all OSPF routers under our administration, so all costs are consistent with each other.
Setting the bandwidth directly on the interface, which I’ve discussed before, is just a bad decision and sloppy way to perform path manipulation as we saw in EIGRP offset-lists. It effects QoS and whatever else may be depending on the interfaces bandwidth value.
However, the configuration is locally significant to that interface, and is configured with:
R1(config)#int fa0/1
R1(config-if)#bandwidth ?
<1-10000000> Bandwidth in kilobits
inherit Specify that bandwidth is inherited
receive Specify receive-side bandwidth
This is measured in kilobits here, so watch that on exam day, and unless asked to tinker with on exam don’t mess with the interfaces bandwidth – There’s always a better way!
The third and final way of changing the cost, is also done on the interface, and is very simple to configure:
R1(config-if)#ip ospf cost ?
<1-65535> Cost
So I could make all my Serial links that are a cost of 64 look like they are FastEthernet links with a Cost of 1, but on my lab that would serve no purpose as the links aren’t actually any faster… or are they?
Lets test it out:
R1(config-if)#int s0/0/0
R1(config-if)#ip ospf cost 1
R1(config-if)#
ASR#2
[Resuming connection 2 to r2 … ]
*Mar 31 01:32:22.661: %SYS-5-CONFIG_I: Configured from console by console[OK]
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int s0/0
R2(config-if)#ip ospf cost 1
R2(config-if)#
ASR#3
[Resuming connection 3 to r3 … ]
*Mar 31 22:41:18.954: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/1 from FULL to DOWN, Neighbor Down: Dead timer expired
*Mar 31 22:41:18.990: %OSPF-5-ADJCHG: Process 1, Nbr 4.4.4.4 on FastEthernet0/1 from LOADING to FULL, Loading Done
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int s0/2
R3(config-if)#ip ospf cost 1
Now, when I do “clear ip ospf proc” on R1, it is like pulling teeth waiting for the Adjacencies to R2 and R3 to reform. Lets see if this speeds things up:
R1#clear ip ospf proc
Reset ALL OSPF processes? [no]: yes
R1#
*May 18 03:26:26.398: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on Serial0/0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*May 18 03:26:26.398: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on Serial0/0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*May 18 03:26:26.470: %OSPF-5-ADJCHG: Process 1, Nbr 5.5.5.5 on FastEthernet0/1 from FULL to DOWN, Neighbor Down: Interface down or detached
R1#
*May 18 03:26:30.254: %OSPF-5-ADJCHG: Process 1, Nbr 5.5.5.5 on FastEthernet0/1 from LOADING to FULL, Loading Done
R1#
After waiting for about 5-10 seconds, I realized I had not found the key to making a Serial link the speed of Fast Ethernet, however it does influence the Total Cost to a destination network, for example from R1 to R4… well I’ll just show you the OSPF Route Table now:
R1#sh ip route ospf
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/2] via 172.12.123.2, 00:00:40, Serial0/0/0
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/2] via 172.12.123.3, 00:00:40, Serial0/0/0
172.12.0.0/16 is variably subnetted, 5 subnets, 2 masks
O IA 172.12.34.0/24 [110/2] via 172.12.123.3, 00:00:40, Serial0/0/0
R1#
Over Serial Links I have the bandwidth speed Cost of 1, so if I had 20 routers in a line connected via Serial Links and issued this same command, the destination network at the end would have a cost of 20 but take about a light year to transmit (1 light year = True path Cost of 1,260).
So once more, to verify path cost on an interface, you should have the default of 1, 10, 64 burned into your memory but you can also use “sh ip ospf int X” or “sh ip ospf bri X” which is actually a much faster command to get a glance at your OSPF interfaces:
R1#sh ip ospf int bri
Interface PID Area IP Address/Mask Cost State Nbrs F/C
Se0/0/0 1 0 172.12.123.1/24 64 DR 2/2
Lo1 1 1 1.1.1.1/32 1 LOOP 0/0
Fa0/1 1 15 172.12.15.1/24 1 BDR 1/1
R1#
That is all I have in me for tonight, I will be pumping these out until maybe for about another week, so after tomorrow will probably be misc topics like NTP, IP SLA, and a good deal more BGP review before exam day.