Understand BGP Finite State

Understand BGP finite state

Pasted image 20250306161631.png

IEDescription
1BGP Start
2BGP Stop
3BGP Transport connection open
4BGP Transport connection closed
5BGP Transport connection open failed
6BGP Transport fatal error
7ConnectRetry timer expired
8Hold timer expired
9Keepalive timer expired
10Receive Open message
11Receive Keepalive message
12Receive Update message
13Receive Notification message

Idle state

BGP always begin at idle state, which refuses all incoming connection. When BGP start event (IE 1) occured. BGP will initialise and start ConnectRetry timer. It initialise TCP connection to the neighbor, and listen for TCP connection from the neighbor as well.

Start event (IE 1) can be done by:

  • Operator restart BGP
  • Operator re-configure BGP
  • Router re-try again after failure that led to Idle state. Given the condition that the ConnectRetry timer expired. IOS initial ConnectRetry is 120 seconds

Connect state

BGP process is waiting for TCP connection to the neighbor to be completed. If TCP connection.

If connection is

  • Successful, it will clear ConnectRetry timer and send BGP Open Message and transition to OpenSent state
  • Unsuccessful, BGP will resets the ConnectRetry timer and actively listen to connection initialised by the neighbor. It will transition to Active state

If the ConnectRetry timer expire, it will reset the timer and make another attempt for TCP connection. The above condition loops back.

Active state

BGP process tries to initiate TCP connection. If TCP connection is successful, it will clear ConnectRetry timer and complete initialisation, send BGP Open Message to the neighbor and transition to Open Sent

The IoS default Hold time is 180 seconds and can be changed with timers bgp statement

If ConnectRetry timer expires while BGP in active state, it will transition back to Connect state and reset the ConnectRetry timer

IF the neighbor atteempts to establish a TCP connection with an unexpected IP address, ConnectRetry timer is reset and the process stay in Active state

OpenSent state

BGP Open Message has sent, BGP is waiting to hear an Open from the neighbor. When the message is received, it will check the fields of the Open message.

If there is any error, we transit to Idle state, a Notification message is sent

If no error, Keepalive message is sent and keep alive timer is set. Hold time is negotiated.

If the negotiated Hold time is zero, the Hold and Keepalive timers are not started, the peer connection will be determine either internal or external. Based on AS number, the tate is changed to OpenConfirm

If TCP disconnection received, local process closes the BGP connection, resets ConnectRetry timer and begin listen for new connections, Transition to Active.

OpenConfirm

BGP process waits for Keepalive or Notification message. If Keepalive received, we transition to Established.

If Notification is received or TCP disconnec is received, we changed to Idle

Established State

BGP are fully established and can excahnge KeepAlive, Update, Notification

If Update or Keepalive message received, Hold timer is restarted

If Notification received, we change to Idle