Got it

BGP Working principle

Latest reply: Dec 15, 2021 13:11:10 397 6 12 0 0

BGP is a dynamic routing protocol used between autonomous systems. It is mainly used to exchange reachable routing information between ASs, construct a propagation path between AS domains, prevent routing loops, and apply some routing strategies at the AS level.

BGP overview

BGP is an external gateway protocol. Unlike internal gateway protocols such as OSPF and RIP, its focus is not on automatically discovering the network topology, but on selecting the best route and controlling the propagation of routes between ASs.

BGP uses TCP as the transport layer protocol (the listening port number is 179), which improves the reliability of the protocol and does not require a special mechanism to ensure the controllability of the connection; because of the use of TCP, it can only send unicast, not send Multicast, so BGP cannot automatically discover the network topology.

BGP performs inter-domain routing, which has very high requirements on the stability of the protocol. Therefore, the high reliability of the TCP protocol is used to ensure the stability of the BGP protocol

BGP peers must be logically connected and have TCP connections. Destination port number is 179, local port number is arbitrary

There is no periodic update, BGP only sends updated routes, which greatly reduces the bandwidth occupied by BGP propagation, so it is suitable for disseminating a large amount of routing information on Internet.

BGP avoids loops by design:

Between ASs: BGP marks the passing AS by carrying AS path information. Routes with local AS numbers will be discarded, thus avoiding loops between domains. In some cases, the router can accept the same AS route through commands.

Inside the AS: The routes learned by BGP in the AS are no longer advertised to BGP neighbors in the AS, avoiding loops in the AS.

BGP provides a wealth of routing strategies, which can implement flexible filtering and selection of routes. BGP provides a mechanism to prevent route flapping, which effectively improves the stability of the Internet network. BGP is easy to expand and can adapt to new developments in the network. It is mainly expanded through TLV.

BGP working principle-packet type

Open message: Negotiate BGP parameters

Update message: Exchange routing information

Keeplive messages: Maintain neighbor relationship

Notification message: Error notification

Route-Refresh message: Used to request the peer to resend routing information after changing the routing policy

 

The operation of BGP is driven by messages. There are five types of messages: Open, Update, Keeplive, Notification, and Route-Refresh:

Open message: Is the first message sent after the TCP connection is established, used to establish the connection relationship between BGP peers. After the peer receives the Open message and negotiates successfully, it will send a Keeplive message to confirm and maintain the validity of the connection. After confirmation, Update, Notification, Keeplive, and Route-Refresh messages can be exchanged between peers

Update message: used to exchange routing information between peers. An Update message can publish multiple pieces of reachable routing information with the same attributes, and can also cancel multiple pieces of unreachable routing information.

Keeplive messages: BGP periodically sends Keeplive messages to peers to maintain the validity of the connection.

Notification message: When BGP detects an error status, it sends a Notification message to the peer, after which the BGP connection is immediately interrupted

Route-Refresh message: Inform the BGP peer to support the route refresh capability locally through the Open message. When Route-Refresh is enabled on all BGP routers, if the BGP ingress routing policy changes, the local BGP router will issue a Route-Refresh message to the peer. Resend to the local BGP router. In this way, the BGP routing table can be dynamically refreshed and new routing strategies can be applied without interrupting the BGP connection.

 

BGP message application

BGP uses TCP to establish a connection, and the local listening port is 179. Similar to TCP connection establishment, BGP connection establishment also goes through a series of conversations and handshake. TCP announces its port and other parameters through handshake negotiation. BGP handshake negotiation parameters include: BGP version, BGP connection retention time, local router ID (Router ID), authorization information, etc. This information is carried in the Open message. In the negotiation process, BGP will be compatible with higher versions and lower versions, so different versions of BGP can also establish connections normally.

After the BGP connection is established, if there is a route to be sent, an Update message is sent to notify the peer. When an Update message advertises a route, it also carries the route attribute of this route, which is used to help the peer BGP protocol select the optimal route. When the local BGP route changes, the BGP peers must be notified through the Update message.

After a period of routing information exchange, neither the local BGP nor the peer BGP has new route advertisements, and tends to a stable state. At this time, Keeplive messages should be sent regularly to maintain the validity of the BGP connection. For local BGP, if no BGP message is sent from the peer within the hold time, it is considered that the BGP connection has been interrupted.

