How sbezverk/gobmp works
Project type and purpose
• Type: An open-source, network-protocol collector/processor tool written in Go.
• Purpose:
– Accept Open BMP (RFC 7854) messages over TCP.
– Parse BGP update NLRI/attributes (multiple AFI/SAFI).
– Build unified “record” objects.
– Publish those records to Kafka topics, NATS, files, or stdout.
– Support “player” (replay) and “validator” (message‐check) commands.
– Run standalone, in Docker, or as a Kubernetes deployment.
File structure (high-level)
• cmd/
– gobmp: main collector binary (HTTP pprof + BMP TCP listener)
– player: replay recorded BMP messages
– validator: validate BMP or JSON files
• pkg/
– gobmpsrv: TCP server, BMP session handling
– parser: low-level BMP message parsing
– base, bgp, bmp, bgpls, evpn, flowspec, …: NLRI/attribute definitions & parsers
– message: unified record schema (types.go)
– kafka, nats, pub: publisher interfaces & implementations
– dumper: file or console output
– validator: runtime message checks
• build/: Dockerfiles, testbed configs, kernel tuning scripts
• deployment/: Kubernetes YAML for gobmp (standalone + with “player”)
• CI/CD: .github/workflows/cicd.yml
• Makefile: build commands for binaries and images
• README.md + BMP.md: protocol reference & usage
Extract architectural insights from README
• goBMP listens on port 5000 for BMP speakers.
• Exposes port 56767 for pprof monitoring.
• Configurable sinks: Kafka servers, JSON file, stdout.
• Intercept mode: forwards raw BMP to another port.
• Deployable as Docker container or K8s deployment.
Main components and interactions
a. Ingress:
– External BMP Speaker(s) → TCP (port 5000) → gobmpsrv (pkg/gobmpsrv)
b. Core processing pipeline:
1. gobmpsrv receives raw BMP messages (common header, per-peer header).
2. parser unpacks BMP messages into Go structs (pkg/parser + pkg/bmp).
3. Per-AFI/SAFI modules (pkg/bgp, pkg/bgpls, pkg/evpn, etc.) parse Update NLRI & attributes.
4. message builder (pkg/message) constructs unified JSON record objects.
5. Optional validator (pkg/validator) can check record correctness.
c. Output/publishing layer:
– KafkaPublisher (pkg/kafka) → Kafka topics
– NATSPublisher (pkg/nats) → NATS streams
– File Dumper (pkg/dumper) → JSON file
– Console Dumper (stdout)
– Custom publisher (pkg/pub) for extensibility
d. Auxiliary components:
– Intercept module: duplicates raw BMP → another TCP port for external processor
– pprof HTTP server → port 56767 (runtime monitoring)
– CLI wrappers (cmd/gobmp, cmd/player, cmd/validator)
Architectural patterns & design principles
• Modular Go packages by protocol feature (separation of concerns).
• Publisher interface pattern: easily add new sinks (Kafka, NATS, file, custom).
• Pluggable parsers for each AFI/SAFI and extension.
• Clear CLI vs. library boundary: cmd/* uses pkg/* internally.
• “Player” and “Validator” reuse core parsing/message logic.
Final checklist
[ ] All major components (listener, parser, per-AFI modules, message builder, publishers) are present
[ ] Extensibility points (new AFI support, new publisher) are highlighted
[ ] Deployment variants (binary vs. Docker vs. Kubernetes) are shown, if needed