Skip to main content

Appendix 5. Implementation Recommendations

This section presents some implementation recommendations.

5.1 Multiple Networks Per Message​

The BGP protocol allows for multiple networks with the same AS path and next-hop gateway to be specified in one message. Making use of this capability is highly recommended. With one network per message there is a substantial increase in overhead in the receiver. Not only does the system overhead increase due to the reception of multiple messages, but the overhead of scanning the routing table for flash updates to BGP peers and other routing protocols (and sending the associated messages) is incurred multiple times as well. One method of building messages containing many networks per AS path and gateway from a routing table that is not organized per AS path is to build many messages as the routing table is scanned. As each network is processed, a message for the associated AS path and gateway is allocated, if it does not exist, and the new network is added to it. If such a message exists, the new network is just appended to it. If the message lacks the space to hold the new network, it is transmitted, a new message is allocated, and the new network is inserted into the new message. When the entire routing table has been scanned, all allocated messages are sent and their resources released. Maximum compression is achieved when all networks share a gateway and common path attributes, making it possible to send many networks in one 4096-byte message.

When peering with a BGP implementation that does not compress multiple networks into one message, it may be necessary to take steps to reduce the overhead from the flood of data received when a peer is acquired or a significant network topology change occurs. One method of doing this is to limit the rate of flash updates. This will eliminate the redundant scanning of the routing table to provide flash updates for BGP peers and other routing protocols. A disadvantage of this approach is that it increases the propagation latency of routing information. By choosing a minimum flash update interval that is not much greater than the time it takes to process the multiple messages this latency should be minimized. A better method would be to read all received messages before sending updates.

5.2 Processing Messages on a Stream Protocol​

BGP uses TCP as a transport mechanism. Due to the stream nature of TCP, all the data for received messages does not necessarily arrive at the same time. This can make it difficult to process the data as messages, especially on systems such as BSD Unix where it is not possible to determine how much data has been received but not yet processed.

One method that can be used in this situation is to first try to read just the message header. For the KEEPALIVE message type, this is a complete message; for other message types, the header should first be verified, in particular the total length. If all checks are successful, the specified length, minus the size of the message header is the amount of data left to read. An implementation that would "hang" the routing information process while trying to read from a peer could set up a message buffer (4096 bytes) per peer and fill it with data as available until a complete message has been received.

5.3 Processing Update Messages​

In BGP, all UPDATE messages are incremental. Once a particular network is listed in an Update message as being reachable through an AS path and gateway, that piece of information is expected to be retained indefinitely.

In order for a route to a network to be removed, it must be explicitly listed in an Update message as being unreachable or with new routing information to replace the old. Note that a BGP peer will only advertise one route to a given network, so any announcement of that network by a particular peer replaces any previous information about that network received from the same peer.

One useful optimization is that unreachable networks need not be advertised with their original attributes. Instead, all unreachable networks could be sent in a single message, perhaps with an AS path consisting of the local AS only and with an origin set to INCOMPLETE.

This approach has the obvious advantage of low overhead; if all routes are stable, only KEEPALIVE messages will be sent. There is no periodic flood of route information.

However, this means that a consistent view of routing information between BGP peers is only possible over the course of a single transport connection, since there is no mechanism for a complete update. This requirement is accommodated by specifying that BGP peers must transition to the Idle state upon the failure of a transport connection.

5.4 BGP Timers​

BGP employs three timers: ConnectRetry, Holdtime, and KeepAlive. Suggested value for the ConnectRetry timer is 120 seconds. Suggested value for the Holdtime timer is 90 seconds.

Suggested value for the KeepAlive timer is 30 seconds. An implementation of BGP shall allow any of these timers to be configurable.

5.5 Frequency of Route Selection​

An implementation of BGP shall allow a border router to set up the minimum amount of time that must elapse between selection and subsequent advertisement of better routes received by a given BGP speaker from BGP speakers located in adjacent ASs.

Since fast convergence is needed within an AS, deferring selection does not apply to selection of better routes chosen as a result of UPDATEs from BGP speakers located in the advertising speaker's own AS. To avoid long-lived black holes, it does not apply to advertisement of previously selected routes which have become unreachable. In both of these situations, the local BGP speaker must select and advertise such routes immediately.

If a BGP speaker received better routes from BGP speakers in adjacent ASs, but have not yet advertised them because the time has not yet elapsed, the reception of any routes from other BGP speakers in its own AS shall trigger a new route selection process that will be based on both updates from BGP speakers in the same AS and in adjacent ASs.