8.2 Basic BGP Operations
8.2.2 How BGP works
BGP is a path vector protocol used to carry routing information between ASs; the information BGP routers advertise to their peers includes a sequence of AS numbers which indicate the complete path to the destination. BGP uses TCP as its transport protocol (port 179), ensuring that all the transport reliability such as retransmission is taken care of by TCP and does not need to be implemented in BGP itself.

When two BGP routers form a transport protocol connection between each other they are called neighbors or peers; each router running BGP is called a BGP speaker. Figure illustrates this relationship. Peer routers exchange multiple messages to open and confirm the connection parameters, such as the BGP version running between the two peers (for example, Version 3 for BGP3 and Version 4 for BGP4). If there are any disagreements between the peers, notification errors are sent and the connection does not get established.

Initially, all candidate BGP routes are exchanged, as illustrated in Figure After this initial exchange of tables, incremental updates are sent as network information changes. The incremental update approach has shown an enormous improvement with respect to CPU overhead and bandwidth allocation over the complete periodic updates used by some older protocols such as EGP.

Peers advertise destinations reachable through them using UPDATE messages, which contain, among other things, a list of <length, prefix> tuples, one for each reachable destination and the path attributes, including such information as the degree of preference for a particular route.

If network reachability information changes -- for example, a route becomes unreachable or a better path becomes available -- BGP informs its neighbors by withdrawing the invalid routes and injecting the new routing information. As illustrated in Figure withdrawn routes are part of the UPDATE message. These are the routes no longer available for use.

If there are no routing changes to transmit to a peer, a BGP speaker will periodically send KEEPALIVE messages to ensure the connection is kept alive. KEEPALIVE packets (19 bytes each) should not cause any strain on the router's processor or link bandwidth because they consume a minimal bandwidth (about 2.5 bits/second if the keepalives are sent every 60 seconds).

Each BGP router keeps a table version number to keep track of the version of the BGP routing table received from each peer. If the table changes, BGP will increment the table version; a rapidly incrementing table version is usually an indication of instabilities in the network or a misconfiguration.