|
libe3 0.6.1
C++ library for E3AP RAN vendor integration
|
Files | |
| e3_dapp_session.cpp | |
| Implementation of the batched dApp Python seam. See e3_dapp_session.hpp. | |
| e3_dapp_session.hpp | |
| Python-facing dApp session over libe3 — batched, low-latency seam. | |
| libe3_swig.hpp | |
SWIG bindings that let Python drive libe3 in the dApp role. A Python dApp can delete its pure-Python E3AP stack (ZMQ + asn1tools) and let libe3 own E3AP on both ends of the link — exactly the split OAI already uses on the RAN side. An example consumer is available in dApp-library.
libe3 owns E3AP: transport, the setup handshake, subscribe/unsubscribe, indication/control framing, and all wire encodings (ASN.1 / JSON / Protobuf, selected at runtime by E3Config.encoding). Python owns E3SM: the service-model payloads ride opaque, as bytes, and are encoded/decoded in Python. libe3py never touches SM contents.
| Symbol | Purpose |
|---|---|
| E3Config, enums (E3Role, E3LinkLayer, E3TransportLayer, EncodingFormat, ResponseCode, AgentState, ErrorCode) | Configure a session. |
| E3Agent (minimal view) | Backwards-compatible seam: construct/config/start, push opaque bytes. Kept for the smoke test. |
| DAppSession + E3Event | The real dApp seam: full lifecycle + a batched, lock-free inbound queue. This is what a Python dApp consumes. |
See e3_dapp_session.hpp for the authoritative, Doxygen-documented API.
send_control(..., request_ack) asks the RAN for an E3_EVENT_CONTROL_RESPONSE (7). It carries request_id (the id send_control returned), ran_function_id, control_id, response_code, cause (-1 for none), detail and, when the Service Model gave one, has_outcome with the bytes in get_payload(). The RAN also answers a control that it refuses itself, with a negative response, whether the control asked or not.
E3_EVENT_MESSAGE_ACK (5) and send_message_ack are DEPRECATED TO BE REMOVED: libe3 sends no MessageAck, and the event reports one that another RAN sends.
An E3_EVENT_XAPP_CONTROL event carries request_ack. When it is true, answer with send_control_response(request_id, ran_function_id, control_id, response_code, cause, detail, outcome), where request_id is the event's request_id.
E3AP runs at real-time sub-millisecond cadence with very high message throughput, so the binding must not become the bottleneck. At those rates the limiters are the count of GIL acquisitions, the count of Python↔C++ boundary crossings, and libe3's C++ worker threads stalling on the GIL — not payload copy size (E3AP payloads are small; bulk IQ travels out-of-band in shared memory).
DAppSession therefore:
Rejected alternatives: SWIG directors run the Python callback on libe3's inbound thread under the GIL (serialises dispatch, deadlock-prone if Python re-enters libe3); a per-message poll pays one GIL round-trip per message and caps throughput with no latency benefit over batching.
A negative subscription response, setup response or message ack arrives as an E3Event with response_code == 1, and cause and detail say why: cause is a libe3py.Cause_* value (for example Cause_UNSUPPORTED_IDENTIFIER when a control id is not one the RAN function advertises) or -1 when the RAN gave none, as Aerial does, and detail is its text or empty. libe3py does not raise: the dApp reads the event and decides, for example to drop the control and subscribe again.
If the RAN releases the dApp or the connection is lost, poll_events returns an E3_EVENT_DISCONNECT event, the dApp id and the subscriptions are gone, and unless cfg.reconnect_interval_ms is 0 the session registers again by itself after that many milliseconds. It gets a new dapp_id() and an E3_EVENT_SETUP_RESPONSE; subscribe again from there. release() and stop() end it for good. A RAN also releases a dApp that has sent nothing for dapp_idle_timeout_s (default 1800), so a dApp that only listens comes back about that often.
On Linux (x86_64 and aarch64, glibc 2.28 or newer, Python 3.10 to 3.13) the binding is a prebuilt wheel that contains libe3, so one command in any virtual environment is enough, with no libe3 installed:
The wheel includes the SCTP transport (link=posix, transport=sctp); it needs the sctp kernel module on the machine at run time (modprobe sctp) and nothing else.
Elsewhere, and from a checkout (pip install .), install libe3 once (./build_libe3 --all-encodings --enable-sctp --install, see the main README; without --enable-sctp the module has no SCTP) and pip builds the module from these sources against the installed libe3 (python/CMakeLists.txt); it needs swig >= 4.0, the Python headers and a C++17 compiler (./build_libe3 -I installs them), and it stops with an error if the installed libe3 is not the same version. For a libe3 outside /usr and /usr/local: pip install --no-binary libe3py libe3py --config-settings=cmake.define.CMAKE_PREFIX_PATH=<prefix>.
For development, ./build_libe3 --enable-swig builds the module in build/swig (run the smoke test with PYTHONPATH=build/swig python3 tests/test_swig_smoke.py); cmake --install installs it only if -DLIBE3_PYTHON_INSTALL_DIR=<dir> is given.
The Simple SM grammar is installed alongside the library under <datadir>/libe3/sm/sm_simple/ — both e3sm_simple.asn (ASN.1) and e3sm_simple.proto (Protobuf) — discoverable via pkg-config --variable=smdir libe3, so Python dApps can reuse the exact grammar their C++ counterpart (examples/simple_agent.cpp) uses instead of copying it.