Monday, June 1, 2009

OSPF thoughts

Open Shortest Path First (OSPF) is a widely-used link-state routing protocol. It is vendor neutral, which contributes to its popularity, since many large networks include equipment from various manufacturers.

OSPF is completely classless - so it incorporates networks and subnet masks into its routing updates and topology tables, and this information is used in the computing of the shortest path to any given network. That is a nice thing about OSPF, since you don't have to worry too much about dis-contiguous networks. You simply add the netmask to the network you plan to advertise in OSPF and the router does the rest of the work.

The down side is that computing the shortest path for all known networks is resource intensive, and in the event of a link going down, the state of that link is flooded to all routers inside the area, and the Dijkstra's Shortest Path First algorithm is run by them all. This takes a lot of memory and CPU power, which can cause a slowdown in your network if it is large. If you have a link "flapping," or going up and down rapidly, this can cause an unstable condition as each router computes and recomputes the paths each time it receives an update (or LSU - link state update).

To mitigate this condition on broadcast multi-access networks and non-broadcast multi-access networks (such as frame relay), OSPF elects a Designated Router and a Backup Designated Router in case the DR fails. This election is won by the device with the numerically largest IP address on the network. OSPF first will calculate the DR/BDR from the logical interfaces and then the physical interfaces, so often times a router will be configured first with a logical loopback address to function as the router ID. On point-to-point networks, where there are only two devices on the network, there is no need for an election. The beauty of this is that any link state updates are sent only to the DR and BDR, and these routers then send the update the remaining routers in its area. Updates are flooded out on multicast addresses: 224.0.0.6 for the DR/BDR updates and then they send updates out to 224.0.0.5, which is the multicast address for all OSPF routers.

Other points of note in configuring ospf is that, when you initiate ospf by entering "router ospf" in global config mode on your router, you specify a "process id," which is a number between 1-65,535. This number is only important to the individual router. It is not advertised to other routers, and does not need to be the same on each router within an area. OSPF uses areas to associate routers together, which gets configured when entering the network to be advertised. All areas must somehow connect to Area 0, which is the backbone area for the OSPF autonomous system.

When configuring OSPF, also of great importance is the use of wildcard masks, which is the opposite of a subnet mask. In essence, a 1 in a subnet mask means "ignore this bit" and a 0 means "check this bit." When you enter a wildcard mask of 0.0.0.255, the router will act on any packet that matches the first three octets of the IP address, with anything in the last octet being a match since it is ignored. So, to advertise the 192.168.1.0/24 network, we would enter the following command after the "router ospf 4" command (the 4 is arbitrary and the process ID for this instance of OSPF on this router):

network 192.168.1.0 0.0.0.255 area 0

This puts all 192.168.1.0 traffic in our backbone area 0.

There is much more about OSPF to know, and these are really just simply my summarization of interesting points. A greater discussion of areas, LSA/LSU's and elections could be had. The main points are that OSPF is a link-state routing protocol that is completely classless, advertises the netmask along with the subnet and interoperates with multiple vendors' equipment because it is non-proprietary. From there you just need to draw it out and configure it a few times...

No comments: