Version 36 (Adrian Georgescu, 02/18/2010 07:24 pm)

1 32 Adrian Georgescu
= MediaProxy ICE Support =
2 1 Redmine Admin
3 1 Redmine Admin
== Background ==
4 1 Redmine Admin
5 31 Adrian Georgescu
[ ICE methodology] has been defined to solve the NAT traversal issue of RTP media as much as possible in the SIP end-points. Where the end-point topology does not allow, a TURN server has been standardized to provide end-points with a visible public presence that can be used to relay traffic to SIP end-points behind an unfriendly NAT type (e.g. symmetric). TURN servers are not widely deployed today whereas solutions like SIP Proxies in tandem with RTP relays are. 
6 1 Redmine Admin
7 31 Adrian Georgescu
RTP relays that work in tandem with SIP Proxies perform similar function to the TURN protocol except that the reservation is done by the SIP Proxy rather than by the user agent. The SIP User Agent does not need to support TURN protocol in order to use the relay, which makes it compatible with any SIP User Agent available today. Such solution used widely today is the tandem '''OpenSIPS/MediaProxy'''. 
8 11 Redmine Admin
9 33 Adrian Georgescu
Until the addition of this functionality, MediaProxy module used to rewrite the SDP in order to present to the destination SIP User Agent a reachable IP:port number for sending RTP/RTCP. This had the dis-advantage that the session was always using a relay and it was mutually exclusive with the use of ICE. The rewriting of the SDP and the missing candiate correspondent to the c= line of the SDP caused the target SIP end-point to reply with ICE missmatch and the ICE negotiation always failed in its tracks.
10 3 Redmine Admin
11 36 Adrian Georgescu
By using the current solution, the SIP Proxy administrator can decide whether ICE is allowed and which priority the MediaProxy candidate has on a per call basis. There is no need for deploying a TURN server anymore in order to support ICE negotiation between end-points.
12 36 Adrian Georgescu
13 30 Adrian Georgescu
== Implementation ==
14 1 Redmine Admin
15 31 Adrian Georgescu
To circumvent the failure of ICE negotiation, MediaProxy module in OpenSIPS is now:
16 3 Redmine Admin
17 30 Adrian Georgescu
 * Creating a proper candidate based on the media relay IP:port allocation
18 30 Adrian Georgescu
 * Appending the candidate to the offer/answer of the SDP
19 30 Adrian Georgescu
 * Allows an administrator to set a policy about when to use of the relay candidate
20 1 Redmine Admin
21 30 Adrian Georgescu
OpenSIPS mediaproxy module has a new setting:
22 1 Redmine Admin
23 1 Redmine Admin
24 27 Redmine Admin
25 1 Redmine Admin
26 1 Redmine Admin
27 1 Redmine Admin
This module parameter defines which AVP should be used to set the ICE candidates priority. It can take 3 different values: "none", "low" or "high". None means no candidate will be added at all, and low or high affect on the priority field of the ICE candidate being inserted. Example:
28 27 Redmine Admin
29 1 Redmine Admin
30 1 Redmine Admin
route {
31 27 Redmine Admin
32 27 Redmine Admin
$avp(s:ice_priority) := "low";
33 27 Redmine Admin
34 1 Redmine Admin
35 25 Redmine Admin
36 25 Redmine Admin
37 30 Adrian Georgescu
For the initial INVITE and its reply, mediaproxy module now appends an ICE candidate to the SDP as follows:
38 1 Redmine Admin
39 1 Redmine Admin
40 28 Adrian Georgescu
if (ice_priority_avp != none and 
41 1 Redmine Admin
    SDP offer contains a=ice-pwd and a=ice-ufrag and a=candidate line(s) then 
42 1 Redmine Admin
	append to the SDP the following line:
43 29 Adrian Georgescu
	a=candidate:R 1 UDP PRIORITY MP_IP MP_PORT typ relay
44 25 Redmine Admin
        a=candidate:R 2 UDP PRIORITY MP_IP MP_RTCP_PORT typ relay
45 1 Redmine Admin
46 12 Redmine Admin
47 1 Redmine Admin
48 1 Redmine Admin
49 1 Redmine Admin
 * R (foundation) = we'll use 'R' to represent we are emulating a relayed candidate
50 25 Redmine Admin
 * PRIORITY = 2!^24 * POLICY + 2!^8  * 65535 + 2!^0  * 256 - Candidate ID (1 for RTP, 2 for RTCP)
51 23 Adrian Georgescu
    * POLICY = 0  if $avp(s:ice_priority) == low and POLICY = 126  if $avp(s:ice_priority) == high.
52 27 Redmine Admin
53 30 Adrian Georgescu
54 30 Adrian Georgescu
If ICE negotiation succeeds and the MediaProxy relay candidate has not been selected by the end-points, MediaProxy deallocates its ports after the built-in timeout and does not terminate the dialog in case of missing BYEs. MediaProxy decides this, if both SDP offer and answer have ICE support and if STUN binding requests (which correspond to ICE probing) have been detected while no RTP has been subsequently sent through the relay. 
55 34 Adrian Georgescu
56 35 Adrian Georgescu
== Prerequisites  ==
57 34 Adrian Georgescu
58 35 Adrian Georgescu
You need MediaProxy version 2.4.0 or higher to support this functionality and the correspondent mediaproxy opensips module due to be uploaded soon to the trunk 1.6 version.