OSPF

The OSPF is link-state routing protocol. Link state protocol is such that the metric is based on bandwidth, load, reliability etc. of a given link as oppose to number of hops between networks.

Also the OSPF or Open Shortest Path First is an Interior Gateway Protocol (IGP) as oppose to BGP (Border Gateway Protocol). BGP is not within a scope of this article, neither is a requirement for the CCNA. BGP protocol uses Area Border Routers to route between Autonomous Systems. This means it operates within a boundary of a single Autonoumous System (AS) also known as OSPF Domain. The Autonoumous System is defined as a system or a network under management or control of a single entity or person. The system is usually managed as an area or a group of areas.

As Jerremy Cioara says that in Las Vegas they have a rule: “What ever happens in Vegas stays in Vegas”. Similar rule applies to IGP or Area Border Router. Everything that happens within the scope of a IGP protocol is never transmitted outside the Autonomous System.

In a given AS, all the areas belong to Area 0, known as a Back Bone Area.

Cisco recommends that a single Area should contain not more than 50 routers.

The OSPF doesn’t send entire routing or a topology table across to all neighbouring routers like the RIP did. Instead, it establishes a neighbour relationship with its neighbours. The routers elects between themselves a router (or two) that are in charge of making sure that all other routers within the same area know all the information about the specific area.

Neighbour relationship

The OSPF Routers have to establish neighbour relationships before they can go any further. To establish the relationship they use Hello message (this is a technical term).

The Hello massages and Neighbour relationship

For a router to establish a neighbour relationship with another router the following parameters must match on both routers and their Hello messages :

  • Timers (Hello and Dead Interval) need to be set to the same values respectively
  • The interfaces must belong to the same Autonomous System
  • The routers need to belong to the same Area (CCNA requirement is to know how to configure OSPF for a single area)
  • If authentication is used, the routers should have the same password. For the CCNA, you do not need to know how to configure this feature.

This Hello message’s parameters does not need to match :

  • Router priority
  • Router ID – Designated Router/Backup Designated Router IP address
  • Neighbour

After establishing a neighbour relationship the OSPF choose one router in the area as Designated Router. Sometimes is also elects a Backup Designated Router. The role of a Designated Router is to keep all the other routers on the same page and up to date regarding the area information.

Note: The role of Designated Router and it’s Backup are locally relevant, meaning in another area different routers are going to play this role.

The OSPF Designated Router Elections

The OSPF protocols choose one router per area as Designated Router and sometimes another one to play a role of Backup Designated Router. The router with the highest Router ID wins the elections.

Note: Mnemonics to remember whether highest or lowest value wins elections.

  • It is usually the case that for The Layer 2 technologies the lower values wins
  • For The Layer 3 technologies, the higher values win elections.

As a router ID routers use, in order of preference:

  • Hard-coded router priority
  • IP number of a loopback (virtual)
  • IP number of a physical IP interface.

Note: The interfaces to influence the RID need to be active – in up/up state.

After electing the Designated Router and it’s Backup, the OSPF uses two broadcast IP addresses (224.0.0.5 and 224.0.0.6)* to exchange information about what a single router knows about it’s own directly connected links and what is known about entire area – what is the state of entire network.

* Broadcast OSPF addresses

  • 224.0.0.5All OSPF routers.
  • 224.0.0.6 – Designated OSPF routers, not just ordinary OSPF routers

States of the OSPF adjacency formation

Note: Some parts of the following text, concerning OSPF adjacency states, is copied with some modifications from the Cisco.com website. Personally I believe that was the original source, despite you could find many quotations of this one and similar texts all over the Internet. My own modifications were meant to make it easier to understand without extensive course that is part of CCNP or CCIE curriculum. Also to make it consistent with the British standard spelling of some words that are different in American English.

Although it is beyond the CCNA exam requirements, it might be interesting to know what are states of routers participating in the OSPF protocol as they form adjacency relationships. Maybe you won’t be surprised when you see some of them in the** show command output.

  • Down – No Hello packets has been received.
    The Hellos can be sent to the neighbour. Either in order to form a new relationship or to maintain an existing one.If a router, after transition into Full adjacency state, doesn’t receive a Hello packet from a neighbour within Router Dead Interval time, it assumes that a neighbour is not available anymore and changes the state of the adjacency relationship to Down.
  • Attempt – This state is used only for NBMA (Non-Broadcast Multiple Access) environments. It is used to (re)establish adjacency with a neighbour from which Hellos have not been received before Dead Interval timer elapses.
  • Init – The router has received a Hello packet from a neighbour. However, ID of the receiving router was not included in this packet. Normally as a confirmation of receiving a Hello packet, the router sends it’s own Hello packet with router ID of the original sender.After receiving a Database Descriptor (DBD) packet from a neighbour will cause a transition to the 2-way state.
  • 2-Way – The routers has seen each other’s ID in Hello packets. At this state, the routers decide whether or not to form adjacency relationship, based on the parameters defined in their Hello packets.For Broadcast and Non-Broadcast Multi-Access networks, routers will became a Full Neighbour only with Designated Router and it’s Backup. At the end of this state the Designated Router and it’s Backup will be elected.For a Point-to-point or Point-to-multipoint networks all OSPF participating routers will become neighbours with all other OSPF routers in a given area.I was told that ordinary OSPF router only reaches the 2-Way state with others routers, which are not Designated or Backup Designated Routers. Only DR/BDR can reach the Full state of adjacency. This nuance makes it a perfect detail to ask a candidate on the exams.
  • ExStart – This is the state where all routers start to exchange link-state information with theirs Designated Router and Backup Designated Router. At this state, all routers are either the Master or a Slave in the relationship to a Designated Router. Also, routers choose their initial sequence number. Routers with a higher ID are Masters. They start the link-state information exchange and they also can increment the sequence number.

