Skip to main content

BGP Messages

·1724 words·9 mins
lab1918
Author
lab1918

Border Gateway Protocol (BGP), specifically BGP version 4 (BGP-4), which is the standard version used on the Internet, defines four types of messages for communication between BGP routers. These message types are essential for establishing and maintaining BGP sessions, exchanging routing information, and ensuring the stability of BGP connections. The four message types are:

  1. Open Message:

    • Purpose: Used to open a BGP session between two routers (peers).
    • Contents: Includes important parameters such as the BGP version number, the autonomous system (AS) number of the sender, a hold time for the session, and the BGP identifier of the sender.
    • Function: Establishes the initial parameters of the BGP session.
  2. Update Message:

    • Purpose: Used to exchange routing information.
    • Contents: Contains information about new routes being advertised or routes being withdrawn. It also includes path attributes which provide details about the route, such as the AS_PATH, NEXT_HOP, and other BGP attributes.
    • Function: The primary mechanism through which BGP routers exchange routing information. It’s used to advertise the availability of routes or to withdraw previously advertised routes.
  3. Keepalive Message:

    • Purpose: Used to maintain an established BGP session.
    • Contents: This is a small message, typically without a body (only a header).
    • Function: Sent periodically to ensure that the connection between BGP peers is alive. It serves as a heartbeat message to prevent the hold timer from expiring, which would cause the session to close.
  4. Notification Message:

    • Purpose: Used to signal errors or notify the peer of an abnormal condition.
    • Contents: Includes an error code and an error subcode, and may also include data related to the error.
    • Function: If there are problems with the session or if a router needs to close the session for any reason, a Notification message is sent. It helps in diagnosing issues in BGP operations.

Each of these message types plays a specific role in the BGP session lifecycle and routing information exchange. Proper understanding and handling of these messages are crucial for the stable operation of BGP on a network.

BGP Open message:
#

The BGP Open message is one of the key message types in the Border Gateway Protocol (BGP). It’s used to establish a BGP session between two routers. Here’s a breakdown of the BGP Open message format:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                           Marker                              |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Length               |      Type     | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|       Version                 |   My Autonomous System        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Hold Time           |     BGP Identifier            |
|                               |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Opt Parm Len  |                                               
+-+-+-+-+-+-+-+-+    Optional Parameters (variable)
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1. Marker (16 bytes): A fixed field set to all ones. It’s used for compatibility with previous versions of BGP.

  2. Length (2 bytes): This field indicates the total length of the message, including the header, in bytes.

  3. Type (1 byte): For an Open message, this field is set to 1.

  4. Version (1 byte): This field indicates the BGP version being used. For BGP-4, this is set to 4.

  5. My Autonomous System (2 bytes): The Autonomous System (AS) number of the sender.

  6. Hold Time (2 bytes): The proposed maximum time (in seconds) that can elapse between the receipt of successive Keepalive and/or Update messages from the sender.

  7. BGP Identifier (4 bytes): A unique identifier for the BGP router, usually the router’s IP address.

  8. Optional Parameters Length (1 byte): The total length of the Optional Parameters field in bytes.

  9. Optional Parameters (variable length): This field can contain various optional parameters, like authentication information or capabilities. The length and content of this field vary depending on what optional parameters are used.

The BGP Open message is critical for initiating BGP sessions. It sets the foundational parameters for the session, such as the BGP version, the AS numbers of the participating routers, and the keepalive parameters. The correct configuration and handling of these parameters are essential for establishing and maintaining stable BGP peering relationships.

BGP Update message:
#

