ICND1 100-105

# SPF Algorithm and OSPF Router ID

## SPF Algorithm

Where I live we use kilometers for measuring. Some are using inches, feet, yards, miles, a very archaic measurement system and thankfully Open Shortest Path First, or OSPF, has a better measurement system, doesn't it?

It definitely does, and the term we associate with OSPF's measurement system is, cost. Cost, that's a term you need to ingrain in your memory, cost. It's known as THE metric. So how far is a certain destination network away from this particular router? And you'll notice that every router keeps track of their own cost to reach each of those different destination networks. By default it's based on bandwidth for OSPF. It's inversely proportional to bandwidth. So what that means is, if the bandwidth is really really low, it has a high cost, if the bandwidth is really really high, for example a 10 gigabit link, well then the cost would be low. So Shortest Path First Algorithm is adding up all the costs along the path to get to the destination network, and in the end its ultimate goal is to find the path with the lowest cost. So the best cost is the one that is the lowest. So how is it calculated? Well we have this reference value known as the reference bandwidth. And by default, this bandwidth is set to 100 Mbps. So since it's set to 100 Mbps, when I divide that by the interface bandwidth, we'll use 100 Mbps link in this example. We would have a cost of one, correct?

Well the cost would be one, and we can't go lower than this, just so we're clear, we don't get into decimal points and things like that, but this begs the question now. There are network links that are faster than Fast Ethernet. What do we see nowadays? We see gigabit, 10 gigabit, 40 gigabit, soon there'll be 100 gigabit. Well that's getting to the extremes and vastly exceeds Fast Ethernet. But, let's say I was comparing a Fast Ethernet link and its cost, and a 10 gigabit link which is very available, you can get lots of 10 gigabit link here right now. So Fast Ethernet and 10 gigabit, there's a factor of 100 apart between the two. How would OSPF see those?

Our default implementation of OSPF, they would both be seen equal, they both have a cost of one. The calculation would be a value greater than zero but less than one. We can't have less than one as an option, so it's rounded up to one, well so is the 100 megabit link. So anything greater than 100 Mbps will have a cost of one by default, and that's a problem. That's definitely a problem, because they are not equal; they're treated equal but they're not equal. So, how do we solve this problem? Can we change a value here to make it work? Am I going to reduce the speed of my 10 gigabit link or my 100 megabit link? No, that doesn't make sense, what would we do?

Well there are really two ways, you could go interface by interface and change the cost, we don't really want to get into that, that's in the weeds, we would like to be at a higher level whenever we can. So what we do is we change the rules. We change the reference bandwidth, and we would change it to something like 10 Gigabit, we change it to 10 Gigabit, and some of the data center gear that Cisco puts out does in fact change the rules by default, but not our Cisco routers and our multilayer switches that we are speaking to you about. So it's just something to bear in mind, and it would have severe ramifications if you had really high-speed links.

## OSPF router ID

This is another one of those really critical elements of our OSPF discussion, the router ID. Now before we get into how this mechanism works, I want to share with you where it's really used. There are two places where this is required to be stable, consistent, and doesn't change when the router reboots. They are OSPF virtual links and filtering, when filtering is based on specific routers. Neither of those are topics for anywhere close to right now. However, router ID is something that can and should be controlled, and it's because of those technologies that you'll see deeper. It is elected from something that can change reboot to reboot, based on physical conditions. See here's how the router ID is elected or at least when it is elected, that's the bigger thing. Router ID is a numeric name, it's chosen when the OSPF process starts. And let's say we had a network that was big, that was ready, it's been working for years and they were running OSPF. A router reboots in the OSPF world and that router was terminating a virtual link.

Well when the router reboots, it then restarts the OSPF protocol, and this is when the election occurs. Now the election looks at the physical interfaces, those physical interfaces have the IP addresses that are the input and the competing values in the election, but only the up/up interfaces get to compete; up/down, down/down administratively down, those don't play in the election. So it is possible that at the time of reboot we'll have different interfaces this time around that are up/up than last time. So we got to stabilize this, because we can see that they can change, they can absolutely change. So, now we've said by default it's chosen from the IP addresses of up/up interfaces, but how do we weigh all of those IP addresses? I might have 10, I might have 15, or I might just have 2, how do I weigh that?

We look for the highest IP address. So simply start reading the IP address from left to right. If one of the IP addresses start with 10 another one starts with 192, well then the 192 one is higher, it will beat out the one that starts with 10. So we're looking for the highest IP address. But we said we want stability. Do we get stability on physical interfaces? No physical interfaces can flap; they can go up, they can go down. As we said, when we reboot a device things can change, all right. So how do we introduce stability here with our router ID? Well one of the things we can do is manually set, just set it and forget it. Here's my router ID using the router-id command and we're done. It'll always be that router ID.

RouterX(config)#router ospf 100
RouterX(config-router)#router-id 10.2.2.2
RouterX(config-router)#end
RouterX#copy running-config startup-config
RouterX#clear ip ospf process

But there's another way to introduce stability, and that would be with loopback interfaces. What's a loopback interface?