Note: Sometimes a hard-coded router priority plays a role in a Designated Router elections. In such case, the DR sometimes can play a role of a Slave instead of a Master.

  • Exchange – In this state the OSPF participating routers exchange DataBase Descriptor (DBD) packets, which contains only headers of link-state advertisement (LSA) and describe the contents of the entire link-state database. Each DBD packet has a sequence number which can be incremented only by the master which is explicitly acknowledged by the slave.Routers also send link-state request packets and link-state update packets in this state. The updates are acknowledged by link-state acknowledgements.The contents of the DBD received are compared to the information contained in the routers link-state database to check if new or more current link-state information is available with the neighbor.
  • Loading – In this state, the actual exchange of link state information occurs. Based on the information provided by the DBDs, routers send link-state request packets. The neighbour then provides the requested link-state information in link-state update packets. During the adjacency, if a router receives an outdated or missing LSA, it requests that LSA by sending a link-state request packet. All link-state update packets are acknowledged.
  • Full – In this state, routers are fully adjacent with each other. All the routers in a network have their LSAs exchanged and the routers’ databases are fully synchronized on all OSPF participating routers.

The Full state is the normal state for an OSPF router during its operation. If a router is stuck in another state, it’s an indication that there are problems in forming adjacencies. The only exception to this is the 2-way state, which is normal on a broadcast network. Routers achieve the full state with their DR and BDR only. Neighbours always see each other as 2-way.

Note: The Full state is also known as passive and all the other state are described as active. When the state is active it means the link-state information between routers is somewhat inconsistent or out dated,s to it needs to be synchronized, hence the activity of the state. If the network is fully converged* the link-state information doesn’t need to be exchanged. Routers only send the Hello packets periodically hence, the name is passive.

* Convergence is the state of the network when all it parts agree on what they know about the network.

After achieving a Full state routers calculate their own best paths to each destination in their topology table, using the SPF (Shortest Path First) algorithm* with themselves as the roots of the spanning tree.

* SPF is also known as Dijkstra algorithm

OSPF Timers

Whilst researching the OSPF timers I have found that there are quite a few of timers in the protocol itself. However, Cisco doesn’t seem to be concerned with anything more than just two of them. As a comparison, Juniper allows configuring more than just the Cisco’s two.

The purpose of the two that Cisco uses is to make sure that the routing protocol can detect some routers or parts of a network being unavailable or non-operational.

  • Hello Interval – describes after how many seconds router will send it’s Hello packet to let every other router know that it is still there and ready for routing.
  • Dead Interval – describes after how many seconds router will be considered non-operational and for not part of the network anymore.

The default values differ depending on type of the network in seconds

  • Broadcast networks – Ethernet, Point-to-Point, Point-to-Multipoint
  • Non-Broadcast networks – X.25, FrameRelay
Hello Interval Dead Interval
Broadcast 10 40
Non-Broadcast 30 120

The OSPF packet types

  1. Hello packet – These packets are multicast periodically to 224.0.0.5 multicast address on all interfaces (unicast on virtual-links) enabling dynamic discovery of neighbours and maintain neighbour relationships. On broadcast and NBMA networks, Hello packets are used to elect DR and BDR.
  2. Database Descriptor packet – For link-state routing protocol, it is required that the link-state databases for all routers remain synchronized. The synchronization starts as soon as the adjacency is formed between neighbours. OSPF uses Database Descriptor (DBD) packets for this purpose.
  3. Link State Request packet – After DBD packets exchange process, the router may find it does not have an up-to-date database. The LSR packet is used to request pieces of a neighbour database that are more up-to-date. 
  4. Link State Update packet – Link State Update (LSU) packets are OSPF packet Type 4. These packets implement the flooding of LSAs. Each LSA contains routing, metric and topology information to describe a portion of OSPF network. The local router advertises LSA within an LSU packet to its neighbouring routers. In addition, the local router advertises the LSU packet with information in response to an LSR packet.
  5. Link State Acknowledgement packet – OSPF requires an acknowledgement for the receipt of each LSA. Multiple LSAs can be acknowledged in a single LSAck packet.

Whilst researching the OSPF, I found a lot of interesting articles. I could go on and dig deeper and deeper for quite a while into the details how it all works. One example could be to describe a real life wire captures of packets and explain what means it’s parts what and how it all works together or to go through some troubleshooting exercises. The OSPF is clearly superior to RIP, even with as little as I have written here.

The more extensive article that explains how the OSPF packets are built shows a live wire captures and describes its operation can be found here https://sites.google.com/site/amitsciscozone/home/important-tips/ospf/ospf-packet-types . Maybe in not too distant future I will write an article about the OSPF again and go deeper into some more details.

This entry was posted in Cisco and tagged , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a comment