Project

General

Profile

Routing guide » History » Version 43

Adrian Georgescu, 01/20/2014 09:34 PM

1 5 Tijmen de Mes
h1. Routing Guide
2
3 20 Adrian Georgescu
MSP and SIP Thor platforms are based on a SIP Proxy/Registrar/Presence Agent design. Each SIP server node maintains transaction and dialog state for each session and is able to terminate each of them based on various criteria. The platform handles and controls the RTP and MSRP media planes and is able to take decisions related to authorization, authentication, accounting, NAT traversal and session termination based on the media flow behavior. The design eliminates the need of separate session border controller elements which just add costs, hurt scalability and add no end-user features.  
4 1 Tijmen de Mes
5 12 Adrian Georgescu
The platform has rich telephony functions equivalent with traditional Class 4 switches (routing inter-carrier calls) and Class 5 switches (routing last-mile calls to end-users).
6 1 Tijmen de Mes
7 12 Adrian Georgescu
The platform can be equally used to perform SIP services that include and are not limited to Residential VoIP, Prepaid Cards, Video Calling, Presence and IM, Trunking, Least Cost Routing and ENUM Peering.
8 1 Tijmen de Mes
9 4 Tijmen de Mes
h2. Logical Architecture
10 2 Tijmen de Mes
11 6 Tijmen de Mes
!msp-interconnect.png!
12 2 Tijmen de Mes
13 42 Adrian Georgescu
h2. IP addressing
14
15 43 Adrian Georgescu
The platform is designed to operate using IPv4 addresses using public IP space, this topology allows end-points to operate behind any type of NAT router. The end-points can use both private or private IPv4 addresses.
16 42 Adrian Georgescu
17
18 1 Tijmen de Mes
h2. SIP Entities
19
20 2 Tijmen de Mes
This document describes routing logic between several SIP entities defined as follows:
21
22 4 Tijmen de Mes
# SIP Proxy: the platform core that performs the logic described in this document
23
# End-Point: a SIP end-user device that is configured with the credentials of a SIP account for which the platform is responsable
24
# PBX: a SIP end-point or intermediary that is configured under a foreign SIP domain not handled by the platform
25
# PSTN gateway: a SIP end-point or intermediary that is handling the translation between IP (using SIP protocol) and PSTN networks
26 1 Tijmen de Mes
27 4 Tijmen de Mes
h2. Supported Signaling
28 3 Tijmen de Mes
29 20 Adrian Georgescu
The platform supports SIP protocol over UDP/TCP/TLS transports. Additional, a gateway to and from XMPP remote domains can be configured. 
30 2 Tijmen de Mes
31 3 Tijmen de Mes
h2. Supported Media
32 2 Tijmen de Mes
33
The platform supports sessions containing the following media types:
34 1 Tijmen de Mes
35 4 Tijmen de Mes
* Audio (RTP and sRTP)
36
* Video (RTP and sRTP)
37
* FAX (RTP and T.38)
38
* Instant messaging (MSRP and its relay extension)
39
* File transfer (MSRP and its relay extension)
40
* Page mode messaging (SIP MESSAGE method)
41 22 Adrian Georgescu
* Presence (PIDF XML)
42 2 Tijmen de Mes
43 4 Tijmen de Mes
The platform is codec agnostic, the negotiation of the codecs depends entirely on the end-points. The MediaProxy component that relays the RTP media between the end-points, for NAT traversal and accounting purposes, relays all packets at IP layer 3 (UDP protocol that encapsulates the RTP/RTCP streams). The actual payload with the particular codecs used inside the RTP streams is transparently passed between end-points without interference from MediaProxy.
44 2 Tijmen de Mes
45 1 Tijmen de Mes
Other payloads are supported as long as they are embedded into a supported stream, for example any payload that is embedded within the RTP streams (zRTP, DTMF tones) or MSRP streams (file transfer, multy-party chat service, desktop sharing).
46
47 2 Tijmen de Mes
h2. Primitives
48
49 3 Tijmen de Mes
The routing of SIP sessions is governed by two main protocols:
50 2 Tijmen de Mes
51 4 Tijmen de Mes
# Domain based SIP routing based on RFC3261 and RFC3263
52
# ENUM lookups based on RFC3761
53 2 Tijmen de Mes
54
The routing logic of the platform can be configured by changing its database tables and configuration files. The primitives used for routing are:
55
56
57 4 Tijmen de Mes
|Registrar database|Used to translate a SIP address into a SIP contact address|
58
|ENUM|Used to translate an E.164 telephone number into a SIP address|
59
|SIP alias|Used for adding aliases to existing SIP accounts|
60
|Emergency numbers|Translation between 911 and 112 into closest emergency access points|
61
|Call diversion|Translate a SIP address into another based on signaling conditions or end-user preferences|
62 1 Tijmen de Mes
|DNS lookups|Translate a SIP domain/hostname into an protocol:IP:port combination|
63 22 Adrian Georgescu
|LCR|Used for selection of outgoing PSTN gateway|
64 2 Tijmen de Mes
65
66 4 Tijmen de Mes
h2. Server Location
67 1 Tijmen de Mes
68 4 Tijmen de Mes
To locate the SIP Proxy/Registrar for a domain, SIP endpoints must perform DNS lookups based on RFC3263 that return the IP:port combination for which the server is configured.
69 1 Tijmen de Mes
70 4 Tijmen de Mes
h2. Configuration Files
71 1 Tijmen de Mes
72 4 Tijmen de Mes
Index of SIP Proxy configuration files located in/etc/opensips/:
73 2 Tijmen de Mes
74 4 Tijmen de Mes
75
|config/settings.m4|Contains the settings that can customize the routing logic|
76
|config/opensips.m4|Contains the proxy routing logic (should not be modified)|
77
|config/siteconfig/handle-incoming-pstn.m4|Used to customize routing logic for incoming PSTN calls|
78
|config/siteconfig/handle-local-extensions.m4|Used to define installation specific custom local extensions|
79
|config/siteconfig/handle-outgoing-peers.m4|Used to customize routing for outgoing calls to non-local domains|
80
|config/siteconfig/postprocess-request.m4|Used to customize outgoing requests before they leave the proxy|
81
|config/siteconfig/preprocess-pstn.m4|Used to customize outgoing PSTN requests before applying LCR routing|
82
|config/siteconfig/preprocess-request.m4|Used to apply custom pre-processing to a request before anything else|
83
|config/siteconfig/preprocess-uri.m4|Used to apply custom pre-processing to the request URI before converting to E164|
84
85
86
The settings.m4 file is used to customize the existing routing logic defined in opensips.m4 using the predefined routing options. 
87
 The files under the siteconfig/ directory can contain installation specific routing logic, which will be included by opensips.m4 and will allow for the routing logic to be adapted to the specific requirements of a given installation. The opensips.m4 file will always be overwritten on upgrades, so it should never be modified, while the files under the siteconfig/ directory will never be overwritten and can be modified without restrictions.
