Navigating the Border Gateway Protocol: Understanding BGP Neighborship States
Border Gateway Protocol is a routing protocol used to form communication between different Autonomous Systems on the internet.
Join the DZone community and get the full member experience.
Join For FreeBorder Gateway Protocol is a routing protocol used to form communication between different Autonomous Systems on the internet. BGP works over a TCP connection and goes through multiple steps to establish and maintain a session. Let's dive in to understand it.
Topology:
Detailed BGP neighborship states:
Idle
This is the initial stage of the BGP process, in Idle state the BGP process anticipates a start event. BGP is not proactively looking to connect with its BGP neighbor. The BGP process is also checking for any errors or misconfiguration which could prevent it from forming a neighborship with its peer. Once checks are completed, BGP progresses to the Connect state. The router now attempts to establish a TCP connection, if established, it transitions to the next stage which is the Open Sent state, where BGP messages are exchanged. Once open messages are exchanged, the session transitions to the Open Confirm state and then finally to the Established state, where BGP routes are exchanged. Remember, if any errors get identified the BGP session falls back to the Idle state.
Connect
BGP process when it transitions from Idle to Connect state, its attempts to establish a TCP connection with its neighbor. A ConnectRetry timer is configured for connection attempts. If a TCP connection is not established before the timer expires, the session transitions to an Active state. When established, an Open message is sent, transitioning the session to OpenSent. If it fails, the router might attempt again, revert to Idle, or switch to Active based on the retry policy.
Active
In the Active state, the BGP process actively keeps trying to form a TCP connection in this state. The router might go back and forth between Connect and Active state all the while trying to establish a connection. Once the connection is established, the router sends an Open message and transitions to OpenSent. Repeated failures can lead the router to return to Idle to avoid excessive retries.
OpenSent
When the transition to the OpenSent state is completed, the router sends an Open message to its peer which contains BGP-related info such as BGP version, AS number, hold timer, BGP identifier, and optional parameters. The open messages are exchanged. The received open messages are validated, essentially checking for compatible BGP versions, and acceptable AS numbers, and verifying the configuration for errors. If the parameters in the Open message are accepted, the router sends a Keepalive message and moves on to the OpenConfirm state.
OpenConfirm
In the Open Confirm state, the router is on standby, waiting for a Keepalive message from its peer. This message confirms that the session parameters are all good and the peer is ready to continue. The router has a hold timer running, and if it doesn’t get the Keepalive message within this period, it will send a Notification message and revert to the Idle state. A BGP hold timer is a mechanism that monitors how long it's been since a router received a successful keepalive message. However, if the Keepalive message does come through on time, the router responds with its own Keepalive message and then transitions to the Established state.
Established
Once the BGP session hits the Established state, it's fully up and running. The routers will swap Update, Keepalive, and Notification messages as necessary. Update messages handle the exchange of routing information, announcing new routes and withdrawing old ones that are no longer valid. Keepalive messages are sent regularly to make sure the session stays active, with the timing based on the agreed-upon hold time. If something goes wrong, like invalid route info or if the peer stops responding, a Notification message is sent, and the session might drop back to the Idle state. As long as everything is running smoothly and no errors pop up, the routers will keep exchanging routing info in the Established state.
Opinions expressed by DZone contributors are their own.
Comments