Before OSPF will start to work seamlessly, one very important thing has to be accomplished, neighbor relationship namely. Every router in the network has to pass through a few stages of establishing relationships process, before network reach full convergence. What exactly happens behind the scene during establishing of relationship ?
OSPF Neighbors Relationship process can be divided onto a few stages :
1) Routers elect Designated Router (DR) and Backup Designated Router (BDR). It happens based on the Priority. The router with the highest Priority becomes DR. The second one becomes BDR and the remained routers become DROTHERs. Each router by default has Priority 1, routers with Priority 0 don’t take part in DR and BDR election. If priority is not set (on both routers is the same) then Router ID is tie-breaker. Router ID is an assigned number, if the number hasn’t been assigned then the lowest loopback ip address becomes Router ID. DR and BDR deal with sending routing upates to the Drothers, this is why OSPF uses 2 multicast addresses, one of them is being used by drothers to send information about topology changes to BR and BDR and the second one to send updates from BR and BDR to the other routers. The main goal of this acting is reducing the flow within the area.
2) Hello, Dead Timers, Area ID and MTU have to match on each router in Area, otherwise relationship will not be established !. Hello packets are sent by routers in order to let to know other routers that the router is still alive (keepalive mechanism). Dead Timers describes how much time may pass, before the router will be considered as a “dead”.
3) Routers exchange DBD (Data Base Descriptions) packets with LSA headers, and build LSDB based on DBD packets. Each router in Area should have the same LSDB (Link State Data Base). Routers compares theirs DBD and if notice a differences (different networks), then send LSR (Link State Requests). As the answer get LSU (Link State Update). I wrote another article about LSA packets flow here
4) Routers achieve FULL STATE and neighbor relationship is established !
OSPF STATES :
There are a few states before routers achieve FULL RELATIONSHIP, these states occur on each router in fixed order:
DOWN – HELLO packets are being sent, but not received yet, no relationship
ATTEMPT – used for manually configured neighborhood
INIT – HELLO packet has been received from new neighbor
2 WAY – neighbors are being identified (DR/BDR election)
EXTART – master and slave relation is being established. Master and Slave are being elected based on Router ID, the router with the higher ID becomes the Master. The role of Master is initiating of routers “conversation” about DBD exchanging. Designated Router may be the Slave if has lower Router ID than DROTHER. Router ID is 32 bits number (I put only last octet on the picture).
EXCHANGE – Data Base Descriptions packets are exchanged and compared between routers. At this stage may happen failures like “MTU mismatch” or “doubled Router ID”, the same Router ID on different routers.
LOADING – exchanging LSR / LSU / LSAck packets.
FULL – Full adjacency and neighbor relationship is established !