88
89 2 Tijmen de Mes
h2. NAT Traversal
90 1 Tijmen de Mes
91 4 Tijmen de Mes
NAT traversal methods encountered in the field and their properties:
92 1 Tijmen de Mes
93 4 Tijmen de Mes
* SIP server based (Relay) - reliable server side technology that works with all SIP clients, this method is used by the platform
94
* SIP client based (ICE) - client and server technology where client may negotiate media paths, is supported by the platform
95
* Intermediates based:
96
** NAT routers with SIP Application Level Gateway (SIP ALG) - located in customer premises network and the most *unreliable* technique
97
** Sessions Border Controllers (SBC) - located in service provider network - reliable with high cost and high complexity
98 1 Tijmen de Mes
99 4 Tijmen de Mes
The most reliable way to solve NAT issues with SIP is server based, by relaying packets using servers visible by both end-points. A new methodology under development is ICE, which relies partially on the SIP clients. NAT traversal applied in intermediates only introduce problems and SBCs add costs without adding value to the SIP service.
100 2 Tijmen de Mes
101
Below is a display of all possible NAT traversal techinques used for SIP and related media.
102
103 6 Tijmen de Mes
!nat-traversal-techniques.png!
104 1 Tijmen de Mes
105 4 Tijmen de Mes
The platform handles the NAT traversal for all its end-points by relaying all traffic, signaling and media through its servers that have public IP address and are visible for both end-points involved in a call flow.
106 2 Tijmen de Mes
107 4 Tijmen de Mes
Optional, "ICE can be deployed":http://mediaproxy-ng.org/wiki/ICE when supported by the end-points. The media relay acts like a TURN candidate and the operator may choose on a per call basis when and how this relay is to be used. When using ICE, SIP sessions that do not have a BYE cannot be accounted for.
108 2 Tijmen de Mes
109 4 Tijmen de Mes
NAT traversal is not the same thing as Firewall traversal. A firewall has an administrative policy, which must be set to support SIP and associated media traffic.
110 2 Tijmen de Mes
111 1 Tijmen de Mes
h3. Platform Ports
112
113 4 Tijmen de Mes
See the Firewall Setup section for a list of ports used by the platform software.
114 1 Tijmen de Mes
115 4 Tijmen de Mes
bq. Make sure that NAT traversal functions related to SIP known as SIP ALG functionality in the NAT routers are disabled.
116 1 Tijmen de Mes
117 4 Tijmen de Mes
118
119 1 Tijmen de Mes
h2. AAA
120
121
Authentication, Authorization and Accounting are performed depending on particular call flows as follows:
122
123 4 Tijmen de Mes
h3. Authentication
124 1 Tijmen de Mes
125 4 Tijmen de Mes
The trust relationship between SIP subscribers and SIP Proxy is based on DIGEST algorithm, both have a database with shared credentials.
126 1 Tijmen de Mes
127 4 Tijmen de Mes
h4. Sessions
128
129 1 Tijmen de Mes
Authentication for INVITE requests based on two methods:
130 2 Tijmen de Mes
131 4 Tijmen de Mes
# *SIP credentials*, when the From header contains a domain served by the platform. The From header presented by the device must match the credentials used for authentication.
132
# *Trusted peer* identified by IP address, used when the From header contains a remote domain and the request URI is not a local SIP address.
133 1 Tijmen de Mes
134 4 Tijmen de Mes
By default, incoming SIP sessions from remote domains to local SIP accounts served by the platform are not authenticated and always authorized.
135 1 Tijmen de Mes
136
For Instant Messaging and File transfers, MSRP relay reservations are authenticated using the same credentials for each SIP account.
137
138 4 Tijmen de Mes
h4. Register
139 1 Tijmen de Mes
140
Authentication for REGISTER methods is based on SIP credentials, this method can be used only by local SIP accounts and will not be relayed outside the platform. The From header presented by the SIP device must match the credentials used for authentication.
141 2 Tijmen de Mes
142
h4. Presence
143 1 Tijmen de Mes
144
The platform provides a Presence Agent that handles PUBLISH, SUBSCRIBE and NOTIFY methods based on SIP SIMPLE standards. The following event packages are supported:
145
146 4 Tijmen de Mes
* presence
147
* presence.winfo
148 19 Adrian Georgescu
* xcap-diff
149 1 Tijmen de Mes
150 4 Tijmen de Mes
Authentication for PUBLISH is based on SIP credentials, this methods can be used only by local SIP accounts and will not be relayed outside the platform. The From header presented by the SIP device must match the credentials used for authentication. Authentication for SUBSCRIBE requests are based on SIP credentials, when the From header contains a domain served by the SIP Proxy.
151 1 Tijmen de Mes
152 4 Tijmen de Mes
SUBSCRIBE requests from remote domains are allowed without authentication when the request URI is a local SIP address served by the platform.
153 1 Tijmen de Mes
154
SUBSCRIBE for the events message-summary and presence.winfo are allowed only for local users.
155
156 2 Tijmen de Mes
XCAP requests are authenticated using the same credentials for each SIP account.
157 1 Tijmen de Mes
158
The following XCAP documents are supported:
159
160 13 Adrian Georgescu
http://www.openxcap.org/projects/openxcap/wiki/Features
161 2 Tijmen de Mes
162 4 Tijmen de Mes
h3. Authorization
163 1 Tijmen de Mes
164 4 Tijmen de Mes
h4. Sessions
165 2 Tijmen de Mes
166
Authorization for outgoing SIP sessions can be performed for local SIP accounts based on:
167 1 Tijmen de Mes
168 4 Tijmen de Mes
# Access to PSTN
169
# Administrative blocking
170
# Monthly quota usage
171
# Prepaid balance
172 14 Adrian Georgescu
# Concurrent number of calls
173 4 Tijmen de Mes
# Call barring (user driven)
174
# Custom SIP Proxy logic
175 1 Tijmen de Mes
176 2 Tijmen de Mes
Authorization for incoming SIP sessions can be performed for local SIP accounts based on:
177
178 14 Adrian Georgescu
# Source IP address
179 4 Tijmen de Mes
# Administrative blocking
180
# Accept based on caller
181
# Accept based on time of day
182
# Reject based on caller id
183
# Custom SIP Proxy logic
184 1 Tijmen de Mes
185
Automatic session cut-off
186
187
SIP sessions can be terminated forcefully by the platform based on the following conditions:
188
189 4 Tijmen de Mes
# Prepaid balance exceeded (in real time)
190
# Monthly quota exceeded (on the next call)
191
# Maximum call duration exceeded
192
# RTP media timeout
193 14 Adrian Georgescu
# Signaling path lost
194
195 1 Tijmen de Mes
196 4 Tijmen de Mes
h4. Presence
197 1 Tijmen de Mes
198 2 Tijmen de Mes
Authorization for SUBSCRIBE for the presence event can be performed for local SIP accounts based on:
199
200 4 Tijmen de Mes
# XCAP pres-rules document
201
# Trusted peers
202 2 Tijmen de Mes
203
204
205 4 Tijmen de Mes
h3. Accounting
206 2 Tijmen de Mes
207 4 Tijmen de Mes
All SIP and RTP sessions are accounted by using RADIUS requests. See "accounting guide for more information":/wiki/AccountingGuide.
208 1 Tijmen de Mes
209 4 Tijmen de Mes
h2. End-Point to End-Point
210 1 Tijmen de Mes
211 7 Tijmen de Mes
!flow-sip-phone-a-b.png!
212 4 Tijmen de Mes
213
214
|Authentication|SIP account A|
215
|Authorization|SIP account A|
216
|Billing party|SIP account A|
217
|Accounting|Postpaid, Prepaid|
218
|Media types|RTP (audio and video), Presence, MSRP (Instant messaging and file transfers)|
219
|Address resolution|SIP address, SIP alias, Quickdial, ENUM|
220
|From header|Must contain a local SIP domain|
221 30 Adrian Georgescu
|Fraud Control | PIKE, ACL, Call control | 
222 4 Tijmen de Mes
223
h3. Quick Dial
224
225 1 Tijmen de Mes
Quick dial is a per SIP account feature that allows to dial short numbers to match other SIP accounts in the same number range. The SIP Proxy will try to autocomplete the number to form a full address. To use this feature:
226
227 4 Tijmen de Mes
# The username part of the SIP account must be numeric (example "31208005169@ag-projects.com":mailto:31208005169@ag-projects.com)
228
# The *quickdial* attribute of the SIP account must be set to a substring matching the beginning of the username (e.g. 312080051).
229
# When user dials 60 the example above, the SIP Proxy will concatenate the quickdial set to 312080051 with the dialed number 60 and try "31208005160@ag-projects.com":mailto:31208005160@ag-projects.com as destination.
230 1 Tijmen de Mes
231 4 Tijmen de Mes
h2. End-Point to PBX
232 1 Tijmen de Mes
233 7 Tijmen de Mes
!flow-sip-phone-a-pbx-b.png!
234 1 Tijmen de Mes
235
236 4 Tijmen de Mes
|Authentication|SIP account A|
237
|Authorization|SIP account A|
238
|Caller Id|Asserted by the platform|
239
|Billing party|SIP account A|
240
|Accounting|Postpaid, Prepaid|
241
|Media types|RTP (audio)|
242
|Address resolution|ENUM|
243
|From header|Must contain a local SIP domain|
244 30 Adrian Georgescu
|Fraud Control | PIKE, ACL, Call control | 
245 1 Tijmen de Mes
246 4 Tijmen de Mes
h2. PBX to PBX
247
248 7 Tijmen de Mes
!flow-pbx-a-pbx-b.png!
249 4 Tijmen de Mes
250 1 Tijmen de Mes
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 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). To allow traffic from a PBX, the platform uses the concept of trusted peers. A trusted peer is an IP address that is allowed to route SIP calls through the platform without digest authorization. Beware that, no checks are done by the proxy related to the incoming caller identity, as long as the SIP sessions originate from the trusted IP address. Once you trust an IP address, you trust all traffic generated by it.
251
252
253 4 Tijmen de Mes
|Authentication|None|
254
|Authorization|Trusted peer A|
255
|Caller Id|Supplied by trusted peer A|
256
|Billing party|Trusted peer A|
257
|Accounting|Postpaid|
258 36 Adrian Georgescu
|Media types|RTP (audio, video), T.38 Fax, SIP MESSAGE|
259 1 Tijmen de Mes
|Address resolution|ENUM|
260 4 Tijmen de Mes
|From header|Must contain a non-local SIP domain|
261 30 Adrian Georgescu
|Fraud Control | None | 
262 2 Tijmen de Mes
263 4 Tijmen de Mes
* 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.
264
* 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.
265
266
h2. End-Point to PSTN
267
268 1 Tijmen de Mes
For interconnection with PSTN, a SIP trunking service must be setup between the SIP Proxy and the PSTN gateway provider. The authorization of SIP requests is based on transitive trust. The SIP Proxy has a trust relationship with each SIP subscriber and the PSTN gateway has a trust relation with the SIP Proxy. The trust relation between the SIP Proxy and the PSTN gateway is based on the IP addresses. The PSTN gateway cannot use DIGEST authentication in the relation with the SIP Proxy because it does not have access to the SIP accounts database of the SIP Proxy.
269
270 4 Tijmen de Mes
h3. PSTN Gateway Requirements
271 2 Tijmen de Mes
272
Must have:
273
274 4 Tijmen de Mes
* SIP signaling based on RFC 3261
275
* DNS lookups based on RFC 3263
276
* Support for SIP extensions for caller id and privacy (P headers)
277
* RTP active mode (send RTP data as soon as call setup is completed)
278
* Use public routable IP addresses for both signaling and media
279 2 Tijmen de Mes
280
Recommended:
281
282 4 Tijmen de Mes
* ENUM lookups based on RFC 3761
283 2 Tijmen de Mes
284
Routing to PSTN destinations is realized by provisioning the PSTN carriers, gateways and routes (also known as Least Cost Routing engine or LCR). The structure of the PSTN provisioning is as follows:
285
286 9 Tijmen de Mes
  Route ->  Carriers -> Gateways -> Rules
