Tenant Management

A Tenant is the billing entity in Wholesale, representing a downstream customer.

1. Create a Tenant

Wholesale → Tenant Management → Create Tenant:

FieldDescriptionExample
NameTenant display nameCustomer A
BalanceCurrent account balance10000.00
Credit LimitAllowed overdraft limit1000.00
Sell Rate DeckRate deck used for billing this tenantsell-deck-cn
Routing ProfileRouting profile used by this tenantprofile-default
LCR EnabledWhether to enable least-cost routingtrue
Max ConcurrentMaximum simultaneous calls for this tenant200
Max CPSMaximum calls per second for this tenant50
Statusenabled / disabledenabled

Balance Check Logic

On inbound calls the system checks: Balance + Credit Limit ≥ Sell Rate × Min Duration

If not met, the system returns SIP 402 Payment Required.

2. Tenant Trunk Bindings

Tenants connect to the system through trunks and need inbound trunk bindings:

Tenant Details → Trunks → Add Trunk Binding:

SettingDescription
SIP TrunkSelect a configured inbound trunk
Source IPsAllowed source IP list for the tenant
DescriptionRemarks

Authentication Methods

Tenant inbound authentication supports two modes:

Mode 1: IP ACL

The tenant’s SIP traffic comes from fixed IPs. The system matches the tenant by source IP.

Mode 2: X-Wholesale-Token

A signed Token is carried in the HTTP header, suitable for dynamic IP scenarios. Tokens are generated via the console API.

3. Balance & Top-Up

3.1 Top-Up

Tenant Details → Top Up:

  • Enter the top-up amount
  • Upload payment proof (optional)
  • The system logs the top-up in rustpbx_recharge_logs

3.2 Balance Details

Tenant Details → Balance Details: Displays top-up records, charge summaries, and current balance.

4. CPS & Concurrency Limits

Each tenant can have independent rate limiting:

LimitFieldMechanism
Concurrent callsmax_concurrent_callsReal-time counter
Calls per secondmax_cps1-second sliding window

In the console under Wholesale → Monitoring & Throttling, you can view in real time for each tenant:

  • Current concurrent calls
  • Current CPS
  • Rejected call counts (Prometheus metrics wholesale_concurrent_limit_rejected_total, wholesale_cps_limit_rejected_total)

5. Rate & Routing Association

Tenant
  ├── Sell Rate Deck (sell_deck_id) ──► Billing: Trie longest prefix match
  └── Routing Profile (routing_profile_id) ──► Trie prefix match → select trunk
                                          └── Trunk has buy rate deck ──► Cost calculation
  • Sell rate: Amount deducted from the tenant’s balance
  • Buy rate: Carrier cost associated with the trunk (used for profit calculation and LCR)
  • Profit = Sell price - Buy price

6. Number Rewriting

Tenant-level global number rewriting rules can be configured:

OperationDescriptionExample
Caller StripRemove first N digits from callerstrip=2, 021234567812345678
Caller PrependAdd prefix to callerprepend=0, 12345678012345678
Callee StripRemove first N digits from calleestrip=1, 02123456782112345678
Callee PrependAdd prefix to calleeprepend=86, 123456788612345678
Regex Replacesed syntax s/pattern/replacement/s/^0/86/0212348621234

Rewriting order: Tenant-level rewriting → Routing rule rewriting → Trunk tech prefix