Skip to content

µBSS

A convergent Business Support System and Online Charging System for telecommunications operators. The platform handles real-time prepaid charging over DIAMETER (RFC 4006), offline postpaid billing from CDR files, monthly bill-cycle batch processing, PDF invoice rendering, roaming mediation and settlement, and a gRPC management surface consumed by the PHP CRM front-end (var/www/, in the same FHS tree). It is implemented in C++20 on the ACE Reactor framework, with MySQL X DevAPI as the persistence layer.

High-Level Architecture

graph LR
    subgraph Network["Telco network"]
        NE["GGSN / PGW / MSC<br/>(DIAMETER peer)"]
        Usage["Network / partner<br/>(home usage files)"]
        Visited["Visited operator<br/>(roaming usage files)"]
    end

    subgraph CRM["CRM front-end (PHP, var/www)"]
        UI["Web dashboard"]
    end

    subgraph Server["bin/server (C++ / ACE)"]
        Prepaid["Prepaid<br/>(DIAMETER server)"]
        CDRLoader["CDR Loader<br/>(timer)"]
        Billing["Billing<br/>(per bill-cycle)"]
        BillFmt["Bill Formatter<br/>(PDF)"]
        CRMSrv["CRM gRPC server<br/>(JWT + TLS)"]
        MedRole["Mediation<br/>(usage ingest, timer)"]
        RoamRole["Roaming<br/>(D1 charge + D2 TAP-out, timer)"]
        Refdata["Refdata<br/>(in-memory cache)"]
        Lic["License validator<br/>(Ed25519)"]
    end

    DB[("MySQL 8<br/>X DevAPI")]
    PDF[("var/spool/invoice/&lt;y&gt;/&lt;m&gt;/<br/>bc_&lt;n&gt;/*.pdf")]
    TapOut[("var/spool/tapout/")]
    LicFile[("var/lib/license/<br/>platform.lic")]

    NE -- "DIAMETER CCR/CCA<br/>(TLS, RFC 4006)" --> Prepaid
    Usage -- "usage files" --> MedRole
    Visited -- "roaming usage files" --> MedRole
    UI -- "gRPC + JWT (TLS)" --> CRMSrv

    Prepaid --> DB
    CDRLoader --> DB
    Billing --> DB
    BillFmt --> DB
    BillFmt --> PDF
    CRMSrv --> DB
    MedRole -- "home CDR (var/spool/cdr/new)" --> CDRLoader
    MedRole -- "canonical CDR" --> RoamRole
    RoamRole --> DB
    RoamRole --> TapOut
    Refdata --> DB
    Lic -- "verifies" --> LicFile
    Prepaid -.-> Refdata
    CDRLoader -.-> Refdata
    Billing -.-> Refdata
    CRMSrv -.-> Refdata
    RoamRole -.-> Refdata

Subsystems

Convergent rating engine

A single Rater class rates both prepaid Charge / Balance_reserve events and postpaid CDR records against the same REF_Price_plan reference data, applying free-units allowance per service per month. Both paths converge on identical price-plan tables and identical service codes, yielding consistent unit pricing across the prepaid and postpaid customer lifecycle. See Convergent Rating.

Prepaid charging

A DIAMETER Credit-Control Application server implementing RFC 6733 (base) and RFC 4006 (Gy). The Acceptor listens on a configured TCP port with TLS (ACE_SSL, using the etc/certs/ server pair); each accepted connection runs in a detached ACE_Svc_Handler thread that decodes CCR messages, performs BalanceReserve for INITIAL_REQUEST / UPDATE_REQUEST and Charge for TERMINATION_REQUEST / EVENT_REQUEST, and replies with a CCA carrying granted units and a validity time. See Prepaid Charging.

Postpaid billing

BillingHandler is a timer-driven ACE_Event_Handler that polls the activity queue table for work items and dispatches each through a thread pool. It supports single-subscriber billing (SINGLE_BILLING), full bill-cycle runs (FULL_BILLRUN), and a developer-only mass prepaid rating mode. The platform is launched with one process per bill-cycle, each instance filtering activities by its configured billing.billcycle. The CRM's on-demand ExecuteBilling / ExecuteBillCycle RPCs bypass the queue: they run the same billing primitives synchronously inside the CRM process and return the result. See Postpaid Billing.

