<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes" ?>
<?rfc compact="yes" ?>
<?rfc sortrefs="no" ?>
<rfc ipr="full2026" docName="draft-ietf-sip-connect-reuse-00.txt">
<front>
    <title abbrev="SIP Connection Reuse">
       Connection Reuse in the Session Initiation Protocol (SIP)
    </title>
    <author initials="R." surname="Mahy" fullname="Rohan Mahy">
      <organization>Cisco Systems, Inc.</organization>
      <address>
	<postal>
	  <street>101 Cooper Street</street>
	  <city>Santa Cruz</city> <region>CA</region> <code>95060</code>
	  <country>USA</country>
 	</postal>
	<email>rohan@cisco.com</email>
      </address>
    </author>
    <date month="Aug" year="2003" />
    <area>Transport</area>
    <workgroup>SIP WG</workgroup>
    <keyword>I-D</keyword>
    <keyword>Internet-Draft</keyword>
    <keyword>connection reuse</keyword>
    <abstract>
      <t>
When SIP entities use a connection oriented protocol to send a request, they typically originate their connections from an ephemeral port. The SIP protocol includes mechanisms which insure that responses to a request, and new requests sent in the original direction reuse an existing connection.  However, new requests sent in the opposite direction are unlikely to reuse the existing connection.  This frequently causes a pair of SIP entities to use one connection for requests sent in each direction, and can result in potential scaling and performance problems.  This document proposes requirements and a mechanism which address this deficiency. 
      </t>
    </abstract>
  </front>
  <middle>
    <section title="Conventions">
      <t>
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", 
"RECOMMENDED",  "MAY", and "OPTIONAL" in this document are to be interpreted as described 
in <xref target="RFC2119">RFC-2119</xref>.
</t>
</section>

