BGP States: Understanding BGP Neighbor Adjacency

Border Gateway Protocol (BGP) routers establish neighbor adjacency before being able to exchange routing information. However, unlike other routing protocols which use multicast or broadcast to discover their neighbors, BGP neighbors are manually configured. BGP forms a BGP session through a TCP connection on TCP Port 179 with its peers or neighbor routers. The BGP Finite State Machine (FSM) is used to maintain the BGP table, which contains the peers and operational status. To establish a BGP session, the BGP FSM may take the router through the different BGP states. Listed below are six BGP states.

 

Idle State

Idle is BGP’s first state. If BGP detects a start event where a new BGP neighbor is configured or an established BGP peering is reset, BGP will initialize some resources and reset the ConnectRetryTimer. Then, it tries to initiate a TCP connection to the BGP peer. It will also listen for a new connection established by a BGP peer router. If BGP succeeds in this stage, it will move to Connect state.

If it fails, BGP will stay in an Idle state. The ConnectRetryTimer is then set to 60 seconds and it should decrement to zero for the connection to be initiated again. If it fails again, the previous ConnectRetryTimer will be doubled and should be decremented to zero for a new connection to be initiated again.

 

Connect State

In this state, BGP waits for the three-way TCP handshake to be completed. If it succeeds, the ConnectRetryTimer will be reset by the established BGP session process. An OPEN message to the neighbor will be sent and will proceed to the OpenSent state.

If it fails, the state will continue to the Active state. If the ConnectRetry timer gets to zero and the Connect stage is not yet completed, the ConnectRetryTimer will be reset and BGP will attempt a new three-way TCP handshake. If some other things happen, such as BGP being reset, then the state will go back to Idle.

 

Active State

BGP attempts a new three-way TCP handshake and establishes a connection with the BGP neighbor in this state. If it succeeds, an OPEN message will be sent to the neighbor and the hold timer will be set to 4 minutes. Then, the state will be changed to OpenSent.

If the TCP connection fails and/or the ConnectRetryTimer gets depleted, the state will return back to Connect state. The ConnectRetryTimer will be reset as well. Again, if some other things happen, such as the BGP process being reset, the state will go back to Idle.

 

OpenSent State

After sending an OPEN message to the neighbor, BGP waits for an OPEN message from the BGP neighbor as well. The OPEN messages are both checked and compared for errors, such as:

  • BGP version numbers should match.
  • The OPEN message AS number must match the BGP neighbor’s AS number.
  • The OPEN message source IP address must match the BGP neighbor’s IP address.
  • BGP Identifiers, Router ID (RID), must exist and should be unique.
  • Security Parameters

If there are no errors on the OPEN messages, BGP will send a KEEPALIVE message. The hold time is also negotiated using the lowest value between the two BGP routers. Then, the state will be moved to OpenConfirm.

If an error is found, a NOTIFICATION message will be sent, and the state will return to Idle. If the TCP session fails and gets disconnected, BGP will close the TCP connection and will reset the ConnectRetryTimer. The state will be back to an Active state. If any other event happens, the state will be moved to Idle.

 

OpenConfirm State

In this state, BGP waits for KEEPALIVE messages from the BGP neighbor. If the BGP router receives a KEEPALIVE message, the state will move to an Established state and the BGP neighbor adjacency will be complete. If this happens, the hold timer will be reset as well.

If a NOTIFICATION message is received, or if the hold timer gets depleted, or if a stop event manifests, then the state will be back to Idle.

 

Established State

Finally, the last of the BGP states, the established state, is where the BGP neighbor adjacency is established. The BGP peers or BGP neighbors send UPDATE messages to exchange routing information. When UPDATE and KEEPALIVE BGP messages are received, the hold timer will be reset. If a NOTIFICATION message is received or if the hold timer expires, the state will move back to Idle.


Download our Free CCNA Study Guide PDF for complete notes on all the CCNA 200-301 exam topics in one book.

We recommend the Cisco CCNA Gold Bootcamp as your main CCNA training course. It’s the highest rated Cisco course online with an average rating of 4.8 from over 30,000 public reviews and is the gold standard in CCNA training: