Skip to content

Roaming

Roaming implements the operator's roaming business logic in two directions:

  • Direction 1 (outbound) — charging the operator's own subscribers for usage they generated on foreign networks, normalized by Mediation.
  • Direction 2 (inbound) — handling visiting subscribers from other operators on this network: a simulated visitor lifecycle, wholesale (IOT) metering, and the settlement output (TAP-out) owed to their home operator.

It runs as the independent roaming role of the server binary. Direction-1 charging is deliberately an extension of the platform's existing offline rating path, not a new engine: the home, non-roaming path is byte-for-byte unchanged because the roaming branch is reached only when is_roaming = true.

Glossary

Term Definition
HPMN / home operator This platform, for subscribers it owns.
VPMN / visited operator The network a subscriber is currently attached to.
Direction 1 / outbound roaming Our subscriber abroad; we receive usage and charge our own subscriber.
Direction 2 / inbound roaming Foreign subscriber on our network; we meter and emit settlement output to their home operator.
Outbound roamer Our own subscriber, currently abroad (the chargee in Direction 1).
Visiting roamer / visitor A foreign operator's subscriber on our network (the metered party in Direction 2).
GRUR — Generic Roaming Usage Record Mediation's canonical normalized record, modeled on TAP3/TD.57 semantics; the built-in Direction-1 input format.
IOT / DIOT Inter-Operator Tariff — the wholesale price the visited operator charges the home operator; the basis of Direction-2 output pricing.
PLMN / TADIG code Network/operator identifier (MCC+MNC / GSMA code) used to tag visited & home networks.
TAP3 (TD.57) / NRTRDE (TD.35) / RAP (TD.32) GSMA inter-operator formats: settlement / near-real-time fraud / error-return. We model TAP3 semantics.
TAP-out Our generated Direction-2 settlement output batch.

Direction 1 — charging our own roamers

Roaming consumes the canonical CDRs Mediation writes to the roaming spool (var/spool/roaming/new/), resolves the home subscriber, and rates each through the platform's convergent Rater with a roaming-tariff branch (usr/src/rater.cpp). For an is_roaming CDR the per-unit cost comes from ROAMING_TARIFF::retail(plan, svc, visited_plmn) instead of the home price; an untariffed roaming CDR is failed rather than charged at the home rate. Charges land in the same offline / online tables (carrying is_roaming, visited_plmn_id, wholesale_charge) and flow through the normal bill cycle.

graph LR
  S["roaming spool"] --> R[Roaming role]
  R -->|Rater retail roaming tariff| OFF[(offline)]
  OFF --> BC[bill cycle] --> INV[invoice]

Direction-1 records reuse the mediation_id (CDR.id) idempotency key: a re-presented record is routed to var/spool/roaming/duplicate/ and never double-charged.

Direction 2 — visiting roamers

A visiting roamer is a temporary, VLR-style record (visiting_roamer), kept entirely separate from the home subscriber base — a visitor never becomes a subscriber and never produces a home offline/bills row. Operators manage the lifecycle from the CRM Visiting Roamers admin section, which calls the CRMService RPCs (BringInVisitor, SimulateVisitorUsage, EndVisit, ListVisitingRoamers, ListPlmns).

sequenceDiagram
  participant A as CRM admin
  participant C as CRMService
  participant R as Roaming role
  participant T as tapout spool
  A->>C: BringInVisitor (IMSI, home PLMN)
  A->>C: SimulateVisitorUsage (xN)
  A->>C: EndVisit
  R->>R: price unpriced usage @ wholesale IOT
  R->>T: aggregate settle-eligible usage → TAP-out batch

The Roaming role's Direction-2 pass prices each visitor_usage row at ROAMING_TARIFF::wholesale(partner_plmn, svc) — independent of the home retail tariff — and then settles eligible visitors (ended visits, or active visits older than the configured sweep age) into TAP-out batches.

TAP-out (settlement output)

Priced usage is grouped by recipient home PLMN and written as a TAP-out batch to var/spool/tapout/ — the simulation stand-in for delivery to the visitor's home operator. Each batch carries our sender_tadig, the recipient TADIG, a per-recipient monotonic sequence_no (race-safe via a UNIQUE(recipient, sequence) constraint + retry), and audit totals (event_count, total_charge, currency). The event rows reuse the GRUR field core, so a batch is re-ingestible by Mediation in principle. Usage rows are stamped with their tapout_batch_id atomically so a re-tick can never re-export them.

Data model

Table Purpose
ref_plmn Networks/operators (TADIG, MCC+MNC, country, tariff zone).
roaming_tariff Per-service retail (Direction 1) and wholesale/IOT (Direction 2) prices, by plan / partner PLMN / zone.
visiting_roamer VLR-style visitor presence record (IMSI, home PLMN, status, visit window).
visitor_usage Metered inbound usage, priced at the IOT, linked to its TAP-out batch.
tapout_batch Generated Direction-2 settlement batches (sequence, totals, file path).

The offline / online tables gain additive is_roaming, visited_plmn_id, wholesale_charge columns (default 0 / NULL), so non-roaming inserts are unchanged.

ref_plmn is reference data (not carried by RefData); the Visiting Roamers admin section needs it to resolve home-PLMN / IOT-partner selects — an empty or missing table makes ListPlmns fail. A fresh install seeds it from usr/src/sql/billing_02_reference_data.sql. On a database created before roaming shipped, apply usr/src/sql/migrations/2026_06_roaming_seed.sql, or use CRM → Admin → Testing → Roaming PLMNs, which inserts the Orange & Vodafone EU networks (idempotent — existing rows are skipped).

Out of scope

Real MAP/Diameter signaling; byte-exact TAP3/RAP ASN.1 BER encoding; live clearing-house exchange; partial-record correlation/aggregation; online (prepaid) Direction-1 roaming. The visitor lifecycle and TAP-out are deliberately a simulation that models TAP3 semantics, not a wire-faithful implementation.

Configuration

See Configuration — roaming.toml carries [modules] roaming = 1, the Direction-1 spool paths, and the Direction-2 keys tapout_path, sender_tadig, settlement_currency, and sweep_age_s.

Mediation · Convergent Rating · CRM · Prepaid Charging