Unlike RIP OSPF exchanges frequent updates in order to keep the routing table up to date, instead of exchanging the full routing tables.
OSPF routers that have formed adjacencies exchange Link State Updates (LSUs) which contain Link State Advertisements (LSAs) this has information regarding the networks/subnets. The LSAs are stored in a Link State Database; once all LSAs have been exchanged and the OSPF network has converged the routers will have a synchronised link state database. The SPF algorithm is then run on the contents of the link state database to create the OSPF routing table.
To ensure OSPF routers have up to date database, LSAs are assigned sequence numbers. When OSPF router received LSA, it checks the database for any existing entries if no entry the router will add to its database and then flood the LSA out of every OSPF enabled interface (except the interface it received the LSA from).
If entry for the link, the sequence number is queried
- If sequence number is the same: LSA is ignore
- If sequence number lower: Router ignores the update, send an LSU containing an LSA to the sender with the most up to date information.
- If sequence number higher: router adds the LSA to its database and sends an LSA acknowledgement to the sender. Router floods LSA and updates its own routing table
Once initial exchange of LSAs has taken place no further exchange unless change of network topology. However a Summary LSA is sent every 30 seconds
OSPF Message Types
OSPF uses 5 types of routing protocol packets; they share a common protocol header. Every OSPF packet is directly encapsulated in the IP header and uses protocol number 89.
Hello Packet – used to discover, build and maintain OSPF neighbour adjacencies. Routers must agree common parameters sent within the hello packet.
DBD packet – when OSPF adjacency is established a DBD packet is used to describe the LSDB so routers know if databases are in sync.
LSR packet – a router requests (sends) an LSR to OSPF neighbour to send back up to date LSAs information.
LSU packet – used in response to an OSPF neighbours LSR packet, this contains LSA information.
LSAck packet – acknowledges the other packet types; used to make flooding of LSAs reliable.
OSPF LSA Types
The OSPF Topology is described by LSAs, which build the LSDB.
Common LSA Types:
Type 1 – Router LSA
- Displays all networks/subnets advertised by the routers in the local area
- Generated by each router for every area the router has a link in.
- Flooded to single area only
- Link ID (connection) type (stub, transit, point-to-point, virtual-link) and their IP address configuration
- LSA’s refreshed every 30 minutes (1800 seconds)
“show ip ospf database router” command will show the Type 1 LSAs on an OSPF router. This will display the network/subnet information being advertised by the other OSPF routers in the same area as well as routes advertised by it-self. Use the command “show ip ospf database router self-originate” to display only routes/LSAs that were locally originated.
In the example below you will clearly see the Type 1 LSA output generated by router R1.
LSA Type 1 for router R1 showing its own routes and confirms the loopback interfaces are being advertised into OSPF.
LSA Type 1 for router R1 showing routes for the connected router R2. Output reflects that R1 has 4 links, confirms the RID is 0.0.0.2, identifies the Loopback interface networks and their metrics as well as the transit network and router IP address.
Type 2 – Network LSA
- Sent out only by DRs
- Lists each of the attached routers, the DR itself and identifies the networks in the area. Used to help routers identify other routers in the area and have a full picture of the network.
- A Type 2 is generated for every NBMA or Transit network within an area
- Flooded within the area but do not leave the area which they are generated
“show ip ospf database network” command will list details of the Type 2 LSAs
Type 3 – Summary LSA
- Identifies the inter-routes sent from one area to another via an ABR
- LSA Type 1 & 2 get converted to an LSA Type 3
- Use manual route summarisation to further reduce the amount of Type 3 LSAs
- Sent by ABRs only
- Not flooded into a Total Stub Area
In the example below the router R1 is an ABR, with an interface into area 0 and area 2.
Using the “show ip ospf database summary” command will list details of the Type 3 LSAs. On router R1 they reveal individual Type 3 Summary LSAs for the Loopback interfaces for the routers R3 and R5.
We can reduce the number of Type 3 LSAs by manually summarising the routes on the ABR. If we run the command “area x range <network> <subnet mask>”
R1 (config)# router ospf 1
R1 (config-router)# area 2 range 10.10.0.0 255.255.252.0
Re-running the command “show ip ospf database summary” on router R1 will reveal one Type 3 Summary LSA for the summarised network. Notice that the Network Mask is now /22 covering all the loopback interface networks of the routers in area 2, rather than before individual Type 3 LSAs for each /32 loopback network.
Type 4 – ASBR Summary LSA
- Identifies the path to the ASBR
- Sent by ABRs only
- Not flooded into a Total Stub Area
“show ip ospf database asbr-summary” command will list details of the Type 4 LSAs. Identifying the ASBR RID address and the Advertising Routers RID, aswell as metric information.
Type 5 – Autonomous System LSA
- Used to advertise networks from other autonomous systems (RIP, EIGRP, BGP etc)
- Identifies the external routes generated by the ASBR
- Sent by ASBRs only and are flooded to the entire AS
- Type 4 LSA is required to find the ASBR
“show ip ospf database” command to show the OSPF database.
“show ip ospf database external” command will list details of the Type 5 LSAs. This will list in greater detail the individual external networks, the RID of the advertising router, network mask and Metric Type (1 or 2, 2 as default).
Other LSA types:
Type 6 – Multicast OSPF LSA
Type 7 – Not-so-Stubby area LSA
- Sent by ASBRs only
Type 8 & 9 – Used in OSPFv3 for link-local addresses and intra-area prefixes
Type 10 & 11 – Generic LSA, for future development of OSPF
OSPF Router Types
Internal Router – all interfaces are in the same area
Backbone Router – a router with at least one interface in area 0
ABR (Area Border Router) – router(s) with at least one interface in area 0 and one in another area. An ABR can summarise routes.
ASBR (AS Border Router) – is a router that is redistributing routes in OSPF from another routing protocol (RIP, EIGRP, BGP etc). An ASBR can summarise routes.
“show ip ospf” command will identify what the status of the local router is – eg “area border” and/or “autonomous system boundary router” etc
“show ip ospf border-routers” command will list what ABRs and ASBRs the local router is aware of
OSPF Network Types
OSPF defines network types based on their physical link types. Common network types:
Point-to-Point – routers use multicast to dynamically discover neighbours. There is NO
DR/BDR election because there is only ever 2 routers. It is the default OSPF network type for serial links and point-to-point Frame Relay sub-interfaces.
Broadcast – routers use multicast to dynamically discover neighbours. DR and BDR elected to optimize exchange of routing information. Default OSPF network type for Ethernet links.
Non-Broadcast – used on networks theat interconnect more than 2 routers without broadcast capability. Frame relay and ATM are examples of NBMA networks. Neighbours are configured statically, election of DR/BDR follows. This network type is default for all physical interfaces and multipoint subinterfaces using Frame Relay encapsulation.
Point-to-Multipoint – is a logical collection of point-to-point links, all interfaces belong to the common IP subnet. Every interface IP address will appear in the neighbours routing table as a /32 host route. Neighbours discovered using multicast, there is NO DR/BDR election.
Loopback – default network type on a loopback interface
The network type can be configured manually on an interface using the command “ip ospf network <network type>”. E.g
R1 (config)# interface gigabitethernet 1/0/1
R1 (config-if)# ip ospf network point-to-point