Open Shortest Path First (OSPF) is a link-state based routing protocol designed as a replacement for RIP. As its name implies, OSPF makes use of Dijkstra's Shortest Path First (SPF) algorithm in order to determine the best route to a given destination based on the information within its link-state or topological database.
OSPF is open - the standard was developed by the Internet Engineering Task Force (IETF) and is readily available for anyone to implement and use. The current version of OSPF for IPv4 is OSPF version 2 (or OSPFv2 for short) and is documented in RFC2328.
OSPF exhibits a number of advantages over distance vector protocols such as RIP and IGRP. Due to the fact that it is a link-state based protocol OSPF has faster convergence, better scalability and is less susceptible to faulty routing information (we are no longer routing by rumour!).
Other features of OSPF include:
The general operation of OSPF can be summarised as follows:
The network traffic generated by OSPF is minimal. Once the initial exchange of LSAs has been completed, the only traffic will be small Hello packets sent every 10 seconds (for broadcast networks). Additionally, LSAs are readvertised every 30 minutes. Other than this no OSPF traffic should be required unless changes occur to the network topology or link-state.
Dijkstra's SPF algorithm allows us to construct a tree with the minimal distance between n nodes. Recall from lecture 1 that a tree is a minimally connected network, with only one path between every two nodes. By definition, a tree means that routing loops are impossible and routing decisions are simple since there is only one possible path.
In the case of a router we will work with three sets of data: the link-state database, a list of shortest paths and a working list of paths. To find the shortest path from a given router to all other routers:
In this example network the "distances" are to be found from router A to all others.
The end result (in order of discovery) is:
A-C 2
A-B 3
A-C-D 4
108/ interface speed bps.This results in the following OSPF costs:
| Media type | Default Bandwidth | Default OSPF cost |
| Ethernet | 10Mbps | 10 |
| Fast Ethernet | 100Mbps | 1 |
| FDDI | 100Mbps | 1 |
| T1 (serial) | 1544Kbps | 64 |
| 56Kbps serial | 1544Kbps | 64 |
| HSSI | 45Mbps | 2 |
An OSPF network (Autonomous System) can be divided into Areas. This has advantages from a network scalability perspective. Large OSPF areas have the following problems:
Subdivision into areas reduces these problems and in addition, reduces route update overhead. Routers need only pass summary information between areas, not the full database.
It is rumoured [RFC 2328] that "all" communications between areas must pass through a backbone area, leading to the star topology below:
This means that the routers in the OSPF system need considerably more thought in their configuration as they may be called on to perform different routing functions.
All OSPF routers in an area have identical copies of the area topology database.
On a broadcast medium, OSPF routers elect a Designated Router (DR) and a Backup Designated Router (BDR). This reduces the amount of traffic that would otherwise occur when every router tried to exchange its database with every other router.
Routers exchange databases only with the the DR and the BDR, not with all other routers in the area.
In general communication between routers is addressed to the AllSPFRouter multicast group (224.0.0.5), whilst traffic addressed to the DRs is sent to the DRouters multicast group (224.0.0.6).
In order for an area to be formed, all routers must agree on:
Routers send out OSPF Hello packets every 10 seconds (30 seconds on non-broadcast media). Routers discover their neighbours by listening to these broadcasts.
When a network area comes up for the first time, routers examine Hello packets from their neighbours and compare priorities.
If two or more routers share the highest priority, they then compare their IDs (the numerically highest IP address of any of their interfaces or loopback addresses). The winner becomes the DR, the runner up becomes the BDR.
Following the initial election, the DR and the BDR retain their status, even if a higher priority router is added to the area. It's only when both DR and BDR fail that another router can take over as DR.
If the DR fails, the BDR is promoted and a new BDR is elected. If the BDR fails, a new BDR is elected.
To ease the restriction that "all areas connect to the backbone", OSPF provides for Virtual Links.
These are point to point links joining ABRs so that the outlying area can be connected to the backbone via only one transit area.
It is rumoured that Virtual Links are not "good style" and should only ever be used as emergency fixes, not as an inherent part of the network design.
OSPF summarises routing tables only when manually configured on an ABR or ASBR. OSPF summarisation can be done on any bit boundary. For this to work efficiently, IP addresses in an area need to be carefully allocated (see later lecture).
For example, if an area contained network addresses 192.168.0.x through to 192.168.15.x (where x is a host number and 0...15 is the subnet number), then all 16 subnets could be described (summarised) as 192.168.0.0/20.
This means that if the first 20 bits of the IP address match the first 20 bits of 192.168.0.0, then the destination is within the summarised area. Note that OSPF does not describe route summaries quite this way. The intent is the same, but the syntax is different.
Route summarisation is an "obvious good thing"™: It reduces the size of the topology database and thereby reduces the number of rules a router has to use to determine where to send a packet.
Some transmission media are inherently not broadcast capable (ATM, X25, Frame Relay).
It may be necessary to manually force the election of a DR and BDR. Point-to-point links will then need to be configured to all routers in the area (without broadcasting, routers won't be able to find their neighbours).
Routers will have to replicate packets to simulate multicasting, which increases processing load on the routers.
R1(config)# R1(config)#interface Ethernet0/0 R1(config-if)#ip address 192.168.1.254 255.255.255.0 R1(config-if)#no shutdown R1(config-if)#bandwidth 1...10000000 Bandwidth in kilobits R1(config-if)#exit R1(config)#
R1(config)#ip routing
R1(config)# R1(config)#router ospf 100 R1(config-router)#network 192.168.1.0 0.0.0.255 area 0 R1(config-router)#network 192.168.4.0 0.0.0.255 area 1 R1(config-router)#exit R1(config)#
Note that the 100 following the "router ospf" command identifies the specific routing process that we will be configuring.
copy running-config startup-config
R1#show ip ospf neighbor R1#show ip ospf database R1#show ip ospf border-routers R1#show ip ospf interface Ethernet0/0