CDR loader

CDRLoader polls a configured directory for protobuf-serialized CDR files, validates each record, rates it via Rater, persists it through DB_layer::insert(), and moves the source file to either processed/ (with .done suffix) or error/ (with .error suffix). Files are processed in a single background thread guarded by an atomic flag, preventing overlapping cycles. See Postpaid Billing.

Bill formatter

BillFormatterHandler polls for bills with BILL_STATUS_NEW, locks each one, renders the appropriate Inja template (prepaid.html or postpaid.html) with bill data and call/balance history, and produces a PDF via plutobook. The output is written to var/spool/invoice/<year>/<month>/bc_<billcycle>/<billing_id>.pdf and the bill row is transitioned to BILL_STATUS_PAID (prepaid) or BILL_STATUS_UNPAID (postpaid). See Invoicing.

CRM gRPC service

CRMServer builds a grpc::Server and registers CRMServiceImpl, exposing the full management surface — subscribers (including lifecycle Suspend / Reactivate / Terminate), usage, bills (including the ReformatBill re-issue path), vouchers, notifications, statistics, reference data, and on-demand billing. Every call is gated by an AuthInterceptor that validates HS256 JWTs against the configured issuer and audience. Transport is TLS by default. See CRM.

Licensing

LicenseValidator enforces an offline Ed25519-signed license file before any module starts. Validation binds the license to /etc/machine-id, checks the expiry timestamp, and detects clock rollback via an HMAC-protected Last-Known-Good-Time (LKGT) state file. The 32-bit feature mask gates per-module runtime enablement (PREPAID, CDR_LOADER, STATS, BILLING, BILL_FMT, CRM, DIAMETER). See Licensing.

Mediation

MediationDaemon is a timer-driven ACE handler (the mediation role) and the single entry point for usage files, home and roaming alike. A configuration-driven format registry selects a descriptor by filename/header, decodes the file (csv / jsonl / fixed, or a native passthrough of serialized CDRs), maps and validates each record, and normalizes it to the canonical billing.CDR — home records go to the CDR loader feed (var/spool/cdr/new/), roaming records to the Roaming role (Direction-1 input). New vendor formats are added by dropping a descriptor TOML — no recompile. See Mediation.

Roaming

RoamingDaemon (the roaming role) implements both roaming directions. Direction 1: it rates the canonical CDRs from Mediation through the convergent Rater's roaming-tariff branch and charges the operator's own subscribers into offline/online. Direction 2: it meters visiting roamers from other operators at the wholesale IOT and emits TAP-out settlement batches to var/spool/tapout/, never billing the visitor as a home subscriber. See Roaming.

Test platform

A self-contained integration test platform under usr/share/tests/backend/ covers eight flows end-to-end (CDR rating, prepaid DIAMETER, invoice generation, subscriber lifecycle, mediation, roaming charging/settlement, product catalogue, and end-to-end convergent-billing use-cases). The full regression set is 78 tests, currently 77 passing / 1 documented SKIP (the M-2 time-of-day pricing feature). A separate three-test deployment-acceptance pack (usr/share/tests/e2e/) checks an installed platform. The same harness carries user-acceptance scenarios; stress testing is shipped as four dedicated scenarios (S-01..S-04) with per-scenario thresholds and markdown reports, driven by ./run_stress.sh. See Testing.

Technology Stack

Layer Component
Language C++20 (clang or gcc)
Build CMake (>= 3.10), Make, custom shell wrappers
Foundation framework ACE (DOC Group) — Reactor, Acceptor, Svc_Handler, Singleton, Signal, Time_Value
RPC gRPC C++ + Protocol Buffers (proto3)
Real-time charging DIAMETER over TCP — RFC 6733 base, RFC 4006 Credit-Control
Persistence MySQL 8 via the official mysqlcppconnx X DevAPI connector
Configuration TOML via tomlplusplus
Templating Inja (Jinja2-style) for HTML bill templates
PDF rendering plutobook
Cryptography OpenSSL — Ed25519 license signatures, HMAC-SHA256 LKGT, HS256 JWT
Logging ACE ACE_LOG_MSG with optional JSON callback (JsonLogCallback)
Frontend PHP 8.1+ CRM in var/www/ (same FHS tree) — native ext-grpc client