Section Appendix F. Implementation Recommendations

This section presents some implementation recommendations.
Appendix F.1.  Multiple Networks Per Message
   The BGP protocol allows for multiple address prefixes with the same
   path attributes to be specified in one message.  Using this
   capability is highly recommended.  With one address prefix per
   message there is a substantial increase in overhead in the receiver.
   Not only does the system overhead increase due to the reception of
   multiple messages, but the overhead of scanning the routing table for
   updates to BGP peers and other routing protocols (and sending the
   associated messages) is incurred multiple times as well.
   One method of building messages that contain many address prefixes
   per path attribute set from a routing table that is not organized on
   a per path attribute set basis is to build many messages as the
   routing table is scanned.  As each address prefix is processed, a
   message for the associated set of path attributes is allocated, if it
   does not exist, and the new address prefix is added to it.  If such a
   message exists, the new address prefix is appended to it.  If the
   message lacks the space to hold the new address prefix, it is
   transmitted, a new message is allocated, and the new address prefix
   is inserted into the new message.  When the entire routing table has
   been scanned, all allocated messages are sent and their resources are
   released.  Maximum compression is achieved when all destinations
   covered by the address prefixes share a common set of path
   attributes, making it possible to send many address prefixes in one
   4096-byte message.
   When peering with a BGP implementation that does not compress
   multiple address prefixes into one message, it may be necessary to
   take steps to reduce the overhead from the flood of data received
   when a peer is acquired or when a significant network topology change
   occurs.  One method of doing this is to limit the rate of updates.
   This will eliminate the redundant scanning of the routing table to
   provide flash updates for BGP peers and other routing protocols.  A
   disadvantage of this approach is that it increases the propagation
   latency of routing information.  By choosing a minimum flash update
   interval that is not much greater than the time it takes to process
   the multiple messages, this latency should be minimized.  A better
   method would be to read all received messages before sending updates.
Appendix F.2.  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 should combine them into the same UPDATE message.
Appendix F.3.  Path Attribute Ordering
   Implementations that combine update messages (as described above in
   Section 6.1) may prefer to see all path attributes presented in a
   known order.  This permits them to quickly identify sets of
   attributes from different update messages that are semantically
   identical.  To facilitate this, it is a useful optimization to order
   the path attributes according to type code.  This optimization is
   entirely optional.
Appendix F.4.  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.
Appendix F.5.  Control Over Version Negotiation
   Because 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.
Appendix F.6.  Complex AS_PATH Aggregation
   An implementation that chooses to provide a path aggregation
   algorithm retaining 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 ASes 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 ASes (as defined above) within each
            AS_PATH attribute that are in the same relative order within
            both AS_PATH attributes.  Two ASes, 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 ASes identified
            in (a), in exactly the same order as they appear in the
            AS_PATH attributes to be aggregated.  If two consecutive
            ASes identified in (a) do not immediately follow each other
            in both of the AS_PATH attributes to be aggregated, then the
            intervening ASes (ASes that are between the two consecutive
            ASes that are the same) in both attributes are combined into
            an AS_SET path segment that consists of the intervening ASes
            from both AS_PATH attributes.  This segment is then placed
            between the two consecutive ASes identified in (a) of the
            aggregated attribute.  If two consecutive ASes identified in
            (a) immediately follow each other in one attribute, but do
            not follow in another, then the intervening ASes of the
            latter are combined into an AS_SET path segment.  This
            segment is then placed between the two consecutive ASes
            identified in (a) of the aggregated attribute.
         c) For each pair of adjacent tuples in the aggregated AS_PATH,
            if both tuples have the same type, merge them together if
            doing so will not cause a segment of a length greater than
            255 to be generated.
      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.
Security Considerations
   A BGP implementation MUST support the authentication mechanism
   specified in RFC 2385 [RFC2385].  The authentication provided by this
   mechanism could be done on a per-peer basis.
   BGP makes use of TCP for reliable transport of its traffic between
   peer routers.  To provide connection-oriented integrity and data
   origin authentication on a point-to-point basis, BGP specifies use of
   the mechanism defined in RFC 2385.  These services are intended to
   detect and reject active wiretapping attacks against the inter-router
   TCP connections.  Absent the use of mechanisms that effect these
   security services, attackers can disrupt these TCP connections and/or
   masquerade as a legitimate peer router.  Because the mechanism
   defined in the RFC does not provide peer-entity authentication, these
   connections may be subject to some forms of replay attacks that will
   not be detected at the TCP layer.  Such attacks might result in
   delivery (from TCP) of "broken" or "spoofed" BGP messages.
   The mechanism defined in RFC 2385 augments the normal TCP checksum
   with a 16-byte message authentication code (MAC) that is computed
   over the same data as the TCP checksum.  This MAC is based on a one-
   way hash function (MD5) and use of a secret key.  The key is shared
   between peer routers and is used to generate MAC values that are not
   readily computed by an attacker who does not have access to the key.
   A compliant implementation must support this mechanism, and must
   allow a network administrator to activate it on a per-peer basis.
   RFC 2385 does not specify a means of managing (e.g., generating,
   distributing, and replacing) the keys used to compute the MAC.  RFC
   this area, and provides rationale to support this guidance.  It notes
   that a distinct key should be used for communication with each
   protected peer.  If the same key is used for multiple peers, the
   offered security services may be degraded, e.g., due to an increased
   risk of compromise at one router that adversely affects other
   routers.
   The keys used for MAC computation should be changed periodically, to
   minimize the impact of a key compromise or successful cryptanalytic
   attack.  RFC 3562 suggests a crypto period (the interval during which
   a key is employed) of, at most, 90 days.  More frequent key changes
   reduce the likelihood that replay attacks (as described above) will
   be feasible.  However, absent a standard mechanism for effecting such
   changes in a coordinated fashion between peers, one cannot assume
   that BGP-4 implementations complying with this RFC will support
   frequent key changes.
   Obviously, each should key also be chosen to be difficult for an
   attacker to guess.  The techniques specified in RFC 1750 for random
   number generation provide a guide for generation of values that could
   be used as keys.  RFC 2385 calls for implementations to support keys
   "composed of a string of printable ASCII of 80 bytes or less."  RFC
   3562 suggests keys used in this context be 12 to 24 bytes of random
   (pseudo-random) bits.  This is fairly consistent with suggestions for
   analogous MAC algorithms, which typically employ keys in the range of
   16 to 20 bytes.  To provide enough random bits at the low end of this
   range, RFC 3562 also observes that a typical ACSII text string would
   have to be close to the upper bound for the key length specified in
   RFC 2385.
   BGP vulnerabilities analysis is discussed in [RFC4272].
IANA Considerations
   All the BGP messages contain an 8-bit message type, for which IANA
   has created and is maintaining a registry entitled "BGP Message
   Types".  This document defines the following message types:
         Name             Value       Definition
         ----             -----       ----------
         OPEN             1           See Section 4.2
         UPDATE           2           See Section 4.3
         NOTIFICATION     3           See Section 4.5
         KEEPALIVE        4           See Section 4.4
   Future assignments are to be made using either the Standards Action
   process defined in [RFC2434], or the Early IANA Allocation process
   defined in [RFC4020].  Assignments consist of a name and the value.
   The BGP UPDATE messages may carry one or more Path Attributes, where
   each Attribute contains an 8-bit Attribute Type Code.  IANA is
   already maintaining such a registry, entitled "BGP Path Attributes".
   This document defines the following Path Attributes Type Codes:
        Name               Value       Definition
        ----               -----       ----------
        ORIGIN              1          See Section 5.1.1
        AS_PATH             2          See Section 5.1.2
        NEXT_HOP            3          See Section 5.1.3
        MULTI_EXIT_DISC     4          See Section 5.1.4
        LOCAL_PREF          5          See Section 5.1.5
        ATOMIC_AGGREGATE    6          See Section 5.1.6
        AGGREGATOR          7          See Section 5.1.7
   Future assignments are to be made using either the Standards Action
   process defined in [RFC2434], or the Early IANA Allocation process
   defined in [RFC4020].  Assignments consist of a name and the value.
   The BGP NOTIFICATION message carries an 8-bit Error Code, for which
   IANA has created and is maintaining a registry entitled "BGP Error
   Codes".  This document defines the following Error Codes:
         Name                       Value      Definition
         ------------               -----      ----------
         Message Header Error       1          Section 6.1
         OPEN Message Error         2          Section 6.2
         UPDATE Message Error       3          Section 6.3
         Hold Timer Expired         4          Section 6.5
         Finite State Machine Error 5          Section 6.6
         Cease                      6          Section 6.7
   Future assignments are to be made using either the Standards Action
   process defined in [RFC2434], or the Early IANA Allocation process
   defined in [RFC4020].  Assignments consist of a name and the value.
   The BGP NOTIFICATION message carries an 8-bit Error Subcode, where
   each Subcode has to be defined within the context of a particular
   Error Code, and thus has to be unique only within that context.
   IANA has created and is maintaining a set of registries, "Error
   Subcodes", with a separate registry for each BGP Error Code.  Future
   assignments are to be made using either the Standards Action process
   defined in [RFC2434], or the Early IANA Allocation process defined in
   [RFC4020].  Assignments consist of a name and the value.
   This document defines the following Message Header Error subcodes:
         Name                         Value        Definition
         --------------------         -----        ----------
         Connection Not Synchronized   1           See Section 6.1
         Bad Message Length            2           See Section 6.1
         Bad Message Type              3           See Section 6.1
   This document defines the following OPEN Message Error subcodes:
         Name                         Value        Definition
         --------------------         -----        ----------
         Unsupported Version Number     1          See Section 6.2
         Bad Peer AS                    2          See Section 6.2
         Bad BGP Identifier             3          See Section 6.2
         Unsupported Optional Parameter 4          See Section 6.2
         [Deprecated]                   5          See Appendix A
         Unacceptable Hold Time         6          See Section 6.2
    This document defines the following UPDATE Message Error subcodes:
         Name                             Value    Definition
         --------------------              ---     ----------
         Malformed Attribute List           1      See Section 6.3
         Unrecognized Well-known Attribute  2      See Section 6.3
         Missing Well-known Attribute       3      See Section 6.3
         Attribute Flags Error              4      See Section 6.3
         Attribute Length Error             5      See Section 6.3
         Invalid ORIGIN Attribute           6      See Section 6.3
         [Deprecated]                       7      See Appendix A
         Invalid NEXT_HOP Attribute         8      See Section 6.3
         Optional Attribute Error           9      See Section 6.3
         Invalid Network Field             10      See Section 6.3
         Malformed AS_PATH                 11      See Section 6.3
