Link-state advertisements (LSA) are used to communicates the router’s local routing topology to all other local routers in the same OSPF area. There are 11 types of LSAs although only the 6 most commonly used ones are described in this post.
LSA Basics
Only the router that created the LSA can modify or withdraw it, all other routers can only process or forward it. Each LSA contains the sequence number and max-age timer. The router that originally advertised an LSA re-floods it (after incrementing sequence number by 1) based on a per-LSA link state refresh interval (default 30 mins). Every router expects to have its LSA refreshed within each LSAs max-age timer (default 60 mins). When max-age is reached the LSA is flushed from the database by setting its age to the max-age (60 min) and flooding it throughout the network.
show ip ospf databaseShows LSA info, sequence number, refresh and max-age timers show ip ospf database database-summaryNumber of LSAs per type
After checking the Type1 LSAs the routers will do recursive lookups on Type2 LSAs searching through all the adjacencies off the DRs until they eventually come to a stub router (the edge of network).
There are 3 types of networks attached to a router:
- Transit network: A network over which 2 or more OSPF routers become neighbors and a DR is elected
- Another router: A direct P-t-P or P-t-M with an adjacency formed, used if only 2 routers on link
- Stub network: A subnet on which a router has not formed any neighbor relationships, like loopbacks or secondary IPs. Loopbacks are always advertised as /32 even if they have a different mask. To change this make them a network type of P-t-P.
Two very useful commands when troubleshooting OSPF to see why a route you think you are advertising is not in the routing table:
show ip ospf database self-originateOn router where route is advertised make sure it is in OSPF show ip ospf database adv-routerip On neighbor make sure can see it in LSAs from the source
Type1 LSAs list all the links off that router and their metric, Type2 list all the Type1 LSAs know by the DR and Type3, Type5 and Type7 advertise the prefix, mask, metric and the address of the ABR or ASBR advertising it (can differ depending on the area type).
Type1 and Type2 LSAs are only circulated within the area that they are produced.
Inside an area OSPF uses link state logic, but between areas it must act like a distance vector protocol. The advertisement of Type3 LSAs hides the topology in the original area from second area, just listing the destination subnet, metric (cost) and the ABR that advertised it.
Type1 - Router
Produced by every router for each area they are part of. Are flooded throughout the same area describing itself, all its links or interfaces (in that area), the state and outgoing cost of each link and any know OSPF neighbors. If it says ‘routing bit set on this LSA’ it means that there is a route to this destination in the routing table. ‘Link connected to: point-to-point’ are adjacent routers, ‘transit’ are Adjacent DRs and ‘stub’ are all directly connected networks or loopbacks.
show ip opsf database routerlsid Each router is identified by LSID that is the RID show ip opsf database routerlsid self-originateNetworks this router originates show ip opsf database router adv-routerip See the LSAs being advertised by this router
Type2 - Network
Created by the DR representing the multi-access network and all attached routers as a pseudonode (virtual router). It has no metric in the LSA as the cost to any route is always 0. The DR role is decided per-interface (network segment) rather than per-router.
show ip opsf database networkdr_lsid LSID is the DRs interface address. The attached networks are a list of all Type 1 LSAs connected to the pseudonode
Type3 – Summary
Originated by an ABR and sent into an area to advertise routes outside that area. Flooded only into areas it is originated into by the ABR, it doesn’t traverse any other areas.
It will not forward Type1 or Type2 LSAs, it is just the best route to a destination and the cost to reach that subnet. There is no SPF calculation so is effectively distance vector. If are multiple routes to a destination will have separate LSAs for each with a different advertising router.
show ip opsf database summarylsid LSID is the subnet. Includes ABR which advertised it & cost to ABR show ip ospf database summarynetwork adv-routerip See summary being advertised by specific ABR show ip opsf border-routersTo see cost to reach the ABR
Type4 - ASBR Summary
Identical to Type3 LSAs except the destination they advertise is an ASBR rather than a network. Created by the ABR in response to receiving a Type5 LSA. They are created at the border of each area when a Type5 LSA is passed on into that area and are all the possible different routes (via ABRs) to get to the ASBR. Contains RID of ASBR, ABR that created it and the cost/metric from the ASBR to the ABR.
show ip opsf database asbr-summarylsid LSID is that of the ASBR show ip opsf border-routersTo see cost to reach the ABRs and ASBRs
Type5 - AS External
Originated by the ASBR. Advertises a destination external to the OSPF area such as redistributed routes or routes sourced from another routing protocol. They are flooded throughout the domain to all areas as either E1 (advertised metric includes internal cost) or E2 (advertised metric is just external cost). Within the OSPF database they are situated under the process rather than any area as they are external meaning they are not tied to any area.
show ip opsf database external | begin ASBRStart from LSA Type4 show ip opsf database externallsid LSID is external network. The advertising router is the RID of the ASBR that created it & the forwarding address is 0.0.0.0 meaning forward it to the advertising router RID (ASBR - LSA4)
For any given prefix/length OSPF always prefers E1 over E2 routes. The costs that can be added for external routes are:
- Best intra-area cost to reach the ASBR if the ASBR is in the same area (taken from the areas LSDB)
- The cost from the ABR to the ASBR if the ASBR is in a different area (taken from the Type4 LSA). Applies only for E1 prefixes
- The external cost for the route (taken from the Type5 LSA)
E2 is just the seed metric (what redistribution adds) that is advertised to others. This is never incremented and is put in routing table on all routers. Within Type5 LSA that are E2 there is a forward metric (although can only view it in show ip route) which is the cost to get to the ASBR. It increments depending on how far away the router is from the ASBR. It only comes into play if there are multiple exit points, routers look at the forwarding metric as the tie breaker it the metrics for the external router are the same.
E1 doesn’t have a forward metric in the LSA, instead its metric value is the result of the metric plus the forward metric and it is this value that is advertised to all other routers in OSPF.
show ip routeIf is E1 only shows 1 metric value that incorporates both the metric and forwarding metric. If is E2 shows the metric (of the external route) as well as a Forward metric (cost to the ASBR) which is not used unless as tie-breaker
Type7 - NSSA External
Originated by ASBRs in a NSSA area. Identical to Type5 LSAs, but rather than been flooded throughout the OSPF domain they are only flooded within the NSSA area in which they were created. At the ABR they are translated from Type7 to Type5 LSAs but no Type4 LSA is created as the forward address is set to the router in the NSSA area that advertised it (not 0.0.0.0) so other routers will route direct to that.
Uses the same external metric type logic as Type5 LSAs, but are represented as N1 and N2.
show ip opsf database external | begin ASBRStarts from LSA Type4 show ip opsf database nssa-externallsid LSID is external network
Type5 LSAs will have the forward address: 0.0.0.0, meaning route traffic towards the advertising router (ASBR) through the ABR who created the Type4 LSA. Traffic will always traverse through the ABR that created the Type4 LSA, with the Type4 LSA representing the cost from the ABR to ASBR.
Type7 forward address will always be the RID of the original advertising router (ASBR). When the Type7 is converted into a Type5 no Type4 is created and the advertising router is changed to that of the ABR that performed the conversion. However, the forward address is still set as the original ASBR who originated the Type7 LSA (not 0.0.0.0) meaning traffic can be forwarded over any path rather than always through the ABR that did the Type7 to Type5 translation.
Type5 and Type7 differences
- Type 4 LSA: Advertising Router is the RID of ABR who created it
- Type 5 LSA: Advertising Router is the RID of the ASBR (Type4 LSA created if traverses an area) and the Forward Address of 0.0.0.0 means look in the Type4 LSA for the ABR address who created it
- Type 5 LSA translated from Type 7: Advertising Router is the ABR who did the translation and the Forward Address is inbound/outbound interface of the ASBR
- Type 7 LSA: Advertising Router is the RID of the ASBR and the Forward Address is inbound/outbound interface of the ASBR
General OSPF specific commands
show ip routeO is Intra-area show ip route | in O IAShow only inter-area routes show ip ospf database database-summarySummary table showing the number of each type of LSA show ip opsf databaseAll LSAs and info such as Link ID (RID) and advertising router show ip opsf database adv-routerip Show LSAs advertised by the specified router show ip ospf border-routesThe internal route table with paths and costs to ABR and ASBRs show ip opsf database routerShow Type1 LSAs show ip opsf database networkShow Type2 LSAs show ip opsf database summaryShow Type3 LSAs show ip opsf database asbr-summaryShow Type4 LSAs show ip opsf database externalShow Type5 LSAs show ip opsf database nssa-externalShow Type7 LSAs show ip ospfid area database.....Can use any of the LSA cmds to look at the LSAs for just a specific area. However, remember Type5 is shown under the process rather than any specific area they are routes external to OSPF