The Taxonomy of Networks: Categorizing the Global Internet
The Taxonomy of Networks: Categorizing the Global Internet
[!NOTE] Technical Context:
netbase.cpp| Lines 99-105In lines 99 through 105 of
netbase.cpp, we encounter the Taxonomy Engine of the Bitcoin network. TheParseNetworkfunction is the utility that allows a node to understand its own "Context." It translates the human-readable strings found in configuration files (likebitcoin.conf) into the internalenumtypes that drive the node's routing logic.1. The
ParseNetworkSignature: Semantic TranslationLine 99 defines the function:
enum Network ParseNetwork(const std::string& net_in).This is a "Semantic Mapper." Its job is to take the "Chaos" of user input (where a user might type "IPv4", "ipv4", or "IPV4") and map it to a single, deterministic integer value defined in the
Networkenumeration. For the 1 Lakh Page encyclopedia, this is a lesson in Input Normalization—the art of reducing infinite variations of user intent into a finite set of machine-ready instructions.2.
ToLower(net_in): The Equality GuaranteeLine 100 uses
ToLower().This is a "Defensive Coding" masterpiece. By converting the entire input string to lowercase before performing any checks, the architect ensures that the node is Case-Insensitive. This prevents user errors: if a user types
ONIONin their config file, the node will still correctly identify the Tor network. It is a "User-Friendly" design that minimizes support calls and configuration frustration.3.
NET_IPV4andNET_IPV6: The Core TiersLines 101-102 map the standard internet tiers.
"ipv4": Returns
NET_IPV4."ipv6": Returns
NET_IPV6.These are the "Primary Networks" of the global web. By categorizing them as separate enums, the Bitcoin node can apply different rules to them (e.g., "Don't use IPv6 if my local ISP is buggy," as we saw in Part 038).
4. "onion": The Shield of Privacy
Line 103 handles the Tor (Onion) network.
The mapping to
NET_ONIONis what triggers the specific SOCKS5 proxy logic we will analyze in future articles. By treating Tor as a "First-Class Network" (equal in status to IPv4), the Bitcoin architect has made privacy a Core Design Principle, not just an "Add-On." This allows the node to have a "Tor-Specific" personality, with its own timeouts and its own proxy settings.5. "i2p": The Invisible Internet
Line 104-105 begins the mapping for I2P (Invisible Internet Project).
Like Tor, I2P is a decentralized anonymizing network. Including it in the
ParseNetworklogic demonstrates Bitcoin Core's Platform Agnosticism. The node doesn't care which privacy network you use, as long as it can be categorized into this taxonomy. By supporting multiple privacy overlays, the Bitcoin protocol remains resilient against the potential failure or censorship of any single one.Architectural Synthesis: The Logical Switchboard
ParseNetworkis the "Switchboard" for the node's configuration. It allows the software to answer the question: "What world am I living in?"By centralizing this taxonomy in a single function, the architect ensures that the entire 690,000-line codebase uses the same "Definitions" for the network. Whether you are in the Mempool, the Wallet, or the Peer-to-Peer engine, "IPv4" always means
NET_IPV4. This Uniformity of State is what allows for the complex "Multi-Network" routing that we will see in the next batch of articles.Conclusion: Naming the World
Lines 99-105 are the "Naming Ceremony" of the network stack. We have defined the four great categories of the modern internet: IPv4, IPv6, Tor, and I2P. With these enums, the node can now begin to apply different "Rules of Engagement" to each world, providing a customized experience for every type of user.
In Article 0046, we will complete this taxonomy and move into the logic for detecting "Local" vs. "Routable" addresses.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: