6.4 KiB
BGP Context
Current Goal
The BGP module is being evolved from an anomaly-only demo into a layered observability pipeline:
raw observations -> enrichment -> detectors -> incidents -> console/Earth visualization
The practical product goal is to turn low-level BGP control-plane changes into understandable network situation events with collector coverage, impact regions, and incident-centric visualization.
Current Backend Architecture
Data Layers
-
BGPObservation- File:
backend/app/models/bgp_observation.py - Purpose: store normalized raw routing observations from live/history sources.
- Typical fields:
sourcecollectorpeer_asnpeer_ipprefixevent_typeas_pathorigin_asnnext_hopcommunitiesobserved_atraw_payloadcollector_geoingest_batch_id
- File:
-
BGPAnomaly- File:
backend/app/models/bgp_anomaly.py - Purpose: hold atomic detector outputs.
- Current detector output types include:
origin_changemore_specific_burstmass_withdrawal
- File:
-
BGPIncident- File:
backend/app/models/bgp_incident.py - Purpose: aggregate atomic anomalies into incident-level objects for humans and the UI.
- File:
Pipeline
Main flow is currently anchored in:
backend/app/services/collectors/bgp_common.pybackend/app/services/bgp_enrichment.pybackend/app/services/bgp_detectors.pybackend/app/services/bgp_incidents.py
Operational flow:
- collectors fetch raw BGP data
normalize_bgp_event()standardizes payloads- observations are persisted to
bgp_observations - enrichment augments events with analysis context
- detectors create
bgp_anomalies - incident aggregation rolls anomalies up into
bgp_incidents
Current Ingest Sources
-
RIPE RIS Live- Collector file:
backend/app/services/collectors/ris_live.py - Used for realtime observation flow.
- Collector file:
-
CAIDA BGPStream Backfill- Collector file:
backend/app/services/collectors/bgpstream.py - Used as history/backfill entry point.
- Collector file:
Current Enrichment Status
Implemented enrichment skeleton in:
backend/app/services/bgp_enrichment.py
Current enrichments:
- prefix family / prefix length
- supernet / more-specific derivation
- deduplicated AS path
- path prepending hints
- collector region info
- prefix baseline hints
- new-origin detection
- ASN organization profile from PeeringDB where available
- prefix scope / impacted region hints
Current limitation:
RPKIis still placeholder-only and returnsunknown- no real ROA validation source is integrated yet
Current API Surface
Primary API file:
backend/app/api/v1/bgp.py
Available endpoints:
/api/v1/bgp/events/api/v1/bgp/events/summary/api/v1/bgp/events/{id}/api/v1/bgp/anomalies/api/v1/bgp/anomalies/summary/api/v1/bgp/anomalies/{id}/api/v1/bgp/incidents/api/v1/bgp/incidents/summary/api/v1/bgp/incidents/{id}
Visualization GeoJSON endpoints:
backend/app/api/v1/visualization.py/api/v1/visualization/geo/bgp-collectors/api/v1/visualization/geo/bgp-anomalies/api/v1/visualization/geo/bgp-incidents
Current Earth Behavior
Relevant files:
frontend/public/earth/js/bgp.jsfrontend/public/earth/js/main.jsfrontend/public/earth/js/info-card.jsfrontend/public/earth/js/constants.jsfrontend/public/earth/index.html
Current design:
- Collectors are always shown when BGP is enabled.
- Incident markers are now the primary Earth BGP markers.
- If there are no incidents, Earth falls back to anomaly markers.
- If there are no anomalies either, collectors still provide presence.
- The right-side stats now show:
- BGP events
- collector count
- BGP status summary
Current BGP status strategy:
- incidents present: show active incident count
- no incidents but anomalies present: show active anomaly count
- no incidents/anomalies but collectors present: show
当前无活跃事件 - no BGP data at all: show
暂无观测数据
Earth info-card strategy:
bgpcard is now incident-centric in wordingbgp_collectorcard shows collector location and current event count
Current Console Behavior
Relevant page:
frontend/src/pages/BGP/BGP.tsx
Current BGP console page has three levels:
-
observation summary
- total events
- collector count
- prefix count
-
incident summary and incident table
-
anomaly detail table plus recent observation events
This means the BGP page still has useful signal even when there are zero anomalies.
Known Product/Engineering Boundaries
- The current system is still closer to an event board than a full BGP sensing platform.
- RIS coverage still needs to expand beyond narrow subscription scope.
- BGPStream history is still not full MRT-to-prefix decoded analytics.
- Collector geography still depends heavily on static RIPE RIS mappings.
- Incident-to-cable/IXP/region association is still weak and early-stage.
- Earth currently visualizes logical observation/impact structure, not true physical traffic paths.
Test Status
BGP-specific tests live in:
backend/tests/test_bgp.py
Verified status at this point:
17 passed
Covered areas include:
- normalization
- observation serialization
- enrichment
- detectors
- incident aggregation
- batch anomaly creation
- BGP events/incidents API
- summary endpoints
Most Relevant Files
Backend:
backend/app/models/bgp_observation.pybackend/app/models/bgp_anomaly.pybackend/app/models/bgp_incident.pybackend/app/services/collectors/bgp_common.pybackend/app/services/bgp_enrichment.pybackend/app/services/bgp_detectors.pybackend/app/services/bgp_incidents.pybackend/app/api/v1/bgp.pybackend/app/api/v1/visualization.py
Frontend:
frontend/src/pages/BGP/BGP.tsxfrontend/public/earth/js/bgp.jsfrontend/public/earth/js/main.jsfrontend/public/earth/js/info-card.jsfrontend/public/earth/js/constants.jsfrontend/public/earth/index.html
Recommended Next Steps
- Expand realtime collector coverage and include withdrawals more broadly.
- Integrate real RPKI validation data.
- Improve route leak and path instability detectors.
- Strengthen incident aggregation semantics and titles.
- Add weak correlation from incidents to:
- cable corridors
- landing points
- IXPs
- other traffic anomaly sources
- Refine Earth hover/click handoff between collectors and incidents.