Model Architecture: BGP
The following section has more relevance to model developers (e.g., Modeler users). All router nodes that support BGP have a BGP module that spawns BGP-related processes in the router. The two processes that model BGP are
bgp.pr.mbgp_conn.pr.m
The bgp process model is the root process model. It is responsible for handling all incoming BGP packets. It also reads all the BGP configuration during initialization and creates one instance of the bgp_conn process model for each BGP neighbor configured on the node.
The following table lists the process models used by the BGP model.
Table 32: BGP Process Models
| Process Model | Description |
|---|---|
bgp |
Root process that controls the BGP peering sessions established with neighbors. The process initiates peering connections to all configured neighbors at the specified start time and dispatches any messages from neighbors to the correct bgp_conn process. |
bgp_conn |
The bgp_conn process model represents the BGP finite state machine described in RFC 1771. A single bgp_conn process is created for each bgp peer the router communicates with. Once initiated, this child process is responsible for initiating, maintaining, and tearing down the BGP and TCP connection processes. |
Model States and Operation: BGP
bgp Process Model
After initialization, the bgp process model waits in the Active state for an interrupt. The states "Open Indication", "Open Confirm", and "Data Arrival" handle interrupts related to setting up connections. Based on the connection for which these packets arrive, the bgp process invokes the appropriate bgp_conn child process.
The "Update Message" state is an important state that is entered when bgp gets an update packet from a neighbor. Based on the neighbor from which the packet has arrived, the appropriate bgp_conn process is invoked. This process then handles all the reachability and unreachability information present in the incoming packet by updating the RIB-IN of the connection and handing the control back to the parent bgp process. The parent bgp process then processes all the new information. It removes the unfeasible routes from the LOCAL-RIB, updates the LOCAL-RIB with new routes after running the BGP decision algorithm, and updates the IP forwarding table, if necessary.
Once all of the routes are processed, the parent process invokes all of the other bgp_conn child processes, so this new information is propagated to other neighbors.
"Node failure" is a state that is entered when a node fails. During this state, the BGP table is cleared out, and the corresponding entries are removed from the IP forwarding table. Control comes back to the Active state only if a recovery interrupt is received.
Additionally, redistribution interrupts are handled by the function bgp_ext_rte_ind_handle (). This causes an update of the BGP local RIB, and the propagation of the information to all the neighbors.
bgp_conn Process Model
bgp_conn is a child process of the bgp process. For every BGP neighbor of a node, there is one instance of bgp_conn. The states of the bgp_conn process reflect the current state of a particular connection, as the names suggest. The bgp_conn process model is responsible for processing incoming update messages and updating the RIB-IN. It is also responsible for pushing changes from the LOCAL-RIB to the RIB-OUT and sending update messages to the neighbor on a TCP connection.
Figure 118: bgp_conn Process Model

BGP-IP Interaction
BGP uses the common route table API to insert, delete, and update routes in the IP forwarding table. You can search for the string "Cmn_Rte_Table" to locate all the instances where BGP communicates with IP.
Note: Many support functions are present in the bgp_support.ex.c external file. One way to understand the working of the BGP processes is by running a simulation in debug mode and stepping through the execution. It is best to start with a simple network containing two or three nodes that are running BGP among themselves.