Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1# Embedded ASMap data3## Background5The ASMap feature (available via `-asmap`) makes it possible to use a peer's AS Number (ASN), an ISP/hoster identifier,6in netgroup bucketing in order to ensure a higher diversity in the peer7set. When not using this, the default behavior is to have the buckets formed8based on IP prefixes but this does not9prevent having connections dominated by peers at the same large-scale hoster,10for example, since such companies usually control many diverse IP ranges.11In order to use ASMap, the mapping between IP prefixes and AS Numbers needs12to be available. This mapping data can be provided through an external file13but Bitcoin Core also embeds a default map in its builds to make the feature14available to users when they are unable to provide a file.16## Data sourcing and tools18ASMap is a mapping of IP prefix to ASN, essentially a snapshot of the19internet routing table at some point in time. Due to the high volatility20of parts of this routing table and the known vulnerabilities in the BGP21protocol it is challenging to collect this data and prove its consistency.22Sourcing the data from a single trusted source is problematic as well.24The [Kartograf](https://github.com/asmap/kartograf) tool was created to25deal with these uncertainties as good as possible. The mapping data is sourced from RPKI, IRR and26Routeviews. The former two are themselves used as security mechanisms to27protect against BGP security issues, which is why they are considered more secure and28their data takes precedence. The latter is a trusted collector of BGP traffic29and only used for IP space that is not covered by RPKI and IRR.31The process in which the Kartograf project parses, processes and merges these32data sources is deterministic. Given the raw download files from these33different sources, anyone can build their own map file and verify the content34matches with other users' results. Before the map is usable by Bitcoin Core35it needs to be encoded as well. This is done using `asmap-tool.py` in `contrib/asmap`36and this step is deterministic as well.38When it comes to obtaining the initial input data, the high volatility remains39a challenge if users don't want to trust a single creator of the used ASMap file.40To overcome this, multiple users can start the download process at the exact41same time which leads to a high likelihood that their downloaded data will be42similar enough that they receive the same output at the end of the process.43This process is regularly coordinated at the [asmap-data](https://github.com/bitcoin-core/asmap-data)44project. If the result hash that was observed by the most participants is signed45by 5 participants or more, the resulting ASMap file is added to the repository for46public use. Files will not be merged to the repository47without at least two additional reviewers confirming that the process described48above was followed as expected and that the encoding step yielded the same49file hash. New files are created on an ongoing basis but without any central planning50or an explicit schedule.52## Release process54As an upcoming release approaches the embedded ASMap data should be updated55by replacing the `ip_asn.dat` with a newer ASMap file from the asmap-data56repository so that its data is embedded in the release. Ideally, there may be a file57already created recently that can be selected for an upcoming release. Alternatively,58a new creation process can be initiated with the goal of obtaining a fresh map59for use in the upcoming release.61## Verifying the ASMap in use63The ASMap version is the SHA256 hash of the encoded data, so it matches the64output of `sha256sum` on the file and the hash attested in the asmap-data65repository. On startup, `bitcoind` logs the version of the ASMap it is using:67```68Using asmap version <hash> for IP bucketing69```71The same hash is returned as `asmap_version` by the `getnetworkinfo` RPC.
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.