Friday, January 27, 2012

The BGP Finite State Machine

The BGP Finite State Machine

The stages of BGP connection establishment and maintenance can be described in terms of a finite state machine. The figure above shows the complete BGP finite state machine and the input events that can cause a state transition.

Below describes the 6 BGP neighbor relationship states:

Idle BGP always begins in this state, in which it refuses all incoming connections. When a BGP Start event occurs, the BGP process initializes all BGP resources, starts the ConnectRetry timer, initializes a TCP connection to the neighbor, listens for a TCP initialization from the neighbor, and changes state to Connect.
Connect The BGP process is waiting for its own TCP connection attempt to complete. If the connection is successful, the BGP process resets the ConnectRetry timer, completes initialization, sends an Open message to the neighbor, and transitions to the Open Sent state. If the TCP connection is unsuccessful, the BGP process continues to listen for incoming TCP connections to be initiated by the neighbors, resets the ConnectRetry timer, and transitions to the Active state.
Active The BGP process is trying to initiate a TCP connection with the neighbor. If the connection is successful, the BGP process resets the ConnectRetry timer, completes initialization, sends an Open message to the neighbor, and transitions to the Open Sent state; else if the ConnectRetry timer expires, BGP resets the ConnectRetry timer and transitions back to the Connect state.
Open Sent An Open message has been sent, the BGP process is waiting for an Open message from its neighbor. When an Open is received, all its fields are checked. If an error exists, sends a Notification message and transitions to the Idle state. If no errors exist in the received Open message, sends a Keepalive message and set the Keepalive timer. Negotiate the Hold time, the smaller value is agreed upon. Do not start the Hold and Keepalive timers if the negotiated Hold time is 0. Determine the peer connection to be either internal or external based on the AS number on the peer and transitions to the Open Confirm state.
Open Confirm The Open message from the neighbor has been received.
Waits for the initial Keepalive message or a Notification message.
If a Keepalive message is received, transitions to the Established state.
If a Notification message or a TCP Reset is received, transitions to the Idle state.
Established The BGP peer connection is fully established and the peers can exchange Update, Keepalive, and Notification messages. If an Update or Keepalive message is received, resets the Hold timer (if the negotiated hold time is non-zero). If a Notification message is received, transitions to the Idle state.


The default ConnectRetry timer is 120 seconds and it cannot be changed nor tuned. The BGP process checks whether the passive TCP session is established only after the timer is expired. If the passive TCP session is not established, the BGP process initiates a new active TCP connection attempt to the remote BGP peer. During the idle period of the ConnectRetry timer, the remote BGP peer can establish a BGP session to the local BGP router.

No comments:

Post a Comment