OSPF NEIGHBOR STATES
http://www.firewall.cx/networking-topics/routing/ospf-routing-protocol
https://www.cisco.com/c/en/us/support/docs/ip/open-shortest-path-first-ospf/13685-13.html
- Down state
- Attempt state
- Init state
- 2-Way state
- Exstart state
- Exchange state
- Loading state
- Full state
Once OSPF is enabled on a router interface, a Link State Database (LSD) is established and all interfaces running OSPF are added to this table to be used in Link State Advertisements (LSAs), OSPF then the begins neighbor discovery and forming adjacency process.
DOWN STATE
The Down State is the first OSPF neighbor state and means no Hello packets have been received from a neighbor. In an already established OSPF adjacency, an OSPF state will transition from a FULL or 2-Way State to the Down State when the router Dead Interval Timer expires (4 x Hello Interval timer), which means OSPF has lost communication with its neighbor and is now considered non-reachable or dead.
2-WAY STATE
This state designates that bi-directional communication has been established between two routers. Bi-directional means that each router has seen the other's hello packet. This state is attained when the router receiving the hello packet sees its own Router ID within the received hello packet's neighbor field. At this state, a router decides whether to become adjacent with this neighbor.
On broadcast media and non-broadcast multiaccess networks, a router will reach Full state (adjacent) only with the designated router (DR) and the backup designated router (BDR); it stays in the 2-way state with all other neighbors. On Point-to-point and Point-to-multipoint networks, a router becomes full with all connected routers.
SENDING & RECEIVING OSPF HELLO MESSAGES (2-WAY STATE PART 1)
An OSPF router generates a Hello packet every poll interval -10 seconds for Peer-to-Peer (P2P) networks and 30 seconds for Non-Broadcast-Multiple-Access (NBMA) networks by default- and advertises it through multicast address 224.0.0.5 to all routers connected to its interfaces while it searches for potential OSPF neighbors. The Hello message contains a list of information needed to form an OSPF neighbor relation between two neighboring routers, the following a list of information contained the Hello messages:
- OSPF Router ID. The router’s ID which is configured or automatically selected by OSPF (analyzed below)
- Hello Interval Timer. Frequency upon which Hello packets are sent.
- Dead Interval Timer. Defines how long we should wait for hello packets before we declare the neighbor dead.
- Subnet Mask
- Router Priority. Used to help determine the Designated Router (DR). Higher priority takes precedence. A configured Priority of 0 means the router will not become a DR or BDR.
- List of reachable OSPF neighbors in the network.
- Area ID
- DR & BDR’s IP addresses (if exists)
- Authentication Password (if configured)
Once a neighbor router (R2) running OSPF receives the Hello message, it runs a check on the above list.
The following conditions must be met for two routers to become neighbors:
- They must have the same IP network/subnet
- The Hello and Dead Interval timers must be identical
- Router interfaces connecting two routers must have the same Area ID
- Type of area must be identical (normal or stub area)
- Authentication password (if used) must be identical
REPLYING HELLO MESSAGES (2-WAY STATE PART 2)
When R2 receives the OSPF Hello message from R1 and all necessary Hello parameters match, R2 will send a Reply Hello packet back to R1.
The Reply Hello allows the R1 (who sent the original Hello message) to investigate if the neighboring router R2 is listed in its neighbor listor not.
- If the neighboring router R2 is listed as a neighbor already, then R1 resets its dead timer and the Reply Hello messages act as a Keep Alive mechanism.
- If the neighboring router R2 is not listed in R1’s neighbor database, it will add the newly discovered neighbor R2 router to its OSPF neighbor database. All further OSPF Hello and Hello Reply messages will act as a Keep Alive mechanism.
DR Election (2-WAY STATE PART 3)
DR and BDR election is also done in 2-WAY STATE. The router with the highest OSPF priority on a segment will become the DR for that segment. The same process is repeated for the BDR. In case of a tie, the router with the highest RID will win. The default for the interface OSPF priority is one. Remember that the DR and BDR concepts are per multiaccess segment. Setting the ospf priority on an interface is done using the ip ospf priority <value> interface command.
A priority value of zero indicates an interface which is not to be elected as DR or BDR. The state of the interface with priority zero will be DROTHER.
EXSTART STATE
Once the DR and BDR are elected, the actual process of exchanging link state information can start between the routers and their DR and BDR.
In this state, the routers and their DR and BDR establish a master-slave relationship and choose the initial sequence number for adjacency formation. The router with the higher router ID becomes the master and starts the exchange, and as such, is the only router that can increment the sequence number. Also, it is possible that a DR plays the role of slave. Master/slave election is on a per-neighbor basis
EXCHANGE STATE
In the exchange state, OSPF routers exchange database descriptor (DBD) packets. Database descriptors contain link-state advertisement (LSA) headers only and describe the contents of the entire link-state database. Each DBD packet has a sequence number which can be incremented only by master which is explicitly acknowledged by slave. Routers also send link-state request packets and link-state update packets (which contain the entire LSA) in this state. 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.
In short:
1. Master sends DataBase Descriptor (DBD) update packet first.
2. Slave checks DataBase Descriptor (DBD) and finds new routes information, it then requests updates by sending a Link State Request(LSR) packet.
Loading STATE
In this state, the actual exchange of link state information occurs. Based on the information provided by the DBDs, routers send link-state request (LSR) packets. The neighbor then provides the requested link-state information in link-state update(LSU) 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 (LSAck).
In short:
3. Master sends back updates through Link State Updates (LSU) packets.
4. Slave acknowledges the reception of updates by sending a Link State Acknowledge (LSAck) packet.
5. Slave sends DataBase Descriptor (DBD) update packet next.
6. Master requests updates by sending a Link State Request (LSR) packet.
7. Slave sends updates through the Link State Update (LSU) packets.
8. Master acknowledges receiving updates by sending a Link State Acknowledge (LSAck) packet.
There are no diagrams showing steps 5 to 8, however these are similar to the first 4 steps, but with the Master router requesting the Link State Request (LSR).
Full STATE
In this state, routers are fully adjacent with each other. All the router and network LSAs are exchanged and the routers' databases are fully synchronized.
Full is the normal state for an OSPF router. If a router is stuck in another state, it is an indication that there are problems in forming adjacencies. The only exception to this is the 2-way state, which is normal in a broadcast network. Because, routers only achieve the FULL state with their DR and BDR in NBMA/broadcast media or every neighbor(only one) in the remaining media such as point-to-point and point-to-multipoint, while 2-way state with the rest of neighbours.