rs-pfcp
A high-performance Rust implementation of the PFCP (Packet Forwarding Control Protocol) for 5G networks, providing 100% compliance with 3GPP TS 29.244 Release 18 specification.
๐ What is PFCP?
PFCP is the critical communication protocol between Control Plane and User Plane functions in 5G networks:
- SMF (Session Management Function) โ UPF (User Plane Function)
- Manages packet forwarding rules, traffic steering, and usage reporting
- Essential for 5G service orchestration, QoS enforcement, and network slicing
โจ Key Features
- ๐ 100% 3GPP TS 29.244 Release 18 Compliance - All 70 Information Elements implemented
- ๐ฅ High Performance - Zero-copy binary protocol implementation with Rust's memory safety
- ๐งช Battle Tested - 854 comprehensive tests with full round-trip serialization validation
- ๐ ๏ธ Developer Friendly - 100% builder pattern coverage with type-safe validation
- ๐ Production Ready - YAML/JSON message display, network interface support, and robust examples
Protocol Coverage
- โ 25/25 Message Types (100% coverage) - All core session and association management
- โ 104+ Information Elements implemented (272+ enum variants defined) - Complete 3GPP TS 29.244 Release 18 core IEs
- โ Advanced Features - Network slicing (S-NSSAI), multi-access support, F-TEID with CHOOSE flags
- โ 5G Core Integration - Session establishment, modification, deletion, and usage reporting
๐โโ๏ธ Quick Start
Installation
Add to your Cargo.toml:
[]
= "0.1.2"
Basic Usage
use ;
use ;
// Create a session establishment request
let request = new
.node_id
.fseid
.create_pdrs
.create_fars
.build?;
// Serialize to bytes for network transmission
let bytes = request.marshal;
// Parse received messages
let parsed_msg = parse?;
match parsed_msg.msg_type
Network Examples
The library includes comprehensive examples for real-world scenarios:
# Run PFCP heartbeat server
# Run session client connecting to UPF
# Analyze captured PFCP traffic
# Demo quota exhaustion reporting
&&
๐๏ธ Architecture
Core Components
rs-pfcp/
โโโ src/ie/ # Information Elements (70 types)
โ โโโ f_teid.rs # F-TEID with 3GPP compliant CHOOSE flags
โ โโโ pdn_type.rs # PDN connection types (IPv4/IPv6/Non-IP)
โ โโโ snssai.rs # 5G Network Slicing identifiers
โ โโโ ...
โโโ src/message/ # PFCP Messages (18 types)
โ โโโ session_*.rs # Session lifecycle management
โ โโโ association_*.rs # Node association handling
โ โโโ heartbeat.rs # Keep-alive mechanism
โโโ examples/ # Production-ready examples
โโโ session-server/ # UPF simulator
โโโ session-client/ # SMF simulator
โโโ pcap-reader/ # Traffic analysis tool
Key Design Principles
- Type Safety - Rust's type system prevents protocol errors at compile time
- Zero Copy - Efficient binary serialization without unnecessary allocations
- Builder Patterns - Intuitive construction of complex PFCP messages
- Error Handling - Comprehensive error types with proper cause codes
- Testing - Every marshal/unmarshal operation verified with round-trip tests
๐ Documentation
| Document | Purpose |
|---|---|
| IE_SUPPORT.md | Complete Information Element implementation status |
| PFCP_MESSAGES.md | Message types, usage patterns, and code examples |
| SESSION_REPORT_DEMO.md | Quota management and usage reporting walkthrough |
| 3GPP_COMPLIANCE_REPORT.md | Detailed compliance verification and integration testing |
| CLAUDE.md | Development commands and codebase architecture |
๐ง Development
Build and Test
# Build the library
# Run all tests (854 tests)
# Run specific test category
# Check code formatting and linting
# Generate documentation
Example Workflows
# Test complete session lifecycle
&
# Analyze protocol compliance
# Benchmark performance
๐ Real-World Usage
5G Network Integration
// SMF establishing session with UPF
let session_request = new
.node_id
.fseid
.create_pdrs
.create_fars
.build?;
Usage Reporting & Quota Management
// Handle quota exhaustion reports from UPF
match message.msg_type
๐ค Contributing
We welcome contributions! This library is actively maintained and we're happy to help with:
- ๐ Bug Reports - Protocol compliance issues, performance problems
- ๐ก Feature Requests - Additional 3GPP features, improved APIs
- ๐ Documentation - Examples, tutorials, architectural guides
- ๐งช Testing - Real-world scenarios, edge cases, performance benchmarks
๐ License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
๐ Acknowledgments
- Inspired by the excellent go-pfcp library
- Built according to 3GPP TS 29.244 Release 18 specification
- Developed with โค๏ธ for the 5G networking community
Ready to build next-generation 5G networks with Rust? Check out our examples to get started! ๐