RFC 1654

A Border Gateway Protocol 4 (BGP-4)

๐Ÿ“… published July 1994, from ietf

Okay bestie, let's get the basics down first โœจ This is RFC 1654, called A Border Gateway Protocol 4 (BGP-4) ๐ŸŽ€ It's a Standards Track doc from the Network Working Group, dated July 1994. The editors are Y. Rekhter (T.J. Watson Research Center, IBM Corp.) and T. Li (cisco Systems) ๐Ÿงš The header doesn't list any Obsoletes or Updates, but Section 1 says the earlier version came out as RFC 1267 in October 1991 ๐ŸŒธ

Status of this Memo ๐Ÿ’Œ

This is an Internet standards track protocol for the Internet community, and the authors want your discussion and suggestions for improvements ๐Ÿซถ For the standardization state and status of this protocol, check the current edition of the "Internet Official Protocol Standards" (STD 1) ๐Ÿ“‹ Distribution of this memo is unlimited ๐ŸŒˆ

1. Acknowledgements ๐Ÿซถ

This doc was originally published as RFC 1267 in October 1991, and it was co-written by Kirk Lougheed (cisco Systems) and Yakov Rekhter (IBM) ๐Ÿ’œ

Big thanks to Guy Almes (Rice University), Len Bosack (cisco Systems), and Jeffrey C. Honig (Cornell University) for their contributions to the earlier version ๐Ÿ“

We'd like to explicitly thank Bob Braden (ISI) for reviewing the earlier version, plus his constructive and valuable comments ๐Ÿ’…

We'd also thank Bob Hinden, Director for Routing of the Internet Engineering Steering Group, and the team of reviewers he pulled together to review the previous version (BGP-2) of this document. That team was Deborah Estrin, Milo Medin, John Moy, Radia Perlman, Martha Steenstrup, Mike St. Johns, and Paul Tsuchiya, and they acted with a strong combination of toughness, professionalism, and courtesy ๐Ÿ‘‘

This updated version is the product of the IETF BGP Working Group, with Yakov Rekhter and Tony Li as editors. Certain sections borrowed heavily from IDRP [7], which is the OSI counterpart of BGP. For that, credit goes to the ANSI X3S3.3 group, chaired by Lyman Chapin (BBN), and to Charles Kunzinger (IBM Corp.), who was the IDRP editor within that group โœจ We'd also like to thank Mike Craren (Proteon, Inc.), Dimitry Haskin (Wellfleet), John Krawczyk (Wellfleet), and Paul Traina (cisco) for their insightful comments ๐Ÿ”ฅ

We'd specially acknowledge the numerous contributions by Dennis Ferguson (ANS) ๐Ÿฆ‹

2. Introduction ๐ŸŽ€

The Border Gateway Protocol (BGP) is an inter-Autonomous System routing protocol ๐ŸŒ It's built on experience gained with EGP as defined in RFC 904 [1], and with EGP usage in the NSFNET Backbone as described in RFC 1092 [2] and RFC 1093 [3] ๐Ÿ’–

The main job of a BGP speaking system is to exchange network reachability information with other BGP systems. That information includes the list of Autonomous Systems (ASs) the reachability information travels through. That's enough to build a graph of AS connectivity, which lets you prune routing loops and enforce some policy decisions at the AS level ๐Ÿง 

BGP-4 brings a new set of mechanisms for classless interdomain routing. It supports advertising an IP prefix and gets rid of the concept of network "class" within BGP ๐Ÿซง BGP-4 also adds mechanisms for aggregating routes, including aggregation of AS paths. These changes support the proposed supernetting scheme [8, 9] ๐ŸŒˆ

Now, to figure out which policies you can enforce with BGP, you have to focus on one rule: a BGP speaker only advertises to its peers (the other BGP speakers it talks to) in neighboring ASs the routes it actually uses itself ๐Ÿ‘€ This rule matches the "hop-by-hop" routing paradigm that's used pretty much everywhere on the Internet right now ๐ŸŒธ Some policies can't work with hop-by-hop, so they need techniques like source routing. For example, BGP doesn't let one AS send traffic to a neighboring AS while expecting that traffic to take a different route from the traffic that started in the neighboring AS ๐Ÿ™ˆ But BGP can support any policy that fits hop-by-hop. Since the current Internet only uses hop-by-hop, and BGP can support any policy that fits that paradigm, BGP is extremely applicable as an inter-AS routing protocol for the current Internet ๐Ÿ˜ญ๐Ÿ’–

A deeper look at which policies can and can't be enforced with BGP is outside the scope of this document. For that, check the companion document on BGP usage [5] ๐Ÿงš

BGP runs over a reliable transport protocol ๐Ÿซถ That means it doesn't have to implement explicit update fragmentation, retransmission, acknowledgement, or sequencing. You can use any authentication scheme the transport protocol supports on top of BGP's own authentication mechanisms. The error notification mechanism in BGP assumes the transport protocol supports a "graceful" close, meaning all outstanding data gets delivered before the connection closes ๐Ÿ’…

BGP uses TCP [4] as its transport protocol. TCP meets BGP's transport requirements and shows up in virtually every commercial router and host ๐ŸŒˆ In the following descriptions, "transport protocol connection" can be understood as a TCP connection. BGP uses TCP port 179 to set up its connections ๐ŸŽ€