<section title="Introduction and Problem Statement">
<t>
<xref target="RFC3261">SIP</xref> entities can communicate using either unreliable/connectionless (ex: UDP) or reliable/connection-oriented (ex: TCP, <xref target="RFC2960">SCTP</xref>) transport protocols.  When SIP entities use a connection-oriented protocol (such as TCP or SCTP) to send a request, they typically originate their connections from an ephemeral port. 
</t><t>
In the following example, Entity A listens for SIP requests over <xref target="RFC2246">TLS</xref> on TCP port 5061 (the default port for SIP over TLS over TCP), but uses an ephemeral port (port 8293) for a new connection to Entity B.  These entities could be SIP User Agents or SIP Proxy Servers.
</t>
<figure><artwork><![CDATA[
       +-----------+ 8293 (UAC)      5061 (UAS) +-----------+
       |           |--------------------------->|           |
       |  Entity   |                            |  Entity   |
       |     A     |                            |     B     |
       |           | 5061 (UAS)                 |           |
       +-----------+                            +-----------+
]]></artwork></figure>
<t>
The SIP protocol includes mechanisms which insure that responses to a request reuse the existing connection which is typically still available, and also includes provisions for reusing existing connections for other requests sent by the originator of the connection.  However, new requests sent in the opposite direction (routed from the target of the original connection toward the originator of the original connection) are unlikely to reuse the existing connection.  This frequently causes a pair of SIP entities to use one connection for requests sent in each direction, as shown below.
</t>
<figure><artwork><![CDATA[
       +-----------+ 8293              5061 +-----------+
       |           |.......................>|           |
       |  Entity   |                        |  Entity   |
       |     A     | 5061              9741 |     B     |
       |           |<-----------------------|           |
       +-----------+                        +-----------+
]]></artwork></figure>
<t>
This extra pair of connections can result in potential scaling and performance problems.  For example, each new connection using TLS requires a TCP 3-way handshake, a handful of round-trips to establish TLS, and (typically) expensive asymetric authentication and key generation algorithms, and certificate verification.   This effectively doubles the load on each entity.  Setting up a second connection can also cause excessive delay (especially in networks with long round-trip times) for subsequent requests, even requests in the context of an existing dialog (for example a reINVITE or BYE after an initial INVITE, or a NOTIFY after a SUBSCRIBE <xref target="RFC3265"/> or a <xref target="RFC3515">REFER</xref>).
</t><t>
Consider the call flow shown below where Proxy A and Proxy B use the Record-Route mechanism to stay involved in a dialog.  Proxy B will establish a new TLS connection just to send a BYE request.
</t>
<figure><artwork><![CDATA[
   INVITE ->   create connection 1
   <- 200      response over connection 1
   ACK ->      reuse connection 1

   <- BYE      create connection 2
   -> 200      response over connection 2
]]></artwork></figure>
<t>
ReINVITEs are expected to be handled automatically and rapidly in order to avoid media and session state from being out of step.  If a reINVITE requires a new TLS connection, the reINVITE could be delayed by several extra round-trip times.  Depending on the round-trip time, this combined delay could be perceptible or even annoying to a human user.
This is especially problematic for some common SIP call flows (for example, the recommended example flow in figure number 4 in 
<xref target="I-D.ietf-sipping-3pcc">3pcc</xref>) use many reINVITEs.
</t><t>
Consider also a call flow where a handheld organizer sends a REFER request which establishes a dialog to a SIP phone.  Typically this would require a second connection back to the handheld to be established.
</t>
<figure><artwork><![CDATA[
   REFER ->               connection 1
   <- 202                 connection 1
   <- NOTIFY              connection 2
   200 ->                 connection 2
              INVITE ->
              <- 200
   <- NOTIFY              connection 2
   200 ->                 connection 2
]]></artwork></figure>
<t>
Likewise when clusters or farms of cooperating SIP servers (for example proxy servers) are configured together, SIP entities have no way to prefer a server with an existing connection.  For example, Proxy server B has no mechanism to choose an existing connection with Proxy cluster A.
</t>
<figure><artwork><![CDATA[
       +-----------+
       |           |
       |   Proxy   |
       |    A1     |                        +-----------+
       |           |                        |           |
       +-----------+                        |   Proxy   |
       +-----------+ 8293              5061 |     B     |
       |           |----------------------->|           |
       |   Proxy   |                        +-----------+
       |     A2    |
       |           |
       +-----------+
]]></artwork></figure>
<t>
As a result, Proxy B might open a new connection to another proxy server for requests sent in the opposite direction.
</t>
<figure><artwork><![CDATA[
       +-----------+
       |           |
       |   Proxy   |
       |     A1    | 5061              9741 +-----------+
       |           |<.......................|           |
       +-----------+                        |   Proxy   |
       +-----------+ 8293              5061 |     B     |
       |           |----------------------->|           |
       |   Proxy   |                        +-----------+
       |     A2    |
       |           |
       +-----------+
]]></artwork></figure>
<t>
The rules for handling the Transport layer described in Section 18 of <xref target="RFC3261">SIP</xref> do not associate incoming connections with the listening port which corresponds to the same SIP entity.  If the Tranport layer had some way to associate these connections, then request and responses originated from either node could reuse existing connections as shown below.
</t>
<figure><artwork><![CDATA[
       +-----------+                        +-----------+
       |           |                        |           |
       |   Node A  | 8293              5061 |   Node B  |
       |           |<======================>|           |
       |           |                        |           |
       +-----------+                        +-----------+
]]></artwork></figure>
</section>

<section title="Requirements">
<t><list style="numbers">
<t>
A connection sharing mechanism SHOULD allow SIP entities to reuse existing connections for requests and repsonses originated from either peer in the connection.
</t><t>
A connection sharing mechanism SHOULD allow SIP entities to reuse existing connections with closely coupled nodes which act as a single SIP entity (for example a cluster of nodes acting as a proxy server).
</t><t>
A connection sharing mechanism MUST NOT require UACs (clients) to send all traffic from well-know SIP ports.
</t><t>
A connection sharing mechanism MUST NOT require configuring ephemeral port numbers in DNS.
</t><t>
A connection sharing mechanism MUST prevent unauthorized hijacking of other connections.
</t><t>
Connection sharing SHOULD persist across SIP transactions and dialogs.
</t></list>
</t>
</section>