287 2 Tijmen de Mes
288
289 4 Tijmen de Mes
For each PSTN prefix (called a PSTN route) a set of carriers can be assigned with an optional priority. Each carrier can have one or more gateways and each gateway can have optional rules for converting the number. For more information see the "provisioning guide":/wiki/ProvisioningGuide.
290
291 2 Tijmen de Mes
Once the SIP request is authenticated, the SIP Proxy authorizes the request based on the rights associated with the subscriber account and decides whether a SIP session to the PSTN gateway is allowed or not. If the session is allowed, the SIP Proxy asserts an identity associated to the SIP account, which can be the telephone number presented as caller ID to the destination, locates a PSTN gateway for the dialed number (by using least cost routing or other configured logic) and forwards the request to the PSTN gateways inserting itself in the path of subsequent messages.
292
293 7 Tijmen de Mes
!flow-sip-phone-a-pstn.png!
294 2 Tijmen de Mes
295
296 4 Tijmen de Mes
|Authentication|SIP account A|
297
|Authorization|SIP account A|
298
|Caller Id|Asserted by the platform|
299 1 Tijmen de Mes
|Billing party|SIP account A|
300 4 Tijmen de Mes
|Accounting|Postpaid, Prepaid|
301 36 Adrian Georgescu
|Media types|RTP (audio, video), T.38 Fax, SIP MESSAGE|
302 4 Tijmen de Mes
|Address resolution|ENUM, LCR|
303 2 Tijmen de Mes
|From header|Must contain a local SIP domain|
304 27 Tijmen de Mes
|Fraud Control | PIKE, ACL, Call limit | 
305 2 Tijmen de Mes
306 4 Tijmen de Mes
h3. Caller id indication
307 2 Tijmen de Mes
308 4 Tijmen de Mes
The platform generates a Caller ID indication by appending Remote-Party-Id or P-Asserted identity headers, depending on its configuration. The content of the headers is generated with the SipAccount->rpid attribute associated with the SIP account.
309 2 Tijmen de Mes
310 4 Tijmen de Mes
h2. PSTN to End-Point
311 2 Tijmen de Mes
312 4 Tijmen de Mes
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.
313 2 Tijmen de Mes
314 41 Tijmen de Mes
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*.
315 40 Tijmen de Mes
316 4 Tijmen de Mes
h4. ENUM Routing
317
318 7 Tijmen de Mes
!msp-enum-lookup.png!
319 4 Tijmen de Mes
320 2 Tijmen de Mes
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.
321
322
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.
323
324
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.
325
326 4 Tijmen de Mes
h4. Manual Routing
327 2 Tijmen de Mes
328 4 Tijmen de Mes
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.
329 2 Tijmen de Mes
330
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.
331
332
You must setup the following SIP Proxy configuration file:
333
334 8 Tijmen de Mes
  sipproxy:/etc/opensips/config/siteconfig/handle-incoming-pstn.m4
