BGP peer establishment, update, and deletion involve five types of messages, six state machine states, and five route exchange rules.
BGP peers exchange the following messages, among which Keepalive messages are periodically sent and other messages are triggered by events.
Open message
Used to establish BGP peer relationships.
Update message
Used to exchange routes between BGP peers.
Notification message
Used to terminate BGP connections.
Keepalive message
Used to maintain BGP connections.
Route-refresh message
Used to request the peer to retransmit routes if routing policies are changed. Only the BGP devices supporting route-refresh can send and respond to Route-refresh messages.
In Figure 1, a BGP device uses a finite state machine (FSM) to determine its operations with peers. The FSM has six states: Idle, Connect, Active, OpenSent, OpenConfirm, and Established. Three common states are involved in BGP peer establishment: Idle, Active, and Established.
The Start event occurs when an operator configures a BGP process or resets an existing BGP process or when the router software resets a BGP process.
If an error occurs at any state of the FSM, for example, the BGP device receives a Notification packet or TCP connection termination notification, the BGP device returns to the Idle state.
In Connect state, the BGP device starts the Connect Retry timer and waits to establish a TCP connection.
In Active state, the BGP device keeps trying to establish a TCP connection with the peer.
In OpenSent state, the BGP device waits for an Open message from the peer and then checks the validity of the received Open message, including the AS number, version, and authentication password.
In Established state, the BGP device exchanges Update, Keepalive, Route-refresh, and Notification messages with the peer.
A BGP device adds optimal routes to the BGP routing table to generate BGP routes. After establishing a BGP peer relationship with a neighbor, the BGP device follows the following rules to exchange routes with the peer:
Advertises the BGP routes received from IBGP peers only to its EBGP peers.
Advertises the BGP routes received from EBGP peers to its EBGP peers and IBGP peers.
Advertises the optimal route to its peers when there are multiple valid routes to the same destination.
Sends only updated BGP routes when BGP routes change.
Accepts all the routes sent from its peers.