Understanding the BGP Finite State Machine: From IDLE to ESTABLISHED

The Border Gateway Protocol (BGP) is the backbone routing protocol of the internet, allowing different autonomous systems (AS) to exchange routes. Understanding how BGP routers establish connections using the BGP finite state machine is critical for network engineers. This post will explain the various states in which a BGP session transitions through to an operational connection.

IDLE State 

The IDLE state is the initial condition of a BGP router. In IDLE, the router is dormant, waiting for an event to initiate a BGP peering session. Two possible events can transition the router from IDLE to the next state:

  • ManualStart – User manually clears/resets the BGP session
  • AutomaticStart – Internal automatic event based on configuration

Upon receiving either start event, the router will:

  • Initialize peer connection resources 
  • Reset the ConnectRetryCounter to 0
  • Start the ConnectRetryTimer
  • Initiate a TCP handshake to the peer
  • Listen for an incoming connection
  • Change state to CONNECT


The router attempts to establish a TCP connection with the configured peer in the CONNECT state. This involves completing the TCP 3-way handshake. The router stays in CONNECT until the handshake finishes successfully or fails.

On success, the router proceeds to OPEN SENT. On failure, it moves to ACTIVE instead. 


The ACTIVE state represents a failed initial connect attempt. The router will try to establish the TCP connection again and send an OPEN message to the peer. 

If the second try fails, the router returns to CONNECT again. Seeing a router stuck in ACTIVE generally means no working BGP session.


In OPEN SENT, the TCP connection should now be established. The router sends a BGP OPEN message containing parameters like:

  • BGP version 
  • Local AS number
  • Hold timer
  • Router ID
  • Optional parameters

The peer router receives this OPEN and responds with its own.


When the local router receives the OPEN message from the peer, it enters OPEN CONFIRM. Here, the router sends a KEEPALIVE message to confirm receipt of the peer’s OPEN. 

Next stop: the desired ESTABLISHED state!


Finally, when BGP parameters are agreed upon and keepalive messages exchanged, the routers reach the ESTABLISHED state. Only now will the routers exchange route updates. 

ESTABLISHED is the only operational state – all other states represent connection startup or errors. Troubleshooting BGP means getting routers out of intermediate states into ESTABLISHED.

Understanding this progression through the finite state machine is foundational when working with BGP routers out in the wild!