« Previous - Version 3/61 (diff) - Next » - Current version
Redmine Admin, 03/20/2009 10:15 am


= ICE negotiation through OpenSIPS/Mediaproxy =

Background

ICE negotiation is used to solve the NAT traversal issue of RTP media as much as possible in the end-points. Where the 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 the end-points behind unfriendly NAT type (e.g. symmetric). TURN servers are not widely deployed today whereas solution like SIP Proxy in tandem with RTP relays are. RTP relays work in tandem with the SIP Proxy to perform similar function to the TURN protocol except that the reservation is done by the SIP Proxy rather than by the user agent. The UA has no need to support TURN in order to use a server relay.

Such RTP relay used widely today is MediaProxy. MediaProxy rewrites the SDP in order to present the destination UA with a reachable IP:port number for sending RTP/RTCP. To allow end-points to negotiate ICE, the SDP offer must contain a candidate correspondent to the the c= line of the SDP. The rewrite of the SDP causes the target end-point to replay with ice missmatch and the ICE negotiation fails in its tracks.

Requirements

To circumvent the failure of ICE negotiation, mediaproxy module should be able to:

  • Create a proper candidate based on relay allocation
  • Append the candidate them to the offer/answer of the SDP
  • Allow an administrator to set a policy about when to use of the relay candidate
  • Solve the accounting issues and BYE sending depending on the use of ICE
Implementation

Add a setting to mediaproxy module

{{{
mediaproxy_ice_candidate=none|low|medium|high
}}}

{{{
if mediaproxy_ice_candidate != none and SDP offer contains ice-offer (has a=candidate line(s)) then
append to the SDP the following line:
a=candidate:ID 1 UDP PRIORITY MP_IP MP_PORT typ relay raddr UA_IP rport UA_PORT
}}}

where

  • ID = is the highest ID found in SDP + 1
  • PRIORITY = 2!^24 * POLICY + 2!^8 * 65535 + 2!^0 * 256 - ID
  • POLICY = 0 if mediaproxy_ice_candidate = low and POLICY = 126 if mediaproxy_ice_candidate = high
  • UA_IP the IP used by the end-point
  • UA_port the port used by the end-point

This process must be performed at the first INVITE for both offer and answer.

Once the ICE negotiation is completed a re-INVITE indicates this fact. The re-INVITE contains the selected candidate and a flag to mention that the ICE negotiation has been completed. The mediaproxy module should analyze the re-invite and figure out whether the relay IP:port has been chosen for the RTP media. If the anser is negative than MediaProxy should deallocate its port and cancel subsequent action related to accounting and dialog terminating purposes.