Hosted by: Logo

SaRP - SIP and RTP proxy

SaRP is a SIP and RTP proxy designed specifically to handle the problems inherit in NAT and SIP.
The current implementation is written in Perl but a cross-platform C++ version is being worked on.
Sourceforge project page

Current status:

Project criteria:

Planned features:
The planned feature: Monitor RTP traffic and gracefully disconnect call if no data flows in one/both directions for a defined time period. has been dropped.
Monitoring RTP will not work since there are occasions when a host may not send audio for some time but will still want the call to be active. Instead we will rely on using the SIP based heartbeat.

The following are a cut-and-paste from two emails that pretty much describe what it is:

I've been dealing with this problem since the first moment I've dealt
with VoIP. Basically I've had enough of it and have started writing a
very simple SIP and RTP proxy. It will pass all SIP related traffic
through it, effectively teminating all connections on itself from the
point of view of the UAs. It is also configurable as to what it's
external address is when dealing with non-internal traffic. This is
name based so that people on dynamic IPs can also use it. Lastly it is
going to be cross-platform to account for users of _any_ NATing
device/platform. All of this is clearly laid out in a number of Internet
Drafts from the IETF from _early_ 2000!

Okay, this is the simple plan for starters.

                   networks         Preferably has
                      |          .- Dynamic DNS entry
              .--     |         /   for real world IP
              |   NAT router <-'
  Optional -->|       |
              |       | <---- DNAT of ports to proxy
              `--     |
                      |      --.
                SIP/RTP proxy  |
                   /  |  \     |    Must have ability
                  /   |   \    |<-- to talk directly
                 UA1 UA2 UAn   |    without NAT or firewall
UA  = User Agent
SIP = control channel
RTP = data channel

Required configuration for SIP proxy:
* DNS name / real world IP for external traffic
* Specific list of ports that it will listen/send on
* address of Internal network

Useful configuration:
* user to IP mapping for internal calls
* catchall to IP mapping of unknown/unspecified user

SIP process flow:
0. if $from ! in $internal_net && $to ! in $internal_net
   then drop and ALERT
1. if $from in $internal_net && $to in $internal_net
   then forward
   (With no modification this should then cause the UAs to negotiate RTP as
2. if packet = BYE
   then modify, forward, remove connection record and close UDP RTP ports
3. if active connection then modify and forward
4. if $from in $internal_net && $to ! in $internal_net
   then record connection
   modify and forward
5. if $from ! in $internal_net && $to in $internal_net
   then record connection
   lookup user_to_IP_mapping, modify and forward

  if ($from_ip or $to_ip) ! in $internal_net
    if $from_ip in $internal_net then rewrite to $real_world_ip from DNS query
    if $to_ip in $internal_net then rewrite to $proxy_internal_ip
    if packet = SIP
      rewrite local UDP ports for RTP to those defined in config
      open RTP connections
    forward modified packet