<section title="Overview of Proposed Mechanism">
<t>
The proposed mechanism uses a new Via header field parameter.  The "alias" parameter is included in a Via header field value to indicate that the originator of the request wants to create a transport layer alias, so that the sent-by address becomes mapped to the current connection. 
</t><t>
Assuming the Via header field value shown below from the most recent request arrived over a connection from 60.54.32.1 port 8241:
</t>
<figure><artwork>
   Via: SIP/2.0/TLS 60.54.32.1:5061;branch=z9hG4bKa7c8dze ;alias
</artwork></figure>
<t>
The transport layer creates an alias, such that any requests going to the "advertised address" (60.54.32.1 port 5061) are instead sent over the existing connection (to the "target" of the alias) which is coming from port 8241.  This sharing continues as long as the target connection stays up.  The SIP community recommends that servers keep connections up unless they need to reclaim resources, and that clients keep connections up as long as they are needed. Connection reuse works best when the client and the server maintain their connections for long periods of time.  SIP entities therefore SHOULD NOT drop connections on completion of a transaction or termination of a dialog.
</t><t>
Likewise when clusters or farms of cooperating SIP servers (for example proxy servers) are configured together, the proposed mechanism allows a SIP entity to select a server with an existing connection.  With the proposed mechanism, Proxy B  sends requests for Proxy cluster A to node A2 with whom it shares an existing connection.
</t>
<figure><artwork><![CDATA[
       +-----------+
       |           |
       |   Proxy   |
       |     A1    |                        +-----------+
       |           |                        |           |
       +-----------+                        |   Proxy   |
       +-----------+ 8293              5061 |     B     |
       |           |<======================>|           |
       |   Proxy   |                        +-----------+
       |     A2    |
       |           |
       +-----------+
]]></artwork></figure>
<t>
For example, on receipt of a message with the topmost Via header shown below, the transport layer creates an alias such that requests going to the advertised address (host-a.atlanta.com) are sent over the target connection (from 60.54.32.1:8241). 
</t>
<figure><artwork>
   Via: SIP/2.0/TLS host-a.atlanta.com;branch=z9hG4bK7c8dze ;alias
</artwork></figure>
<t>
As a result, this has an important interaction with the DNS resolution mechanisms for SIP described in <xref target="RFC3263">RFC3263</xref>.  When new requests arrive for host-a.atlanta.com, proxy B still needs to perform a DNS NAPTR lookup to select the transport. Once the transport is selected, an SRV lookup would ordinarily occur to find the appropriate port number. In this case, the transport layer uses a connection reuse alias instead of performing the SRV query. 
</t><t>
Below is a partial DNS zone file for atlanta.com.
</t>
<figure><artwork>
; NAPTR queries for the current domain (atlanta.com)
;
; order pref flags service regexp replacement
@ IN NAPTR 50 50 "s" "SIPS+D2T" "" _sips._tcp.
 
; SRV records for the proxy use 5060/5061
;
;; Priority Weight Port Target
_sips._tcp.host-a  IN SRV 0 1 5061 host-a1
_sips._tcp.host-a  IN SRV 0 1 5061 host-a2

host-a1  IN A 60.54.32.1
host-a2  IN A 60.54.32.2
  </artwork></figure>
<t>
The existence of an alias parameter is treated as a request which asks the transport layer to create an alias (named by the sent-by parameter, which  could be a hostname) that points to the alias target (the current connection) 
</t><t>
This mechanism is fully backwards compatible with existing implementations.  If the proposed Via parameter is not understood by the recipient, it will be ignored and the two implementations will revert to current behavior (two connections).
</t>


<section title="Authorizing an alias request">
<t>
Authorizing connection aliases is essential to prevent connection hijacking.  For example a program run by a malicious user of a multiuser system could attempt to hijack SIP requests destined for the well-known SIP port from a large relay proxy.  
</t><t>
To correctly authorize an alias, both the active connection and the alias need to authenticate using the same credentials.  This could be accomplished using one of two mechanisms.  The first (and preferred) mechanism is using TLS mutual authentication, such that the subjectAltName of the originator certificate corresponds to both the current connection and the target address of the alias.   The Via sent-by address needs to be within the scope protected by the certificate presented by the originator during TLS mutual authentication and the received IP address needs be a valid IP address for the sent-by host or hosts.  In other words, the sent-by address and port combination MUST be resolvable from the subjectAltName of the originator certificate, and the received IP address MUST be resolvable from the sent-by address.  This is in addition to other requirements for TLS authentication and authorization discussed in <xref target="RFC3261">SIP</xref> and <xref target="RFC3263">Locating SIP Servers</xref>.
</t><t>
The second mechanism is to accept an alias if the target address of the alias is equivalent (using SIP comparison rules) to a valid Contact already registered by the same user.  This user could be authenticated through any SIP or TLS mechanism (ex: user certificate, or <xref target="RFC1510">Kerberos</xref>), but would typically use <xref target="RFC2617">Digest authentication</xref>.  For example, if Alice registers a Contact of 123.45.67.89:5061, she could inform Proxy 1 of the existence of a connection to her from Proxy 2.  This would allow her to preemptively originate TLS connections, as her user agent may not have access to a site certificate with which to authenticate incoming TLS connections. 
</t>
<figure><artwork><![CDATA[
                                            +-----------+
                                            |           |
                                            |   Proxy   |
       +-----------+ 8672              5061 |     1     |
       |           |----------------------->|           |
       |   Alice   |                        +-----------+
       |           |                        +-----------+
       |           |----------------------->|           |
       +-----------+ 8293              5061 |   Proxy   |
                                            |     2     |
                                            |           |
                                            +-----------+
]]></artwork></figure>
</section>

<section title="Formal Syntax">
<t>
The following syntax specification uses the augmented Backus-Naur Form (BNF) as described in 
<xref target="RFC2234">RFC-2234</xref>.  This document proposes to extend via-params to include a a new via-alias defined below.
</t>
<figure><artwork>
   via-params = via-ttl / via-maddr / via-received / via-branch / 
                via-alias / via-extension

   via-alias  = "alias"
</artwork></figure>
</section>
</section>

<section title="Security Considerations">
<t>
This document presents requirements and a  mechanism for reusing existing connections easily.  Connection reuse presents many opportunities for abuse and hijacking, but these attacks can be prevented if the guidelines in the authorization section are followed.  
</t>
</section>

<section title="IANA Considerations">
<t>
This document introduces no additional considerations for IANA.
</t>
</section>

<section title="Acknowledgments">
<t>
Thanks to Jon Peterson for helpful answers about certificate behavior with SIP, Jonathan Rosenberg for his initial support of this concept, and Cullen Jennings for providing a sounding board for this idea.
</t>
</section>


  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.3261" ?>
      <?rfc include="reference.RFC.2119" ?>
      <?rfc include="reference.RFC.2234" ?>
      <?rfc include="reference.RFC.2246" ?>
      <?rfc include="reference.RFC.2617" ?>
      <?rfc include="reference.RFC.3263" ?>
    </references>
    <references title="Informational References">
      <?rfc include="reference.I-D.ietf-sipping-3pcc" ?>
      <?rfc include="reference.RFC.3265" ?>
      <?rfc include="reference.RFC.3515" ?>
      <?rfc include="reference.RFC.1510" ?>
      <?rfc include="reference.RFC.2960" ?>
    </references>
  </back>
</rfc>