335 2 Tijmen de Mes
336
337 4 Tijmen de Mes
Example:
338 1 Tijmen de Mes
339
<pre class="wiki">
340 38 Adrian Georgescu
if (src_ip == 201.176.11.13) {
341
    DINFO("Call from Carrier 1");
342 2 Tijmen de Mes
343 31 Adrian Georgescu
    $rd = "SERVER_DOMAIN";
344
    prefix("+");
345
    set_billing_party();
346
    DINFO("Performing ENUM lookup");
347
    route(__ENUM_LOOKUP);
348
   
349
    if ($retcode==-1) {
350
        DINFO("User not found");
351
        sl_send_reply('404', 'User not found');
352
        LOG_MISSED_CALL('404');
353 30 Adrian Georgescu
        exit;
354 31 Adrian Georgescu
    } else if (!is_uri_host_local()) {  
355
        DINFO("Call to non local user");
356
        sl_send_reply('403', 'Invalid destination');
357
        LOG_MISSED_CALL('403');
358 4 Tijmen de Mes
        exit;
359 1 Tijmen de Mes
    }
360 4 Tijmen de Mes
}
361
</pre>
362
363
364 2 Tijmen de Mes
|Authentication|None|
365
|Authorization|Custom SIP Proxy logic|
366 4 Tijmen de Mes
|Billing party|Trusted peer|
367
|Accounting|Postpaid|
368 7 Tijmen de Mes
|Media types|RTP (audio)|
369 4 Tijmen de Mes
|From header|Must contain a non-local SIP domain|
370 2 Tijmen de Mes
|Address resolution|ENUM, Custom SIP Proxy logic|
371
372 29 Adrian Georgescu
h2. PBX to PSTN
373 1 Tijmen de Mes
374 2 Tijmen de Mes
!flow-pbx-a-pstn.png!
375
376 1 Tijmen de Mes
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. Simultaneous call limit, Access Lists, Pike flood detection, quota checks are disabled. Also trusted peers, as their name imply, are allowed to set Caller Id information and Privacy headers, the SIP Proxy will not check nor enforce them fro Trusted peers.
377 34 Adrian Georgescu
378
|Authentication|Based on source IP address|
379 36 Adrian Georgescu
|Authorization|None required, transit is allowed|
380
|Caller Id|Supplied by trusted peer|
381
|Billing party|IP address|
382
|Accounting|Postpaid|
383
|Media types|RTP (audio, video), T.38 Fax, SIP MESSAGE|
384 34 Adrian Georgescu
|Address resolution|ENUM, LCR, Custom SIP Proxy logic|
385
|From header|Must contain a non-local SIP domain|
386 39 Adrian Georgescu
|Request URI|Must contain a local SIP domain|
387 34 Adrian Georgescu
|Fraud control|Source IP only|
388 1 Tijmen de Mes
389
390 34 Adrian Georgescu
h3. Routing
391 35 Adrian Georgescu
392
To allow transiting the proxy, *handle-incoming-pstn.m4* configuration file is configured with this logic:
393 34 Adrian Georgescu
394 32 Adrian Georgescu
<pre>
395
if (FROM_TRUSTED_PARTY) {
396
    DINFO("Call from trusted party");
397
398
    $var(need_transit) = 0;
399
    if (uri =~ "^sip:PSTN_REGEXP@.*") {
400
        $rd = "SERVER_DOMAIN";
401
        strip(2);
402
        prefix("+");
403
        set_billing_party();
404
        DINFO("Performing ENUM lookup");
405
        route(__ENUM_LOOKUP);
406
407
        if ($retcode==-1) {
408
            DINFO("ENUM number not found. PSTN transit");
409
            revert_uri();
410
            $var(need_transit) = 1;
411
        }
412
    } else if (uri =~ "^sip:LOCAL_PSTN_REGEXP@.*") {
413
        $rd = "SERVER_DOMAIN";
414
        strip(1);
415
        prefix("+COUNTRY_CODE");
416
        set_billing_party();
417
        DINFO("Performing ENUM lookup");
418
        route(__ENUM_LOOKUP);
419
420
        if ($retcode==-1) {
421
            DINFO("ENUM number not found. PSTN transit");
422
            revert_uri();
423
            $var(need_transit) = 1;
424
        }
425
    } else if (uri =~ "^sip:COUNTRY_CODE[1-9][0-9]{4,}@.*") {
426
        $rd = "SERVER_DOMAIN";
427
        prefix("+");
428
        set_billing_party();
429
        DINFO("Performing ENUM lookup");
430
        route(__ENUM_LOOKUP);
431
432
        if ($retcode==-1) {
433
            DINFO("ENUM number not found. PSTN transit");
434
            revert_uri();
435
            $var(need_transit) = 1;
436
        }
437
    } else if (uri =~ "^sip:\+[0-9]{7,}@.*") {
438
        $rd = "SERVER_DOMAIN";
439
        set_billing_party();
440
        DINFO("Performing ENUM lookup");
441
        route(__ENUM_LOOKUP);
442
        if ($retcode==-1) {
443
            DINFO("ENUM number not found. PSTN transit");
444
            strip(1);
445
            prefix("00");
446
            $var(need_transit) = 1;
447
        }
448
    }
449
    if ($var(need_transit) == 1) {
450
        DINFO("Transit call from trusted peer $si");
451
        route(__PSTN_TRANSIT);
452
        exit;
453
    }
454
455
    # Check if it's a local user
456
    if (!is_uri_host_local()) {
457
        set_billing_party();
458
        setflag(ACCOUNTING_FLAG);
459
        $avp(can_uri) = $ru;
460
        t_on_reply("__INVITE_REPLY");
461
        if (!isflagset(NO_MEDIAPROXY_FLAG)) {
462 4 Tijmen de Mes
            DINFO("Engaging mediaproxy for SIP transit call");
463
            engage_media_proxy();
464 29 Adrian Georgescu
        }
465
        $avp(invite_timeout) = OUTGOING_TIMEOUT;
466 4 Tijmen de Mes
        DINFO("Set timeout to OUTGOING_TIMEOUT");
467 29 Adrian Georgescu
        route(__SEND_OUT);
468
        exit;
469
    }
470 2 Tijmen de Mes
}
471 1 Tijmen de Mes
</pre>
472
473 33 Adrian Georgescu
h3. Provisioning
474
475
The IP address(es) of the PBX must be added in the trusted table using the SOAP/XML provisioning API. To allow trusted parties to transit your SIP Proxy edit sip:/etc/opensips/config/siteconfig/handle-incoming-pstn.m4 and add to it:
476
477 2 Tijmen de Mes
 * 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.
