Page MenuHomePhabricator

Routes: PSTN
AG Projects RTC Platforms (Routing Guides)

This guide describes the routing from and to PSTN.

PSTN to End-Point

The platform is designed to accept traffic from outside SIP end-points (this includes remote PSTN gateways) to any local user. This means that a PSTN gateway that initiates a session to a correct SIP address user@domain belonging to the platform will be accepted and routed to the SIP devices belonging to the user with no extra configurations. When a SIP session originates from the PSTN, only the dialed telephone (a.k.a. E.164) number is known. For routing sessions from the PSTN to the SIP Proxy of the platform the gateway must translate the telephone number into a valid SIP address.

PSTN gateways for incoming traffic to local users must be provisioned in the PSTN Gateways section of Provisioning server by IP. Because they are only used for incoming traffic, no PSTN route or PSTN rules must be added for them. These PSTN gateways that should not transit the platform don't need an entry in Trusted Peers.

ENUM Routing

book-general-sip-platform-msp-enum-lookup (311×506 px, 60 KB)

The ideal way to achieve this number translation with minimum configuration is for the PSTN gateway to perform an ENUM lookup (RFC 3761). All popular open source software gateways like Asterisk and OpenSIPS are able to perform ENUM lookups and commercial gateways have started adding this support into their commercial products.

The ENUM look-up queries the DNS server provisioned with E.164 numbers by the operator, which is always kept up to date by the operator. The result of a successful ENUM lookup is a SIP address. Once the ENUM lookup is complete, the PSTN gateway can initiate the SIP session to the SIP address returned by the ENUM lookups.

The only setting required in the PSTN gateway for this setup is the top level domain used to perform ENUM lookups. The ENUM top level domain must be the same used by the SIP Proxy lookup and NGNPro provisioning.

Manual Routing

For PSTN gateways that are not able to perform ENUM lookups and from which we need to accept incoming sessions, the SIP Proxy can be configured to accept any traffic, manipulate the number format based on custom rules and help performing the ENUM lookup in the behalf of the gateway.

The PSTN gateway must be configured for the E.164 number ranges to be routed to the MSP platform and the hostname of the SIP Proxy machine (e.g. sip.example.com). Do not use static IP addresses in the PSTN configuration, use the DNS name configured by the operator so that when the IP addresses of the SIP Proxy change or when multiple SIP Proxies are used by default (like in SIP Thor) the gateway does not need to be re-configured.

You must setup the following SIP Proxy configuration file:

sipproxy:/etc/opensips/config/siteconfig/handle-incoming-pstn.m4

Example:

handle-incoming-pstn.m4
if (src_ip == 201.176.11.13) {
    DINFO("Call from Carrier 1");

    $rd = "SERVER_DOMAIN";
    prefix("+");
    set_billing_party();
    DINFO("Performing ENUM lookup");
    route(__ENUM_LOOKUP);

    if ($retcode==-1) {
        DINFO("User not found");
        sl_send_reply('404', 'User not found');
        LOG_MISSED_CALL('404');
        exit;
    } else if (!is_uri_host_local()) {
        DINFO("Call to non local user");
        sl_send_reply('403', 'Invalid destination');
        LOG_MISSED_CALL('403');
        exit;
    }
}
AuthenticationNone
AuthorizationCustom SIP Proxy logic
Billing partyTrusted peer
AccountingPostpaid
Media typesRTP (audio)
From headerMust contain a non-local SIP domain
Address resolutionENUM, Custom SIP Proxy logic

PSTN to PBX

book-general-sip-platform-flow-pbx-a-pstn (387×637 px, 47 KB)

AuthenticationNone
AuthorizationTrusted peer PSTN gateway
Caller IdSupplied by PSTN gateway
Billing partyTrusted peer PSTN gateway
AccountingPostpaid
Media typesRTP audio, T.38 Fax, SIP MESSAGE
From headerMust contain a non-local SIP domain
Address resolutionENUM, Custom SIP Proxy logic

Next Steps

Continue by: