How omec-project/upf works
1. Top-level split: control plane agent vs datapath
- The repository implements a 3GPP UPF with two major runtime pieces:
- pfcpiface: a Go control-plane agent that speaks PFCP to the mobile core control plane.
- BESS-based datapath: the packet-processing plane, built around the external BESS project.
- The main architectural boundary is between PFCP/session management and packet forwarding. PFCP configures the datapath; the datapath handles user traffic.
2. Northbound interface to the mobile core
- cmd/pfcpiface/main.go starts the PFCP agent.
- The agent talks to SMF/SPGW-C over PFCP for association setup/release, heartbeats, session establishment/modification, and reports.
- The repo also supports UPF-initiated PFCP association, so the agent can initiate the control connection as well as respond to it.
3. PFCP message processing pipeline
- Inside pfcpiface, PFCP messages are parsed into domain objects for rules and session state.
- The key rule types are PDR, FAR, QER, SDF filters, and PFDs, each with its own parser and session model.
- This layer is responsible for turning protocol messages into internal session/rule representations before any datapath-specific translation happens.
4. Session and state management
- Session state is maintained separately from the raw PFCP transport handling.
- Files such as sessions.go, sessions_store.go, local_store.go, session_pdr.go, session_far.go, and session_qer.go indicate a persistent in-memory model for per-UE/per-session configuration.
- Supporting components include UE IP pool management, F-TEID handling, node identity, and helpers for connection/message correlation.
5. Datapath abstraction boundary
- pfcpiface/datapath.go defines the abstraction layer between the PFCP agent and the concrete datapath.
- This is the key extensibility point: PFCP semantics are translated into a common internal API, then into datapath-specific commands.
- The README notes that new datapaths can be added by implementing new plugins; the current implementation targets BESS.
6. BESS southbound integration
- pfcpiface/bess.go and the generated pfcpiface/bess_pb/* protobuf bindings are the southbound control channel to BESS.
- The PFCP agent programs BESS modules, ports, flows, and service chains through this interface.
- This is where PFCP session rules become concrete forwarding behavior, QoS enforcement, NAT/routing behavior, and monitoring hooks in the datapath.
7. Packet-processing capabilities in the datapath
- The BESS datapath supports N3/N4/N6/N9 interfaces, IPv4 routing, fragmentation/reassembly, UE NAT, branching/ULCL, DDN notification behavior, QoS rate limiting, and telemetry for per-flow latency/throughput.
- The conf/*.bess, conf/*.jsonc, and related config files describe datapath pipelines and deployment variants for different interface counts or runtime modes.
- This is the layer that actually forwards and transforms user packets; the Go agent does not process user-plane packets directly.
8. Telemetry and operational visibility
- pfcpiface/metrics exports Prometheus metrics for PFCP and datapath behavior.
- pfcpiface/telemetry.go, web_service.go, and notifier.go indicate additional operational surfaces for status/notifications.
- The conf/grafana/* dashboards and conf/prometheus.yml show that Prometheus/Grafana are first-class observability dependencies for the system.
9. Configuration and runtime profiles
- pfcpiface/config.go and the conf directory hold configuration for UPF behavior, datapath selection, port layouts, and simulation/testing profiles.
- There are multiple BESS/CNDP/packet-generator configuration artifacts, suggesting the repository is organized around deploy-time composition rather than a single fixed topology.
- deployments/upf-k8s.yaml provides a Kubernetes deployment boundary for running the UPF in cluster environments.
10. Testing and simulation layers
- Unit tests live alongside the Go code in pfcpiface/*_test.go.
- test/integration contains end-to-end tests that validate PFCP agent behavior against a datapath, with a fake BESS implementation in pkg/fake_bess for isolation.
- ptf/ is a separate packet-test harness for BESS-UPF, using Python, TRex, and PTF to verify actual packet forwarding behavior.
- conf/sim.py, conf/gtp_echo.py, and related scripts support simulation and route-control workflows.
11. Tooling and build outputs
- The project is primarily Go-based, with generated protobufs checked in for the BESS control protocol.
- Docker is a major packaging boundary: the repo builds at least two images, pfcpiface and bess.
- CI, linting, and repository hygiene are managed through GitHub Actions, golangci-lint, pre-commit, and spellcheck configs.
12. How the data flow should look in a diagram
- Control-plane flow: SMF/SPGW-C → PFCP over N4 → pfcpiface → session/rule state → datapath adapter → BESS control plane.
- User-plane flow: UE traffic → BESS datapath interfaces → BESS forwarding/NAT/QoS/routing pipeline → external network.
- Observability flow: PFCP/datapath metrics → Prometheus → Grafana dashboards.
- Test/validation flow: Go unit/integration tests and PTF/TRex tests validate the PFCP agent and datapath separately and together.
Main entry points: pfcpiface.go PFCP core · bess.go BESS control · up4.bess BESS pipeline · prometheus.go Metrics
Components 20
Control plane
PFCP agent and session management
- pfcpiface main · Starts the PFCP agent runtime.
cmd/pfcpiface/main.go - PFCP core · Top-level PFCP control-plane orchestration.
pfcpiface/pfcpiface.go - PFCP messages · Parses PFCP messages into domain objects.
pfcpiface/messages.go - Session store · Maintains per-session and per-UE PFCP state.
pfcpiface/sessions.go - Rule parsers · Parses PDR, FAR, QER, SDF, and PFD inputs.
pfcpiface/parse_pdr.go - Rule state · Represents session-local PDR/FAR/QER state.
pfcpiface/session_pdr.go - UPF model · UPF identity, F-TEID, IP pools, and node/session helpers.
pfcpiface/upf.go
Datapath
BESS integration and packet forwarding pipeline
- Datapath API · Abstracts datapath operations behind a common API.
pfcpiface/datapath.go - BESS control · Programs the BESS datapath from PFCP intent.
pfcpiface/bess.go - BESS protos · Checked-in protobuf bindings for BESS RPCs.
pfcpiface/bess_pb/bess_msg.pb.go - BESS pipeline · Datapath pipeline definitions for interfaces and forwarding behavior.
conf/up4.bess
Observability
Metrics, telemetry, and dashboards
- Metrics · Exports PFCP and datapath metrics.
pfcpiface/metrics/prometheus.go - Telemetry · Status, notifications, and web-facing operational surfaces.
pfcpiface/telemetry.go - Dashboards · Prometheus datasource and Grafana dashboard definitions.
conf/grafana/upf-custom.json
Validation
Unit, integration, and packet-level testing
- Fake BESS · In-memory BESS replacement for integration tests.
pkg/fake_bess/fake_bess.go - Integration tests · End-to-end PFCP and datapath validation.
test/integration/basic_test.go - PTF harness · Python/TRex/PTF packet-forwarding validation.
ptf/tests/unary/check_rules.py
Build & deploy
Packaging, configuration, and runtime profiles
- Runtime config · UPF and datapath configuration profiles.
conf/upf.jsonc - K8s deploy · Containerized UPF deployment in Kubernetes.
deployments/upf-k8s.yaml - Sim tools · Simulation and route-control scripts.
conf/sim.py
Connections 20
- pfcpiface main → PFCP core: starts · Entrypoint launches the PFCP control agent.
- PFCP core → PFCP messages: parses · PFCP transport is decoded into internal message objects.
- PFCP messages → Rule parsers: extracts rules · Rule-specific parsers derive PDR/FAR/QER/SDF/PFD state.
- Rule parsers → Rule state: builds · Parsed rules become session-local state models.
- PFCP core → Session store: stores · Sessions are created, modified, and released in state.
- Session store → UPF model: uses · Session state depends on UE/IP/F-TEID/node helpers.
- PFCP core → Datapath API: targets · Control-plane actions are translated into datapath operations.
- Datapath API → BESS control: implements · Current concrete datapath implementation is BESS.
- BESS control → BESS protos: RPCs · BESS programming uses generated protobuf service bindings.
- BESS control → BESS pipeline: programs · PFCP intent becomes packet-forwarding pipeline state.
- BESS pipeline → Runtime config: configured by · Deployment/runtime profiles parameterize the datapath pipeline.
- PFCP core → Metrics: exports · PFCP and datapath behavior is exported as metrics.
- Telemetry → Metrics: feeds · Telemetry hooks surface operational data through metrics.
- Dashboards → Metrics: visualizes · Dashboards consume Prometheus metrics.
- K8s deploy → Runtime config: deploys · Kubernetes manifests bind runtime configuration into the deployment.
- Integration tests → Fake BESS: isolates · Integration tests use a fake BESS implementation.
- Integration tests → PFCP core: verifies · Tests exercise PFCP agent behavior end to end.
- PTF harness → BESS pipeline: validates · Packet tests validate actual forwarding behavior.
- Sim tools → Runtime config: drives · Simulation scripts use the runtime configuration profiles.
- PFCP core → Telemetry: reports · Operational notifications and web surfaces come from the control plane.