arrow Open Source Projects

CIDR-Bottle

CIDR-Bottle is a high-performance implementation of a Patricia Trie for handling network routing information (such as ROAs & Routing Tables) for reconciliation, supporting both sub-tree checking and longest-prefix matching.

gitlab Source

PyPi PyPi

Docs Docs

License MIT license

CIDR-Bottle

SHARE

linkedin share twitter share reddit share

Transform Your IP Route Validation with Lightning-Fast Patricia Trie Performance

CIDR-Bottle is a specialized Patricia Trie implementation designed specifically for parsing and validating CIDRs in routing tables, RIR Allocation & Assignment records, and ROAs (Route Origin Authorization).

Built for the modern network engineer who demands both precision and performance, CIDR-Bottle delivers where traditional IP address libraries fall short.

An attractive screenshot of the example code from the repo

Why Patricia Trie? Why CIDR-Bottle?

Patricia Trie (Practical Algorithm to Retrieve Information Coded as Alphanumeric) has been the gold standard for IP routing lookups since BSD 4.3 Reno. Patricia tree performance for IP address lookup can achieve up to 35 million operations per second in optimized implementations, making it the backbone of high-performance routing systems.

The DevOps & NetOps Advantage

Performance That Scales

  • Process millions of IP lookups per second
  • Handle routing tables with hundreds of thousands of prefixes
  • Optimize memory usage with efficient trie structures
  • Support for both IPv4 and IPv6 address families

Built for Modern BGP Security

In an era where BGP hijacks and route leaks threaten network stability, CIDR-Bottle helps you build:

  • RPKI/ROA Integration: Validate route origins against cryptographically signed ROAs
  • Route Validation: Ensure BGP announcements match authorized origins
  • Prefix Filtering: Implement robust ingress/egress filtering policies
  • IRR Reconciliation: Cross-reference routing data with Internet Routing Registry entries

Developer-Friendly Python Integration

# Simple, intuitive API for complex routing operations
from cidr_bottle import Bottle

# Defaults to IPv4
root = Bottle()  # 0.0.0.0/0

root.insert("198.51.100.0/24", {'asn':64512})
root.insert("203.0.113.0/24", {'asn':65000}})

# Pythonic lookups
if "198.51.100.3/32" in root:
    prefix = root["198.51.100.3/32"] # Longest Prefix Matching will deliver the record inserted for 10.0.0.0/8

Real-World Use Cases

1. ROA Validation Pipeline

  • Ingest ROA data from RPKI repositories
  • Build optimized trie structure for rapid lookups
  • Validate incoming BGP announcements in real-time
  • Flag invalid or suspicious routes instantly

2. Network Automation

  • Automate prefix allocation and deaggregation detection
  • Generate routing policies based on trie analysis
  • Implement dynamic filtering based on route validation states
  • Integrate with CI/CD pipelines for network configuration

3. BGP Analytics & Monitoring

  • Track routing table growth and fragmentation
  • Identify prefix hijacking attempts
  • Monitor ROA coverage for your address space
  • Generate compliance reports for security audits

Technical Excellence

Optimized for Network Engineers:

  • Longest Prefix Match (LPM): Essential for routing decisions
  • Efficient Memory Layout: Minimized cache misses for maximum throughput
  • Binary Prefix Operations: Native CIDR notation support
  • Incremental Updates: Add/remove prefixes without rebuilding

Built on Proven Foundations:

  • Patricia Trie algorithm battle-tested in production routers
  • Designed by network engineers for network engineers
  • Open-source development on GitLab
  • Active community and regular updates

More Speed

If you want to squeeze out every last drop of performance, using CIDR-Man’s CIDR and FastBottle (instead of Bottle) vastly improves CIDR-Bottle’s performance.

FastBottle

By restricting the interface to support only CIDR objects FastBottle utilises CIDR-Man to vastly improve the performance compared to Bottle.

Using the same example as above the FastBottle version would look like:

# Simple, intuitive API for complex routing operations
from cidr_man import CIDR
from cidr_bottle import FastBottle

# Defaults to IPv4
root = Bottle()  # 0.0.0.0/0

root.insert(CIDR("198.51.100.0/24"), {'asn':64512})
root.insert(CIDR("203.0.113.0/24"), {'asn':65000}})

# Pythonic lookups
if CIDR("198.51.100.3/32") in root:
prefix = root[CIDR("198.51.100.3/32")] # Longest Prefix Matching will deliver the record inserted for 10.0.0.0/8

Get Started Today

Installation:

pip install cidr-bottle

Dependencies

Support

This is a free library licensed under the MIT license, if you notice a bug or have a feature request please raise a ticket in GitLab, and we’ll do our best to support you. If you need priority support or wish to fast-track a feature request, you’re welcome to engage us to answer your request.

Join the Community: Contribute to the future of secure, efficient IP routing. Whether you’re securing BGP at an ISP, automating network operations at scale, or building the next generation of network tools, CIDR-Bottle provides the performance and reliability you need.

License

CIDR-Bottle is licensed under the MIT license


CIDR-Bottle: Where Network Performance Meets Routing Security

Tags: #BGP #RPKI #PatriciaTrie #NetworkAutomation #Python #DevOps #NetOps #RoutingTable #ROA #IPAddressManagement #NetworkSecurity #OpenSource

arrow Open Source overview