Normative References
   [RFC791]  Postel, J., "Internet Protocol", STD 5, RFC 791, September
             1981.
   [RFC793]  Postel, J., "Transmission Control Protocol", STD 7, RFC
             793, September 1981.
   [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
   [RFC2385] Heffernan, A., "Protection of BGP Sessions via the TCP MD5
   [RFC2434] Narten, T. and H. Alvestrand, "Guidelines for Writing an
             IANA Considerations Section in RFCs", BCP 26, RFC 2434,
             October 1998.
Informative References
   [RFC904]  Mills, D., "Exterior Gateway Protocol formal
   [RFC1092] Rekhter, J., "EGP and policy based routing in the new
   [RFC1093] Braun, H., "NSFNET routing architecture", RFC 1093,
             February 1989.
   [RFC1105] Lougheed, K. and Y. Rekhter, "Border Gateway Protocol
   [RFC1163] Lougheed, K. and Y. Rekhter, "Border Gateway Protocol
   [RFC1267] Lougheed, K. and Y. Rekhter, "Border Gateway Protocol 3
   [RFC1771] Rekhter, Y. and T. Li, "A Border Gateway Protocol 4 (BGP-
   [RFC1772] Rekhter, Y. and P. Gross, "Application of the Border
   [RFC1518] Rekhter, Y. and T. Li, "An Architecture for IP Address
   [RFC1519] Fuller, V., Li, T., Yu, J., and K. Varadhan, "Classless
             Inter-Domain Routing (CIDR): an Address Assignment and
   [RFC1930] Hawkinson, J. and T. Bates, "Guidelines for creation,
             selection, and registration of an Autonomous System (AS)",
   [RFC1997] Chandra, R., Traina, P., and T. Li, "BGP Communities
   [RFC2439] Villamizar, C., Chandra, R., and R. Govindan, "BGP Route
   [RFC2474] Nichols, K., Blake, S., Baker, F., and D. Black,
             "Definition of the Differentiated Services Field (DS Field)
   [RFC2796] Bates, T., Chandra, R., and E. Chen, "BGP Route Reflection
   [RFC2858] Bates, T., Rekhter, Y., Chandra, R., and D. Katz,
   [RFC3392] Chandra, R. and J. Scudder, "Capabilities Advertisement
             September 2000.
   [RFC3065] Traina, P., McPherson, D., and J. Scudder, "Autonomous
   [RFC3562] Leech, M., "Key Management Considerations for the TCP MD5
   [IS10747] "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.
   [RFC4272] Murphy, S., "BGP Security Vulnerabilities Analysis", RFC
             4272, January 2006
   [RFC4020] Kompella, K. and A. Zinin, "Early IANA Allocation of
             2005.
Editors' Addresses
   Yakov Rekhter
   Juniper Networks
   EMail: yakov@juniper.net
   Tony Li
   EMail: tony.li@tony.li
   Susan Hares
   NextHop Technologies, Inc.
   825 Victors Way
   Ann Arbor, MI 48108
   Phone: (734)222-1610
   EMail: skh@nexthop.com
Full Copyright Statement
   Copyright (C) The Internet Society (2006).
   This document is subject to the rights, licenses and restrictions
   contained in BCP 78, and except as set forth therein, the authors
   retain all their rights.
   This document and the information contained herein are provided on an
   "AS IS" basis and THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS
   OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET
   ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED,
   INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE
   INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED
   WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Intellectual Property
   The IETF takes no position regarding the validity or scope of any
   Intellectual Property Rights or other rights that might be claimed to
   pertain to the implementation or use of the technology described in
   this document or the extent to which any license under such rights
   might or might not be available; nor does it represent that it has
   made any independent effort to identify any such rights.  Information
   on the procedures with respect to rights in RFC documents can be
   found in BCP 78 and BCP 79.
   Copies of IPR disclosures made to the IETF Secretariat and any
   assurances of licenses to be made available, or the result of an
   attempt made to obtain a general license or permission for the use of
   such proprietary rights by implementers or users of this
   specification can be obtained from the IETF on-line IPR repository at
   http://www.ietf.org/ipr.
   The IETF invites any interested party to bring to its attention any
   copyrights, patents or patent applications, or other proprietary
   rights that may cover technology that may be required to implement
   this standard.  Please address the information to the IETF at
   ietf-ipr@ietf.org.
Acknowledgement
   Funding for the RFC Editor function is provided by the IETF
   Administrative Support Activity (IASA).