478 4 Tijmen de Mes
 * The domain name used by the PBX in the Request URI must be different than any domain served by the SIP Proxy otherwise the Proxy will try to lookup a local user.
479 2 Tijmen de Mes
480 1 Tijmen de Mes
h3. Rating
481 2 Tijmen de Mes
482 4 Tijmen de Mes
To rate the traffic generated by trusted peers you must add a rating plan in CDRTool rating engine based on the source IP address (the gateway field in rating customers table). Beware that no quota can be imposed on the traffic of a trusted peer.
483 2 Tijmen de Mes
484 33 Adrian Georgescu
h3. Caller Id
485 2 Tijmen de Mes
486
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, make sure that the way caller ID indication is provided by the trusted party is compatible with what the PSTN gateway expects.
487 4 Tijmen de Mes
488
h2. PSTN to PBX
489
490
!flow-pbx-a-pstn.png!
491
492
493
|Authentication|None|
494
|Authorization|Trusted peer PSTN gateway|
495 2 Tijmen de Mes
|Caller Id|Supplied by PSTN gateway|
496 4 Tijmen de Mes
|Billing party|Trusted peer PSTN gateway|
497
|Accounting|Postpaid|
498 37 Adrian Georgescu
|Media types|RTP audio, T.38 Fax, SIP MESSAGE|
499 4 Tijmen de Mes
|From header|Must contain a non-local SIP domain|
500 2 Tijmen de Mes
|Address resolution|ENUM, Custom SIP Proxy logic|
501
502
h2. Call Diversion
503 4 Tijmen de Mes
504
!flow-sip-phone-a-b-diverted.png!
505
506
A user may chose to divert his/her calls based on various conditions (like unconditional, busy or not online) to another SIP address including PSTN destinations. Diverted calls are always charged to the user who enabled them. For every call diversion, a new Diversion header is appended to the original SIP request.
507 1 Tijmen de Mes
508 28 Tijmen de Mes
509 4 Tijmen de Mes
|Authentication|SIP account A|
510
|Authorization|SIP account A|
511
|Billing party|SIP account B|
512 7 Tijmen de Mes
|Accounting|Postpaid, Prepaid|
513 4 Tijmen de Mes
|Address resolution|SIP address, SIP alias, Quickdial, ENUM, LCR|
514 2 Tijmen de Mes
|Fraud control | Forwarding destinations can be limited |
515
516
h2. Presence
517 4 Tijmen de Mes
518
!flow-presence.png!
519
520 2 Tijmen de Mes
Multiple watchers are subscribed to a publisher. The Publisher authorizes the watchers to subscriber to presence notifications by updating pres-rules XCAP document. The Publisher must subscribe to event presence.winfo to receive notifications from the Presence Agent about the watcher list.
521 18 Adrian Georgescu
522 4 Tijmen de Mes
523 7 Tijmen de Mes
|Authorization|XCAP pres-rules|
524 4 Tijmen de Mes
|Address resolution|SIP address, SIP alias, Quickdial, ENUM|
525 2 Tijmen de Mes
|Accounting|None|
526
527 1 Tijmen de Mes
h2. Presence using RLS
528 15 Adrian Georgescu
529
!flow-rls-services.png!
530
531 4 Tijmen de Mes
A subscriber uploads to the XCAP server a resource list. Then it subscribes to the list by sending a SUBSCRIBE for event presence with extra header Supported: eventlist, the Presence agent then subscribes to all recipients from the resource lists and returns consolidated NOTIFY with the state of all lists.
532 1 Tijmen de Mes
533
534 4 Tijmen de Mes
|Authorization|XCAP org.openmobilealliance.pres-rules|
535
|Contacts Storage| XCAP rls-services and resource-lists|
536 7 Tijmen de Mes
|Signaling|RLS SUBSCRIBE RFC4662 and RLMI NOTIFY RFC4662|
537 4 Tijmen de Mes
|Address resolution|SIP address, SIP alias, Quickdial, ENUM|
538 1 Tijmen de Mes
|Accounting|None|
539
540 4 Tijmen de Mes
h2. IM using MSRP Relay
541 1 Tijmen de Mes
542 7 Tijmen de Mes
!flow-msrp-relay.png!
543 1 Tijmen de Mes
544 4 Tijmen de Mes
Instant Messaging based on MSRP protocol is similar to a regular SIP audio session. Instead of RTP media , MSRP is used for establishing a media channel. Instead of MediaProxy, A MSRP relay is used to traverse the NAT. The called party reserves a session in the MSRP relay and offeres it in the response to the SIP INVITE. The calling party the initiates a TCP/TLS connection to the relay reserved address and the called party does the same. By using the relay both parties can establish a TCP flow from behind their NAT routers.
545 1 Tijmen de Mes
546 4 Tijmen de Mes
h2. IM using MSRP ACM
547 1 Tijmen de Mes
548 7 Tijmen de Mes
!flow-msrp-acm.png!
549 1 Tijmen de Mes
550
MSRP ACM is an alternative method for traversing NAT that is standardized by 3GPP that is interoperable with the IETF MSRP relay specification. The SBC mangles the SDP and stays in the SIP signaling and MSRP media path and forces the end-points to be both active (that is starting the outbound MSRP connection) when behind NAT.
551
552 4 Tijmen de Mes
h2. IM using MSRP ACM and Relay
553
554 1 Tijmen de Mes
!flow-msrp-acm-relay.png!
555
556 4 Tijmen de Mes
MSRP ACM and Relay methodologies can interoperate.
557 1 Tijmen de Mes
558 4 Tijmen de Mes
h2. File Transfer
559 1 Tijmen de Mes
560 21 Tijmen de Mes
File transfer based on MSRP protocol is similar to a regular SIP audio session. Instead of RTP media , MSRP is used for establishing a media channel. A MSRP relay is used to traverse the NAT.
561 1 Tijmen de Mes
562 16 Adrian Georgescu
h2. Emergency Calls
563
564
Emergency calls refer to dialing short numbers usually associated with emergency services like police or fire-brigade (e.g. 112 or 911). When a session is setup to a short number designated as an emergency number (in the SIP Proxy configuration), a database lookup is performed by the proxy in the emergency&#95;mapping table. Based on the *region* attribute provisioned with the SIP account, the final destination corresponding with the emergency number is looked up. Only local users can dial an emergency number.
565
566
See [[Provisioning_guide#Emergency-Numbers|"Provisioning the emergency numbers"]] section for more information.
567
568 17 Adrian Georgescu
h2. XMMP gateway
569 1 Tijmen de Mes
570
The platform can be setup to federate with remote XMPP domains using a gateway function. The functionality is described at:
571
572 4 Tijmen de Mes
http://sylkserver.ag-projects.com/projects/sylkserver/wiki/DesignXMPP
573
574
h2. PBX Media Functions
575
576
Functions involving playing media in the middle of a call setup are not possible by the design of a SIP Proxy. Features like:
577
578 1 Tijmen de Mes
* IVR
579 4 Tijmen de Mes
* Auto-attendant
580 1 Tijmen de Mes
* Call queues and ACD
581
* Listen-in and barge-in
582
* Call parking
583
* Music on hold (MoH)
584
585
are not performed by a SIP Proxy. Such functions can be implemented only by dedicated IP-PBX added to the platform. The platform is used to route calls between such PBXs, from the MSP perspective these PBX are seen as SIP trunks connected to the platform.