Note
For two years, this 5G core and its source code were kept private and confidential at the Mobile Communication Company of Iran (MCI), the Telecommunication Company of Iran (TCI), the Telecommunication Infrastructure Company (TIC), SamanTel, Rightel, and Iran's Ministry of Information and Communications Technology.
After two years, following an update to part of the underlying technology, the confidentiality restrictions on the core were lifted and it was released publicly for use by the telecommunications developer community.
A memory-safe 5G Core Network in Rust, ported from Open5GS.
Overview · Status · Quick start · Architecture · Roadmap · Security · License
5G Core Telecom Network is a rewrite of Open5GS in Rust. Open5GS is one of the most widely deployed open-source 5G Cores. It is written in C, follows 3GPP Release 17, and runs in private 5G networks, research labs and operator test beds around the world.
Open5GS works well, but C makes every parser a possible memory-safety bug, and a 5G Core parses untrusted input on every interface. This project keeps the Open5GS design, configuration format and behaviour, and moves the code to Rust so that whole classes of bugs (buffer overflows, use-after-free, data races) can no longer happen.
The port is done module by module. Each Rust file names the C file it replaces,
and a copy of the original C code is kept in upstream/open5gs
so reviewers can compare the two side by side.
- Safety. No
unsafecode. Every decoder treats input as hostile and returns an error instead of panicking. - Compatibility. Same YAML configuration layout and the same SBI, NGAP, NAS, PFCP and GTP-U behaviour as Open5GS, so the two can run side by side during a migration.
- Correctness you can check. Cryptography is verified against 3GPP test vectors, and protocol code is tested with real message bytes.
- Readable code. Small crates with one job each, documented public APIs.
Warning
The project is at an early stage. It is not ready for production networks or real subscribers. See Roadmap and SECURITY.md.
| Component | Open5GS source (C) | Rust crate | Status |
|---|---|---|---|
| Identities: PLMN, AMF-ID, S-NSSAI, SUPI, TBCD, FQDN | lib/proto/types.c |
a5gc-core |
Done |
| Milenage f1–f5*, AUTN, AUTS, GSM-Milenage | lib/crypt/milenage.c |
a5gc-crypt |
Done |
| 5G and EPS key derivation (Kausf, Kseaf, Kamf, RES*, KgNB, KASME, ...) | lib/crypt/ogs-kdf.c |
a5gc-crypt |
Done |
| GTP-U v1 header, extension headers, echo | lib/gtp/v1 |
a5gc-gtp |
Done |
| PFCP header, IEs, heartbeat and association | lib/pfcp |
a5gc-pfcp |
Node procedures done, session IEs in progress |
| 5GS NAS headers, mobile identity, registration, authentication | lib/nas/5gs |
a5gc-nas |
Core messages done |
| SBI data models (NFProfile, PatchItem, ProblemDetails, ...) | lib/sbi/openapi |
a5gc-sbi |
NRF models done |
| NRF: NF register, update, heartbeat, deregister, list, discover | src/nrf |
a5gc-nrf |
Done (subscriptions pending) |
| AUSF, UDM, UDR | src/ausf, src/udm, src/udr |
Planned | |
| AMF (NGAP, NAS) | src/amf |
Planned | |
| SMF, UPF | src/smf, src/upf |
Planned | |
| PCF, NSSF, BSF, SCP, SEPP | src/pcf, src/nssf, ... |
Planned |
- Rust 1.85 or newer (
rustupis the easiest way to install it) - Linux is the main target. macOS and Windows work for development.
git clone https://github.com/AMISEF/5G-Core-Telecom-Network.git
cd 5G-Core-Telecom-Network
cargo build --release
cargo test --workspaceThe NRF listens on 127.0.0.10:7777 by default, the same address Open5GS
uses, and accepts both HTTP/1.1 and HTTP/2 over cleartext (h2c).
cargo run --release --bin a5gc-nrfd -- --config configs/nrf.yamlOn Linux, 127.0.0.10 works without extra setup. On macOS, add the alias
first: sudo ifconfig lo0 alias 127.0.0.10.
Register an AMF, find it, and remove it:
ID=0b6e9c3c-6f3c-41ee-9a52-5b5f3fdc6a01
# NFRegister
curl -s -X PUT http://127.0.0.10:7777/nnrf-nfm/v1/nf-instances/$ID \
-H 'Content-Type: application/json' \
-d '{"nfInstanceId":"'$ID'","nfType":"AMF","nfStatus":"REGISTERED",
"ipv4Addresses":["127.0.0.5"]}'
# NFDiscover
curl -s 'http://127.0.0.10:7777/nnrf-disc/v1/nf-instances?target-nf-type=AMF&requester-nf-type=SMF'
# Heartbeat (NFUpdate)
curl -s -X PATCH http://127.0.0.10:7777/nnrf-nfm/v1/nf-instances/$ID \
-H 'Content-Type: application/json-patch+json' \
-d '[{"op":"replace","path":"/nfStatus","value":"REGISTERED"}]'
# NFDeregister
curl -s -X DELETE http://127.0.0.10:7777/nnrf-nfm/v1/nf-instances/$IDThe NRF follows the same TS 29.510 API as the Open5GS NRF, so Open5GS network functions are meant to register with it unchanged. Automated interoperability tests against Open5GS are on the roadmap.
use a5gc_core::PlmnId;
use a5gc_crypt::{kdf, milenage};
// k, opc, amf, sqn and rand come from the subscriber record and a random source.
let plmn = PlmnId::new(999, 70, 2)?;
let snn = plmn.serving_network_name(); // "5G:mnc070.mcc999.3gppnetwork.org"
let av = milenage::generate(&opc, &amf, &k, &sqn, &rand);
let xres_star = kdf::xres_star(&av.ck, &av.ik, &snn, &rand, &av.xres)?;flowchart LR
UE([UE]) -- N1 NAS --> AMF
gNB([gNB]) -- N2 NGAP --> AMF
gNB -- N3 GTP-U --> UPF
AMF -- SBI --> AUSF
AUSF -- SBI --> UDM
UDM -- SBI --> UDR
AMF -- SBI --> SMF
SMF -- N4 PFCP --> UPF
UPF -- N6 --> DN([Data network])
AMF & SMF & AUSF & UDM & UDR & PCF & NSSF -. register / discover .-> NRF
classDef done fill:#1f883d,stroke:#1a7f37,color:#fff;
classDef next fill:#9a6700,stroke:#7d4e00,color:#fff;
class NRF done;
class AMF,SMF,UPF,AUSF,UDM,UDR,PCF,NSSF next;
Green: running in Rust today. Amber: next in line. The protocol crates that these functions need (NAS, PFCP, GTP-U, crypto, SBI models) are already in place.
5G-Core-Telecom-Network/
├── crates/
│ ├── core/ a5gc-core identities: PLMN, AMF-ID, S-NSSAI, SUPI, TBCD, FQDN
│ ├── crypt/ a5gc-crypt Milenage and 3GPP key derivation
│ ├── gtp/ a5gc-gtp GTP-U v1 codec
│ ├── pfcp/ a5gc-pfcp PFCP codec (N4)
│ ├── nas/ a5gc-nas 5GS NAS codec (N1)
│ └── sbi/ a5gc-sbi SBI data models (TS 29.510, TS 29.571)
├── nf/
│ └── nrf/ a5gc-nrf Network Repository Function (binary: a5gc-nrfd)
├── configs/ YAML configuration, Open5GS layout
├── upstream/open5gs/ original C sources being ported (reference only)
├── COPYRIGHT LICENSE NOTICE SECURITY.md
└── Cargo.toml workspace
- Read the Open5GS C module and the 3GPP specification it implements.
- Write the Rust version with the same behaviour, keeping the C function
names in the doc comments (
Port of ogs_kdf_kamf()). - Fix what C made easy to get wrong: bounds checks before every read, constant-time comparisons for secrets, no global state.
- Test with 3GPP test vectors and with real message bytes.
- Copy the C files into
upstream/open5gsfor side-by-side review.
- Workspace, CI, security policy
- Core identities, Milenage and key derivation, GTP-U, PFCP node procedures
- NAS mobile identity, registration and authentication messages
- NRF (management, heartbeat, discovery)
- NRF: status subscriptions and notifications, OAuth2 tokens, TLS
- AUSF, UDM, UDR with 5G AKA end to end
- NGAP (ASN.1 PER) and the AMF
- PFCP session procedures, SMF and UPF (user plane on Linux)
- PCF, NSSF, BSF, SCP, SEPP
- Interoperability tests against Open5GS and UERANSIM
Security is a design goal of this project, not an afterthought:
#![forbid(unsafe_code)]in every crate.- Decoders check every length field against the buffer and cap repeated structures, so malformed packets cannot cause panics or unbounded allocation.
- MAC verification uses constant-time comparison. Key material never appears in
Debugoutput or logs. - The NRF validates each profile before storing it: UUID format, matching IDs, heartbeat range, allowed PLMNs, reachable endpoints and request size.
Please report vulnerabilities privately as described in SECURITY.md.
Contributions are welcome. Before opening a pull request:
cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
cargo test --workspacePort one Open5GS module per pull request. Name the C files you ported, add
tests with real message bytes or 3GPP vectors, and keep unsafe out.
Copyright © 2026 AMISEF. Created and maintained by AMISEF.
5G Core Telecom Network is free software, licensed under the GNU Affero General Public License v3.0 or later. Because this project is a port of Open5GS, it uses the same license, and the Open5GS authors keep the copyright in their original work. See COPYRIGHT and NOTICE for details.
The AGPL means that if you run a modified version of this software as a network service, you must make your source code available to the users of that service.
- Open5GS by Sukchan Lee and contributors, the foundation this project is built on.
- Jouni Malinen, author of the Milenage reference code in hostap.
- The RustCrypto, Tokio and axum projects.