Today we will talk about the OSPF dynamic routing protocol, as required for Cisco’s CCNA Exam. You should learn this protocol carefully, not only because Cisco requires a good knowledge for the CCNA certification, but you will find it in many network deployments today. From all Interior Gateway Protocols (IGPs), OSPF is probably the most common one.
OSPF (Open Shortest Path First) is probably the most widely-used Interior Gateway Protocol (IGP). The reason it became so popular is because it’s a link-state routing protocol. Link-state routing protocols are able to create the topology of your network by gathering information from all the other routers. By having the map of your network, the link-state protocol is able to select the best path to any destination in your network. Unlike distance vector routing protocols, link-state routing protocols are not sending periodic updates(this is an important CCNA concept to know), instead, after the network has converged, they advertise updates only when the topology changes. Having this behavior, OSPF is able to recalculate the routes very fast in case the topology changes or a link is failing. This is definately a concept you want to memorize for your CCNA exam as you will definatley see it on your Cisco certification exam.
As defined by RFC 2328, OSPF is using an arbitrary value called cost for its metric. Cisco decided to use bandwidth as the OSPF cost metric.
OSPF’s advantages are its fast convergence and its scalability, which allows for large network scenarios. Currently, OSPFv2 is used for IPv4 networks and OSPFv3 for IPv6 networks. OSPF also supports Variable-Length Subnet Masking (VLSM) and Classless Inter-Domain-Routing (CIDR).
OSPF uses areas to manage the network. Areas are 32-bit numbers. Those numbers can either be in decimal form or in octet-based dot-decimal notation, just like IPv4 addresses. Area 0 (or 0.0.0.0) represents the backbone of an OSPF network.
The OSPF package header is included in every OSPF packet. In the IP packet header, the protocol field is set to 89 and the destination address is set to the ALLSPFRouters address, 224.0.0.5.
The OSPF protocol is sending the following packet types which will be covered on your CCNA 640-802 exam:
1. Hello – used to discover the neighbors, establish the parameters on which the routers must agree, build adjacencies, elect Designated Router (DR) and Backup Designed Router (BDR).
2. DBD – Database Description is used to check if the database is synchronized between the sending and the receiving router.
3. LSR – Link-State Request is used to request specific link-state records.
4. LSU – Link-State Update packets are used to reply to LSRs and also to announce new informations or changes to the current topology.
5. LSAack – Link-State Acknowledgement is send by the receiving router to confirm the receipt of an LSU.
OSPF uses the Dijkstra’s shortest path first alhorithm (SPF) to create the SPF tree.
The default Administrative Distance is 110, which makes OSPF preferred over other IGPs, like IS-IS and RIP.
To protect your network routers from receiving unsolicited and bogus OSPF information, the protocol is able to encrypt and authenticate the routing information. This way, the routers will receive information only from routers configured with the same authentication information.
To enable OSPF on a router, you must enter router ospf process-id in the global configuration mode, where process-id is a number between 1 and 65535. This number does not have to be the same on all routers and can be randomly selected. Its influence takes place only locally and it’s not advertised on the network.
To announce a route through OSPF, the network network-address wildcard-mask area area-id command is used in router configuration mode. For example, to announce the network 192.168.0.0/24 you must enter network 192.168.0.0 0.0.0.255 area 0. The wildcard mask is calculated by subtracting the netmask from 255.255.255.255. For example, the wildcard mask for 255.255.255.224 is 0.0.0.31.
Router(config)#router ospf 1
Router(config-router)#network 192.168.0.0 0.0.0.255 area 0
Router(config-router)#network 10.0.0.0 0.0.0.31 area 0
OSPF has 3 methods to determine the router-id in the following order: 1) use the IP address configured with the router-id command; 2) use the highest IP address of any Loopback interface; 3) use the highest IP of any other interface. If you didn’t configure the router ID, you can find out which one is it with the show ip protocols command. However, if the Router ID is automatically assigned and you decide to change it with the router-id command, you must use the clear ip ospf process command. Please note that, if you decide to use a Loopback or a physical interface, the above command may not work and you may have to reload your router.
Router(config)#router ospf 1
Router(config-router)#router-id 192.168.0.1
Router(config-router)#ctrl-Z
Router#clear ip ospf process
The metric of OSPF can be easily determined with the following formula: 10^8 / speed of the interface in bps. For example, the metric of an Ethernet interface is 10^8 / 10,000,000 bps = 10. The metric of T1 (1.544Mbps) is 10^8 / 1,544,000 bps = 64. Considering this formula, any Fast Ethernet or faster interface has a metric of 1. Also, please note that the value of the metric in OSPF from the router to a network is the accumulated value of all metrics until it reaches that network. For example, if R1 needs to get to R3 through R2, and the metric between R1 and R2 is 1 and the metric from R2 and R3 is 64, the total value of the metric is 65.
However, if you are using for example a serial interface, which is able to support a T1 link but you have only a 128kbps link, you must use the bandwidth or the ip ospf cost interface command to set the appropriate value. Without it, OSPF may not be able to calculate the real cost and you may get an undesirable routing behavior.
Router(config)#interface serial 0/0/0
Router(config-if)#bandwidth 128
Router(config)#interface serial 0/0/0
Router(config-if)#ip ospf cost 781
Of course, today’s networks have even higher speed links, and you may have for example 10GigE interfaces along with 1GigE and Fast Ethernet. The problem here is that the metric for all these interfaces will be 1 which can lead to an unexpected behavior. To solve this problem, you can adjust the reference-bandwidth (the value is in Mbits per second):
Router(config)#router ospf 1
Router(config-router)#auto-cost reference-bandwidth 10000
Please return next week to see Part II of our Cisco CCNA Certification 640-802 OSPF topic where we will be covering some of the challenges of OSPF in a multi-access environment.