|
libe3 0.6.1
C++ library for E3AP RAN vendor integration
|
libe3 is a standalone, vendor-neutral C++ library for implementing the E3AP (E3 Application Protocol) on both sides of the protocol — RAN functions (DU, CU-CP, CU-UP) and dApp clients. It provides a clean object-oriented API for both roles while hiding transport, encoding, and protocol complexity.
E3Agent serves both sides of the E3 interface — the same class, switched by one config field:
Install all required packages using the project's installer (recommended) or manually:
The packaging tools (dpkg-dev, debhelper, fakeroot) are only needed by scripts/create_deb.sh.
The easiest way to build libe3 is using the provided build script:
Alternatively, you can use CMake directly:
This is the recipe the OAI E3 agent and the dApp library point to. It installs libe3 like any other library, once and with sudo, into /usr/local; after that nothing that builds against it needs sudo or extra environment variables. Every wire encoding is built, since a gNB has to serve whichever one its dApp uses:
| Option | Default | Description |
|---|---|---|
| LIBE3_BUILD_TESTS | ON | Build unit tests |
| LIBE3_BUILD_EXAMPLES | ON | Build examples |
| LIBE3_BUILD_INTEGRATION_TESTS | OFF | Build the integration test suite (multi-role end-to-end tests + full-loop benchmark) |
| LIBE3_ENABLE_ZMQ | ON | Enable ZeroMQ transport |
| LIBE3_ENABLE_ASN1 | ON | Enable ASN.1 encoding |
| LIBE3_ENABLE_E2SM_DAPP | ON | Build the E2SM-DAPP codec libraries (needs LIBE3_ENABLE_ASN1, see docs/e2sm-dapp) |
| LIBE3_ENABLE_JSON | OFF | Enable JSON encoding support. It also builds the JSON encoding rules (JER) into the asn1c runtime, so a service model that links libe3::asn1_e3ap is generated with -gen-JER (LIBE3_ASN1_JER in find_package(libe3) says so; libe3/asn1_layout_check.h refuses a unit generated the other way) |
| LIBE3_ENABLE_PROTOBUF | OFF | Enable Protocol Buffers encoding support |
| LIBE3_ENABLE_ASAN | OFF | Enable AddressSanitizer |
| LIBE3_ENABLE_TSAN | OFF | Enable ThreadSanitizer |
| LIBE3_ENABLE_SWIG | OFF | Build the SWIG-generated Python bindings (_libe3py.so + libe3py.py) |
| LIBE3_ENABLE_SCTP | OFF | Enable the SCTP POSIX transport (needs libsctp-dev) |
Note on SCTP: the transport is off by default. It is the only dependency that needs a kernel module plus a distro -dev package for a single system header, and the deployed E3 links are IPC or TCP, so ./build_libe3 -I no longer installs it. E3TransportLayer::SCTP still exists in the ABI, and in the C API and Python bindings that mirror its value, whichever way the flag is set — but asking a build without it for the SCTP transport fails at socket creation with a message telling you to rebuild, rather than silently falling back to another protocol. Configuring with -DLIBE3_ENABLE_SCTP=ON and no headers installed fails at configure time, naming the package.
sudo apt install -y libsctp-dev # lksctp-tools-devel on Fedora/RHEL, lksctp-tools on Arch./build_libe3 --enable-sctp
Note on encoding selection: LIBE3_ENABLE_ASN1, LIBE3_ENABLE_JSON, and LIBE3_ENABLE_PROTOBUF are independent compile-time inclusion flags — any combination can be ON simultaneously to build a library that supports several encodings. The active encoding is selected at runtime via the encoding field of e3_config_t (0 = ASN1, 1 = JSON, 2 = PROTOBUF) when calling e3_agent_create_with_config().
The same E3Agent class can act as a dApp client. Set E3Config.role to E3Role::DAPP and register handlers for the messages flowing back from the RAN:
See examples/simple_dapp.cpp for a complete reference dApp using the Simple service model. It pairs with examples/simple_agent.cpp and is wire-compatible with Python dApp clients that implement the same Simple SM encoding.
A single dApp process can connect to multiple RAN agents simultaneously by instantiating multiple E3Agent objects, each with its own configuration:
Each instance has its own threads, connector, encoder, and per-peer DAppSubscriptionState. The library guarantees that N coexisting E3Agent instances in one process do not share mutable state.
Service Models implement the libe3::ServiceModel interface. Control action handlers are registered from the SM implementation via register_control_callback and the E3Agent routes incoming control actions to the appropriate SM.
The library exposes IPC endpoints by default (see E3Config defaults) so local testing with dApps on the same host is supported using the IPC transport. There is no dedicated simulation_mode field in E3Config; instead adjust endpoints and transport selection to run in isolated/local environments.
The single entry-point class for both roles. Configure E3Config.role = E3Role::RAN to bind as a RAN function, or E3Role::DAPP to connect as a dApp client. Methods are annotated (RAN) or (dApp) where they apply to only one role; the rest are common.
| Method | Description |
|---|---|
| init() | Initialize the agent |
| start() | Start processing threads |
| stop() | Stop the agent |
| state() | Get current state |
| is_running() | Check if agent is running |
| register_sm(sm) | Register a Service Model |
| get_available_ran_functions() | Get available RAN function IDs from registered SMs |
| set_dapp_report_handler(handler) | Set callback for incoming dApp reports (dApp → RAN) |
| set_dapp_status_changed_handler(handler) | Set callback for dApp status changes (connect, disconnect, subscribe, unsubscribe) |
| send_indication(dapp_id, ran_function_id, data) | (RAN) Send an indication to a specific dApp |
| send_xapp_control(dapp_id, ran_function_id, data, sequence_id, out_message_id, request_ack) | (RAN) Forward an xApp control action to a specific dApp. out_message_id receives the id of the control, the request_id of the answer. request_ack asks the dApp for a ControlResponse |
| get_registered_dapps() | (RAN) Get list of registered dApp IDs |
| get_dapp_subscriptions(dapp_id) | (RAN) Get subscriptions for a dApp |
| get_ran_function_subscribers(ran_function_id) | (RAN) Get subscribers for a RAN function |
| set_indication_handler(handler) | (dApp) Callback for incoming IndicationMessage |
| set_subscription_response_handler(handler) | (dApp) Callback for incoming SubscriptionResponse |
| set_setup_response_handler(handler) | (dApp) Callback for incoming SetupResponse |
| set_xapp_control_handler(handler) | (dApp) Callback for incoming XAppControlAction |
| send_message_ack(request_id, response_code) | DEPRECATED TO BE REMOVED. libe3 sends no MessageAck for a control; use the ControlResponse |
| set_message_ack_handler(handler) | (dApp) DEPRECATED TO BE REMOVED. Callback for an incoming MessageAck that another RAN sends |
| set_control_response_handler(handler) | Callback for incoming ControlResponse. (dApp) The RAN's answer to a control. (RAN) A dApp's answer to an xApp control |
| set_disconnect_handler(handler) | (dApp) Callback when the RAN released the dApp or the connection to it was lost. The dApp then registers again by itself unless reconnect_interval_ms is 0 |
| wait_for_setup(timeout) | (dApp) Block until setup handshake completes |
| subscribe(ran_function_id, telemetry, control, ...) | (dApp) Subscribe to a RAN function |
| unsubscribe(ran_function_id) | (dApp) Tear down a subscription |
| send_control(ran_function_id, control_id, data, sequence_id, out_message_id, request_ack) | (dApp) Send a control action to the RAN. request_ack asks for a ControlResponse when the control has been dealt with. The RAN answers a control that it refuses itself either way |
| send_control_response(request_id, ran_function_id, control_id, result) | (dApp) Answer an xApp control whose request_ack is set |
| send_report(ran_function_id, data) | (dApp) Send a dApp report to the RAN |
| release() | (dApp) Send ReleaseMessage to the RAN |
| dapp_id() | (dApp) Identifier assigned by the RAN in SetupResponse |
| subscribed_ran_functions() / active_subscription_ids() | (dApp) Per-instance subscription state |
| config() | Access current E3Config |
| dapp_count() | (RAN) Number of registered dApps. (dApp) 0/1 based on assignment |
| subscription_count() | Number of active subscriptions on this side |
The E3Config structure contains agent configuration and defaults suitable for local development (IPC) or production deployments.
| Field | Type | Description |
|---|---|---|
| role | E3Role | RAN (default — binds sockets) or DAPP (connects to a remote RAN) |
| ran_identifier | string | Unique RAN identifier (used when role=RAN) |
| dapp_name | string | dApp name advertised in SetupRequest (used when role=DAPP) |
| dapp_version | string | dApp version advertised in SetupRequest |
| vendor | string | Vendor name for SetupRequest |
| e3ap_version | string | E3AP protocol version string |
| link_layer | E3LinkLayer | ZMQ or POSIX |
| transport_layer | E3TransportLayer | SCTP, TCP, IPC |
| setup_endpoint | string | Setup connection endpoint (default: ipc:///tmp/dapps/setup). The POSIX link serves everything on this one endpoint, with the IPC path /tmp/dapps/e3 while the field keeps its default; for TCP and SCTP tcp://host:port or sctp://host:port names the host and port |
| subscriber_endpoint | string | Subscriber endpoint, ZeroMQ only (default: ipc:///tmp/dapps/dapp_socket) |
| publisher_endpoint | string | Publisher endpoint, ZeroMQ only (default: ipc:///tmp/dapps/e3_socket) |
| setup_port | uint16_t | Port of the setup channel (default 9990); the one port of the POSIX link. subscriber_port (9999) and publisher_port (9991) are ZeroMQ only |
| socket_buffer_bytes | size_t | POSIX over SCTP: SO_SNDBUF and SO_RCVBUF of both peers (default 2 MiB, 0 keeps the kernel's) |
| sctp_delayed_sack | bool | POSIX over SCTP: whether delayed SACK stays on (default false, off) |
| allowed_peers | vector<string> | POSIX over TCP and SCTP, RAN: literal addresses a dApp may connect from (default empty, any) |
| maximum_associations | size_t | POSIX, RAN: most dApps connected at once (default 0, unlimited) |
| encoding | EncodingFormat | ASN1, JSON, or PROTOBUF |
| connect_timeout_ms | uint32_t | Connect timeout (ms) |
| recv_timeout_ms | uint32_t | Receive timeout (ms) |
| send_timeout_ms | uint32_t | Send timeout (ms) |
| dapp_idle_timeout_s | uint32_t | RAN: seconds without a message from a dApp before it is released and removed (default 1800, 0 never). Only what the dApp sends counts. In the C API, e3_config_t has dapp_idle_timeout_s and the flag set_dapp_idle_timeout, since 0 is a legitimate value |
| reconnect_interval_ms | uint32_t | dApp: milliseconds between attempts to register again after a release, a lost link or a failed setup (default 1000, 0 never). The new session has a new dApp id and no subscriptions |
| receive_buffer_size | size_t | Receive buffer size (bytes) |
| send_buffer_size | size_t | Send buffer size (bytes) |
| io_threads | size_t | Number of I/O threads |
| log_level | int | Logging level (0=none .. 5=trace) |
Interface for implementing custom service models.
| Method | Description |
|---|---|
| name() | SM name (e.g., "KPM") |
| version() | SM version number |
| ran_function_id() | RAN function ID served by this SM |
| telemetry_ids() | Telemetry identifiers provided by the SM |
| control_ids() | Control identifiers accepted by the SM |
| ran_function_data() | Optional opaque bytes included in SetupResponse |
| granted_periodicity(requested_us) | Optional: the least time between two indications the SM keeps for a subscription, reported in the SubscriptionResponse. Absent by default. A C Service Model sets it with e3_service_model_set_granted_periodicity_cb() before registering |
| init() | Initialize the SM (register callbacks) |
| destroy() | Destroy the SM and release resources |
| start() | Start SM processing (on first subscription) |
| stop() | Stop SM processing (on last unsubscription) |
| is_running() | Check if SM is currently running |
The library version is managed via the VERSION file in the project root. During compilation, CMake reads this file and generates libe3/version.hpp with the version macros:
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
The full API reference is automatically generated with Doxygen and published to GitHub Pages on every release. See docs/utilities/latrec.md for the latency-recording (latrec) guide: the mechanism, the clock model, ring naming/sizing, the stage catalog, and the capture-to-CSV workflow. The two loops the stage catalog measures are described in docs/control-loops/path-a-e3-loop.md (E3 only) and docs/control-loops/path-b-e2-e3-loop.md (the full E2-E3 loop). The E2SM-DAPP service model, which carries that loop over E2, is specified in docs/e2sm-dapp/README.md. The E3 Application Protocol is specified in docs/e3ap/README.md, and the Spectrum and L1-KPM service models in docs/e3sm/README.md. Each specification has a Word edition in the O-RAN format. See docs/interop.md for what pairs with OAI, Aerial and OCUDU, the JSON libe3 speaks, the field contracts where peers differ (the periodicity unit, for one), and the change ledger.
🔗 https://wineslab.github.io/libe3/
To build the documentation locally:
libe3 ships an optional SWIG-generated Python binding so the same C++ library can back Python dApp clients. It is off by default — enable it with -DLIBE3_ENABLE_SWIG=ON:
The module exposes two layers: a backwards-compatible minimal E3Agent view, and the full DAppSession dApp seam — a complete lifecycle (start / wait_for_setup / subscribe / send_control / release / stop) plus a batched, lock-free inbound queue drained via poll_events(max_batch, timeout_ms), designed for the sub-millisecond / high-throughput E3AP path (GIL released during blocking calls). SM payloads cross as native bytes; per-SM encoding stays in Python so existing Python SM implementations work unchanged. The binding is built by pip against the installed libe3 (python/CMakeLists.txt), links it statically, and refuses an installed libe3 of another version.
See swig/README.md for the architecture, rationale, and a full Python usage example, and swig/e3_dapp_session.hpp for the documented API.
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details, and [NOTICE](NOTICE) for the attribution that redistributors are required to carry.
If you use libe3, or derive a protocol definition or an implementation from it, please cite it. See CITATION.cff, or use the "Cite this repository" button on GitHub. The paper reference will be added here once it is published. This is a request, not a condition of the license.
This work has been partially supported by OUSD(R&E) through Army Research Laboratory Cooperative Agreement Number W911NF-24-2-0065.