This memo uses the term `Autonomous System' (AS) throughout. The classic definition is a set of routers under a single technical administration, using an interior gateway protocol and common metrics to route packets within the AS, and an exterior gateway protocol to route packets to other ASs ๐Ÿฐ Since that definition came about, it's become common for a single AS to run several interior gateway protocols and sometimes several sets of metrics inside it. The word Autonomous System here stresses that, even with multiple IGPs and metrics, an AS's administration still looks to other ASs like it has a single coherent interior routing plan and gives a consistent picture of which networks are reachable through it โœจ

The planned use of BGP in the Internet environment, including topology, the interaction between BGP and IGPs, and enforcing routing policy rules, is covered in a companion document [5] ๐Ÿ“š This document is the first in a series planned to explore different aspects of BGP application. Send your comments to the BGP mailing list at iwg@ans.net ๐Ÿ’Œ

3. Summary of Operation ๐Ÿฆ‹

Two systems form a transport protocol connection with each other. They exchange messages to open and confirm the connection parameters ๐Ÿค The initial data flow is the entire BGP routing table. Incremental updates are sent as the routing tables change ๐Ÿ”„ BGP doesn't require periodic refresh of the whole BGP routing table, so a BGP speaker has to keep the current version of the entire BGP routing tables of all of its peers for the length of the connection ๐Ÿง  KeepAlive messages are sent periodically to make sure the connection is still alive ๐Ÿ’— Notification messages go out in response to errors or special conditions. If a connection runs into an error condition, a notification message is sent and the connection gets closed ๐Ÿšจ

The hosts running the Border Gateway Protocol don't need to be routers ๐Ÿ–ฅ๏ธ A non-routing host could swap routing information with routers via EGP or even an interior routing protocol. That non-routing host could then use BGP to swap routing information with a border router in another Autonomous System. The implications and applications of this setup are left for further study ๐Ÿ”ญ

If a particular AS has multiple BGP speakers and provides transit service for other ASs, you have to be careful to keep the routing view consistent inside the AS ๐Ÿงฉ The interior routing protocol gives a consistent view of the AS's interior routes. A consistent view of the routes outside the AS can come from having all BGP speakers inside the AS keep direct BGP connections with each other ๐Ÿซถ Using a common set of policies, the BGP speakers agree on which border routers will serve as exit/entry points for particular networks outside the AS. That info gets passed to the AS's internal routers, possibly through the interior routing protocol ๐Ÿ“ฌ Be sure the interior routers have all been updated with transit information before the BGP speakers announce to other ASs that transit service is being provided โญ

Connections between BGP speakers in different ASs are called "external" links. BGP connections between BGP speakers in the same AS are called "internal" links ๐ŸŒˆ In the same way, a peer in a different AS is an external peer, and a peer in the same AS may be described as an internal peer ๐ŸŽ€

3.1 Routes: Advertisement and Storage ๐Ÿ›ฃ๏ธ

For this protocol, a route is a unit of information that pairs a destination with the attributes of a path to that destination:

  • Routes are advertised between a pair of BGP speakers in UPDATE messages. The destination is the systems whose IP addresses are reported in the Network Layer Reachability Information (NLRI) field, and the path is the information reported in the path attributes fields of that same UPDATE message ๐Ÿ’Œ
  • Routes are stored in the Routing Information Bases (RIBs): namely, the Adj-RIBs-In, the Loc-RIB, and the Adj-RIBs-Out. Routes that will be advertised to other BGP speakers must be present in the Adj-RIB-Out. Routes that will be used by the local BGP speaker must be present in the Loc-RIB, and the next hop for each of these routes must be present in the local BGP speaker's forwarding information base. Routes received from other BGP speakers are present in the Adj-RIBs-In ๐Ÿ—‚๏ธ

If a BGP speaker decides to advertise a route, it may add to or modify the path attributes of that route before advertising it to a peer โœจ

BGP gives you ways for a BGP speaker to tell its peer that a route it previously advertised isn't available anymore ๐Ÿ™…โ€โ™€๏ธ There are three ways a given BGP speaker can say a route has been withdrawn from service:

a) The IP prefix that expresses the destinations for a previously advertised route can be advertised in the WITHDRAWN ROUTES field of the UPDATE message, which marks the route as no longer available for use ๐Ÿซฅ

b) A replacement route with the same Network Layer Reachability Information can be advertised ๐Ÿ”

c) The BGP speaker - BGP speaker connection can be closed, which implicitly takes all routes the pair of speakers had advertised to each other out of service ๐Ÿ’”

3.2. Routing Information Bases

okay so every BGP speaker keeps its own RIB (Routing Information Base), and it's split into three distinct parts ๐ŸŽ€

  • a) Adj-RIBs-In: this is where routing info learned from inbound UPDATE messages lives. These are the routes that are available as an input to the Decision Process ๐Ÿ“ฅ
  • b) Loc-RIB: the local routing info the BGP speaker picked after applying its local policies to whatever is sitting in its Adj-RIBs-In ๐Ÿ‘‘
  • c) Adj-RIBs-Out: the info the local BGP speaker picked for advertising to its peers. Whatever is stored here gets carried in the local speaker's UPDATE messages and sent out to those peers ๐Ÿ’Œ

so basically, Adj-RIBs-In is the raw, unprocessed tea from your peers ๐Ÿต, the Loc-RIB is the stuff you actually chose after the Decision Process โœจ, and the Adj-RIBs-Out is you neatly organising routes for each specific peer through your UPDATE messages ๐Ÿ’…

ngl the best part is that the model is just a model ๐Ÿงš. It separates the three RIBs conceptually, but it neither implies nor requires that an implementation keeps three separate copies of the routing information. Whether you store 3 copies or 1 copy with pointers is totally up to you, because the protocol doesn't constrain that choice ๐Ÿฆ‹


4. Message Formats โœจ

this section is all about the message formats BGP uses ๐ŸŽ€

messages get sent over a reliable transport protocol connection ๐Ÿšš. A message only gets processed after it has been entirely received ๐Ÿ“ฆ. The maximum message size is 4096 octets, and all implementations are required to support this maximum message size ๐Ÿ’–. The smallest message that may be sent is a BGP header with no data portion, which is 19 octets ๐ŸŒธ

4.1. Message Header Format

every message starts with a fixed-size header ๐Ÿ’Œ. There may or may not be a data portion after it, depending on the message type. Here's how the fields are laid out ๐Ÿ‘€

    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     |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Marker:

the Marker is a 16-octet field holding a value that the receiver of the message can predict ๐Ÿ”ฎ. If the Type of the message is OPEN, or if the Authentication Code used in the OPEN message of the connection is zero, then the Marker must be all ones ๐Ÿ™ˆ. Otherwise, the value of the marker can be predicted by some computation specified as part of the authentication mechanism being used. The Marker can be used to detect loss of synchronization between a pair of BGP peers, and to authenticate incoming BGP messages ๐Ÿ›ก๏ธ

Length:

the Length is a 2-octet unsigned integer for the total length of the message, header included, in octets ๐Ÿ“. So it lets you find the (Marker field of the) next message in the transport-level stream, e.g. ๐Ÿงญ. The Length value must always be at least 19 and no greater than 4096, and it may be further constrained depending on the message type ๐Ÿ’…. No "padding" of extra data is allowed after the message, so the Length field must have the smallest value required for the rest of the message ๐Ÿซถ

Type:

this is a 1-octet unsigned integer for the type code of the message ๐ŸŽŸ๏ธ. These type codes are defined:

                                    1 - OPEN
                                    2 - UPDATE
                                    3 - NOTIFICATION
                                    4 - KEEPALIVE

4.2. OPEN Message Format

after a transport protocol connection is established, the first message each side sends is an OPEN message ๐Ÿค. If the OPEN message is acceptable, a KEEPALIVE message confirming the OPEN gets sent back ๐Ÿ’•. Once the OPEN is confirmed, UPDATE, KEEPALIVE, and NOTIFICATION messages may be exchanged ๐Ÿฆ‹

on top of the fixed-size BGP header, the OPEN message has these fields:

    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
    +-+-+-+-+-+-+-+-+
    |    Version    |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |     My Autonomous System      |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |           Hold Time           |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                         BGP Identifier                        |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |  Auth. Code   |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                                                               |
    |                       Authentication Data                     |
    |                                                               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Version:

this is a 1-octet unsigned integer for the protocol version number of the message ๐ŸŽ€. The current BGP version number is 4 โœจ

My Autonomous System:

this 2-octet unsigned integer is the Autonomous System number of the sender ๐ŸŒˆ

Hold Time:

this 2-octet unsigned integer is the number of seconds the sender proposes for the value of the Hold Timer โณ. When an OPEN message comes in, a BGP speaker MUST calculate the value of the Hold Timer by using the smaller of its configured Hold Time and the Hold Time received in the OPEN message ๐Ÿงฎ. The Hold Time MUST be either zero or at least three seconds ๐Ÿซถ. An implementation may reject connections on the basis of the Hold Time ๐Ÿ™…โ€โ™€๏ธ. The calculated value is the maximum number of seconds that may elapse between the receipt of successive KEEPALIVE and/or UPDATE messages by the sender ๐Ÿ’œ

BGP Identifier:

this 4-octet unsigned integer is the BGP Identifier of the sender ๐Ÿชช. A given BGP speaker sets its BGP Identifier to an IP address assigned to that speaker ๐Ÿก. The value is determined on startup and is the same for every local interface and every BGP peer ๐ŸŒธ

Authentication Code:

this 1-octet unsigned integer tells you which authentication mechanism is being used ๐Ÿ”. Whenever an authentication mechanism is specified for use within BGP, three things must be included in the specification:

  • the value of the Authentication Code which indicates use of the mechanism,
  • the form and meaning of the Authentication Data, and
  • the algorithm for computing values of Marker fields.

Only one authentication mechanism is specified as part of this memo:

  • its Authentication Code is zero,
  • its Authentication Data must be empty (of zero length), and
  • the Marker fields of all messages must be all ones.

The semantics of non-zero Authentication Codes lies outside the scope of this memo ๐Ÿšง

note that a separate authentication mechanism may be used in establishing the transport level connection ๐Ÿ’Œ

Authentication Data:

the form and meaning of this variable-length field depend on the Authentication Code ๐Ÿ—๏ธ. If the Authentication Code field is zero, the Authentication Data field must have zero length. The semantics of a non-zero length Authentication Data field are outside the scope of this memo ๐Ÿ™ˆ

note that you can work out the length of the Authentication Data field from the message Length field with this formula:

            Message Length = 29 + Authentication Data Length

the minimum length of the OPEN message is 29 octets, header included ๐ŸŽ€

4.3. UPDATE Message Format

UPDATE messages are how routing information gets transferred between BGP peers ๐Ÿš€. The information in an UPDATE packet can be used to construct a graph describing the relationships of the various Autonomous Systems ๐Ÿ•ธ๏ธ. By applying rules (we'll get to those) you can detect routing information loops and some other anomalies, and remove them from inter-AS routing ๐Ÿงน

an UPDATE message is used to advertise a single feasible route to a peer, or to withdraw multiple unfeasible routes from service (see 3.1) ๐Ÿฆ‹. An UPDATE message may advertise a feasible route and withdraw multiple unfeasible routes from service at the same time โœจ. The UPDATE message always includes the fixed-size BGP header, and can optionally include the other fields shown below ๐Ÿ’…

   +-----------------------------------------------------+
   |   Unfeasible Routes Length (2 octets)               |
   +-----------------------------------------------------+
   |  Withdrawn Routes (variable)                        |
   +-----------------------------------------------------+
   |   Total Path Attribute Length (2 octets)            |
   +-----------------------------------------------------+
   |    Path Attributes (variable)                       |
   +-----------------------------------------------------+
   |   Network Layer Reachability Information (variable) |
   +-----------------------------------------------------+

Unfeasible Routes Length:

this 2-octets unsigned integer is the total length of the Withdrawn Routes field in octets ๐Ÿงพ. Its value must allow the length of the Network Layer Reachability Information field to be determined as specified below ๐Ÿ”

a value of 0 means no routes are being withdrawn from service, and that the WITHDRAWN ROUTES field is not present in this UPDATE message ๐Ÿ™…โ€โ™€๏ธ

Withdrawn Routes:

this is a variable length field with a list of IP address prefixes for the routes being withdrawn from service ๐Ÿ—‚๏ธ. Each IP address prefix is encoded as a 2-tuple of the form <length, prefix>, and its fields look like this ๐Ÿ‘‡

          +---------------------------+
          |   Length (1 octet)        |
          +---------------------------+
          |   Prefix (variable)       |
          +---------------------------+

the use and meaning of these fields go like this ๐Ÿงš

  • a) Length: the Length field is the length in bits of the IP address prefix. A length of zero means a prefix that matches all IP addresses (with prefix, itself, of zero octets) ๐ŸŒ
  • b) Prefix:

The Prefix field is just a bunch of IP address prefixes, padded with extra trailing bits so the end of the field lands on an octet boundary ๐Ÿงš And bestie, the value of those trailing bits is irrelevant, so don't stress about them ๐Ÿ’…

Total Path Attribute Length:

This is a 2-octet unsigned integer that tells you the total length of the Path Attributes field in octets ๐Ÿ“ Its value must allow the length of the Network Layer Reachability field to be figured out, which we'll get to in a sec ๐Ÿฆ‹

A value of 0 means there's no Network Layer Reachability Information field in this UPDATE message at all โœจ

Path Attributes:

Every UPDATE has a variable-length sequence of path attributes ๐Ÿ’– Each one is a triple <attribute type, attribute length, attribute value>, and the length is variable too, so it's a whole vibe ๐ŸŒˆ

The Attribute Type is two octets. The first is the Attribute Flags octet and the second is the Attribute Type Code octet ๐ŸŽ€

                0                   1
                0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
               |  Attr. Flags  |Attr. Type Code|
               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Okay so the flags octet is packed with little switches ๐Ÿ”ฅ The high-order bit (bit 0) is the Optional bit. If it's set to 1 the attribute is optional, and if it's set to 0 the attribute is well-known ๐Ÿ‘‘

The second high-order bit (bit 1) is the Transitive bit. For an optional attribute, 1 means it's transitive and 0 means it's non-transitive ๐Ÿฆ‹ For well-known attributes, the Transitive bit must be set to 1. (See Section 5 for a discussion of transitive attributes. It's giving main character energy ๐Ÿ’…)

The third high-order bit (bit 2) is the Partial bit. It tells you whether the info in an optional transitive attribute is partial (1) or complete (0) ๐Ÿงš For well-known attributes and for optional non-transitive attributes, the Partial bit must be set to 0.

The fourth high-order bit (bit 3) is the Extended Length bit. It says whether the Attribute Length is one octet (0) or two octets (1) ๐Ÿ“ Extended Length may be used only if the length of the attribute value is greater than 255 octets. Not before, bestie ๐Ÿ™ˆ

The lower-order four bits of the Attribute Flags octet are unused. They must be zero (and must be ignored when received) ๐Ÿซถ

The Attribute Type Code octet holds the Attribute Type Code. The ones that are currently defined get their own discussion in Section 5 ๐Ÿ“š

Now for the length bit. If Extended Length is set to 0, the third octet of the Path Attribute holds the length of the attribute data in octets. If Extended Length is set to 1, then the third and fourth octets together hold that length ๐ŸŒธ

The remaining octets are the attribute value, and how you read them depends on the Attribute Flags and the Attribute Type Code ๐Ÿ“ Here are the supported Attribute Type Codes, their values and what they're for ๐Ÿ‘‡

a) ORIGIN (Type Code 1):

ORIGIN is a well-known mandatory attribute that tells you where the path information came from ๐ŸŒˆ The data octet can be one of these values:

      Value      Meaning

      0         IGP - Network Layer Reachability Information
                   is interior to the originating AS

      1         EGP - Network Layer Reachability Information
                   learned via EGP

      2         INCOMPLETE - Network Layer Reachability
                   Information learned by some other means

Its usage is defined in 5.1.1 ๐Ÿ’–

b) AS_PATH (Type Code 2):

AS_PATH is a well-known mandatory attribute made up of a sequence of AS path segments. Each segment is a triple <path segment type, path segment length, path segment value> ๐Ÿฆ‹

The path segment type is a 1-octet field with these values defined:

      Value      Segment Type

      1         AS_SET: unordered set of ASs a route in the
                   UPDATE message has traversed

      2         AS_SEQUENCE: ordered set of ASs a route in
                   the UPDATE message has traversed

The path segment length is a 1-octet field that holds the number of ASs in the path segment value field โœจ The path segment value field has one or more AS numbers, and each one is a 2-octet field ๐Ÿงš

Usage of this attribute is defined in 5.1.2 ๐ŸŽ€

c) NEXT_HOP (Type Code 3):

This is a well-known mandatory attribute that gives the IP address of the border router that should be used as the next hop to the destinations listed in the Network Layer Reachability field of the UPDATE message ๐Ÿ”ฅ

Usage of this attribute is defined in 5.1.3 ๐Ÿ’…

d) MULTI_EXIT_DISC (Type Code 4):

This is an optional non-transitive attribute. It's a four-octet non-negative integer, and a BGP speaker's decision process can use its value to tell apart multiple exit points to a neighboring autonomous system ๐ŸŒˆ

Its usage is defined in 5.1.4 ๐Ÿฆ‹

e) LOCAL_PREF (Type Code 5):

LOCAL_PREF is a well-known discretionary attribute and a four-octet non-negative integer ๐Ÿ‘‘ A BGP speaker uses it to tell the other BGP speakers in its own autonomous system how much it prefers an advertised route. Usage of this attribute is described in 5.1.5 ๐Ÿ’–

f) ATOMIC_AGGREGATE (Type Code 6)

ATOMIC_AGGREGATE is a well-known discretionary attribute with a length of 0 ๐ŸŒธ A BGP speaker uses it to tell other BGP speakers that the local system picked a less specific route without picking a more specific route that's included in it ๐Ÿ™ˆ Usage of this attribute is described in 5.1.6 โœจ

g) AGGREGATOR (Type Code 7)

AGGREGATOR is an optional transitive attribute with a length of 6 ๐Ÿงš It holds the last AS number that formed the aggregate route (encoded as 2 octets), followed by the IP address of the BGP speaker that formed the aggregate route (encoded as 4 octets) ๐Ÿ’œ Usage of this attribute is described in 5.1.7 ๐Ÿซถ

Network Layer Reachability Information:

This variable-length field holds a list of IP address prefixes ๐Ÿฆ‹ Its length in octets isn't encoded explicitly, but you can calculate it like this:

            UPDATE message Length - 23 - Total Path Attributes Length -
            Unfeasible Routes Length

Here's the breakdown. UPDATE message Length is the value encoded in the fixed-size BGP header. Total Path Attribute Length and Unfeasible Routes Length are the values encoded in the variable part of the UPDATE message. And 23 is the combined length of the fixed-size BGP header, the Total Path Attribute Length field and the Unfeasible Routes Length field ๐Ÿงฎโœจ

Reachability info is encoded as one or more 2-tuples of the form <length, prefix>, and they look like this ๐Ÿ‘‡

                  +---------------------------+
                  |   Length (1 octet)        |
                  +---------------------------+
                  |   Prefix (variable)       |
                  +---------------------------+

a) Length:

The Length field gives the length in bits of the IP address prefix. A length of zero means a prefix that matches all IP addresses (with a prefix that's zero octets long, itself) ๐ŸŒธ

b) Prefix:

The Prefix field holds IP address prefixes, followed by enough trailing bits to make the end of the field fall on an octet boundary. Again, the value of the trailing bits is irrelevant ๐Ÿ’…


Okay, so the minimum length of an UPDATE message is 23 octets. That's 19 octets for the fixed header, plus 2 octets for the Unfeasible Routes Length, plus 2 octets for the Total Path Attribute Length. (In that minimum case, Unfeasible Routes Length is 0 and Total Path Attribute Length is 0 too.) ๐Ÿซถ

An UPDATE message can advertise at most one route, and that route can be described by several path attributes ๐ŸŒˆ All path attributes in a given UPDATE message apply to the destinations carried in its Network Layer Reachability Information field ๐Ÿ’–

An UPDATE message can also list multiple routes to be withdrawn from service ๐Ÿฆ‹ Each route is identified by its destination, expressed as an IP prefix. That uniquely identifies the route within the BGP speaker to BGP speaker connection it was previously advertised on ๐Ÿงš

An UPDATE message may advertise only routes to be withdrawn from service. In that case it won't include path attributes or Network Layer Reachability Information ๐Ÿ™ˆ On the flip side, it may advertise only a feasible route, and then the WITHDRAWN ROUTES field doesn't need to be present โœจ

4.4 KEEPALIVE Message Format

Here's the tea ๐Ÿต BGP doesn't use any transport protocol-based keep-alive mechanism to check whether peers are reachable ๐Ÿ’… Instead, peers exchange KEEPALIVE messages often enough that the Hold Timer never expires ๐Ÿฆ‹ A reasonable maximum time between KEEPALIVE messages would be one third of the Hold Time interval ๐Ÿงš

KEEPALIVE messages MUST NOT be sent more frequently than one per second. An implementation MAY adjust the rate at which it sends KEEPALIVE messages based on the Hold Time interval ๐ŸŽ€

If the negotiated Hold Time interval is zero, then periodic KEEPALIVE messages MUST NOT be sent โญ

A KEEPALIVE message is just the message header, and its length is 19 octets ๐ŸŒธ

4.5 NOTIFICATION Message Format ๐Ÿšจ

okay bestie, a NOTIFICATION message gets sent whenever an error condition is detected ๐Ÿ˜ญ. It's giving dramatic exit energy: the BGP connection is closed immediately after sending it ๐Ÿ’€.

In addition to the fixed-size BGP header, the NOTIFICATION message has these fields:

    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
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | Error code    | Error subcode |           Data                |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Error Code ๐ŸŽ€

This 1-octet unsigned integer tells you what type of NOTIFICATION it is. These are the Error Codes that have been defined:

   Error Code       Symbolic Name               Reference

     1         Message Header Error             Section 6.1

     2         OPEN Message Error               Section 6.2

     3         UPDATE Message Error             Section 6.3

     4         Hold Timer Expired               Section 6.5

     5         Finite State Machine Error       Section 6.6

     6         Cease                            Section 6.7

Error subcode ๐Ÿ”

This 1-octet unsigned integer gives you the more specific details about what went wrong. Each Error Code can have one or more Error Subcodes attached to it. If there's no suitable Error Subcode defined, then a zero (Unspecific) value gets used for the Error Subcode field ๐Ÿซถ.

Here are the Message Header Error subcodes:

                      1  - Connection Not Synchronized.
                      2  - Bad Message Length.
                      3  - Bad Message Type.

Here are the OPEN Message Error subcodes:

                      1  - Unsupported Version Number.
                      2  - Bad Peer AS.
                      3  - Bad BGP Identifier.
                      4  - Unsupported Authentication Code.
                      5  - Authentication Failure.
                      6  - Unacceptable Hold Time.

And the UPDATE Message Error subcodes:

                      1 - Malformed Attribute List.
                      2 - Unrecognized Well-known Attribute.
                      3 - Missing Well-known Attribute.
                      4 - Attribute Flags Error.
                      5 - Attribute Length Error.
                      6 - Invalid ORIGIN Attribute
                      7 - AS Routing Loop.
                      8 - Invalid NEXT_HOP Attribute.

                      9 - Optional Attribute Error.
                     10 - Invalid Network Field.
                     11 - Malformed AS_PATH.

Data ๐Ÿงฉ

This variable-length field is used to diagnose why the NOTIFICATION happened. What's in the Data field depends on the Error Code and Error Subcode. See Section 6 below for the full tea โ˜•.

Also, the length of the Data field can be figured out from the message Length field with this formula:

Message Length = 21 + Data Length

The minimum length of the NOTIFICATION message is 21 octets (including the message header). Not a single octet less, periodt โœจ.


5. Path Attributes ๐Ÿ’…

okay, this section is all about the path attributes of the UPDATE message, and there are a lot of rules here, so grab a snack ๐Ÿ“.

Path attributes fall into four separate categories:

  1. Well-known mandatory.
  2. Well-known discretionary.
  3. Optional transitive.
  4. Optional non-transitive.

Well-known attributes MUST be recognized by all BGP implementations. Some of them are mandatory and MUST be included in every UPDATE message. Others are discretionary and MAY or may not be sent in a particular UPDATE message.

All well-known attributes MUST be passed along to other BGP peers (after proper updating, if it's necessary) ๐Ÿฆ‹.

On top of the well-known ones, each path can carry one or more optional attributes. It is not REQUIRED or expected that every BGP implementation supports every optional attribute ๐Ÿ™ˆ. How an unrecognized optional attribute gets handled is decided by the setting of the Transitive bit in the attribute flags octet. Paths with unrecognized transitive optional attributes SHOULD be accepted. If a path with an unrecognized transitive optional attribute is accepted and passed along to other BGP peers, then that unrecognized transitive optional attribute MUST be passed along with the path to other BGP peers, with the Partial bit in the Attribute Flags octet set to 1. If a path with a recognized transitive optional attribute is accepted and passed along to other BGP peers, and the Partial bit in the Attribute Flags octet was set to 1 by some previous AS, then it is not set back to 0 by the current AS ๐Ÿ”ฅ. Unrecognized non-transitive optional attributes MUST be quietly ignored and MUST NOT be passed along to other BGP peers ๐Ÿคซ.

New transitive optional attributes MAY be attached to the path by the originator or by any other AS in the path. If they aren't attached by the originator, the Partial bit in the Attribute Flags octet is set to 1. The rules for attaching new non-transitive optional attributes depend on the nature of that specific attribute. The documentation for each new non-transitive optional attribute is expected to include those rules. (The description of the MULTI_EXIT_DISC attribute gives an example ๐Ÿ‘‘.) All optional attributes, both transitive and non-transitive, MAY be updated (if that's appropriate) by ASs in the path.

The sender of an UPDATE message SHOULD order the path attributes within that UPDATE message in ascending order of attribute type. The receiver of an UPDATE message MUST be prepared to handle path attributes that are out of order ๐Ÿงš.

The same attribute cannot appear more than once within the Path Attributes field of a particular UPDATE message ๐Ÿšซ.

5.1 Path Attribute Usage ๐ŸŒˆ

This part covers how each BGP path attribute is used, one clause at a time โœจ.

5.1.1 ORIGIN

ORIGIN is a well-known mandatory attribute. The ORIGIN attribute SHALL be generated by the autonomous system that originates the associated routing information. It SHALL be included in the UPDATE messages of all BGP speakers that choose to propagate this information to other BGP speakers ๐Ÿ’–.

5.1.2 AS_PATH

AS_PATH is a well-known mandatory attribute ๐Ÿ›ค๏ธ. This attribute identifies the autonomous systems that the routing information carried in this UPDATE message has passed through. The components of this list can be AS_SETs or AS_SEQUENCEs.

When a BGP speaker propagates a route that it learned from another BGP speaker's UPDATE message, it SHALL modify the route's AS_PATH attribute based on where the BGP speaker that the route will be sent to is located:

  • a) When a BGP speaker advertises the route to another BGP speaker located in its own autonomous system, the advertising speaker SHALL NOT modify the AS_PATH attribute associated with the route. ๐Ÿซถ
  • b) When a BGP speaker advertises the route to a BGP speaker located in a neighboring autonomous system, the advertising speaker SHALL update the AS_PATH attribute as follows:
    • 1) if the first path segment of the AS_PATH is of type AS_SEQUENCE, the local system SHALL prepend its own AS number as the last element of the sequence (put it in the leftmost position).
    • 2) if the first path segment of the AS_PATH is of type AS_SET, the local system SHALL prepend a new path segment of type AS_SEQUENCE to the AS_PATH, including its own AS number in that segment.

When a BGP speaker originates a route, then:

  • a) the originating speaker SHALL include its own AS number in the AS_PATH attribute of all UPDATE messages sent to BGP speakers located in neighboring autonomous systems. (In this case, the AS number of the originating speaker's autonomous system will be the only entry in the AS_PATH attribute.) ๐ŸŽ€
  • b) the originating speaker SHALL include an empty AS_PATH attribute in all UPDATE messages sent to BGP speakers located in its own autonomous system. (An empty AS_PATH attribute is one whose length field contains the value zero.) ๐Ÿ’œ

5.1.3 NEXT_HOP โœจ

okay so NEXT_HOP is basically the "next stop" sign ๐Ÿ›ฃ๏ธ๐Ÿ’– It carries the IP address of the border router that should be used as the next hop to reach the networks listed in the UPDATE message. If a border router is in the same AS as its peer, that peer is an internal border router ๐ŸŽ€ Otherwise, it's an external border router ๐Ÿงš

A BGP speaker can advertise any internal border router as the next hop, as long as the interface tied to that router's IP address (the one given in the NEXT_HOP path attribute) sits on a common subnet with both the local and the remote BGP speakers ๐ŸŒธ External border routers are a bit pickier ๐Ÿ’… The speaker can advertise one as the next hop only if it learned that router's IP address from one of its peers, AND the interface for that address shares a common subnet with the local and remote BGP speakers. Also, a BGP speaker needs to be able to support turning off the advertising of external border routers ๐Ÿ™ˆ

Big rule time ๐Ÿšซ A BGP speaker must never advertise a peer's own address back to that peer as a NEXT_HOP for a route the speaker is originating. And it must never install a route with itself as the next hop ๐Ÿ’€

When a speaker passes a route to another speaker in its own AS, the advertising speaker shall not modify the NEXT_HOP attribute on that route ๐Ÿ™Œ And if a speaker got the route over an internal link, it may forward packets to the NEXT_HOP address, as long as that address is on a common subnet with the local and remote BGP speakers ๐Ÿ“ฆ

5.1.4 MULTI_EXIT_DISC ๐Ÿšช

The MULTI_EXIT_DISC attribute may be used on external (inter-AS) links to tell apart multiple exit or entry points into the same neighboring AS ๐Ÿ—บ๏ธ Its value is a four octet unsigned number called a metric. With everything else equal, the exit or entry point with the lower metric should be preferred ๐Ÿ“‰ If it was received over external links, the attribute may be propagated over internal links to other BGP speakers within the same AS. But it is never propagated to BGP speakers in neighboring AS's ๐Ÿ™…

5.1.5 LOCAL_PREF ๐Ÿ’œ

LOCAL_PREF is a well-known discretionary attribute, and it shall be included in every UPDATE message a BGP speaker sends to other speakers in its own AS ๐Ÿ’œ The speaker shall work out a degree of preference for each external route and include it when advertising that route to its internal peers ๐Ÿงฎ The higher degree of preference should be preferred ๐Ÿ‘‘ And the speaker shall use the degree of preference learned via LOCAL_PREF in its decision process (see section 9.1.1) ๐ŸŽฏ

Plot twist ๐Ÿซฃ A speaker shall not include this attribute in UPDATE messages going to speakers in a neighboring AS. And if it shows up in an UPDATE from a speaker outside the receiver's AS, the receiving speaker shall ignore it ๐Ÿ™…

5.1.6 ATOMIC_AGGREGATE ๐ŸŒˆ

ATOMIC_AGGREGATE is a well-known discretionary attribute, and it's basically a "heads up, I hid some details" flag ๐Ÿซฃ Say a speaker gets overlapping routes from one of its peers (see 9.1.4) and picks the less specific route without picking the more specific one. Then the local system shall attach ATOMIC_AGGREGATE to that route when passing it on to other BGP speakers, unless the less specific route already had it ๐ŸŽ

If you receive a route with ATOMIC_AGGREGATE, you shall not strip the attribute off when propagating the route to other speakers ๐Ÿšซโœ‚๏ธ You also shall not make any NLRI of that route more specific (as defined in 9.1.4) when advertising it to other BGP speakers ๐Ÿ™…

Also, if you get a route with ATOMIC_AGGREGATE, you need to be aware that the real path to the destinations in that route's NLRI can go through ASs that aren't listed in the AS_PATH attribute ๐Ÿ—บ๏ธ The path can still be loop-free though ๐Ÿ”โœจ

5.1.7 AGGREGATOR ๐Ÿงบ

AGGREGATOR is an optional transitive attribute ๐Ÿงบ It may be included in updates that were formed by aggregation (see Section 9.2.4.2). A BGP speaker that does route aggregation may add AGGREGATOR, and when it does, the attribute shall contain its own AS number and IP address ๐Ÿ†”


6. BGP Error Handling ๐Ÿšจ

This section is the "uh oh" chapter ๐Ÿ™ˆ It covers what to do when things go sideways while processing BGP messages.

Whenever one of these conditions gets detected, a NOTIFICATION message goes out carrying the indicated Error Code, Error Subcode, and Data fields ๐Ÿ“ฃ Then the BGP connection gets closed ๐Ÿ”’ If no Error Subcode is specified, a zero must be used 0๏ธโƒฃ

So when the text says "the BGP connection is closed" ๐Ÿ’… it means the transport protocol connection has been shut and all resources for that BGP connection have been freed up. Routing table entries tied to the remote peer get marked as invalid โŒ and that invalidity gets passed on to other BGP peers before those routes are deleted from the system ๐Ÿ—‘๏ธ

Unless it's specifically said otherwise, the Data field of the NOTIFICATION message sent to flag an error is empty ๐Ÿซ™

6.1 Message Header error handling ๐Ÿ“จ

Any error spotted while processing the Message Header gets flagged by sending a NOTIFICATION message with Error Code Message Header Error ๐Ÿšฉ The Error Subcode spills the tea on exactly what went wrong ๐Ÿต

For the Marker field: if the message is an OPEN, the expected value is all ones 1๏ธโƒฃ1๏ธโƒฃ For every other BGP message type, the expected value is determined based on the Authentication Code in the BGP OPEN message and the actual authentication mechanism (that second part only kicks in when the Authentication Code in the OPEN is non-zero) ๐Ÿ” If the Marker field isn't the expected one, that's a synchronization error ๐Ÿ˜ฌ and the Error Subcode is set to Connection Not Synchronized.

If any of the following happens, the Error Subcode is set to Bad Message Length ๐Ÿ“

  • the Length field of the message header is less than 19 or greater than 4096,
  • the Length field of an OPEN message is less than the minimum length of an OPEN message,
  • the Length field of an UPDATE message is less than the minimum length of an UPDATE message,
  • the Length field of a KEEPALIVE message is not equal to 19, or
  • the Length field of a NOTIFICATION message is less than the minimum length of a NOTIFICATION message.

In that case, the Data field contains the erroneous Length field ๐Ÿงพ

If the Type field of the message header isn't recognized, the Error Subcode is set to Bad Message Type, and the Data field contains the erroneous Type field ๐Ÿซ 

6.2 OPEN message error handling ๐Ÿ”“

Any error spotted while processing the OPEN message gets flagged by sending a NOTIFICATION message with Error Code OPEN Message Error ๐Ÿšฉ Once again, the Error Subcode tells you the specific nature of the error ๐Ÿ”

If the version number in the Version field of the received OPEN message isn't supported, the Error Subcode gets set to Unsupported Version Number ๐Ÿ”ข The Data field is a 2-octet unsigned integer that tells the peer the largest locally supported version number that's still lower than the version they bid (as shown in the received OPEN message) ๐ŸŽฏ

If the Autonomous System field of the OPEN message is unacceptable, the Error Subcode is set to Bad Peer AS ๐Ÿšซ Deciding which Autonomous System numbers are acceptable is outside the scope of this protocol ๐Ÿคท

If the Hold Time field of the OPEN message is unacceptable, the Error Subcode MUST be set to Unacceptable Hold Time โณ An implementation MUST reject Hold Time values of one or two seconds ๐Ÿ™… An implementation MAY reject any proposed Hold Time ๐Ÿคž And an implementation that does accept a Hold Time MUST use the negotiated value for the Hold Time โœ…

If the BGP Identifier field of the OPEN message is syntactically incorrect, the Error Subcode is set to Bad BGP Identifier ๐Ÿ†” Being syntactically correct here means the BGP Identifier field represents a valid IP host address ๐ŸŒ

If the Authentication Code of the OPEN message isn't recognized, the Error Subcode is set to Unsupported Authentication Code ๐Ÿ”‘ If the Authentication Code is zero, the Authentication Data must be of zero length. Otherwise, the Error Subcode is set to Authentication Failure ๐Ÿšจ

If the Authentication Code is non-zero, the matching authentication procedure gets invoked ๐Ÿชช And if that procedure (based on Authentication Code and Authentication Data) fails, the Error Subcode is set to Authentication Failure ๐Ÿ™…

6.3 UPDATE message error handling ๐Ÿ’Œ

okay so every error we catch while processing an UPDATE message gets flagged with a NOTIFICATION message ๐Ÿšจ using the Error Code UPDATE Message Error. The Error Subcode then spills the tea on exactly what went wrong ๐Ÿซถ

Error checking for an UPDATE message starts with the path attributes ๐Ÿ”. If the Unfeasible Routes Length or Total Attribute Length is way too big (aka if Unfeasible Routes Length + Total Attribute Length + 23 goes past the message Length), the Error Subcode is Malformed Attribute List ๐Ÿ’€.

If any recognized attribute has Attribute Flags that clash with its Attribute Type Code, the Error Subcode is Attribute Flags Error ๐Ÿ™ˆ. The Data field holds the erroneous attribute (type, length and value).

If any recognized attribute has an Attribute Length that doesn't match the expected length for its attribute type code, the Error Subcode is Attribute Length Error ๐Ÿ“. The Data field holds the erroneous attribute (type, length and value) again, because we love receipts ๐Ÿงพ

If any of the mandatory well-known attributes are missing, the Error Subcode is Missing Well-known Attribute ๐Ÿ˜ญ. The Data field holds the Attribute Type Code of the missing one.

If any of the mandatory well-known attributes aren't recognized, the Error Subcode is Unrecognized Well-known Attribute ๐Ÿคจ. The Data field holds the unrecognized attribute (type, length and value).

If the ORIGIN attribute has an undefined value, the Error Subcode is Invalid Origin Attribute ๐ŸŒธ. The Data field holds the unrecognized attribute (type, length and value).

If the NEXT_HOP attribute is syntactically incorrect, the Error Subcode is Invalid NEXT_HOP Attribute ๐Ÿ“. The Data field holds the incorrect attribute (type, length and value). Syntactic correctness just means the NEXT_HOP attribute represents a valid IP host address โœ…. Semantic correctness only applies to the external BGP links ๐ŸŒ. It means the interface tied to the IP address in the NEXT_HOP attribute shares a common subnet with the receiving BGP speaker, and it is not the IP address of the receiving BGP speaker ๐Ÿง . If the NEXT_HOP attribute is semantically incorrect, the error should be logged and the route should be ignored ๐Ÿ“. In this case, no NOTIFICATION message should be sent ๐Ÿคซ

The AS_PATH attribute gets checked for syntactic correctness ๐Ÿ›ฃ๏ธ. If the path is syntactically incorrect, the Error Subcode is Malformed AS_PATH ๐Ÿฅด.

If an optional attribute is recognized, its value gets checked too ๐Ÿ‘€. If an error shows up, the attribute is discarded and the Error Subcode is Optional Attribute Error ๐Ÿ—‘๏ธ. The Data field holds the attribute (type, length and value).

If any attribute appears more than once in the UPDATE message, the Error Subcode is Malformed Attribute List again ๐Ÿ™ƒ.

Last but not least, the NLRI field in the UPDATE message gets checked for syntactic validity ๐Ÿ”Ž. If it's syntactically incorrect, the Error Subcode is Invalid Network Field ๐Ÿ’….


6.4 NOTIFICATION message error handling ๐Ÿ“ฉ

If a peer sends a NOTIFICATION message and there's an error in that message, sadly there's no way to report that error with another NOTIFICATION message ๐Ÿ˜ญ. Any error like that, such as an unrecognized Error Code or Error Subcode, should be noticed, logged locally, and brought to the attention of the administration of the peer ๐Ÿ‘ฉโ€๐Ÿ’ป. How to do that, though, is outside the scope of this document ๐ŸŒˆ

6.5 Hold Timer Expired error handling โฐ

If a system doesn't receive successive KEEPALIVE and/or UPDATE and/or NOTIFICATION messages within the period set in the Hold Time field of the OPEN message, then a NOTIFICATION message with the Hold Timer Expired Error Code must be sent and the BGP connection closed ๐Ÿ”’. Time's up, bestie ๐Ÿ’€

6.6 Finite State Machine error handling ๐ŸŽ€

Any error the BGP Finite State Machine detects (for example, getting an unexpected event) is flagged by sending a NOTIFICATION message with the Error Code Finite State Machine Error ๐Ÿงš

6.7 Cease ๐Ÿฆ‹

If there are no fatal errors (the ones listed in this section, that is), a BGP peer may choose at any time to close its BGP connection by sending a NOTIFICATION message with the Error Code Cease ๐Ÿซง. BUT, the Cease NOTIFICATION message must not be used when a fatal error from this section actually exists ๐Ÿšซ no sneaky Cease when something's actually broken, periodt ๐Ÿ’…

6.8 Connection collision detection ๐Ÿ’ซ

If a pair of BGP speakers try to establish a TCP connection to each other at the same time, two parallel connections between that pair might totally get formed ๐Ÿ™ˆ. We call this situation a connection collision ๐Ÿ’ฅ. Clearly, one of those connections has to be closed ๐Ÿซ 

To figure out which BGP connection to keep during a collision, there's a convention based on the BGP Identifier ๐Ÿชช. The convention is to compare the BGP Identifiers of the peers involved and keep only the connection initiated by the BGP speaker with the higher-valued BGP Identifier ๐Ÿ‘‘

Upon receiving an OPEN message, the local system must examine all of its connections that are in the OpenConfirm state ๐Ÿ”. A BGP speaker may also examine connections in an OpenSent state if it knows the peer's BGP Identifier from outside the protocol ๐Ÿ•ต๏ธโ€โ™€๏ธ. If any of those connections go to a remote BGP speaker whose BGP Identifier equals the one in the OPEN message, the local system runs the following collision resolution procedure ๐Ÿงช:

  1. The BGP Identifier of the local system is compared to the BGP Identifier of the remote system (as specified in the OPEN message).
  2. If the value of the local BGP Identifier is less than the remote one, the local system closes the BGP connection that already exists (the one already in the OpenConfirm state), and accepts the BGP connection initiated by the remote system ๐Ÿค.
  3. Otherwise, the local system closes the newly created BGP connection (the one tied to the newly received OPEN message), and keeps using the existing one (the one already in the OpenConfirm state) ๐Ÿ’–.

Comparing BGP Identifiers is done by treating them as (4-octet long) unsigned integers ๐Ÿ”ข

A connection collision with an existing BGP connection in the Established state causes the newly created connection to be closed, no matter what ๐Ÿ›‘. Also, a connection collision can't be detected with connections in the Idle, Connect, or Active states ๐Ÿ™…โ€โ™€๏ธ

Closing the BGP connection (the result of the collision resolution procedure) is done by sending a NOTIFICATION message with the Error Code Cease ๐ŸŽฌ


7. BGP Version Negotiation ๐ŸŒŸ

BGP speakers may negotiate the protocol version by making several attempts to open a BGP connection, starting with the highest version number each one supports ๐Ÿชœ. If an open attempt fails with the Error Code OPEN Message Error and the Error Subcode Unsupported Version Number ๐Ÿฅฒ, then the BGP speaker has a few things to work with: the version number it tried, the version number its peer tried, the version number its peer passed back in the NOTIFICATION message, and the version numbers it supports ๐Ÿงฉ. If the two peers support one or more versions in common, this lets them quickly figure out the highest common version ๐Ÿ†. To keep BGP version negotiation working, future versions of BGP must keep the format of the OPEN and NOTIFICATION messages ๐Ÿ” this part is literally the reason it all works, so protect it no matter what ๐Ÿ’œ

8. BGP Finite State machine โœจ

Okay so this section is where BGP gets its whole personality ๐Ÿ’… It's written as a Finite State Machine (FSM), and this part gives you a quick vibe check of what BGP does in each state. There's also a condensed version of the FSM in Appendix 1 ๐ŸŽ€

Initially BGP is in the Idle state ๐ŸŒธ

Idle state ๐Ÿ’ค

Idle is giving "I refuse all incoming BGP connections, bestie" ๐Ÿ™…โ€โ™€๏ธ No resources get allocated to the peer. When the Start event shows up (started by either the system or an operator), the local system sets up all its BGP resources, starts the ConnectRetry timer, and reaches out to the other BGP peer with a transport connection. While that's happening it keeps listening for a connection the remote BGP peer might start, and then it moves to Connect โœจ The exact value of the ConnectRetry timer is a local matter, but it SHOULD be sufficiently large to allow TCP initialization. Give TCP time to get ready, periodt ๐Ÿซถ

If a BGP speaker detects an error, it shuts the connection down and goes back to Idle. To get out of Idle, the Start event has to be generated. If that event gets generated automatically, persistent BGP errors may lead to persistent flapping of the speaker ๐Ÿ˜ญ To avoid that mess, it is RECOMMENDED that Start events SHOULD NOT be generated immediately for a peer that was previously moved to Idle because of an error. For a peer that was previously moved to Idle because of an error, the time between consecutive generation of Start events, if they're generated automatically, SHALL exponentially increase. The value of the initial timer SHALL be 60 seconds. The time SHALL be doubled for each consecutive retry. The backoff is literally a whole glow-up arc ๐Ÿ“ˆ

Any other event received in the Idle state is ignored ๐Ÿ™ˆ

Connect state ๐Ÿ”Œ

In Connect, BGP is waiting for the transport protocol connection to finish ๐Ÿงš

If the transport protocol connection succeeds, the local system clears the ConnectRetry timer, finishes initialization, sends an OPEN message to its peer, and moves to OpenSent ๐ŸŽ‰

If the transport protocol connect fails (for example, a retransmission timeout), the local system restarts the ConnectRetry timer, keeps listening for a connection that may be started by the remote BGP peer, and moves to the Active state ๐Ÿฅบ

When the ConnectRetry timer expires, the local system restarts the ConnectRetry timer, starts a transport connection to the other BGP peer, keeps listening for a connection that may be started by the remote BGP peer, and stays in Connect ๐Ÿ”

Start event is ignored in the Active state ๐Ÿ™ƒ

For any other event (started by either system or operator), the local system releases all BGP resources tied to this connection and goes back to Idle ๐Ÿงน


Active state ๐ŸŒท

In Active, BGP is trying to find a peer by starting a transport protocol connection ๐Ÿ”

If the transport protocol connection succeeds, the local system clears the ConnectRetry timer, finishes initialization, sends an OPEN message to its peer, sets its Hold Timer to a large value, and moves to OpenSent. A Hold Timer value of 4 minutes is suggested โณ

When the ConnectRetry timer expires, the local system restarts the ConnectRetry timer, starts a transport connection to the other BGP peer, keeps listening for a connection that may be started by the remote BGP peer, and moves to Connect ๐Ÿ”„

If the local system notices that a remote peer is trying to set up a BGP connection with it, and the IP address of that remote peer is not an expected one, the local system restarts the ConnectRetry timer, rejects the attempted connection, keeps listening for a connection that may be started by the remote BGP peer, and stays in Active ๐Ÿšซ

Start event is ignored in the Active state ๐Ÿ™ƒ

For any other event (started by either system or operator), the local system releases all BGP resources tied to this connection and goes back to Idle ๐Ÿงน


OpenSent state ๐Ÿ“จ

In OpenSent, BGP waits for an OPEN message from its peer. When one arrives, every field gets checked for correctness ๐Ÿ”Ž If the BGP message header checking or the OPEN message checking finds an error (see Section 6.2), or there's a connection collision (see Section 6.8), the local system sends a NOTIFICATION message and moves to Idle ๐Ÿ’€

If there are no errors in the OPEN message, BGP sends a KEEPALIVE message and sets a KeepAlive timer โœ… The Hold Timer, which was originally set to a large value (see above), gets replaced with the negotiated Hold Time value (see section 4.2). If the negotiated Hold Time value is zero, then the Hold Time timer and KeepAlive timers are not started. If the Autonomous System field matches the local Autonomous System number, the connection is an "internal" connection. Otherwise, it's "external". (This will effect UPDATE processing as described below.) Finally, the state changes to OpenConfirm ๐Ÿ‘‘

If a disconnect notification comes in from the underlying transport protocol, the local system closes the BGP connection, restarts the ConnectRetry timer, keeps listening for a connection that may be started by the remote BGP peer, and goes into Active ๐Ÿฅ€

If the Hold Timer expires, the local system sends a NOTIFICATION message with the error code Hold Timer Expired and moves to Idle โฐ

For the Stop event (started by either system or operator), the local system sends a NOTIFICATION message with Error Code Cease and moves to Idle ๐Ÿ›‘

Start event is ignored in the OpenSent state ๐Ÿ™ƒ

For any other event, the local system sends a NOTIFICATION message with Error Code Finite State Machine Error and moves to Idle ๐Ÿ’…

Whenever BGP changes its state from OpenSent to Idle, it closes the BGP (and transport-level) connection and releases all resources tied to that connection ๐Ÿงน


OpenConfirm state ๐Ÿค

In OpenConfirm, BGP waits for a KEEPALIVE or NOTIFICATION message ๐Ÿ‘€

If the local system receives a KEEPALIVE message, it changes its state to Established ๐ŸŒˆ

If the Hold Timer expires before a KEEPALIVE message is received, the local system sends a NOTIFICATION message with error code Hold Timer Expired and moves to Idle โฐ

If the local system receives a NOTIFICATION message, it moves to Idle ๐Ÿ“‰

If the KeepAlive timer expires, the local system sends a KEEPALIVE message and restarts its KeepAlive timer ๐Ÿ’“

If a disconnect notification comes in from the underlying transport protocol, the local system moves to Idle ๐Ÿฅฒ

For the Stop event (started by either system or operator), the local system sends a NOTIFICATION message with Error Code Cease and moves to Idle ๐Ÿ›‘

Start event is ignored in the OpenConfirm state ๐Ÿ™ƒ

For any other event, the local system sends a NOTIFICATION message with Error Code Finite State Machine Error and moves to Idle ๐Ÿ’€

Whenever BGP changes its state from OpenConfirm to Idle, it closes the BGP (and transport-level) connection and releases all resources tied to that connection ๐Ÿงน


Established state ๐Ÿ†

In Established, BGP can swap UPDATE, NOTIFICATION, and KEEPALIVE messages with its peer. This is the main character era ๐Ÿ‘‘โœจ

If the local system receives an UPDATE or KEEPALIVE message, it restarts its Hold Timer, as long as the negotiated Hold Time value is non-zero โฑ๏ธ

If the local system receives a NOTIFICATION message, it moves to Idle ๐Ÿ“‰

If the local system receives an UPDATE message and the UPDATE message error handling procedure (see Section 6.3) finds an error, the local system sends a NOTIFICATION message and moves to Idle ๐Ÿšจ

If a disconnect notification comes in from the underlying transport protocol, the local system moves to Idle ๐Ÿฅฒ

If the Hold Timer expires, the local system sends a NOTIFICATION message with Error Code Hold Timer Expired and moves to Idle โฐ

If the KeepAlive timer expires, the local system sends a KEEPALIVE message and restarts its KeepAlive timer ๐Ÿ’“

Each time the local system sends a KEEPALIVE or UPDATE message, it restarts its KeepAlive timer, unless the negotiated Hold Time value is zero ๐Ÿซถ

For the Stop event (started by either system or operator), the local system sends a NOTIFICATION message with Error Code Cease and moves to Idle ๐Ÿ›‘

Start event is ignored in the Established state ๐Ÿ™ƒ

For any other event, the local system sends a NOTIFICATION message with Error Code Finite State Machine Error and moves to Idle ๐Ÿ’…

Whenever BGP changes its state from Established to Idle, it closes the BGP (and transport-level) connection, releases all resources tied to that connection, and deletes all routes derived from that connection ๐Ÿ—‘๏ธ๐Ÿ’”

9. UPDATE Message Handling โœจ

okay bestie, so an UPDATE message is only allowed to show up when you're in the Established state ๐Ÿ’… Like, not before ๐Ÿ™ˆ And when one does arrive, every single field gets checked for validity, exactly like Section 6.3 says ๐Ÿซถ

Now the unrecognized attribute stuff, which is lowkey important ๐Ÿค“ If an optional non-transitive attribute is unrecognized, it just gets quietly ignored ๐Ÿคซ But if it's an optional transitive attribute you don't recognize, you flip the Partial bit (that's the third high-order bit in the attribute flags octet) to 1 and keep the attribute, so it can keep getting passed along to other BGP speakers ๐Ÿฆ‹

And if you DO recognize an optional attribute and its value is valid, then it depends on what type it is. You process it locally, keep it, and update it if needed so it can be propagated to other BGP speakers later ๐Ÿ’œ

If the UPDATE message has a non-empty WITHDRAWN ROUTES field, the previously advertised routes whose destinations (written as IP prefixes) are contained in that field shall be removed from the Adj-RIB-In ๐Ÿ—‘๏ธ Then this BGP speaker shall run its Decision Process, because that previously advertised route is no longer available for use ๐Ÿ˜ญ

If the UPDATE message contains a feasible route, it shall be placed in the appropriate Adj-RIB-In, and the following additional actions shall be taken. Pay attention, this part is giving main character energy ๐Ÿ‘‘

i) If its Network Layer Reachability Information (NLRI) is identical to the one of a route currently stored in the Adj-RIB-In, then the new route shall replace the older route in the Adj-RIB-In, thus implicitly withdrawing the older route from service. The BGP speaker shall run its Decision Process, since the older route is no longer available for use ๐Ÿ”„

ii) If the new route is an overlapping route that is included (see 9.1.4) in an earlier route contained in the Adj-RIB-In, the BGP speaker shall run its Decision Process, since the more specific route has implicitly made a portion of the less specific route unavailable for use ๐Ÿ™ƒ

iii) If the new route has identical path attributes to an earlier route contained in the Adj-RIB-In, and is more specific (see 9.1.4) than the earlier route, no further actions are necessary โœจ it's already handled, babe

iv) If the new route has NLRI that is not present in any of the routes currently stored in the Adj-RIB-In, then the new route shall be placed in the Adj-RIB-In. The BGP speaker shall run its Decision Process ๐ŸŒธ

v) If the new route is an overlapping route that is less specific (see 9.1.4) than an earlier route contained in the Adj-RIB-In, the BGP speaker shall run its Decision Process on the set of destinations described only by the less specific route ๐Ÿงš


9.1 Decision Process

okay so the Decision Process is where the magic happens โœจ It selects routes for later advertisement by applying the policies in the local Policy Information Base (PIB) to the routes stored in its Adj-RIB-In. The output is the set of routes that will be advertised to all peers, and the selected routes get stored in the local speaker's Adj-RIB-Out ๐ŸŽ€

The selection process is basically a function. It takes the attributes of a given route as an argument and returns a non-negative integer that tells you the degree of preference for that route ๐Ÿ”ข Here's the tea ๐Ÿต: the function that calculates the degree of preference for a given route shall not use as its inputs any of the following: the existence of other routes, the non-existence of other routes, or the path attributes of other routes. Route selection then means applying that function to each feasible route one by one, and then picking the one with the highest degree of preference ๐Ÿ†

The Decision Process works on the routes in each Adj-RIB-In, and it's responsible for:

  • selection of routes to be advertised to BGP speakers located in the local speaker's autonomous system
  • selection of routes to be advertised to BGP speakers located in neighboring autonomous systems
  • route aggregation and route information reduction

It all happens in three distinct phases, and each one gets triggered by a different event ๐ŸŒˆ

a) Phase 1 is responsible for calculating the degree of preference for each route received from a BGP speaker located in a neighboring autonomous system. It also advertises to the other BGP speakers in the local autonomous system the routes that have the highest degree of preference for each distinct destination ๐Ÿ“ฃ

b) Phase 2 is invoked when Phase 1 is done. It's responsible for choosing the best route out of all the available ones for each distinct destination, and for installing each chosen route into the appropriate Loc-RIB ๐Ÿ’…

c) Phase 3 is invoked after the Loc-RIB has been modified. It's responsible for disseminating routes in the Loc-RIB to each peer located in a neighboring autonomous system, according to the policies in the PIB. Route aggregation and information reduction can optionally be performed within this phase ๐Ÿฆ‹


9.1.1 Phase 1: Calculation of Degree of Preference

Phase 1 decision function shall be invoked whenever the local BGP speaker gets an UPDATE message from a peer in a neighboring autonomous system that advertises a new route, a replacement route, or a withdrawn route ๐Ÿ“จ

The Phase 1 decision function is its own separate process, and it finishes once it has no further work to do ๐Ÿ

The Phase 1 decision function shall lock an Adj-RIB-In before it operates on any route inside it, and shall unlock it after operating on all the new or unfeasible routes inside it ๐Ÿ”’

For each newly received or replacement feasible route, the local BGP speaker shall determine a degree of preference. If the route was learned from a BGP speaker in the local autonomous system, then either the value of the LOCAL_PREF attribute shall be taken as the degree of preference, or the local system shall compute it based on preconfigured policy information. If the route was learned from a BGP speaker in a neighboring autonomous system, then the degree of preference shall be computed based on preconfigured policy information. The exact nature of this policy information and the computation involved is a local matter ๐Ÿคทโ€โ™€๏ธ The local speaker shall then run the internal update process of 9.2.1 to select and advertise the most preferable route ๐Ÿš€


9.1.2 Phase 2: Route Selection

The Phase 2 decision function shall be invoked when Phase 1 is complete. It's its own separate process too, and it finishes when it has no further work to do. Phase 2 shall consider all routes present in the Adj-RIBs-In, including the ones received from BGP speakers in its own autonomous system and the ones received from BGP speakers in neighboring autonomous systems ๐Ÿงฉ

The Phase 2 decision function shall be blocked from running while the Phase 3 decision function is in process ๐Ÿšง The Phase 2 function shall lock all Adj-RIBs-In before it starts, and shall unlock them when it's done ๐Ÿ”

If the NEXT_HOP attribute of a BGP route points to an address that the local BGP speaker doesn't have a route to in its Loc-RIB, the BGP route SHOULD be excluded from the Phase 2 decision function ๐Ÿ™…โ€โ™€๏ธ (that's a big ol' SHOULD, bestie ๐Ÿ’€)

For each set of destinations where a feasible route exists in the Adj-RIBs-In, the local BGP speaker shall find the route that has either:

a) the highest degree of preference of any route to the same set of destinations, or

b) is the only route to that destination, or

c) is selected as a result of the Phase 2 tie breaking rules specified in 9.1.2.1.

The local speaker SHALL then install that route in the Loc-RIB, replacing any route to the same destination currently held in the Loc-RIB ๐Ÿ” The local speaker MUST determine the immediate next hop to the address depicted by the NEXT_HOP attribute of the selected route, by doing a lookup in the IGP and picking one of the possible paths in the IGP ๐Ÿ—บ๏ธ This immediate next hop MUST be used when installing the selected route in the Loc-RIB ๐Ÿ’– And if the route to the address in the NEXT_HOP attribute changes so that the immediate next hop changes, route selection should be recalculated as specified above ๐ŸŒ€

Unfeasible routes shall be removed from the Loc-RIB, and the corresponding unfeasible routes shall then be removed from the Adj-RIBs-In ๐Ÿงน


9.1.2.1 Breaking Ties (Phase 2)

Okay this is the tie-breaker section and it's kind of dramatic ๐ŸŽญ In its Adj-RIBs-In a BGP speaker may have several routes to the same destination with the same degree of preference. But the local speaker can only select one of them for the associated Loc-RIB ๐Ÿ˜ค It considers all the equally preferable routes, both the ones from neighboring autonomous systems and the ones from other BGP speakers in the local speaker's autonomous system โš–๏ธ

The following tie-breaking procedure assumes that, for each candidate route, all the BGP speakers within an autonomous system can figure out the cost of a path (interior distance) to the address in the route's NEXT_HOP attribute ๐Ÿ“ Ties shall be broken using this algorithm:

a) If the local system is configured to take MULTI_EXIT_DISC into account, and the candidate routes differ in their MULTI_EXIT_DISC attribute, then select the route with the lowest value of the MULTI_EXIT_DISC attribute ๐Ÿ…

b) Otherwise, select the route with the lowest cost (interior distance) to the entity depicted by the NEXT_HOP attribute of the route. If there are several routes with the same cost, the tie gets broken like this ๐Ÿ‘‡

  • if at least one of the candidate routes was advertised by the BGP speaker in a neighboring autonomous system, select the route that was advertised by the BGP speaker in a neighboring autonomous system whose BGP Identifier has the lowest value among all other BGP speakers in neighboring autonomous systems;
  • otherwise, select the route that was advertised by the BGP speaker whose BGP Identifier has the lowest value. ๐ŸŽ€

9.1.3 Phase 3: Route Dissemination ๐Ÿ“ฃ

okay so Phase 3 is where the good routes finally get passed around ๐Ÿš€ bestie, the Phase 3 decision function shall be invoked on completion of Phase 2, or when any of these things happen:

  • a) when routes in a Loc-RIB to local destinations have changed
  • b) when locally generated routes learned by means outside of BGP have changed
  • c) when a new BGP speaker - BGP speaker connection has been established

the Phase 3 function is its own little process ๐Ÿงš and it finishes once it has no more work to do. the Phase 3 Routing Decision function shall be blocked from running while the Phase 2 decision function is in process, so no hogging the stage ๐Ÿ’…

every route in the Loc-RIB shall get turned into a matching entry in the associated Adj-RIBs-Out. route aggregation and information reduction techniques (see 9.2.4.1) may optionally be applied โœจ

for the future of inter-AS multicast, things get extra iconic ๐ŸŒˆ a BGP speaker that takes part in inter-AS multicast routing shall advertise a route it receives from one of its external peers, and if it installs that route in its Loc-RIB, it shall advertise it back to the peer it came from. for a BGP speaker that does not take part in inter-AS multicast routing, that advertisement is optional. when you do send one, the NEXT_HOP attribute should be set to the address of the peer. an implementation may also optimize that advertisement by trimming the AS_PATH attribute so it only includes its own AS number and the AS number of the peer that advertised the route. (that trimming requires the ORIGIN attribute to be set to INCOMPLETE.) and on top of that, an implementation is not required to pass optional or discretionary path attributes with such an advertisement ๐Ÿซถ

once the Adj-RIBs-Out and the Forwarding Information Base (FIB) are fully updated, the local BGP speaker shall run the external update process of 9.2.2 ๐Ÿฆ‹

9.1.4 Overlapping Routes ๐ŸŽ€

okay this one is lowkey tricky but so fun ๐Ÿ™ˆ a BGP speaker may send routes with overlapping Network Layer Reachability Information (NLRI) to another BGP speaker. NLRI overlap happens when a set of destinations gets identified in more than one route that doesn't match exactly. since BGP encodes NLRI using IP prefixes, the overlap will always have subset relationships. a route describing a smaller set of destinations (a longer prefix) is more specific than a route describing a bigger set (a shorter prefix). and the other way around: a route describing a bigger set of destinations (a shorter prefix) is less specific than a route describing a smaller set (a longer prefix) ๐Ÿ‘‘

the precedence thing basically splits a less specific route into two parts:

  • a set of destinations described only by the less specific route, and
  • a set of destinations described by the overlap of the less specific and the more specific routes

when overlapping routes show up in the same Adj-RIB-In, the more specific route shall take precedence, going from most specific to least specific โœจ

the overlap is a chunk of the less specific route that is feasible but isn't being used right now ๐ŸŒธ so if a more specific route gets withdrawn later, those destinations are still reachable through the less specific route.

if a BGP speaker gets overlapping routes, the Decision Process shall take the meaning of those overlapping routes into account. specifically, if a BGP speaker accepts the less specific route but rejects the more specific route from the same peer, then the destinations in the overlap may not forward along the ASs listed in that route's AS_PATH attribute. so a BGP speaker has these choices:

  • a) Install both the less and the more specific routes
  • b) Install the more specific route only
  • c) Install the non-overlapping part of the less specific route only (that implies de-aggregation)
  • d) Aggregate the two routes and install the aggregated route
  • e) Install the less specific route only
  • f) Install neither route

if a BGP speaker goes with e), it should add the ATOMIC_AGGREGATE attribute to the route. a route that carries the ATOMIC_AGGREGATE attribute can not be de-aggregated, which means its NLRI can not be made more specific. forwarding along a route like that doesn't guarantee that IP packets will actually traverse only the ASs listed in that route's AS_PATH attribute ๐Ÿ™ˆ

and if a BGP speaker goes with a), it must not advertise the more general route without the more specific route ๐Ÿšซ


9.2 Update-Send Process ๐Ÿ“ฎ

the Update-Send process is in charge of advertising UPDATE messages to all peers ๐Ÿ’– for example, it hands the routes picked by the Decision Process out to other BGP speakers, which might be in the same autonomous system or in a neighboring one. the rules for swapping info between BGP speakers in different autonomous systems are in 9.2.2, and the rules for speakers in the same autonomous system are in 9.2.1.

sharing routing info between a group of BGP speakers that are all in the same autonomous system is called internal distribution ๐Ÿ 

9.2.1 Internal Updates ๐Ÿซง

the Internal update process is all about sending routing info to BGP speakers inside the local speaker's own autonomous system.

when a BGP speaker gets an UPDATE message from another BGP speaker in its own autonomous system, the receiving speaker shall not re-distribute the routing info in that UPDATE message to other BGP speakers in its own autonomous system. no echo chamber here ๐Ÿ™…โ€โ™€๏ธ

when a BGP speaker gets a new route from a BGP speaker in a neighboring autonomous system, it shall advertise that route to all the other BGP speakers in its autonomous system with an UPDATE message if any of these conditions happen:

  • 1) the degree of preference that the local BGP speaker gives the newly received route is higher than the degree of preference the local speaker has given to other routes received from BGP speakers in neighboring autonomous systems, or
  • 2) there are no other routes that have been received from BGP speakers in neighboring autonomous systems, or
  • 3) the newly received route is selected as a result of breaking a tie between several routes that have the highest degree of preference, and the same destination (the tie-breaking procedure is specified in 9.2.1.1).

when a BGP speaker gets an UPDATE message with a non-empty WITHDRAWN ROUTES field, it shall remove from its Adj-RIB-In all routes whose destinations were carried in that field (as IP prefixes). the speaker shall also take these extra steps:

  • 1) if the corresponding feasible route had not been previously advertised, then no further action is necessary
  • 2) if the corresponding feasible route had been previously advertised, then:
    • i) if a new route is selected for advertisement that has the same Network Layer Reachability Information as the unfeasible routes, then the local BGP speaker shall advertise the replacement route
    • ii) if a replacement route is not available for advertisement, then the BGP speaker shall include the destinations of the unfeasible route (in the form of IP prefixes) in the WITHDRAWN ROUTES field of an UPDATE message, and shall send this message to each peer it had previously advertised the corresponding feasible route to

all feasible routes that get advertised shall be placed in the appropriate Adj-RIBs-Out, and all unfeasible routes that get advertised shall be removed from the Adj-RIBs-Out ๐Ÿงน

9.2.1.1 Breaking Ties (Internal Updates) โš–๏ธ

okay so if a local BGP speaker is connected to several BGP speakers in neighboring autonomous systems, it ends up with multiple Adj-RIBs-In tied to those peers ๐Ÿฅน those Adj-RIBs-In might hold several equally good routes to the same destination, and every one of them came from a speaker in a neighboring autonomous system. the local BGP speaker shall pick one of them using these rules:

  • a) If the candidate routes differ only in their NEXT_HOP and MULTI_EXIT_DISC attributes, and the local system is configured to take into account the MULTI_EXIT_DISC attribute, select the route that has the lowest value of the MULTI_EXIT_DISC attribute.
  • b) If the local system can ascertain the cost of a path to the entity depicted by the NEXT_HOP attribute of the candidate route, select the route with the lowest cost.
  • c) In all other cases, select the route that was advertised by the BGP speaker whose BGP Identifier has the lowest value.

9.2.2 External Updates ๐ŸŒ

the external update process is about sending routing info to BGP speakers in neighboring autonomous systems โœˆ๏ธ as part of the Phase 3 route selection process, the BGP speaker has updated its Adj-RIBs-Out and its Forwarding Table. all newly installed routes, plus all newly unfeasible routes that have no replacement route, shall be advertised to BGP speakers in neighboring autonomous systems with an UPDATE message.

any routes in the Loc-RIB that are marked as unfeasible shall be removed ๐Ÿ—‘๏ธ and changes to the reachable destinations inside its own autonomous system shall also be advertised in an UPDATE message.

9.2.3 Controlling Routing Traffic Overhead ๐Ÿšฆ

BGP keeps a tight leash on how much routing traffic (that is, UPDATE messages) gets sent ๐Ÿ’œ the goal is to limit both the link bandwidth needed to advertise UPDATE messages and the processing power the Decision Process needs to digest the info inside them โœจ

9.2.3.1 Frequency of Route Advertisement โฑ๏ธ

Okay so MinRouteAdvertisementInterval is the timer that keeps a BGP speaker from spamming route ads ๐Ÿ™ƒ. It determines the minimum amount of time that MUST elapse between advertisements of routes to a particular destination from a single BGP speaker. This rate limiting procedure is per-destination, even though the value itself gets set per BGP peer. ๐Ÿ’…

Two UPDATE messages sent from one BGP speaker that advertise feasible routes to some common set of destinations (learned from BGP speakers in neighboring autonomous systems) MUST be separated by at least MinRouteAdvertisementInterval. Clearly, the only way to hit that exactly is a separate timer for every common set of destinations, and that would be unwarranted overhead ๐Ÿ˜ฉ. So any technique that keeps the gap at least MinRouteAdvertisementInterval, and also keeps a constant upper bound on that gap, is acceptable โœจ.

Since fast convergence is needed inside an autonomous system, this procedure does not apply to routes received from other BGP speakers in the same autonomous system ๐Ÿƒโ€โ™€๏ธ. To avoid long-lived black holes ๐Ÿ•ณ๏ธ, it also doesn't apply to the explicit withdrawal of unfeasible routes. Those are the routes whose destinations (expressed as IP prefixes) are listed in the WITHDRAWN ROUTES field of an UPDATE message.

This procedure doesn't limit the rate of route selection, only the rate of route advertisement ๐Ÿง . If new routes get selected multiple times while waiting for MinRouteAdvertisementInterval to expire, the last route selected SHALL be advertised at the end of MinRouteAdvertisementInterval ๐ŸŽฏ.

9.2.3.2 Frequency of Route Origination ๐ŸŒฑ

The parameter MinASOriginationInterval determines the minimum amount of time that MUST elapse between successive advertisements of UPDATE messages that report changes within the advertising BGP speaker's own autonomous systems ๐Ÿ“ฃ.

9.2.3.3 Jitter ๐ŸŽฒ

To minimize the chance that the distribution of BGP messages from a given BGP speaker contains peaks, jitter SHOULD be applied to the timers associated with MinASOriginationInterval, Keepalive, and MinRouteAdvertisementInterval. A given BGP speaker SHALL apply the same jitter to each of these quantities, regardless of the destinations the updates are being sent to. So jitter will not be applied on a "per peer" basis ๐Ÿ™…โ€โ™€๏ธ.

The amount of jitter to be introduced SHALL be determined by multiplying the base value of the appropriate timer by a random factor, uniformly distributed in the range from 0.75 to 1.0 ๐ŸŽฐ.


9.2.4 Efficient Organization of Routing Information ๐Ÿ—‚๏ธ

Once a BGP speaker has selected the routing information it's going to advertise, it MAY make use of several methods to organize that information efficiently ๐Ÿ’ซ.

9.2.4.1 Information Reduction ๐Ÿงƒ

Information reduction may imply a reduction in granularity of policy control. After information is collapsed, the same policies will apply to all destinations and paths in the equivalence class.

The Decision Process MAY optionally reduce the amount of information it places in the Adj-RIBs-Out by using any of the following methods:

a) Network Layer Reachability Information (NLRI):

Destination IP addresses can be represented as IP address prefixes. Where the address structure lines up with the systems under control of an autonomous system administrator, it will be possible to shrink the NLRI carried in UPDATE messages ๐Ÿ“‰.

b) AS_PATHs:

AS path information can be represented as ordered AS_SEQUENCEs or unordered AS_SETs. AS_SETs are used in the route aggregation algorithm described in 9.2.4.2. They reduce the size of the AS_PATH information by listing each AS number only once, no matter how many times it may have appeared in multiple AS_PATHs that were aggregated.

An AS_SET implies that the destinations listed in the NLRI can be reached through paths that traverse at least some of the constituent autonomous systems. AS_SETs provide enough information to avoid routing information looping โœ…. However, their use may prune potentially feasible paths, since those paths are no longer listed individually as AS_SEQUENCEs. In practice this is not likely to be a problem. Once an IP packet reaches the edge of a group of autonomous systems, the BGP speaker there is likely to have more detailed path information and can tell individual paths to destinations apart ๐Ÿ•ต๏ธโ€โ™€๏ธ.

9.2.4.2 Aggregating Routing Information ๐Ÿงฉ

Aggregation is the process of combining the characteristics of several different routes so that a single route can be advertised. It can happen as part of the decision process, to cut down the amount of routing information placed in the Adj-RIBs-Out ๐Ÿ“ฆ.

Aggregation reduces the amount of information that a BGP speaker must store and exchange with other BGP speakers. Routes can be aggregated by applying the following procedure separately to path attributes of like type and to the Network Layer Reachability Information.

Routes that have the following attributes SHALL NOT be aggregated unless the corresponding attributes of each route are identical: MULTI_EXIT_DISC, NEXT_HOP.

Path attributes that have different type codes can not be aggregated together. Path of the same type code MAY be aggregated, according to the following rules:

ORIGIN attribute: If at least one route among the routes that are aggregated has ORIGIN with the value INCOMPLETE, then the aggregated route MUST have the ORIGIN attribute with the value INCOMPLETE. Otherwise, if at least one route among the routes that are aggregated has ORIGIN with the value EGP, then the aggregated route MUST have the origin attribute with the value EGP. In all other cases, the value of the ORIGIN attribute of the aggregated route is INTERNAL.

AS_PATH attribute: If routes to be aggregated have identical AS_PATH attributes, then the aggregated route has the same AS_PATH attribute as each individual route.

For the purpose of aggregating AS_PATH attributes, we model each AS within the AS_PATH attribute as a tuple <type, value>. Here "type" identifies the type of path segment the AS belongs to (e.g., AS_SEQUENCE, AS_SET), and "value" is the AS number. If the routes to be aggregated have different AS_PATH attributes, then the aggregated AS_PATH attribute SHALL satisfy all of the following conditions:

  • all tuples of the type AS_SEQUENCE in the aggregated AS_PATH SHALL appear in all of the AS_PATH in the initial set of routes to be aggregated.
  • all tuples of the type AS_SET in the aggregated AS_PATH SHALL appear in at least one of the AS_PATH in the initial set (they MAY appear as either AS_SET or AS_SEQUENCE types).
  • for any tuple X of the type AS_SEQUENCE in the aggregated AS_PATH which precedes tuple Y in the aggregated AS_PATH, X precedes Y in each AS_PATH in the initial set which contains Y, regardless of the type of Y.
  • No tuple with the same value SHALL appear more than once in the aggregated AS_PATH, regardless of the tuple's type.

An implementation MAY choose any algorithm which conforms to these rules. At a minimum, a conformant implementation SHALL be able to perform the following algorithm, which meets all of the above conditions:

  • determine the longest leading sequence of tuples (as defined above) common to all the AS_PATH attributes of the routes to be aggregated. Make this sequence the leading sequence of the aggregated AS_PATH attribute.
  • set the type of the rest of the tuples from the AS_PATH attributes of the routes to be aggregated to AS_SET, and append them to the aggregated AS_PATH attribute.
  • if the aggregated AS_PATH has more than one tuple with the same value (regardless of tuple's type), eliminate all but one such tuple by deleting tuples of the type AS_SET from the aggregated AS_PATH attribute.

Appendix 6, section 6.8 presents another algorithm that satisfies the conditions and allows for more complex policy configurations ๐Ÿง .

ATOMIC_AGGREGATE: If at least one of the routes to be aggregated has the ATOMIC_AGGREGATE path attribute, then the aggregated route SHALL have this attribute as well ๐Ÿ’–.

AGGREGATOR: All AGGREGATOR attributes of all routes to be aggregated SHOULD be ignored.


9.3 Route Selection Criteria ๐ŸŽฏ

Generally speaking, additional rules for comparing routes among several alternatives are outside the scope of this document. There are two exceptions:

  • If the local AS appears in the AS path of the new route being considered, then that new route cannot be viewed as better than any other route. If such a route were ever used, a routing loop would result ๐Ÿ”.
  • In order to achieve successful distributed operation, only routes with a likelihood of stability can be chosen. Thus, an AS MUST avoid using unstable routes, and it MUST NOT make rapid spontaneous changes to its choice of route. Quantifying the terms "unstable" and "rapid" in the previous sentence will require experience, but the principle is clear ๐Ÿง˜โ€โ™€๏ธ.

9.4 Originating BGP routes ๐Ÿš€

A BGP speaker MAY originate BGP routes by injecting routing information acquired by some other means (e.g., via an IGP) into BGP. A BGP speaker that originates BGP routes SHALL assign the degree of preference to these routes by passing them through the Decision Process (see Section 9.1). These routes MAY also be distributed to other BGP speakers within the local AS as part of the Internal update process (see Section 9.2.1).

The decision whether to distribute non-BGP acquired routes within an AS via BGP or not depends on the environment within the AS (e.g., type of IGP), and it SHOULD be controlled via configuration ๐ŸŽ€.

Appendix 1. BGP FSM State Transitions and Actions โœจ

okay bestie, this one is the BGP FSM ๐Ÿฆ‹ basically a map of what happens when a thing goes down (a state) and something happens to it (an event). this covers the case where the negotiated Hold Time value is non-zero ๐Ÿซถ

Here are the states:

                1 - Idle
                2 - Connect
                3 - Active
                4 - OpenSent
                5 - OpenConfirm
                6 - Established

And here are the events ๐Ÿ’œ

                1 - BGP Start
                2 - BGP Stop
                3 - BGP Transport connection open
                4 - BGP Transport connection closed
                5 - BGP Transport connection open failed
                6 - BGP Transport fatal error
                7 - ConnectRetry timer expired
                8 - Hold Timer expired
                9 - KeepAlive timer expired
               10 - Receive OPEN message
               11 - Receive KEEPALIVE message
               12 - Receive UPDATE messages
               13 - Receive NOTIFICATION message

The big table is the main event ๐Ÿ’… For each state and event, it tells you what actions fire, what message gets sent (if any), and which state you land in next. It's a lot, so take your time ๐Ÿ“

    Event                Actions               Message Sent   Next State
    --------------------------------------------------------------------
    Idle (1)
     1            Initialize resources            none             2
                  Start ConnectRetry timer
                  Initiate a transport connection
     others               none                    none             1

    Connect(2)
     1                    none                    none             2
     3            Complete initialization         OPEN             4
                  Clear ConnectRetry timer
     5            Restart ConnectRetry timer      none             3
     7            Restart ConnectRetry timer      none             2
                  Initiate a transport connection
     others       Release resources               none             1

    Active (3)
     1                    none                    none             3
     3            Complete initialization         OPEN             4
                  Clear ConnectRetry timer
     5            Close connection                                 3
                  Restart ConnectRetry timer
     7            Restart ConnectRetry timer      none             2
                  Initiate a transport connection
     others       Release resources               none             1

    OpenSent(4)
     1                    none                    none             4
     4            Close transport connection      none             3
                  Restart ConnectRetry timer
     6            Release resources               none             1
    10            Process OPEN is OK            KEEPALIVE          5
                  Process OPEN failed           NOTIFICATION       1
    others        Close transport connection    NOTIFICATION       1
                  Release resources

    OpenConfirm (5)
     1                   none                     none             5
     4            Release resources               none             1
     6            Release resources               none             1
     9            Restart KeepAlive timer       KEEPALIVE          5
    11            Complete initialization         none             6
                  Restart Hold Timer
    13            Close transport connection                       1
                  Release resources
    others        Close transport connection    NOTIFICATION       1
                  Release resources




    Established (6)
     1                   none                     none             6
     4            Release resources               none             1
     6            Release resources               none             1
     9            Restart KeepAlive timer       KEEPALIVE          6
    11            Restart Hold Timer            KEEPALIVE          6
    12            Process UPDATE is OK          UPDATE             6
                  Process UPDATE failed         NOTIFICATION       1
    13            Close transport connection                       1
                  Release resources
    others        Close transport connection    NOTIFICATION       1
                  Release resources
   ---------------------------------------------------------------------

Okay, if the big table feels like a lot, here's the condensed one ๐ŸŒธ It's the same info squished into a grid, with states across the top and events down the side โœจ

Events| Idle | Connect | Active | OpenSent | OpenConfirm | Estab
      | (1)  |   (2)   |  (3)   |    (4)   |     (5)     |   (6)
      |---------------------------------------------------------------
 1    |  2   |    2    |   3    |     4    |      5      |    6
      |      |         |        |          |             |
 2    |  1   |    1    |   1    |     1    |      1      |    1
      |      |         |        |          |             |
 3    |  1   |    4    |   4    |     1    |      1      |    1
      |      |         |        |          |             |
 4    |  1   |    1    |   1    |     3    |      1      |    1
      |      |         |        |          |             |
 5    |  1   |    3    |   3    |     1    |      1      |    1
      |      |         |        |          |             |
 6    |  1   |    1    |   1    |     1    |      1      |    1
      |      |         |        |          |             |
 7    |  1   |    2    |   2    |     1    |      1      |    1
      |      |         |        |          |             |
 8    |  1   |    1    |   1    |     1    |      1      |    1
      |      |         |        |          |             |
 9    |  1   |    1    |   1    |     1    |      5      |    6
      |      |         |        |          |             |
10    |  1   |    1    |   1    |  1 or 5  |      1      |    1
      |      |         |        |          |             |
11    |  1   |    1    |   1    |     1    |      6      |    6
      |      |         |        |          |             |
12    |  1   |    1    |   1    |     1    |      1      | 1 or 6
      |      |         |        |          |             |
13    |  1   |    1    |   1    |     1    |      1      |    1
      |      |         |        |          |             |
      ---------------------------------------------------------------

Appendix 2. Comparison with RFC 1267

okay so BGP-4 can work in an environment where a whole set of reachable destinations gets expressed with one IP prefix ๐ŸŒˆ network classes and subnetting? totally foreign to BGP-4 ๐Ÿ™ˆ so to make that work, BGP-4 changed the semantics and encoding of the AS_PATH attribute, and new text was added to define what IP prefixes mean. those upgrades let BGP-4 support the proposed supernetting scheme [9] ๐Ÿ’–

to keep configuration simple, this version adds a brand new attribute called LOCAL_PREF, which helps with route selection procedures โœจ

INTER_AS_METRIC got renamed to MULTI_EXIT_DISC ๐ŸŽ€ there's also a new attribute, ATOMIC_AGGREGATE, which makes sure certain aggregates don't get de-aggregated ๐Ÿ”ฅ and AGGREGATOR is a new one that can be added to aggregated routes to show which AS, and which BGP speaker inside that AS, did the aggregating ๐Ÿ‘‘

to make sure Hold Timers are symmetric, the Hold Time is now negotiated on a per-connection basis. and Hold Times of zero are supported now too ๐Ÿงš

Appendix 3. Comparison with RFC 1163

all of the changes in Appendix 2, plus these ๐Ÿฆ‹

to detect and recover from a BGP connection collision, there's a new field (BGP Identifier) in the OPEN message ๐Ÿ’… new text (Section 6.8) lays out the procedure for detecting and recovering from collision ๐Ÿซถ

the new document doesn't restrict the border router passed in the NEXT_HOP path attribute to be part of the same Autonomous System as the BGP Speaker anymore ๐ŸŒธ

and the new document optimizes and simplifies the exchange of info about previously reachable routes ๐Ÿ’œ

Appendix 4. Comparison with RFC 1105

all of the changes in Appendices 2 and 3, plus these ๐Ÿ“

minor changes to the RFC1105 Finite State Machine were needed to fit the TCP user interface provided by 4.3 BSD ๐ŸŽ€

the whole notion of Up/Down/Horizontal relations from RFC1105 got removed from the protocol ๐Ÿ’€

and the message format changes from RFC1105 go like this:

  1. The Hold Time field has been removed from the BGP header and added to the OPEN message.
  2. The version field has been removed from the BGP header and added to the OPEN message.
  3. The Link Type field has been removed from the OPEN message.
  4. The OPEN CONFIRM message has been eliminated and replaced with implicit confirmation provided by the KEEPALIVE message.
  5. The format of the UPDATE message has been changed significantly. New fields were added to the UPDATE message to support multiple path attributes.
  6. The Marker field has been expanded and its role broadened to support authentication.
okay so the naming situation is a whole thing ๐Ÿ™ˆ quite often BGP as specified in RFC 1105 is called BGP-1, BGP as specified in RFC 1163 is called BGP-2, BGP as specified in RFC1267 is called BGP-3, and BGP as specified in this document is called BGP-4 ๐Ÿ‘‘

Appendix 5. TCP options that may be used with BGP

okay so if the local system's TCP user interface supports the TCP PUSH function, then each BGP message should be transmitted with the PUSH flag set ๐Ÿ’– setting the PUSH flag forces BGP messages to be transmitted promptly to the receiver โญ

and if a local system TCP user interface supports setting precedence for a TCP connection, then the BGP transport connection should be opened with precedence set to Internetwork Control (110) value (see also [6]) ๐ŸŒˆ

Appendix 6. Implementation Recommendations

okay, this section is where the implementation recommendations live ๐Ÿงš buckle up ๐Ÿซถ

6.1 Multiple Networks Per Message ๐Ÿ’–

okay bestie, so BGP lets you cram multiple networks that share the same AS path and next-hop gateway into ONE message ๐Ÿ“ฆโœจ. Making use of this capability is highly recommended ๐Ÿซถ. Here's the tea: with one network per message, the receiver's overhead goes way up ๐Ÿ˜ญ. It's not just receiving all those extra messages. It's also scanning the routing table for updates to BGP peers and other routing protocols (and sending the associated messages) over and over again ๐Ÿ’€.

One way to build messages with lots of networks per AS path and gateway, from a routing table that isn't organized per AS path, is to build the messages while you scan the table ๐Ÿ—‚๏ธ. As each network gets processed, you allocate a message for its AS path and gateway if one doesn't exist yet, then add the network to it. If that message already exists, the new network just gets appended ๐ŸŽ€. If the message doesn't have room for the new network, you send it, allocate a fresh one, and insert the network there ๐Ÿš€. When the whole table has been scanned, you send every allocated message and release the resources ๐Ÿงน. Maximum compression happens when all networks share a gateway and common path attributes, so you can fit a bunch of networks into one 4096-byte message ๐ŸŒˆ.

When you're peering with a BGP implementation that doesn't compress multiple networks into one message, it may be necessary to take steps to cut down on the overhead from the flood of data you get when a peer is acquired or a significant network topology change happens ๐ŸŒŠ. One method is to limit the rate of updates ๐Ÿข. This eliminates the redundant scanning of the routing table to provide flash updates for BGP peers and other routing protocols ๐Ÿ™ˆ. The catch? It increases the propagation latency of routing information ๐Ÿ˜ฌ. Choosing a minimum flash update interval that isn't much greater than the time it takes to process the multiple messages keeps that latency as low as possible โฑ๏ธ. Honestly, a better method is to read all received messages before sending updates ๐Ÿ‘‘.


6.2 Processing Messages on a Stream Protocol ๐ŸŒŠ

BGP uses TCP as its transport mechanism ๐Ÿงต. Because TCP is a stream, all the data for a received message doesn't necessarily arrive at the same time ๐Ÿ˜ตโ€๐Ÿ’ซ. That makes it hard to process the data as messages, especially on systems like BSD Unix, where you can't tell how much data has been received but not yet processed ๐Ÿ™ƒ.

One method for this situation is to first try to read just the message header ๐Ÿ“จ. For the KEEPALIVE message type, that's a complete message ๐Ÿฅฐ. For other message types, the header should first be verified, in particular the total length ๐Ÿ”. If all the 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 it becomes available, until a complete message has been received ๐Ÿซง.

6.3 Reducing route flapping ๐Ÿฆ‹

To avoid excessive route flapping, a BGP speaker that needs to withdraw a destination and send an update about a more specific or less specific route shall combine them into the same UPDATE message ๐Ÿ’….

6.4 BGP Timers โฐ

BGP employs five timers: ConnectRetry, Hold Time, KeepAlive, MinASOriginationInterval, and MinRouteAdvertisementInterval. The suggested value for the ConnectRetry timer is 120 seconds. The suggested value for the Hold Time is 90 seconds. The suggested value for the KeepAlive timer is 30 seconds. The suggested value for the MinASOriginationInterval is 15 seconds. The suggested value for the MinRouteAdvertisementInterval is 30 seconds.

An implementation of BGP MUST allow these timers to be configurable. โš™๏ธ๐Ÿ’œ

6.5 Path attribute ordering ๐Ÿงฉ

Implementations that combine update messages as described above in 6.1 may prefer to see all path attributes presented in a known order โœจ. That lets them quickly spot sets of attributes from different update messages that are semantically identical ๐Ÿ‘€. To make this happen, it's a useful optimization to order the path attributes according to type code ๐Ÿ”ข. This optimization is entirely optional ๐Ÿ’œ.

6.6 AS_SET sorting ๐Ÿ”ค

Another useful optimization that can be done to simplify this situation is to sort the AS numbers found in an AS_SET ๐Ÿง. This optimization is entirely optional ๐Ÿซถ.

6.7 Control over version negotiation ๐ŸŽ›๏ธ

Since BGP-4 is capable of carrying aggregated routes that cannot be properly represented in BGP-3, an implementation that supports BGP-4 and another BGP version should provide the capability to only speak BGP-4 on a per-peer basis ๐ŸŒธ.

6.8 Complex AS_PATH aggregation ๐Ÿงต

An implementation that chooses to provide a path aggregation algorithm that retains significant amounts of path information may wish to use the following procedure ๐Ÿ’ซ.

For the purpose of aggregating AS_PATH attributes of two routes, we model each AS as a tuple <type, value>, where "type" identifies a type of the path segment the AS belongs to (e.g., AS_SEQUENCE, AS_SET), and "value" is the AS number. Two ASs are said to be the same if their corresponding <type, value> tuples are the same.

The algorithm to aggregate two AS_PATH attributes works as follows:

a) Identify the same ASs (as defined above) within each AS_PATH attribute that are in the same relative order within both AS_PATH attributes. Two ASs, X and Y, are said to be in the same order if either:

  • X precedes Y in both AS_PATH attributes, or
  • Y precedes X in both AS_PATH attributes.

b) The aggregated AS_PATH attribute consists of ASs identified in (a) in exactly the same order as they appear in the AS_PATH attributes to be aggregated. If two consecutive ASs identified in (a) do not immediately follow each other in both of the AS_PATH attributes to be aggregated, then the intervening ASs (ASs that are between the two consecutive ASs that are the same) in both attributes are combined into an AS_SET path segment that consists of the intervening ASs from both AS_PATH attributes; this segment is then placed in between the two consecutive ASs identified in (a) of the aggregated attribute. If two consecutive ASs identified in (a) immediately follow each other in one attribute, but do not follow in another, then the intervening ASs of the latter are combined into an AS_SET path segment; this segment is then placed in between the two consecutive ASs identified in (a) of the aggregated attribute.

If as a result of the above procedure a given AS number appears more than once within the aggregated AS_PATH attribute, all, but the last instance (rightmost occurrence) of that AS number should be removed from the aggregated AS_PATH attribute. ๐Ÿงน


References ๐Ÿ“š

[1] Mills, D., "Exterior Gateway Protocol Formal Specification", STD 18, RFC 904, BBN, April 1984.

[2] Rekhter, Y., "EGP and Policy Based Routing in the New NSFNET Backbone", RFC 1092, T.J. Watson Research Center, February 1989.

[3] Braun, H-W., "The NSFNET Routing Architecture", RFC 1093, MERIT/NSFNET Project, February 1989.

[4] Postel, J., "Transmission Control Protocol - DARPA Internet Program Protocol Specification", RFC 793, DARPA, September 1981.

[5] Rekhter, Y., and P. Gross, "Application of the Border Gateway Protocol in the Internet", T.J. Watson Research Center, IBM Corp., ANS, RFC 1655, T.J. Watson Research Center, MCI, July 1994.

[6] Postel, J., "Internet Protocol - DARPA Internet Program Protocol Specification", STD 5, RFC 791, DARPA, September 1981.

[7] "Information Processing Systems - Telecommunications and Information Exchange between Systems - Protocol for Exchange of Inter-domain Routeing Information among Intermediate Systems to Support Forwarding of ISO 8473 PDUs", ISO/IEC IS10747, 1993

[8] Fuller, V., Li, T., Yu, J., and K. Varadhan, "Classless Inter-Domain Routing (CIDR): an Address Assignment and Aggregation Strategy", RFC 1519, BARRNet, cisco, MERIT, OARnet, September 1993.

[9] Rekhter, Y., and T. Li, "An Architecture for IP Address Allocation with CIDR", RFC 1518, T.J. Watson Research Center, cisco, September 1993.

Security Considerations ๐Ÿ”’

Plot twist: this memo doesn't cover security at all ๐Ÿ’€. Security issues are not discussed in this memo.

Editors' Addresses ๐Ÿ’Œ

Yakov Rekhter

T.J. Watson Research Center IBM Corporation

P.O. Box 218

Yorktown Heights, NY 10598

Phone: (914) 945-3896

EMail: yakov@watson.ibm.com

Tony Li

cisco Systems, Inc.

1525 O'Brien Drive

Menlo Park, CA 94025

EMail: tli@cisco.com ๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from