Analysis of BGP Prepending in the LAC Region in 2024
09/10/2024
By Alejandro Acosta, R&D Coordinator at LACNIC
Introduction
In this report, we will explore a very specific aspect of BGP tables in our region, focusing on the status of BGP prepends. We will provide a detailed review of both IPv4 and IPv6 BGP tables and share our findings.
Commonly known as ‘AS Path Prepending,’ BGP prepending is a long-established and very popular technique designed as a key strategy for influencing route selection and optimizing an AS’s inbound and outbound traffic. It is used by all types of network operators. But how effective is this technique? Should it always be used? Are there any other options?
History
As we mentioned a few months ago in our blog post titled A Much-Needed BGP RFC: AS Path Prepending [1], a document titled ‘AS Path Prepending’ [2] is currently being developed within the IETF, and LACNIC had the opportunity to participate and contribute to the draft. The document outlines several considerations for configuring BGP prepending. This raises the question: Are we doing things right in Latin America and the Caribbean? This report will hopefully address several concerns.
What is AS Path Prepending?
AS Path Prepending is a technique that involves repetitively adding one’s autonomous system identifier (ASN) to the list of ASs in a BGP route path (AS_PATH). Its goal is to influence route selection by making certain paths less attractive to inbound/outbound traffic. In other words, it consists of adding our autonomous system to the AS_PATH and thus artificially ‘lengthening the path’ to a prefix on the Internet.
In the image above, without prepends, Router A prefers to reach C via B. However, when three prepends are added by B, router A decides to reach C via D.
Data Sources Used for This Study
- Extended LACNIC delegated: https://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-extended-latest
- IPv4 and IPv6 BGP tables taken from:
https://bgp.potaroo.net/v6/as2.0/bgptable.txt (IPv6)
https://bgp.potaroo.net/as2.0/bgptable.txt (IPv4)
Scope
- We work with prefixes managed by any of the RIRs
- The AS_PATH must contain at least one AS from the LACNIC service region
Tools to Be Used for This Study
- Python3
- JupyterLabs
- BGP tables in “show ip bgp” format in Cisco IOS
Findings
Total number of prefixes in the routing table
The data below shows the number of prefixes in the DFZ (Default Free Zone) at the time this analysis was performed (snapshot of the routing table taken on 22 August 2024).
IPv6: 214682 (17.99%)
IPv4: 978614 (82.01%)
Number of AS_PATHs that were analyzed
The data in this section correspond to the total number of AS_PATHs that were counted
IPv6: 822573 = 22.10 %
IPv4: 2900978 = 77.90 %
Prefixes where at least one AS in the AS_PATH is from LACNIC
Number of the AS_PATHs above in which ASs from our region can be observed
IPv6: 47242 (26.27 %)
IPv4: 132559 (73.73 %)
Number of prefixes with prepends in LAC
Data in this section shows the total number of prefixes by IP address family where ASNs are obtained by prepending in our region.
IPv6: 16822 (32.36%)
IPv4: 35154 (67.64%)
Number of origin ASs performing prepending, based on the AS_PATH.
The following data reflects the number of origin autonomous systems that perform BGP prepending. In this case, the AS_Origin does not necessarily correspond to LACNIC. As long as there is a LACNIC ASN in the AS_PATH, it is included in the count.
IPv6: 34832 (48.58 %)
IPv4: 36863 (51.42%)
Single-homed ASs performing prepending
Keeping in mind that prepending in single-homed ASNs is not considered a best practice (section 5 of the IETF draft), the following results were obtained for ASNs in the LACNIC service region.
IPv6: 296 (28.21%)
IPv4: 753 (71.79%)
More than 5 prepends in the AS_PATH
In line with the best practice described in section 5 of the IETF draft, there is no need to prepend more than 5 ASs. Thus, we focused on those that exceed this number, as more than 80% of destinations fall within this AS_PATH length.
IPv6: 4177 (51.69%)
IPv4: 3903 (48.31%)
Prefix with the most prepends
The following information corresponds to the maximum prepend length in IPv6 and IPv4.
IPv6: 27 prepends (August 2024)
IPv4: 61 prepends (August 2024)
Where do the prepends occur?
The graphs below show the typical location of prepends in the AS_PATH.
16-bit vs 32-bit prepends
The data represents a simple count of repeated ASNs in AS_PATHs, by bit length. ASNs above 65,535 represent 32-bit ASNs.
16 bits | 32 bits | |
IPv6 | 153603 | 28445 |
IPv4 | 115824 | 68970 |
Top 10 ranking of repetitions
This data ranks the top 10 countries based on the number of times ASNs from those countries performed BGP prepending in the AS_PATH.
For clarity, this is the algorithm we used:
FOR AS_PATH in AS_PATHs_CON_PREPENDS:
FOR ASN in AS_PATH:
ccASN = pais(ASN)
Dict_ASNs_CC[ccASN] = Dict_ASNs_CC[ccASN] + 1
IPv6 | IPv4 | |||
CC | Repetitions | CC | Repetitions | |
MX | 106710 | BR | 76110 | |
BR | 35460 | AR | 29804 | |
CO | 30549 | CO | 26892 | |
AR | 3074 | MX | 10239 | |
PA | 1876 | CR | 5811 | |
EC | 943 | PA | 5172 | |
PE | 859 | CL | 4697 | |
DO | 408 | EC | 4038 | |
CL | 281 | VE | 3605 | |
NI | 272 | PE | 2956 |
Top 5 countries performing BGP prepending in our region (ratio)
To calculate the ratio of countries that perform the most prepends, we first counted the occurrence of each country in each AS_PATH, and then applied the same methodology exclusively to those that included prepends. Finally, the total was divided by the number with prepends.
For example, for Cuba, 12 entries were found in the BGP table (IPv6), with 6 entries having prepends. In this case, the ratio is 2 (12/6).
For Curacao, 108 entries were found in the BGP table (IPv6), 9 of them having prepends, so the ratio is 12 (108/9).
This means that in Cuba, for every 2 AS_PATHs in the global BGP table, 1 includes prepends. Similarly, in Curacao, for every 12 AS_PATHs in the global BGP table, 1 contains prepends.
Top 5 countries with the lowest ratios (performing more prepends):
IPv6 | IPv4 | |||
CC | Ratio | CC | Ratio | |
MX | 1.75 | BZ | 2.6 | |
CU | 2 | AW | 3.04 | |
BO | 3.4 | PY | 3.07 | |
BZ | 3.2 | AR | 3.3 | |
SV | 6 | PA | 3.53 |
TOP 5 countries with the highest ratios (performing less prepends):
IPv6 | IPv4 | |||
CC | Ratio | CC | Ratio | |
SR | 60 | CW | 45.11 | |
GY | 53 | CU | 37.5 | |
CR | 36.61 | SV | 14.96 | |
GT | 28.7 | UY | 11.98 | |
CL | 26.15 | MX | 11.13 |
Conclusions
BGP prepending is a technique commonly used in our region, but it is crucial to disseminate best implementation practices and explore alternative traffic engineering options. Our recent analysis reveals that 296 single-homed organizations are using prepending on IPv6 and 753 on IPv4, a number that raises concern. Moreover, it is alarming that many operators exceed five prepends, with some extreme cases performing up to 27 prepends on IPv6 and 61 on IPv4. Such practices not only don’t have a positive impact on routing tables, but negatively affect memory, CPU, and the networks on BGP Speakers.
An aspect worth noting is the imbalance in the use of prepends between IPv4 and IPv6, which leads us to ask ourselves: What is causing this difference? This analysis seeks to raise awareness about the proper implementation of BGP prepending.
We encourage you to review how you publish your prefixes and ensure responsible implementation!
Do you have any comments? We’d love to hear from you!
I invite you to watch the video of my presentation during the LACNIC 42 LACNOG 2024 event.
References
[1] https://blog.lacnic.net/un-necesario-rfc-sobre-bgp-as-path-prepending/
[2] https://datatracker.ietf.org/doc/html/draft-ietf-grow-as-path-prepending-12
The views expressed by the authors of this blog are their own and do not necessarily reflect the views of LACNIC.