A C++ simulator that models how Internet routes propagate across networks, including security features to detect and prevent route hijacking attacks.
Border Gateway Protocol (BGP) is the routing protocol that makes the Internet work. It allows different networks (called Autonomous Systems or ASes) to share routing information so data can travel from source to destination.
This tool simulates how route announcements spread across the Internet by modeling:
- Real network relationships: Providers, customers, and peers (just like real ISPs)
- Route selection: How networks choose the best path to reach a destination
- Security (ROV): How Route Origin Validation helps prevent malicious route announcements
Use it to:
- Study BGP security vulnerabilities
- Analyze prefix hijacking attacks
- Test Route Origin Validation effectiveness
- Learn how Internet routing works
# From project root
mkdir -p build && cd build
cmake .. && make# From project root
./bgp_simulator \
--relationships bench/many/CAIDAASGraphCollector_2025.10.16.txt \
--announcements bench/many/anns.csv \
--rov-asns bench/many/rov_asns.csv \
--output ribs.csvDefines the Internet topology with provider-customer and peer relationships.
# Format: asn1|asn2|relationship|source
# -1 = asn1 provides transit for asn2
# 0 = asn1 and asn2 are peers
25|27|-1|BGP
30|40|0|BGP
Initial route announcements from networks.
seed_asn,prefix,rov_invalid
25,1.2.3.0/24,True
27,1.2.0.0/16,FalseList of networks that use Route Origin Validation security.
25
100
200
The simulator produces a CSV file showing each network's routing table:
asn,prefix,as_path
25,1.2.3.0/24,"(25,)"
100,1.2.3.0/24,"(100, 25)"Routes spread in three phases matching real BGP behavior:
- Up: Routes go from customers to providers (toward tier-1 ISPs)
- Across: Routes shared between peers
- Down: Routes sent from providers to customers
Networks choose routes based on:
- Relationship: Prefer customer routes (you get paid) over peer routes over provider routes (you pay)
- Path length: Shorter paths win
- Origin: Networks prefer their own announcements
Networks using Route Origin Validation reject announcements marked as invalid, preventing some types of route hijacking attacks.
Run comprehensive tests using pytest to validate simulator functionality:
# Install test dependencies
pip install -r requirements-test.txt
# Run all tests (17 tests covering functionality, cycle detection, and scenarios)
pytest test_bgp_simulator.py -v
# Run specific test categories
pytest test_bgp_simulator.py::TestCycleDetection -vThe test suite validates route propagation, cycle detection, ROV policy enforcement, and compares output against expected results for multiple hijacking scenarios.
cd build && make test_subprefixSimulates an attacker announcing a more specific prefix to hijack traffic.
cd build && make test_prefixTwo networks announce the same prefix - who wins?
cd build && make test_manyMultiple announcements across a large network (70,000+ ASes).
├── include/ # Header files
│ ├── ASGraph.h # Main graph structure
│ ├── AS.h # Individual network
│ ├── Policy.h # BGP and ROV logic
│ └── Announcement.h # Route information
├── src/ # Implementation
├── bench/ # Test cases
└── build/ # Compiled executable
Autonomous System (AS): A network under single administrative control (like an ISP)
AS Path: The sequence of networks a route passes through
Prefix: An IP address range (e.g., 1.2.3.0/24 = 256 addresses)
ROV (Route Origin Validation): Security mechanism to validate route announcements
- C++17 compiler (GCC 7+, Clang 6+, MSVC 2017+)
- CMake 3.14+
Get real Internet topology data from CAIDA: https://www.caida.org/catalog/datasets/as-relationships/
Educational tool for Internet routing research.