Rust-backed async SMPP 3.4 client/server + codec for Python asyncio
A pure-Rust implementation of the SMPP 3.4 protocol (Short Message Peer-to-Peer): a PDU codec plus an asynchronous (tokio) client and server built on a listener-trait model.
The same engine ships two ways from one source tree, one version: a Rust crate (cargo add smpp34, zero Python dependencies) and a Rust-backed Python wheel (pip install smpp34) that exposes the identical async client/server to asyncio. The whole SMPP machinery — framing, windowing, timers, codec — runs in the Rust/tokio core; Python crosses the GIL only once per message, and the extension is free-threaded ("no-GIL") ready. See Python below.
Sessions handle the SMPP timers (session_init, enquire_link, inactivity, response), sequence-number windowing, and optional TLS.
bind_transmitter · bind_receiver · bind_transceiver (+ resps) · outbind · unbind · enquire_link · submit_sm · submit_sm_multi · deliver_sm · data_sm · query_sm · cancel_sm · replace_sm · alert_notification · generic_nack, plus arbitrary TLV (optional parameter) encode/decode.
cargo add smpp34 Quick start — server Implement SmppServerListener and hand it to an SmppServer. Every trait method has a default, so you override only the PDUs you care about — typically on_bind_transceiver and on_submit_sm.
pip install smpp34 Client — connect() binds and returns an Smsc; await sends and inbound events:
import asyncio, smpp34 async def main(): client = smpp34.Client(host="smsc.example.net", port=2775, system_id="esme1", password="secret", bind_type="TRX") smsc = await client.connect() resp = await smsc.submit_sm(destination_addr="31600000000", source_addr="12345", short_message=b"hello") print(resp.message_id, resp.is_success) # pull inbound deliver_sm (MO / DLR) — one GIL crossing per message ev = await smsc.next() # DeliverSmEvent | Disconnected if isinstance(ev, smpp34.DeliverSmEvent): print(ev.source_addr, ev.short_message) await smsc.unbind() asyncio.run(main()) Server — await next() yields an Esme when a client binds, a SubmitSmEvent per inbound message (answer with accept/reject), or Unbound:
pdu = smpp34.SubmitSm(source_addr="12345", destination_addr="31600000000", short_message=b"hello") wire = pdu.encode() msg = smpp34.decode(wire) # -> typed SubmitSm / DeliverSm / RawPdu Runnable samples: python/examples/ (and the Rust equivalents in examples/ — client.rs / server.rs). A throughput and leak harness lives in python/perf/, mirroring the Rust examples/{perf_loopback,leak_check}.rs.
Inbound TLVs are on pdu.tlvs in wire order, with typed accessors from the TlvList trait. Outbound, the builders take them directly:
await smsc.submit_sm("31600000000", b"hi", source_addr="12345", tlvs=[ smpp34.Tlv(smpp34.TLV_USER_MESSAGE_REFERENCE, (42).to_bytes(2, "big")), smpp34.Tlv(smpp34.TLV_MESSAGE_PAYLOAD, b"the real body"), ]) ev = await smsc.next() print([(hex(t.tag), t.value) for t in ev.tlvs]) All 44 spec-defined tags are in TlvTag / smpp34.TLV_*; unknown and vendor-specific tags (0x1400-0x3FFF) pass through byte for byte.
Pass tls = true to SmppClient::new to bind over TLS. The TLS transport is rustls (via tokio-rustls, ring backend), so no system TLS library is needed to build or run.
SmppServer::new / SmppClient::new use sensible default timers. Use the *_with_default_timers constructors to set session_init, enquire_link, inactivity and response timers (milliseconds) and the buffer / window size explicitly.
Measured on a 24-core AMD Ryzen AI 9 HX 370 (single box — the SMSC and ESME are co-located, so the load generator competes for cores; separate hosts scale further). Reproduce with cargo bench and perf/docker-compose.yml.
Codec — single core, criterion (cargo bench):
End-to-end — real TCP, full submit_sm round-trip (send → submit_sm_resp):
The SMSC server sustains 625k+ submit_sm/s even pinned to half the cores; past a few sessions the single-box benchmark is bound by the co-located load generator, not by smpp34.
Both languages drive the same Rust/tokio engine, so the protocol work — framing, windowing, timers, codec — runs at full Rust speed either way. The difference is the Python boundary: the event-pull bridge crosses the GIL once per message.
Reproduce: python/perf/perf_loopback.py (COUNT=200000 SESSIONS=4 WINDOW=64), the thread-scaling demo python/perf/perf_threads.py, and the leak check python/perf/leak_check.py — all after a release build (maturin develop --release).
A CPU flamegraph of the loopback under load (scripts/flamegraph.sh) puts ~99.98% of samples in the kernel (the socket/syscall path) — the user-space codec barely appears. smpp34 is syscall-bound, not CPU-bound: at these rates the cost is the ~600k+ read/write syscalls per second plus the runtime's wakeups, not parsing (the codec runs at millions of PDUs/sec). The remaining headroom is therefore I/O batching — coalescing writes and cutting wakeups — not faster code.
scripts/mem_leak_test.sh installs a counting global allocator and asserts live bytes stay flat (exact — unlike noisy RSS) across both codec round-trips and bind/unbind churn. RSS holds at single-digit MB while pushing millions of PDUs. (The bind/unbind check found and now guards a real session-teardown leak — see the changelog.)
The PDU / TLV / session support matrix is in docs/COMPLIANCE.md; docs/COMPARISON.md maps smpp34 against other SMPP stacks.
The SMPP 3.4 codec and the client/server session handling are used in production, and the crate follows Semantic Versioning: the public Rust API is the contract. The 17-argument send_submit_sm / send_deliver_sm remain available, but the submit_sm() / deliver_sm() builders are the recommended way to send.
Maintained by Real Time Telecom B.V. — carrier-grade telecom infrastructure in Rust.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Enable javascript to be able to filter the list of wheel files.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 4, 2026.




