Chapter 0: Welcome
Welcome to the PFCP Endpoint (PEP) microservice learning guide. PEP is the control-plane brain of the User Plane β it terminates PFCP from the SMF, manages associations and sessions, and pushes forwarding rules to the data-plane.
Repository at a Glance
pfcp-endpoint/
βββ src/ # Main application source
β βββ pep_main.c # Entry point
β βββ pep.c # Top-level PEP module
β βββ pep_ctrl.c # Controller module
β βββ pfcp.c # PFCP protocol codec
β βββ pep_association_engine.c # Association management (392K!)
β βββ pep_session_engine.c # Session management (661K!)
β βββ pep_internal_session_engine.c # Internal sessions
β βββ gtp_path_supervisor.c # GTP path monitoring
β βββ path_supervisor.c # PFCP path supervision
β βββ lep_client_engine.c # LEP (data-plane) client
β βββ ext_adapter.c # External adapter
β βββ config/ # Configuration parsing
β βββ network-instance/ # Network instance management
β βββ pfdm/ # PFD Management
β βββ pfcp-common/ # Shared PFCP utilities
β βββ db-mux/ # Database multiplexer
β βββ common/ # Common utilities
β βββ session/ # Session client
β βββ types/ # Type definitions
β βββ pvtb/ # PVTB (buffering)
β βββ blocked-pools-manager/
βββ libs/ # Local libraries
β βββ action/ # Action command framework
β βββ cli/ # CLI agent
β βββ cm/ # CM mediator/broker
β βββ fen/ # FEN adapter
β βββ fm/ # Fault Management
β βββ partitioner/ # Session partitioning
βββ tests/ # All tests
β βββ ut/ # Unit tests
β βββ sft/ # Signal Flow Tests
β βββ fixture/ # SFT test fixtures/simulators
β βββ mock/ # Mocks
β βββ veto/ # System tests (VETO)
β βββ toads/ # TOADS integration tests
βββ include/ # Public headers
βββ flatbuffers/ # FlatBuffer schemas
βββ up-common/ # Shared libraries (submodule)
βββ Makefile # Developer shortcuts (if exists)
βββ CMakeLists.txt # Build system
βββ Jenkinsfile* # CI/CD pipelines
βββ ruleset2.0.yaml # Bob build rules
Chapter 1: PFCP & the Control Plane
PFCP Recap (from the UPF perspective)
You already know PFCP from the data-plane guide. But PEP is the other side β it's the service that terminates PFCP messages from the SMF and translates them into data-plane configuration.
Key PFCP Concepts in PEP
| Concept | PEP's Role |
|---|---|
| Association | Manages the PFCP association with each SMF (heartbeat, features, recovery) |
| Session | Handles session establishment/modification/deletion, translates PDRs/FARs/QERs |
| SEID | Allocates Session Endpoint Identifiers (unique per session) |
| TEID | Allocates Tunnel Endpoint Identifiers for GTP-U tunnels |
| Heartbeat | Monitors SMF liveness via PFCP heartbeat request/response |
| Recovery | Detects SMF restart (recovery timestamp) and cleans up stale sessions |
| PFD Management | Handles Packet Flow Description provisioning from SMF |
Chapter 2: PEP's Role in PCG
Where PEP Sits
PEP's Responsibilities
- PFCP termination: Decode/encode PFCP messages (TS 29.244)
- Session lifecycle: Create, modify, delete PFCP sessions
- Association management: Handle SMF associations, heartbeats, recovery
- TEID/SEID allocation: Generate unique identifiers for tunnels and sessions
- Config push to DP: Translate PFCP rules into data-plane config (via LEP client)
- UE IP allocation: Request IP addresses from UE-IP Allocator service
- GTP path supervision: Monitor GTP-U path health (echo requests)
- Geo-redundancy: Persist session state to Redis for failover
- Load control: Report load to SMF, implement overload protection
- Metrics & OAM: Prometheus metrics, fault management, CLI
Chapter 3: Neighboring Services
| Service | Interface | Purpose |
|---|---|---|
| SMF | PFCP (N4) | Receives session/association requests |
| Data Plane | LEP (internal REST/FBs) | Pushes forwarding rules |
| CM Mediator | REST (JSON) | Receives configuration |
| Redis (KV DB) | Redis protocol | Session state persistence, geo-redundancy |
| UE-IP Allocator | Internal API | IP address pool management |
| NWCMA | gRPC | Network instance configuration |
| Routing Agent | gRPC | Route announcements for UE IPs |
| PM Server | Prometheus | Metrics scraping |
| Log Transformer | stdout | Structured logging |
π Quiz 1 β Context
Q1: What is PEP's primary role?
Q2: What does SEID stand for?
Q3: How does PEP detect an SMF restart?
Q4: Where does PEP persist session state for geo-redundancy?
Q5: What protocol does PEP use to push rules to the data-plane?
Chapter 4: High-Level Architecture
Single-Threaded Event-Driven
Unlike the data-plane (multi-threaded, CPU-pinned), PEP is primarily single-threaded and event-driven using the EVL event loop. It handles thousands of PFCP messages per second without threads β all via async I/O and callbacks.
Key Source Files
| File | Size | Purpose |
|---|---|---|
pep_session_engine.c | 661K | Session lifecycle (the largest file!) |
pep_association_engine.c | 392K | Association management |
gtp_path_supervisor.c | 230K | GTP-U path monitoring |
pep_internal_session_engine.c | 219K | Internal session handling |
pfcp.c | 185K | PFCP protocol codec |
path_supervisor.c | 124K | PFCP path supervision |
pep.c | 110K | Top-level PEP module |
pep_main.c | 94K | Entry point, initialization |
pep_ctrl.c | 87K | Controller (config, OAM) |
Chapter 5: Association Engine
What is a PFCP Association?
Before an SMF can create sessions, it must establish a PFCP Association with the UPF. This is like a "handshake" that negotiates features and starts heartbeat monitoring.
SMF PEP (UPF)
β β
βββ Association Setup Request βββΊβ (features, node ID, recovery TS)
ββββ Association Setup Response ββ (accepted, UP features, TEID ranges)
β β
βββ Heartbeat Request βββββββββββΊβ (every N seconds)
ββββ Heartbeat Response ββββββββββ
β β
βββ Association Release Req βββββΊβ (graceful teardown)
ββββ Association Release Resp ββββ
Association Engine Responsibilities
- Accept/reject association setup requests
- Track multiple simultaneous SMF associations
- Monitor heartbeats (detect dead SMFs)
- Handle recovery timestamp changes (SMF restart β clean stale sessions)
- Report UP features and capabilities to SMF
- Manage association-level counters and metrics
src/pep_association_engine.c (392K lines) + src/pep_internal_association_engine.cChapter 6: Session Engine
Session Lifecycle
Key Concepts
- SEID Generator (
pfcp-common/src/pep_seid_generator.c) β Generates unique 64-bit Session Endpoint IDs - TEID Generator (
pfcp-common/src/pep_teid_generator.c) β Generates unique 32-bit Tunnel Endpoint IDs - Session Client (
session/src/pep_session_client.c) β Interface to data-plane for session config - Session Cleanup (
pep_session_cleanup.c) β Handles stale session removal - UE-IP Allocator Client (
ueip_allocator_client.c) β Requests IPs from pool service
Chapter 7: Path Supervision
PFCP Path Supervision
PEP monitors the PFCP path to each SMF using heartbeat messages. If heartbeats fail, the association is considered dead and sessions are cleaned up.
// path_supervisor.c handles:
// - Sending heartbeat requests on timer
// - Tracking response timeouts
// - Declaring path failure after N retries
// - Triggering association cleanup on failure
GTP Path Supervision
PEP also monitors GTP-U paths (to gNBs) using GTP Echo Request/Response. This detects transport failures between the UPF and radio access network.
src/gtp_path_supervisor.c (230K!) β One of the largest modules. Handles echo scheduling, failure detection, and reporting to SMF via PFCP Session Report.π Quiz 2 β Architecture
Q1: Is PEP multi-threaded like the data-plane?
Q2: What is the largest source file in PEP?
Q3: What must happen before an SMF can create sessions?
Q4: What does the GTP path supervisor monitor?
Q5: What happens when PEP detects an SMF recovery timestamp change?
Chapter 8: PFCP Protocol Handling
The PFCP Codec
src/pfcp.c (185K) implements the PFCP message encoder/decoder per 3GPP TS 29.244. It handles:
- Message type dispatch (Association, Session, Heartbeat, Node Report)
- IE (Information Element) parsing and validation
- Grouped IE handling (nested structures)
- Error response generation
PFCP Resource Encoder
src/pfcp_resource_encoder.c (64K) encodes PFCP resources (TEIDs, network instance info) into the format expected by the data-plane.
Chapter 9: Network Instances
The src/network-instance/ module manages network instances (DNNs/APNs). Each network instance has:
- A unique NWID (network instance ID)
- Associated IP pools
- GTP access selectors
- Routing configuration
Key files: nw_instance_engine.c (108K), nw_instance_id_engine.c (69K), nw_instance_id_allocator.c, nw_instance_id_cache.c.
Chapter 10: PFD Management
The src/pfdm/ module handles Packet Flow Description Management β the SMF can provision application detection rules (PFDs) that the UPF uses for DPI-less traffic classification.
Key components: pfdm_engine.c, pfdm_provision_handler.c, pfdm_delete_handler.c, pfdm_request_handler.c, pfdm_state_data.c.
Chapter 11: DB Mux & Geo-Redundancy
DB Multiplexer
The src/db-mux/ module abstracts database operations, allowing PEP to work with multiple Redis instances for geo-redundancy.
Geo-Redundancy
PEP persists session state to Redis so that if a PEP pod dies, another can take over. The common/src/db_module.c and common/src/db_tracker_adapter.c handle this.
Sequence Number Allocator
common/src/seqno_allocator.c β Generates unique sequence numbers for PFCP messages, persisted across restarts via Redis.
π Quiz 3 β Subsystems
Q1: What does the PFCP codec in pfcp.c do?
Q2: What is PFD Management used for?
Q3: Why does PEP persist state to Redis?
Q4: What does the DB Mux module abstract?
Q5: What does the NWID represent?
Chapter 12: Module Lifecycle
PEP follows the same module lifecycle pattern as data-plane (create β start β stop β delete). See the data-plane guide Chapter 12 for the full pattern. The same rules apply: start must not fail, stop must be callable before start completes, on_stopped_cb means safe to delete.
// PEP module example (from pep.h)
pep_t* pep_create(pep_options_t* options, evl_t* evl, ...);
void pep_start(pep_t* pep, on_started_cb, ctx);
void pep_stop(pep_t* pep, on_stopped_cb, ctx);
void pep_delete(pep_t* pep);
Chapter 13: Config Handling
Configuration Sources
- CM Mediator (JSON) β Runtime config via REST (
config/pep_config_json_parser.c, 195K) - XML (EPG mode) β Legacy config (
config/pep_config_xml_parser.c, 70K) - Environment variables β Startup options (
config/pep_config_env_parser.c) - Command-line options β (
pep_options.c, 90K)
Config Flow
Chapter 14: LEP Client & Ext Adapter
LEP Client
The LEP (Local Endpoint) Client (lep_client_engine.c, 59K) is how PEP pushes session configuration to the data-plane. It serializes rules into FlatBuffers and sends them over an internal connection.
External Adapter
ext_adapter.c (56K) handles communication with external services (UE-IP allocator, routing agent, etc.).
π Quiz 4 β Code Patterns
Q1: What is the LEP client used for?
Q2: What serialization format does PEP use to talk to data-plane?
Q3: What is the primary config source in PCG mode?
Q4: Which module lifecycle rule applies to PEP?
Q5: What does pep_options.c handle?
Chapter 15: up-common & EVL
PEP uses the same up-common submodule as data-plane. Key libraries: EVL (event loop), timers, mbox, RCU, HTTP, Redis client, TLS, logging, metrics. See data-plane guide Chapters 15-17 for details.
Chapter 16: Local Libraries
PEP has its own libs/ directory with service-specific libraries:
| Library | Purpose |
|---|---|
libs/action/ | Action command framework (operational commands) |
libs/cli/ | CLI agent for troubleshooting commands |
libs/cm/ | CM mediator/broker integration |
libs/fen/ | FEN (Front-End Node) adapter |
libs/fm/ | Fault Management (alarm raising/clearing) |
libs/partitioner/ | Session partitioning across PEP instances |
libs/async_retry_agent/ | Retry logic for async operations |
Chapter 17: Flatbuffers & PFCP Codec
FlatBuffers
PEP uses FlatBuffers (Google's zero-copy serialization) to communicate with the data-plane. Schemas are in flatbuffers/. This is more efficient than JSON for high-frequency session updates.
PFCP Codec Libraries
The src/pfcp-common/ module contains shared PFCP utilities:
pep_seid_generator.cβ SEID allocation (43K)pep_teid_generator.cβ TEID allocation (24K)load_ctrl.cβ Load control reporting to SMF (40K)recovery_timestamp.cβ Recovery timestamp management (27K)pep_uetrace_ctrl.c/pep_uetrace_engine.cβ UE tracing
π Quiz 5 β Libraries
Q1: What is the partitioner library used for?
Q2: Why use FlatBuffers instead of JSON for DP communication?
Q3: What does the FM library handle?
Q4: What does load_ctrl.c report?
Q5: What shared library provides the event loop?
Chapter 18: Build System
Same as data-plane: CMake + Bob + up-common 3PP system. The top-level CMakeLists.txt builds the pfcp-endpoint executable and links all modules.
# Key build commands (similar to data-plane)
$ bob/bob init-dev
$ bob/bob generate:3pp # Download 3PP dependencies
$ bob/bob -p build-dir=builds/san generate:cmake
$ bob/bob -p build-dir=builds/san build:cpp test:cpp
Build variants: builds/san (sanitizers), builds/assert, builds/debug, builds/release, builds/cov.
Chapter 19: Unit & SFT Tests
Test Organization
tests/
βββ ut/ # Unit tests (test single modules with mocks)
β βββ pep_ut_session_engine.c (725K!)
β βββ pep_ut_association_engine.c (216K)
β βββ pep_ut_pfcp.c (64K)
β βββ ...
βββ sft/ # Signal Flow Tests (multi-module integration)
β βββ pep_sft_sessions.c (273K)
β βββ pep_sft_associations.c (98K)
β βββ pep_sft_pfdm.c (470K!)
β βββ ...
βββ fixture/ # SFT simulators
β βββ pep_sft_fix.c (165K - main fixture)
β βββ pep_sft_sim_data_plane.c (simulates DP)
β βββ pep_sft_sim_control_plane.c (simulates SMF)
β βββ pep_sft_sim_lep.c (simulates LEP)
βββ mock/ # Mock implementations
βββ utils/ # Test utilities
Uses the same ET test framework from up-common.
Chapter 20: VETO & TOADS
VETO (System Test)
tests/veto/ contains Python-based system tests that run against a real PCG deployment. They use TRex traffic generator and test end-to-end PFCP flows.
TOADS
tests/toads/ is a container-based integration test framework (similar to data-plane's contest). It runs PEP in a Docker container with simulated peers.
π Quiz 6 β Build & Test
Q1: What is the SFT fixture's role?
Q2: What is TOADS?
Q3: Which test file is the largest?
Q4: What does pep_sft_sim_control_plane.c simulate?
Q5: What build tool orchestrates the build?
Chapter 21: CI Pipelines
Same pipeline structure as data-plane:
- JenkinsfilePreCodeReview β Runs on every Gerrit push (build, test, lint)
- JenkinsfileDrop β Produces versioned artifacts on merge
- JenkinsfilePra β Release pipeline with full VA/compliance
- JenkinsfileVA2.0 β Vulnerability scanning
- JenkinsfileSoC β Security of Code
- JenkinsfileReadinessCheck β ADP readiness verification
Chapter 22: Docker & Helm
PEP is deployed as eric-pc-up-pfcp-endpoint in Kubernetes. The Dockerfile builds a minimal image with the pfcp-endpoint binary. Helm chart is in charts/.
Key differences from data-plane: PEP does NOT need DPDK, SR-IOV, or hugepages. It's a standard network service using regular kernel sockets (UDP for PFCP).
Chapter 23: Day-to-Day Workflow
Same Gerrit workflow as data-plane. Key commands:
# Build and test
$ bob/bob -p build-dir=builds/san generate:cmake
$ bob/bob -p build-dir=builds/san build:cpp test:cpp
# Run specific test
$ bob/bob -p build-dir=builds/san -p cpp-target=pep_ut_session_engine_SUITE test:cpp
# Build image
$ bob/bob -p build-dir=builds/release build image package
-p cpp-target= to run specific suites during development.π Quiz 7 β CI/CD & Deploy
Q1: Does PEP need DPDK or SR-IOV?
Q2: What triggers the PreCodeReview pipeline?
Q3: What is the Helm chart name for PEP?
Q4: What does JenkinsfilePra produce?
Q5: How do you run only the association engine unit test?
π Congratulations!
You've completed the PFCP Endpoint Learning Guide.
24 chapters β’ 7 quizzes β’ From PFCP fundamentals to daily workflow
Start with the SFT tests β they show you exactly how PEP interacts with SMF and data-plane. π