The BGP Update message is crucial for exchanging routing information. Below is a representation of the BGP Update message format, similar to what you might find in an RFC document:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                           Marker                              |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Length               |      Type     | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Withdrawn Routes Length       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Withdrawn Routes (variable)                                   
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Total Path Attributes Length  |                                
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Path Attributes (variable)                                     
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Network Layer Reachability Information (variable)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1. Marker (16 bytes): A fixed field of 16 octets set to all ones. It’s used for compatibility reasons with BGP versions prior to BGP-4.

  2. Length (2 bytes): This 16-bit field indicates the total length of the message, including the header, in octets. The length of the BGP message can be up to 4096 octets.

  3. Type (1 byte): For the Update message, this field is set to 2.

  4. Withdrawn Routes Length (2 bytes): This field gives the total length of the Withdrawn Routes field in octets.

  5. Withdrawn Routes (variable): A list of IP address prefixes for the routes being withdrawn from service. This field is variable in length.

  6. Total Path Attributes Length (2 bytes): This field gives the total length of the Path Attributes field in octets.

  7. Path Attributes (variable): Path attributes are a collection of attributes that provide information about the route. This field is variable in length.

  8. Network Layer Reachability Information (variable): This field contains a list of IP address prefixes that the sender is advertising.

BGP Update messages are used to advertise new routes to a peer or withdraw previously advertised routes. The Withdrawn Routes field is used to remove routes that are no longer valid, while the Path Attributes field includes information such as the AS_PATH, NEXT_HOP, and other attributes that describe the properties of the route being advertised. The NLRI field (Network Layer Reachability Information) contains information about the routes being advertised.

This message structure is a critical part of BGP’s operation, enabling it to perform its core function of exchanging routing information between autonomous systems (AS) on the Internet.

BGP Keepalive message:
#

The BGP Keepalive message is a simple message type used in the Border Gateway Protocol (BGP). Its primary function is to keep the connection between BGP peers alive. The Keepalive message is very basic in its structure, consisting of only the standard BGP message header and no payload. Here’s the format:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                           Marker                              |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Length               |      Type     | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1. Marker (16 bytes): A fixed field set to all ones. It’s primarily for compatibility with older versions of BGP.

  2. Length (2 bytes): For a Keepalive message, this field indicates the total length of the message, which is 19 bytes (standard BGP header size with no payload).

  3. Type (1 byte): For a Keepalive message, this field is set to 4.

Characteristics and Purpose:
#

  • Function: The Keepalive message is used to maintain an established BGP session. It serves as a kind of “heartbeat” signal between BGP peers.

  • Frequency: The frequency at which Keepalive messages are sent depends on the negotiated Hold Time during the BGP session establishment (Open message exchange). The typical practice is to send a Keepalive message every one-third of the Hold Time interval to ensure the connection is alive.

  • No Payload: Unlike other BGP message types, the Keepalive message doesn’t carry any payload (no data or information about routes).

The BGP Keepalive message is crucial for the stability of BGP sessions. By regularly exchanging Keepalive messages, BGP peers can promptly detect if a peer becomes unavailable or if there are issues in the network, allowing for faster response and re-establishment of BGP sessions as needed.

BGP Notification message:
#

The BGP Notification message is used in the Border Gateway Protocol (BGP) to report errors or close a connection. When a BGP speaker detects an error, it sends a Notification message to its peer and then closes the connection. Here’s the format of the BGP Notification message:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                                                               +
|                           Marker                              |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Length               |      Type     | 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Error Code   |   Error Subcode   |   Data (variable)...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  1. Marker (16 bytes): A fixed field set to all ones. It’s used for compatibility with previous versions of BGP.

  2. Length (2 bytes): This field indicates the total length of the message, including the header, in bytes.

  3. Type (1 byte): For a Notification message, this field is set to 3.

  4. Error Code (1 byte): Indicates the type of error that triggered the notification. There are several defined error codes, each pertaining to a different category of errors (e.g., Message Header Error, Open Message Error, Update Message Error, etc.).

  5. Error Subcode (1 byte): Provides more specific information about the error, within the category defined by the Error Code.

  6. Data (variable length): Optional additional information about the error; the content depends on the Error Code and Subcode.

Characteristics and Purpose:
#

  • Function: The Notification message is a mechanism for a BGP router to inform its peer about errors or other conditions that require closing the BGP session.

  • Session Termination: Upon sending or receiving a Notification message, the BGP session is immediately closed.

  • Error Handling: The Error Code and Subcode fields help in diagnosing issues in BGP operations, as they provide specific information about the nature of the problem encountered.

BGP Notification messages are crucial for error handling in BGP operations. They ensure that peers are informed about issues that necessitate closing the session, allowing for proper network management and troubleshooting.