Hello, everyone.
I’ve been over the RFC and I wanted to provide clarity regarding Idle, Connect, and Active, considering that these three states confuse the most people. All of this information is from the BGP RFC.
Idle
This is the initial state that the router will enter the moment we define a neighbor. The RFC says that it happens when:
In response to a ManualStart event (Event 1) or an AutomaticStart event (Event 2).
In other words, the moment we hit a start event such as manually configuring a neighbor (which is a start event) or have this happen automatically (the IOS can do it too), we will hit Idle very fast and the following things will start to happen:
the local system:
- initializes all BGP resources for the peer connection,
- sets ConnectRetryCounter to zero,
- starts the ConnectRetryTimer with the initial value,
- initiates a TCP connection to the other BGP peer,
- listens for a connection that may be initiated by the remote
BGP peer, and
- changes its state to Connect
In other words, the local router will open a socket (TCP/179), allocate resources, find a matching route for the destination and then move to Connect. Idle is basically the preparation phase. You will either be here at the beginning of the peering or in case something goes wrong.
Connect
Idle and Connect are tied together and usually transition fast. In this state, the BGP router is listening for TCP connections (TCP/179) and also trying to establish them towards the destination.
To simplify this, if the connection succeeds, the routers will eventually move to OpenSent and hopefully finish the peering.
Active
BGP’s FSM is good for one thing - causing a migraine. I believe a lot of people are confused about the difference between Connect and Active.
Remember that a router will start in Idle and Reach Connect if the following happens:
In response to a ManualStart event (Event 1) or an AutomaticStart event (Event 2).
Active is a bit different. RFC defines it as:
In this state, BGP FSM is trying to acquire a peer by listening for, and accepting, a TCP connection.
In other words, the Active state is very similar to Connect. However, in the active state, we do not try to establish a TCP connection with the peer, we only listen for them on TCP port 179. This is what the PassiveTcpEstablishment event is.
A passive TCP establishment event, often referred to as a passive open, is the process where a server-side application prepares to accept an incoming network connection. Instead of initiating a connection
When does which one occur?
There are multiple examples of this but I will only include the simple ones.
There are times when the TCP connection fails and the state moves to Connect. There are also times when it moves to Active.
The difference between Connect and Active, in simple terms, is that in the Connect state, we wait for the neighbor by listening on port 179 and at the same time try to establish a connection with it.
In the Active state, we only wait for the neighbor, but do not establish a connection with it.
You will only move from Connect to Active if TCP reports an error (maybe the neighbor closes the connection via an RST or a FIN message) on the connection after it has been successfully established (but before the OPEN messages are exchanged).
If a TcpConnectionFails event (Event 18) is received, the local
system:
- changes its state to Active.
Event 18: TcpConnectionFails
Definition: Event indicating that the local system has received
a TCP connection failure notice.
The remote BGP peer's TCP machine could have sent a
FIN.
Otherwise, you remain in the Connect state or return to the Idle state, it depends on the problem.
The worst part is, as confusing as the FSM is, vendors can decide to implement it differently so what the RFC says does not even always have to be true…
If I had to guess a topic that most people do not understand about BGP, it would probably be this.
The bottom line is, being in the Idle, Connect, or Active states for a long period of time always indicates a problem either with IP reachability or with TCP session establishment.
Just wanted to share this here
David