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, 22.214.171.124.
The OSPF protocol is sending the following packet types:
- 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 information or changes to the current topology.
- 5.LSAack – Link-State Acknowledgement is sent 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#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)#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 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
OSPF however, can be a challenge in Multiaccess Networks. Creating adjacencies for every two routers in your network can result to a great number of unnecessary adjacencies and this leads to LSA flooding. To better understand the result, the formula to figure out how many adjacencies will be creating in this scenario is (n stands for the number of routers): n(n-1)/2. Making the calculations for a 5 router scenario gives us 10. That’s not that much, but let’s do the math for 20 routers: 20(20-1)/2 = 190. Now try to imagine what’s happening when the routers are sending out LSAs. The solution for this problem is to elect a Designated Router (DR).
Designated Routers (DR) is a router elected to distribute the LSAs. This way, large scale networks can avoid LSA floods. After the election of the DR a Backup Designated Router (BDR) is also elected, in case of DR failure. With a DR present in your network, the other routers, instead of flooding LSAs around the network, they only send them to the DR and the BDR using the multicast address 126.96.36.199 ( also known as ALLDRouters). After the DR receives the LSA, it sends it to the other routers in the network using the 188.8.131.52 (also known as ALLSPFRouters).
The election process is a fairly simple one. The DR is the router with the highest OSPF interface priority, the BDR is the one with second-highest OSPF interface priority. If their interface priorities are equal, the router with the highest router ID wins. The show “ip ospf neighbor” command shows the status of the routers.
Router# show ip ospf neighbor
ID Pri State Dead Time Address Interface
10.199.199.137 1 FULL/DR 0:00:31 192.168.80.37 Ethernet0
172.16.48.1 1 FULL/DROTHER 0:00:33 172.16.48.1 Fddi0
172.16.48.200 1 FULL/DROTHER 0:00:33 172.16.48.200 Fddi0
10.199.199.137 5 FULL/DR 0:00:33 172.16.48.189 Fddi0
The DR router should be a powerful one to handle its job. In almost every network you will see many models, some newer, some older. To make sure the router you want will become DR, you can manually set the priority with the “ip ospf priority interface” command (priority is between 0 and 255).
In some cases, you may find that the update interval of Hello and Dead packets it’s not appropriate for your network. In this case, you can adjust them with the “ip ospf hello-interval seconds” and “ip ospf dead-interval seconds” interface commands.
One of the must-have skills for every network administrator is the ability to use the show commands. Every time when you are in doubt about the good operation of your OSPF network, the show “ip ospf” command is here to assist you. To check if two routers have become neighbors, you must use the “show ip ospf neighbors” command. Also, “show ip ospf interface interface-name” will give you information about Hello and Dead times.
- 1) show ip protocols
Router#show ip protocols
Routing protocol is “ospf 1”
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.0.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
192.168.0.0 0.0.0.255 area 0
10.0.0.0 0.0.0.31 area 0
Reference bandwidth unit is 100 mbps
Routing Information Sources:
Gateway Distance Last Update
192.168.0.2 110 11:29:29
10.0.0.2 110 11:29:29
Distance: (default is 110)
- 2) show ip ospf
Router# show ip ospf
Routing Process “ospf 1” with ID 192.168.0.1
Supports only single TOS(TOS0) routes
Supports opaque LSA
Supports Link-local Signaling (LLS)
Initial SPF schedule delay 5000 msecs
Minimum hold time between two consecutive SPFs 10000 msecs
Maximum wait time between two consecutive SPFs 10000 msecs
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 0x0
Number of opaque AS LSA 0. Checksum Sum 0x0
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 0. 0 normal 0 stub 0 nssa
External flood list length 0
Number of interfaces in this area is 2
Area has message digest authentication
SPF algorithm executed 4 times
Area ranges are
Number of LSA 4. Checksum Sum 0x29BEB
Number of opaque link LSA 0. Checksum Sum 0x0
Number of DCbitless LSA 3
Number of indication LSA 0
Number of DoNotAge LSA 0
Flood list length 0
- 3) show ip ospf interface interface-name
Router# show ip ospf interface ethernet 0
Ethernet 0 is up, line protocol is up
Internet Address 192.168.0.202, Mask 255.255.255.0, Area 0.0.0.0
AS 201, Router ID 192.168.0.1, Network Type BROADCAST, Cost: 10
Transmit Delay is 1 sec, State OTHER, Priority 1
Designated Router id 192.168.0.10, Interface address 192.168.0.10
Backup Designated router id 192.168.0.28, Interface addr 192.168.0.28
Timer intervals configured, Hello 10, Dead 60, Wait 40, Retransmit 5
Hello due in 0:00:05
Neighbor Count is 8, Adjacent neighbor count is 2
Adjacent with neighbor 192.168.0.28 (Backup Designated Router)
Adjacent with neighbor 192.168.0.10 (Designated Router)
Every OSPF route in show ip route has an O at the beginning like in the following example:
Router# show ip route
Codes: I – IGRP derived, R – RIP derived, O – OSPF derived,
C – connected, S – static, E – EGP derived, B – BGP derived,
* – candidate default route, IA – OSPF inter area route,
i – IS-IS derived, ia – IS-IS, U – per-user static route,
o – on-demand routing, M – mobile, P – periodic downloaded static route,
D – EIGRP, EX – EIGRP external, E1 – OSPF external type 1 route,
E2 – OSPF external type 2 route, N1 – OSPF NSSA external type 1 route,
N2 – OSPF NSSA external type 2 route
Gateway of last resort is 10.119.254.240 to network 10.140.0.0
O E2 184.108.40.206
O E2 220.127.116.11 [160/5] via 10.119.254.6, 0:00:59, Ethernet2
O E2 10.130.0.0 [160/5] via 10.119.254.6, 0:00:59, Ethernet2
E 172.30.0.0 [200/128] via 10.119.254.244, 0:02:22, Ethernet2
If OSPF is not correctly configured, you, as a network administrator, should be able to figure out what’s missing or what’s the reason it doesn’t work from the output of the show commands. Study the output of these commands carefully in a working environment. Try to break something, study the output again and compare it with the one before. This way you will be able to recognize errors faster.
We hope you found this CCNA topic covering OSPF useful. We are proud to deliver top-notch Cisco CCNA certification articles for you making your CCNA certification exam easier.