Routes: PBX or TrunkAG Projects RTC Platforms (Routing Guides)
This guide describes SIP routing for calls from and to a PBX or a SIP trunk.
The terms PBX and SIP trunk are interchangeable and are further called as PBX.
The platform uses internally the term Trusted peer. So a Trusted Peer defined in the platform represents a remote PBX or a Trunk.
PBX to PBX
The PBX has its own accounts and connected devices. Requests originating from a PBX cannot be therefore authorized based on username/password combinations as they are not provisioned in the platform's subscriber database, they are locally managed by the PBX owner. The traffic generated by the PBX can be only identified by its source IP address(es) or its MS Teams domain, when originating from Microsoft gateways.
To allow traffic from a PBX, the platform uses the concept of trusted peers.
A trusted peer is an entity that is allowed to route SIP calls through the platform without digest authorization, that is used for local users belonging to local domains. Beware that, no checks are done by the proxy related to the incoming caller identity, as long as the SIP sessions originate from a trusted peer. Once you trust a peer, you trust all traffic generated by it. Optionally, you can perform various checks for trusted peers by adding confitions to the custom configuration handle-incoming-pstn.m4 (described later in this document)
Authentication | None |
Authorization | Trusted peer A |
Caller Id | Supplied by trusted peer A |
Billing party | Trusted peer A |
Accounting | Postpaid |
Number formats | E.164, 00.., 0. |
Media types | RTP (audio, video), T.38 Fax, SIP MESSAGE |
Address resolution | ENUM |
From header | Must contain a non-local SIP domain |
Fraud Control | Simultaneous call limit |
- The domain name used by the PBX in the From field must be different than any domain served by the SIP Proxy otherwise the Proxy will challenge the session for credentials as it does for any other locally registered SIP account.
- To route incoming traffic for a number block assigned to the PBX, create ENUM entries that point to the hostname (or IP address) of the PBX.
PBX to PSTN
To allow high call per second ratios for call centers or other high density traffic, many checks related to individual accounts are disabled when using trusted peers. Access Lists, Pike flood detection, quota checks are disabled.
Authentication | Based on source IP address |
Authorization | PSTN transit |
Caller Id | Supplied by trusted peer |
Billing party | IP address |
Accounting | Postpaid only |
Number formats | E.164, 00., 0. |
Media types | RTP (audio, video), T.38 Fax |
Address resolution | ENUM, LCR, Custom SIP Proxy logic |
From header | Must contain a non-local SIP domain |
Request URI | Must contain a local SIP domain |
Fraud control | Simultaneous call limit |
Routing
To allow transiting the proxy, handle-incoming-pstn.m4 configuration file is configured by default with this logic (your particular platform configuration may differ):
if (FROM_TRUSTED_PARTY) { DINFO("Call from trusted party"); $var(need_transit) = 0; if (uri =~ "^sip:PSTN_REGEXP@.*") { $rd = "SERVER_DOMAIN"; strip(2); prefix("+"); set_billing_party(); DINFO("Performing ENUM lookup"); route(__ENUM_LOOKUP); if ($retcode==-1) { DINFO("ENUM number not found. PSTN transit"); revert_uri(); $var(need_transit) = 1; } } else if (uri =~ "^sip:LOCAL_PSTN_REGEXP@.*") { $rd = "SERVER_DOMAIN"; strip(1); prefix("+COUNTRY_CODE"); set_billing_party(); DINFO("Performing ENUM lookup"); route(__ENUM_LOOKUP); if ($retcode==-1) { DINFO("ENUM number not found. PSTN transit"); revert_uri(); $var(need_transit) = 1; } } else if (uri =~ "^sip:COUNTRY_CODE[1-9][0-9]{4,}@.*") { $rd = "SERVER_DOMAIN"; prefix("+"); set_billing_party(); DINFO("Performing ENUM lookup"); route(__ENUM_LOOKUP); if ($retcode==-1) { DINFO("ENUM number not found. PSTN transit"); revert_uri(); $var(need_transit) = 1; } } else if (uri =~ "^sip:\+[0-9]{7,}@.*") { $rd = "SERVER_DOMAIN"; set_billing_party(); DINFO("Performing ENUM lookup"); route(__ENUM_LOOKUP); if ($retcode==-1) { DINFO("ENUM number not found. PSTN transit"); strip(1); prefix("00"); $var(need_transit) = 1; } } if ($var(need_transit) == 1 && !FROM_PSTN_GATEWAY) { DINFO("Transit call from trusted peer $si"); route(__PSTN_TRANSIT); exit; } # Check if it's a local user if (!is_uri_host_local()) { set_billing_party(); setflag(ACCOUNTING_FLAG); $avp(can_uri) = $ru; t_on_reply("__INVITE_REPLY"); if (!isflagset(NO_MEDIAPROXY_FLAG)) { DINFO("Engaging mediaproxy for SIP transit call"); engage_media_proxy(); } $avp(invite_timeout) = OUTGOING_TIMEOUT; DINFO("Set timeout to OUTGOING_TIMEOUT"); route(__SEND_OUT); exit; } }
Provisioning
The IP address(es) of the PBX must be added in the trusted table using the SOAP/XML provisioning API. See Provisioning: Trusted Peers
Phone Numbers
ENUM can be used to assign phone numbers to a particular PBX. The proxy queries two ENUM Top Level Domains. The second ENUM Top Level Domain is used for MS Teams interconnect.
See Provisioning: ENUM chapter for how to map telephone numbers to SIP addresses.
Rating
To rate the traffic generated by trusted peers identified by IP address you must add a rating plan in CDRTool rating engine by using the source IP address of the PBX as the gateway field in the rating customers table.
Caller Id
Traffic generated by the trusted peers and any header thereof containing caller id indication is also trusted. When allowing traffic to transit from PBXs to PSTN gateways connected to the proxy, make sure that the way caller ID indication is provided by the trusted party is compatible with what the PSTN gateway expects.
Number formats
To avoid adding specific rewriting rules, that require the restart of the SIP Proxy, ask the PBX owner to send the numbers formated in E.164 format or starting with 00 prefix insetad of +. If properly configured, local numbers starting with one 0 may also work.
E.164 format: [+][country code][area code][local phone number]
Next Steps
Continue by:
- learning about Routes: End-Point; or
- learning about Routes: MS Teams; or
- learning about Routes: MSRP media; or
- learning about Routes: Presence; or
- learning about Routes: PSTN; or
- learning about Routes: Special; or
- going back to the Overview.
- Defined
- routes/routes_pbx.diviner:1