When the local BGP finds an error during operation (such as the peer BGP version is not supported locally, the local BGP has received an Update message with illegal structure, etc.), a Notification message must be sent to notify the BGP peer. When the local BGP exits the BGP connection, it also needs to send a Notification message.

 

 

BGP working principle-state machine

There are six states in the BGP finite state machine, which are Idle, Connect, Active, Open Sent, Open Confirm and Established.

B1

The Idle state is the initial state of BGP. In the Idle state, BGP rejects the connection request sent by the neighbor. Only after receiving the Start event of this device, BGP starts to try to make a TCP connection with other BGP peers and transitions to the Connect state.

The Start event is caused by an operator configuring a BGP process, or resetting an existing process or router software resetting the BGP process.

After receiving Error events such as Notification message or TCP teardown notification in any state, BGP will go to Idle state.

In the Connect state, BGP starts the connection retransmission timer, waiting for TCP to complete the connection At this stage, a TCP connection request is proactively issued If the TCP connection is successful, BGP sends an Open message to the peer and transitions to the OpenSent state If the TCP connection fails, BGP goes to Active state If the connection retransmission timer expires and BGP still has not received a response from the BGP peer, BGP continues to try to make a TCP connection with other BGP peers and stays in the Connect state If other events occur, return to Idle state.

In the Active state, BGP is always trying to establish a TCP connection at this stage, wait for the other party to initiate a TCP connection If the TCP connection is successful, BGP sends an Open message to the peer, closes the connection retransmission timer, and transitions to the OpenSent state. If the TCP connection fails, BGP stays in Active state If the connection retransmission timer expires and BGP still does not receive a response from the BGP peer, BGP transitions to the Connect state In the OpenSent state, BGP waits for the Open message from the peer and checks the AS number and version authentication code in the received Open message. If the received Open message is correct, BGP sends a Keeplive message and goes to the OpenConfirm state If the received Open message is found to be incorrect, BGP sends a Notification message to the peer and transitions to the Idle state In the OpenConfirm state, BGP waits for Keeplive or Notification messages. If a Keeplive message is received, it goes to Established state, if it receives a Notification message, it goes to Idle state In the Established state, BGP can exchange Update, Keeplive, Route-Refresh and Notification messages with the peer If the correct Update or Keeplive message is received, BGP assumes that the peer is in normal operation and will maintain the BGP connection If an incorrect Update or Keeplive message is received, BGP sends a Notification message to notify the peer and transitions to the Idle state.

Route-Refresh messages will not change the BGP state If a Notification message is received, BGP goes to Idle state If a TCP connection disconnect message is received, BGP disconnects and transitions to the Idle state BGP working principle-BGP routing information processing IP routing table (IP-RIB): Global routing information library, including all IP routing information BGP routing table (Loc-RIB): BGP routing information database, including routing information selected by local BGP speakers Neighbor table: Peer neighbor list Adj-RIB-In: The unprocessed routing information base advertised to the local BGP Speaker Adj-RIB-Out: The local BGP Speaker announces to the routing information base of the specified peer


 

BGP routing information processing:

b2



How BGP works-the principle of interaction between peers:

Routes obtained from IBGP peers are only advertised to EBGP peers

Routes obtained from EBGP peers are advertised to all EBGP and IBGP peers

Only advertise the best route of BGP to the peer

Only send updated BGP routes





IndianKid
Moderator Author Created Jul 14, 2021 15:02:04

Very good and useful post regarding BGP.
Thanks hemin
View more
  • x
  • convention:

hemin88
hemin88 Created Jul 14, 2021 15:54:07 (0) (0)
Thank you brother, you are welcome  
andersoncf1
MVE Author Created Jul 14, 2021 16:40:53

Thanks for sharing Bro! Very useful
View more
  • x
  • convention:

Helpful post! thank you for sharing!
View more
  • x
  • convention:

Good share! Keep up the excellent work!
View more
  • x
  • convention:

AL_93
Moderator Created Dec 15, 2021 13:11:10

Very useful. Thanks dear my friend
View more
  • x
  • convention:

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.