<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc3261 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3261.xml">
<!ENTITY rfc3264 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3264.xml">
<!ENTITY rfc3840 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.3840.xml">
<!ENTITY rfc4028 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4028.xml">
<!ENTITY rfc4235 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4235.xml">
<!ENTITY rfc4566 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4566.xml">
<!ENTITY rfc4961 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4961.xml">
<!ENTITY rfc5245 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5245.xml">
<!ENTITY rfc5359 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5359.xml">
<!ENTITY rfc6337 PUBLIC ""
  "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6337.xml">
]>
<?rfc strict="yes" ?>
<?rfc toc="yes" ?>
<rfc ipr="trust200902" category="info" docName="draft-worley-service-example-14">

<front>
<title abbrev="Music on Hold">
Session Initiation Protocol Service Example -- Music on Hold
</title>
<author initials="D.R." surname="Worley" fullname="Dale R. Worley">
  <organization abbrev="Ariadne">
    Ariadne Internet Services, Inc.
  </organization>
  <address>
    <postal>
      <street>738 Main St.</street>
      <city>Waltham</city>
      <region>MA</region>
      <code>02451</code>
      <country>US</country>
    </postal>
    <phone>+1 781 647 9199</phone>
    <email>worley@ariadne.com</email>
  </address>
</author>
<date day="2" month="October" year="2013"/>
<area>Transport</area>
<workgroup>Dispatch</workgroup>
<keyword>Music on hold</keyword>
<abstract>
<t>
The "music on hold" feature is one of the most desired features of
telephone systems in the business environment.
"Music on hold" is where, when one party to a call
has the call "on hold", that party's telephone provides an audio
stream (often music) to be heard by the other party.
Architectural features of SIP make it
difficult to implement music-on-hold in a way that is fully compliant
with the standards.
The implementation of music-on-hold described in this document is
fully effective and standards-compliant, and has a number of
advantages over the methods previously documented.
In particular, it is less likely to produce peculiar user interface
effects and more likely to work in systems which perform
authentication than the music-on-hold method described in section 2.3
of RFC 5359.
</t>
</abstract>
</front>

<middle>

<section title="Introduction" anchor="intro">

<t>
Within SIP<xref target="RFC3261"/>-based systems, it is desirable to be
able to provide
features that are similar to those provided by traditional telephony
systems. 
A frequently requested feature is "music on hold":
The music-on-hold feature is where, when one party to a call
has the call "on hold", that party's telephone provides an audio
stream (often music) to be heard by the other party.

</t>

<t>
Architectural features of SIP make it
difficult to implement music-on-hold in a way that is fully compliant
with the standards.  The purpose of this document is to describe a
method that is reasonably simple yet fully effective and standards-compliant.
</t>

<section title="Intended Status" anchor="status">

<t>
  The "intended status" of this document is "Informational".  The
  reason that it is not "Best Current Practice" is that this method is
  not specified as "best", nor is this specification intended to
  supersede all other methods for implementing music-on-hold.
</t>

<t>
  All current methods of implementing music-on-hold interoperate with
  each other, in that the two user agents in a call can use different
  methods for implementing music-on-hold with the same functionality
  as if either of the methods was used by both user agents.  Thus,
  there is no loss of functionality if different music-on-hold
  methods are used by different user agents within a telephone
  system, or if a single user agent uses different methods within
  different calls, or at different times within one call.
</t>

<t>
  However, this method has significant advantages over other methods
  now in use, as described in <xref target="advantages"/>.
</t>

</section>

</section>

<section title="Technique" anchor="impl">

<t>
The essence of the technique is that when the executing UA (the user's
UA) performs
a re-INVITE of the remote UA (the other user's UA) to establish the
hold state, it provides no SDP<xref target="RFC4566"/>
offer<xref target="RFC3264"/><xref target="RFC6337"/>,
thus compelling the remote UA to provide an SDP offer.
The executing UA then extracts
the offer SDP from the remote UA's 2xx response,
and uses that as the offer SDP in a new INVITE to
the external media source.  The external media source is thus directed
to provide media directly to the remote UA.
The media source's answer SDP is returned to the remote UA in the ACK
to the re-INVITE.
</t>

<section title="Placing a Call on Hold and Establishing an External Media Stream">

<t>

<list style="numbers">

<t>The executing user instructs the executing UA to put the dialog
on-hold.</t>

<t>The executing UA sends a re-INVITE without SDP to the remote UA,
which forces the remote UA to provide an SDP
offer in its 2xx response.
The Contact header of the re-INVITE includes the '+sip.rendering="no"'
field parameter to indicate that it is putting the call on
hold.  (<xref target="RFC4235"/> section 5.2)
</t>

<t>The remote UA sends a 2xx to the re-INVITE, and includes an SDP offer
giving its own listening address/port.
If the remote UA understands the sip.rendering feature parameter, the
offer may indicate that it will not send media by specifying the media
directionalities as "recvonly" (the reverse of "on-hold") or "inactive".
But the remote UA may offer to send media.
</t>

<t>The executing UA uses this offer to derive the offer SDP of an initial
INVITE that it
sends to the configured music-on-hold (MOH) source.
The SDP in this request is largely copied
from the SDP returned by the remote UA in the previous step,
particularly regarding the
provided listening address/port and payload type numbers.

But the media
directionalities are restricted to "recvonly" or "inactive" as appropriate.
The executing UA may want or need to change the o= line.
In addition, some a=rtpmap lines may need to be added to control the
assignment of RTP payload type numbers.[<xref target="payload"/>]
</t>

<t>
The MOH source sends a 2xx response to the INVITE, which contains an SDP
answer that should include
its media source address as its listening address/port.
This SDP must necessarily<xref target="RFC3264"/> specify "sendonly" or "inactive" as the
directionality for all media streams.
<vspace blankLines="1"/>
Although this address/port should receive no RTP, the specified port
determines the port for receiving RTCP (and conventionally, for sending
RTCP<xref target="RFC4961"/>).
<vspace blankLines="1"/>
By convention, UAs
use their declared RTP listening ports as their RTP source ports as
well.<xref target="RFC4961"/>
The answer SDP will reach the remote UA, thus informing it of the
address/port from which the MOH media will come, and presumably
preventing the remote UA from ignoring the MOH media if the remote UA
filters media packets based on the source address.
This functionality requires the SDP answer to contain the sending
address in the c= line, even though the MOH source does not
receive RTP.)
</t>

<t>The executing UA sends this SDP answer as its SDP answer in the ACK for the
re-INVITE to the remote UA.  The o= line in the answer must be modified
to be within the sequence of o= lines previously generated by the executing
UA in the dialog.  Any dynamic payload type number assignments that
have been created in the answer must be recorded in the state of the
original dialog.</t>

<t>Due to the sip.rendering feature parameter in the Contact of the
re-INVITE and the media directionality in the SDP answer contained in
the ACK, the on-hold state of the dialog is
established (at the executing end).</t>

<t>After this point, the MOH source generates RTP containing the
music-on-hold media, and sends it directly to the listening address/port of the
remote UA. The executing UA maintains two dialogs (one to
the remote UA, one to the MOH source), but does not see or handle the MOH
RTP.</t>

</list>

</t>

</section>

<section title="Taking a Call off Hold and Terminating the External Media Stream">

<t>

<list style="numbers">

<t>The executing user instructs the executing UA to take the dialog off-hold.</t>

<t>The executing UA sends a re-INVITE to the remote UA with SDP that
requests to receive media.
The Contact header of the re-INVITE does not include the '+sip.rendering="no"'
field parameter.
(It may contain a sip.rendering field parameter with value "yes" or
"unknown", or it may omit the field parameter.)
Thus this INVITE removes the on-hold state of the
dialog (at the executing end).
(Note that the version in o= line of the offered SDP must account for
the SDP versions that were passed through from the MOH source.
Also note that
any payload type numbers that were assigned in SDP provided by 
the MOH source must be respected.)</t>

<t>When the remote UA sends a 2xx response to the re-INVITE, the executing UA
sends a BYE request in the dialog to the MOH source.</t>

<t>After this point, the MOH source does not generate RTP and ordinary
RTP flow is reestablished in the original dialog.</t>

</list>

</t>

</section>

<section title="Example Message Flow" anchor="message-flow">

<t>
This section shows a message flow which is an example of this
technique.  The scenario is: Alice establishes a call with Bob. Bob
then places the call on hold, with music-on-hold provided from an
external source.  Bob then takes the call off hold.
In this
scenario, Bob's user agent is the executing UA, while Alice's UA is
the remote UA.
Note that this is just one possible message flow that illustrates this
technique; numerous variations on these operations are allowed by the
applicable standards.
</t>

<figure>
<artwork><![CDATA[
Alice             Bob       Music Source

Alice establishes the call:

  |                |              |
  |    INVITE F1   |              |
  |--------------->|              |
  | 180 Ringing F2 |              |
  |<---------------|              |
  |    200 OK F3   |              |
  |<---------------|              |
  |     ACK F4     |              |
  |--------------->|              |
  |       RTP      |              |
  |<==============>|              |
  |                |              |

Bob places Alice on hold, compelling Alice's UA to provide SDP:

  |                |              |
  |   INVITE F5    |              |
  |   (no SDP)     |              |
  |<---------------|              |
  |   200 OK F6    |              |
  |   (SDP offer)  |              |
  |--------------->|              |
  |                |              |

Bob's UA initiates music-on-hold:

  |                |              |
  |                |  INVITE F7   |
  |                |  (SDP offer, |
  |                |   rev. hold) |
  |                |------------->|
  |                | 200 OK F8    |
  |                | (SDP answer, |
  |                |  hold)       |
  |                |<-------------|
  |                |    ACK F9    |
  |                |------------->|
  |                |              |

Bob's UA provides an SDP answer containing the address/port
of the Music Source:

  |                |              |
  | ACK F10        |              |
  | (SDP answer,   |              |
  |  hold          |              |
  |<---------------|              |
  |    no RTP      |              |
  |<..............>|              |
  |     Music-on-hold RTP         |
  |<==============================|
  |                |              |

The music on hold is active.

Bob takes Alice off hold:

  |                |              |
  |  INVITE F11    |              |
  |  (SDP offer)   |              |
  |<---------------|              |
  |   200 OK F12   |              |
  |   (SDP answer) |              |
  |--------------->|              |
  |     ACK F13    |              |
  |<---------------|              |
  |                |    BYE F14   |
  |                |------------->|
  |                |    200 F15   |
  |                |<-------------|
  |       RTP      |              |
  |<==============>|              |
  |                |              |

The normal media session between Alice and Bob is resumed.
]]></artwork>
</figure>

<figure>
<artwork><![CDATA[
 /* Alice calls Bob. */

 F1 INVITE Alice -> Bob

 INVITE sips:bob@biloxi.example.com SIP/2.0
 Via: SIP/2.0/TLS atlanta.example.com:5061
  ;branch=z9hG4bK74bf9
 Max-Forwards: 70
 From: Alice <sips:alice@atlanta.example.com>;tag=1234567
 To: Bob <sips:bob@biloxi.example.com>
 Call-ID: 12345600@atlanta.example.com
 CSeq: 1 INVITE
 Contact: <sips:a8342043f@atlanta.example.com;gr>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces, gruu
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=alice 2890844526 2890844526 IN IP4 atlanta.example.com
 s=
 c=IN IP4 atlanta.example.com
 t=0 0
 m=audio 49170 RTP/AVP 0
 a=rtpmap:0 PCMU/8000


 F2 180 Ringing Bob -> Alice

 SIP/2.0 180 Ringing
 Via: SIP/2.0/TLS atlanta.example.com:5061
  ;branch=z9hG4bK74bf9
  ;received=192.0.2.103
 From: Alice <sips:alice@atlanta.example.com>;tag=1234567
 To: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 1 INVITE
 Contact: <sips:bob@biloxi.example.com>
 Content-Length: 0


 F3 200 OK Bob -> Alice

 SIP/2.0 200 OK
 Via: SIP/2.0/TLS atlanta.example.com:5061
  ;branch=z9hG4bK74bf9
  ;received=192.0.2.103
 From: Alice <sips:alice@atlanta.example.com>;tag=1234567
 To: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 1 INVITE
 Contact: <sips:bob@biloxi.example.com>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=bob 2890844527 2890844527 IN IP4 biloxi.example.com
 s=
 c=IN IP4 biloxi.example.com
 t=0 0
 m=audio 3456 RTP/AVP 0
 a=rtpmap:0 PCMU/8000


 F4 ACK Alice -> Bob

 ACK sips:bob@biloxi.example.com SIP/2.0
 Via: SIP/2.0/TLS atlanta.example.com:5061
  ;branch=z9hG4bK74bfd
 Max-Forwards: 70
 From: Alice <sips:alice@atlanta.example.com>;tag=1234567
 To: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 1 ACK
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces
 Content-Length: 0


 /* Bob places Alice on hold. */

 /* The re-INVITE contains no SDP, thus compelling Alice's UA
    to provide an offer. */

 F5 INVITE Bob -> Alice

 INVITE sips:a8342043f@atlanta.example.com;gr SIP/2.0
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bK874bk
 To: Alice <sips:alice@atlanta.example.com>;tag=1234567
 From: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 712 INVITE
 Contact: <sips:bob@biloxi.example.com>;+sip.rendering="no"
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces
 Content-Length: 0

 /* Alice's UA provides an SDP offer.
    Since it does not know that it is being put on hold,
    the offer is the same as the original offer and describes
    bidirectional media. */

 F6 200 OK Alice -> Bob

 SIP/2.0 200 OK
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bK874bk
  ;received=192.0.2.105
 To: Alice <sips:alice@atlanta.example.com>;tag=1234567
 From: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 712 INVITE
 Contact: <sips:a8342043f@atlanta.example.com;gr>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces, gruu
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=alice 2890844526 2890844526 IN IP4 atlanta.example.com
 s=
 c=IN IP4 atlanta.example.com
 t=0 0
 m=audio 49170 RTP/AVP 0
 a=rtpmap:0 PCMU/8000
 a=active


 /* Bob's UA initiates music-on-hold. */

 /* This INVITE contains Alice's offer, but with the media
    direction set to "reverse hold", receive-only. */

 F7 INVITE Bob -> Music Source

 INVITE sips:music@source.example.com SIP/2.0
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bKnashds9
 Max-Forwards: 70
 From: Bob <sips:bob@biloxi.example.com>;tag=02134
 To: Music Source <sips:music@source.example.com>
 Call-ID: 4802029847@biloxi.example.com
 CSeq: 1 INVITE
 Contact: <sips:bob@biloxi.example.com>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces, gruu
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=bob 2890844534 2890844534 IN IP4 atlanta.example.com
 s=
 c=IN IP4 atlanta.example.com
 t=0 0
 m=audio 49170 RTP/AVP 0
 a=rtpmap:0 PCMU/8000
 a=recvonly


 F8 200 OK Music Source -> Bob

 SIP/2.0 200 OK
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bKnashds9
  ;received=192.0.2.105
 From: Bob <sips:bob@biloxi.example.com>;tag=02134
 To: Music Source <sips:music@source.example.com>;tag=56323
 Call-ID: 4802029847@biloxi.example.com
 Contact: <sips:music@source.example.com>;automaton
      ;+sip.byeless;+sip.rendering="no"
 CSeq: 1 INVITE
 Content-Length: [omitted]

 v=0
 o=MusicSource 2890844576 2890844576 IN IP4 source.example.com
 s=
 c=IN IP4 source.example.com
 t=0 0
 m=audio 49170 RTP/AVP 0
 a=rtpmap:0 PCMU/8000
 a=sendonly


 F9 ACK Bob -> Music Source

 ACK sips:music@source.example.com SIP/2.0
 Via: SIP/2.0/TLS source.example.com:5061
  ;branch=z9hG4bK74bT6
 From: Bob <sips:bob@biloxi.example.com>;tag=02134
 To: Music Source <sips:music@source.example.com>;tag=56323
 Max-Forwards: 70
 Call-ID: 4802029847@biloxi.example.com
 CSeq: 1 ACK
 Content-Length: 0


 /* Bob's UA now sends the ACK that completes the re-INVITE
    to Alice and completes the SDP offer/answer.
    The ACK contains the SDP received from the Music Source,
    and thus contains the address/port from which the Music Source
    will send media, and implies the address/port which the Music
    Source will use to send/receive RTCP. */

 F10 ACK Bob -> Alice

 ACK sips:a8342043f@atlanta.example.com;gr SIP/2.0
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bKq874b
 To: Alice <sips:alice@atlanta.example.com>;tag=1234567
 From: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 712 ACK
 Contact: <sips:bob@biloxi.example.com>;+sip.rendering="no"
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces
 Content-Length: [omitted]

 v=0
 o=bob 2890844527 2890844528 IN IP4 biloxi.example.com
 s=
 c=IN IP4 source.example.com
 t=0 0
 m=audio 49170 RTP/AVP 0
 a=rtpmap:0 PCMU/8000
 a=sendonly

 /* Bob picks up the call by sending a re-INVITE to Alice. */

 F11 INVITE Bob -> Alice

 INVITE sips:a8342043f@atlanta.example.com;gr SIP/2.0
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bK874bk
 To: Alice <sips:alice@atlanta.example.com>;tag=1234567
 From: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 713 INVITE
 Contact: <sips:bob@biloxi.example.com>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=bob 2890844527 2890844529 IN IP4 biloxi.example.com
 s=
 c=IN IP4 biloxi.example.com
 t=0 0
 m=audio 3456 RTP/AVP 0
 a=rtpmap:0 PCMU/8000


 F12 200 OK Alice -> Bob

 SIP/2.0 200 OK
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bK874bk
  ;received=192.0.2.105
 To: Alice <sips:alice@atlanta.example.com>;tag=1234567
 From: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 713 INVITE
 Contact: <sips:a8342043f@atlanta.example.com;gr>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces, gruu
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=alice 2890844526 2890844527 IN IP4 atlanta.example.com
 s=
 c=IN IP4 atlanta.example.com
 t=0 0
 m=audio 49170 RTP/AVP 0
 a=rtpmap:0 PCMU/8000


 F13 ACK Bob -> Alice

 ACK sips:a8342043f@atlanta.example.com;gr SIP/2.0
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bKq874b
 To: Alice <sips:alice@atlanta.example.com>;tag=1234567
 From: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 713 ACK
 Contact: <sips:bob@biloxi.example.com>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces
 Content-Length: 0


 F14 BYE Bob -> Music Source

 BYE sips:music@source.example.com SIP/2.0
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bK74rf
 Max-Forwards: 70
 From: Bob <sips:bob@biloxi.example.com>;tag=02134
 To: Music Source <sips:music@source.example.com>;tag=56323
 Call-ID: 4802029847@biloxi.example.com
 CSeq: 2 BYE
 Contact: <sips:bob@biloxi.example.com>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces, gruu
 Content-Length: [omitted]


 F15 200 OK Music Source -> Bob

 SIP/2.0 200 OK
 Via: SIP/2.0/TLS atlanta.example.com:5061
  ;branch=z9hG4bK74rf
  ;received=192.0.2.103
 From: Bob <sips:bob@biloxi.example.com>;tag=02134
 To: Music Source <sips:music@source.example.com>;tag=56323
 Call-ID: 4802029847@biloxi.example.com
 Contact: <sips:music@source.example.com>;automaton
      ;+sip.byeless;+sip.rendering="no"
 CSeq: 2 BYE
 Content-Length: 0


 /* Normal media session between Alice and Bob is resumed */
]]></artwork>
</figure>

</section>

<section title="Receiving Re-INVITE and UPDATE from the Remote UA"
	 anchor="IU-remote">

<t>While the call is on-hold, the remote UA can send a request to
modify the SDP or the feature parameters of its Contact header.  This
can be done with either an INVITE or UPDATE method, both of which have
much the same effect in regard to MOH.</t>

<t>A common reason for a re-INVITE is when the remote UA
desires to put the dialog on hold on its end. And because of the need
to support this case, an implementation must process
INVITEs and UPDATEs during the on-hold state as described below.</t>

<t>The executing UA handles these requests by echoing requests and
responses: an incoming request from the remote UA causes the executing
UA to send a similar request to the MOH source and an incoming response from the
MOH source causes the executing UA to send a similar response to the
remote UA.  In all cases, SDP offers or
answers that are received are added as bodies to the stimulated
request or response to the other UA.</t>

<t>
  The passed-through SDP will usually need its o= line modified.  The
  directionality attributes may need to be restricted by changing
  "active" to "recvonly" and "sendonly" to "inactive", as the
  executing UA will not render media from the remote UA.  (If all
  passed-through directionality attributes are "inactive", the
  optimization described in section <xref target="direction-inactive"/>
  may be applied.)  In regard
  to payload type numbers, since the mapping has already been
  established within the MOH dialog, a=rtpmap lines need not be
  added.
</t>

</section>

<section title="Receiving INVITE with Replaces" anchor="invite-replaces">

<t>The executing UA must be prepared to receive an INVITE request with
a Replaces header that specifies the dialog with the remote UA.
If the executing UA wants to create this new dialog in the
on-hold state, it creates a new dialog with the MOH source to obtain
MOH.  The executing UA negotiates the SDP within the dialog created by
the INVITE-with-Replaces by passing the offer through to the new MOH
dialog (if the INVITE contains an offer), or by creating the new MOH
dialog with an offerless INVITE (if the INVITE does not contain an
offer).</t>

<t>Continuing the example of <xref target="message-flow"/>, the
executing UA receives an INVITE-with-Replaces that contains an
offer:</t>

<figure>
<artwork><![CDATA[
Alice             Bob       Music Source          Carol

Bob receives INVITE-with-Replaces from Carol:

  |                |              |                 |
  |                |              | INVITE/Replaces |
  |                |              | From: Carol     |
  |                |              | To: Bob         |
  |                |              | (SDP offer)     |
  |                |<-------------------------------|
  |                | INVITE       |                 |
  |                | From: Bob    |                 |
  |                | To: Music Source               |
  |                | (SDP offer,  |                 |
  |                |  rev. hold)  |                 |
  |                |------------->|                 |
  |                | 200 OK       |                 |
  |                | From: Bob    |                 |
  |                | To: Music Source               |
  |                | (SDP answer, |                 |
  |                |  hold)       |                 |
  |                |<-------------|                 |
  |                | ACK          |                 |
  |                | From: Bob    |                 |
  |                | To: Music Source               |
  |                |------------->|                 |
  |                |              | 200 OK          |
  |                |              | From: Carol     |
  |                |              | To: Bob         |
  |                |              | (SDP answer,    |
  |                |              |  hold)          |
  |                |------------------------------->|
  |                |              | ACK             |
  |                |              | From: Carol     |
  |                |              | To: Bob         |
  |                |<-------------------------------|
  |                |              | Music-on-hold RTP
  |                |              |================>|
  |                |              |                 |

Bob terminates the previous dialog with Alice:

  |                |              |                 |
  | BYE            |              |                 |
  | From: Bob      |              |                 |
  | To: Alice      |              |                 |
  |<---------------|              |                 |
  | 200 OK         |              |                 |
  | From: Bob      |              |                 |
  | To: Alice      |              |                 |
  |--------------->|              |                 |
  |                |              |                 |

Bob terminates the MOH dialog for the dialog with Alice:

  |                |              |                 |
  |                | BYE          |                 |
  |                | From: Bob    |                 |
  |                | To: Music Source               |
  |                |------------->|                 |
  |                | 200 OK       |                 |
  |                | From: Music Source             |
  |                | To: Bob      |                 |
  |                |<-------------|                 |
  |                |              |                 |

The new session continues on hold, between Bob and Carol.
]]></artwork>
</figure>

</section>

<section title="Receiving REFER from the Remote UA" anchor="refer">

<t>The executing UA must be prepared to receive a REFER request within
the dialog with the remote UA.  The SDP within the dialog created by
the REFER is negotiated by sending an offerless INVITE (or offerless
re-INVITE) to the MOH source to obtain an offer, and then using that
offer in the INVITE to the refer target.</t>

<t>Similar processing is used for an out-of-dialog REFER whose
Target-Dialog header refers to the dialog with the remote UA.</t>

<t>Continuing the example of <xref target="message-flow"/>, the
executing UA receives an INVITE-with-Replaces that contains an
offer:</t>

<figure>
<artwork><![CDATA[
Bob receives REFER from Alice:

Alice             Bob       Music Source          Carol

  |                |              |                 |
  | REFER          |              |                 |
  | From: Bob      |              |                 |
  | To: Alice      |              |                 |
  | Refer-To: Carol|              |                 |
  |--------------->|              |                 |
  |                | re-INVITE    |                 |
  |                | From: Bob    |                 |
  |                | To: Music Source               |
  |                | (no SDP)     |                 |
  |                |------------->|                 |
  |                | 200 OK       |                 |
  |                | From: Bob    |                 |
  |                | To: Music Source               |
  |                | (SDP offer,  |                 |
  |                |  hold)       |                 |
  |                |<-------------|                 |
  |                |              | INVITE          |
  |                |              | From: Bob       |
  |                |              | To: Carol       |
  |                |              | (SDP offer,     |
  |                |              |  hold)          |
  |                |------------------------------->|
  |                |              | 200 OK          |
  |                |              | From: Bob       |
  |                |              | To: Carol       |
  |                |              | (SDP answer,    |
  |                |              |  rev. hold)     |
  |                |------------------------------->|
  |                | ACK          |                 |
  |                | From: Bob    |                 |
  |                | To: Music Source               |
  |                | (SDP answer, |                 |
  |                |  rev. hold)  |                 |
  |                |------------->|                 |
  |                |              | ACK             |
  |                |              | From: Bob       |
  |                |              | To: Carol       |
  |                |------------------------------->|
  |                |              | Music-on-hold RTP
  |                |              |================>|
  |                |              |                 |

Bob terminates the previous dialog with Alice:

  |                |              |                 |
  | BYE            |              |                 |
  | From: Bob      |              |                 |
  | To: Alice      |              |                 |
  |<---------------|              |                 |
  | 200 OK         |              |                 |
  | From: Bob      |              |                 |
  | To: Alice      |              |                 |
  |--------------->|              |                 |
  |                |              |                 |
]]></artwork>
</figure>

</section>

<section title="Receiving Re-INVITE and UPDATE from the Music-On-Hold Source"
	 anchor="IU-MOH">

<t>It is possible for the MOH source to send a re-INVITE or
UPDATE request, and the executing UA can support doing so in similar
manner as requests from the remote UA.
However, if the MOH source is within the same
administrative domain as the executing UA, the executing UA may have
knowledge that the MOH
source will not (or need not) make such requests, and so can respond
to any such request with a failure response,
avoiding the need to pass the request through.
The 403 (Forbidden) response is suitable for this purpose because
<xref target="RFC3261"/> specifies that this response indicates "the request SHOULD NOT
be repeated".</t>

<t>However, in an environment in which ICE<xref target="RFC5245"/>
is supported, the MOH
source may need to send requests as part of ICE negotiation with the remote UA.
Hence, in environments that support ICE, the executing UA must be able to
pass through requests from the MOH source as well as requests from
the remote UA.</t>

<t>Again, as SDP is passed through, its o= line will need to be
modified.
In some cases, the directionality attributes will need to be
restricted.
</t>

</section>

<section title="Handling Payload Type Numbers" anchor="payload">

<section title="Analysis">

<t>In this technique, the MOH source generates an SDP answer that
the executing UA presents to the remote UA as an answer within the
original dialog.
In basic functionality, this presents no problem, because
<xref target="RFC3264"/> (section 6.1, at the very end) specifies that the
payload type numbers used in either direction of RTP are the ones
specified in the SDP sent by the recipient of the RTP.
Thus, the MOH source will send RTP to the remote UA using the payload type numbers
specified in the offer SDP it received (ultimately) from the remote UA.</t>

<t>But strict compliance to <xref target="RFC3264"/> (section 8.3.2)
requires that payload type
numbers used in SDP may only duplicate the payload type numbers used in
any previous SDP sent in the same direction
if the payload type numbers represent the same media format (codec) as
they did previously.
However, the MOH source has no knowledge of the payload type numbers
previously used in the original dialog, and it may accidentally
specify a different media format for a previously used payload type number in its
answer (or in a subsequently generated INVITE or UPDATE).
This would cause no problem with media decoding, as it cannot send any
format that was not in the remote UA's offer, but it would violate
<xref target="RFC3264"/>.</t>

<t>Strictly speaking, it is impossible to avoid this problem because
the generator of a first answer in its dialog can
choose the payload numbers independently of the payload numbers in the
offer, and the MOH server believes that its answer is first in the dialog.
Thus the only absolute solution is to have the executing UA rewrite
the SDP that passes through it to
reassign payload type numbers, which would also require it to rewrite
the payload type numbers in the RTP packets -- a very undesirable solution.
</t>

<t>The difficulty solving this problem (and similar problems in other situations)
argues that strict adherence should not be required to the rule that
payload type numbers not be reused for different codecs.</t>

<t>The remainder of this section is devoted to describing a technique to
eliminate this problem, in case it is of practical significance in
some application.
We do not expect that user agents would need to implement it in most
applications.</t>

</section>

<section title="Solution to the Problem">

<t>
We can construct a technique that will strictly adhere to the payload type rule 
by exploiting a SHOULD-level requirement in <xref target="RFC3264"/>
(section 6.1):  "In the case of RTP, if a particular codec was referenced with a
specific payload type number in the offer, that same payload type
number SHOULD be used for that codec in the answer."
Or rather, we exploit the "implied requirement" that if a specific payload number
in the offer is used for a particular codec, then the answer should not use that
payload number for a different codec.
If the MOH source obeys this restriction, the executing UA can modify
the offer SDP to "reserve" all payload type numbers that have ever
been offered by the executing UA to prevent the MOH source from
using them for different media formats.
</t>

<t>
When the executing UA is composing the INVITE to the MOH source, it
compiles a list of all the (dynamically-assigned) payload type numbers
and associated media formats
which have been used by it (or by MOH sources on its behalf) in the
original dialog.
(The executing UA must be maintaining a list of all previously used
payload type numbers anyway, in order to comply with
<xref target="RFC3264"/>.)
</t>

<t>
Any payload type number that is present in the offer but has been used
previously by the executing UA in the original dialog for a different
media format is
rewritten to describe a dummy media format.
(One dummy media format name can be used for many payload type
numbers as multiple payload type numbers can refer to the same
media format.)
A payload type number is added to describe the deleted media format,
the number being either previously unused or previously used by the
executing UA for that media format.
</t>

<t>Any further payload type numbers
which have been used by the executing UA in the
original dialog but which are not mapped to a media format in the
current offer are then mapped to a dummy media format.
</t>

<t>
The result is that the modified offer SDP:

<list style="numbers">
<t>offers the same set of
media formats (ignoring dummies) as the original offer SDP (though possibly with
different payload type numbers),
</t>
<t>associates every payload type number
either with a dummy media format or with the media format that the
executing UA has previously used it for, and
</t>
<t>provides a (real or
dummy) media format for every payload type number that the executing
UA has previously used.
</t>
</list>

These properties are sufficient to force an MOH server that obeys the
implied requirement to generate an answer that is a correct answer to the
original offer and is also compatible with previous SDP
from the executing UA.
</t>

<t>Note that any re-INVITEs from the remote UA that the executing UA
passes through to the MOH server require similar modification, as
payload type numbers that the MOH server receives in past offers are not
absolutely reserved against its use (as they have not been sent in
SDP by the MOH server) nor is there a SHOULD-level proscription
against using them in the current answer (as they do not appear in
the current offer).
</t>

<t>This should provide an adequate solution to the problems with
payload type numbers, as it will fail only if (1) the remote UA is
particular that other UAs follow the rule about not redefining
payload type numbers, and (2) the MOH server does not follow the
implied requirement of <xref target="RFC3264"/> section 6.1.</t>

</section>

<section title="Example of the Solution">

<t>Let us show how this process works by modifying the example of <xref
target="message-flow"/> with this specific assignment of supported
codecs:

<list style="empty">
<t>Alice supports formats X and Y</t>
<t>Bob supports formats X and Z</t>
<t>Music Source supports formats Y and Z</t>
</list>

In this case, the SDP exchanges are:

<list style="empty">
<t>F1 offers X and Y, F3 answers X and Z (which cannot be used)</t>
<t>F6 offers X and Y, but F7 offers X, Y, and a place-holder to block use of type 92</t>
<t>F8/F10 answers Y</t>
</list>

The messages that are changed from <xref target="message-flow"/> are:
</t>

<figure>
<artwork><![CDATA[
 F1 INVITE Alice -> Bob

 INVITE sips:bob@biloxi.example.com SIP/2.0
 Via: SIP/2.0/TLS atlanta.example.com:5061
  ;branch=z9hG4bK74bf9
 Max-Forwards: 70
 From: Alice <sips:alice@atlanta.example.com>;tag=1234567
 To: Bob <sips:bob@biloxi.example.com>
 Call-ID: 12345600@atlanta.example.com
 CSeq: 1 INVITE
 Contact: <sips:a8342043f@atlanta.example.com;gr>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces, gruu
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=alice 2890844526 2890844526 IN IP4 atlanta.example.com
 s=
 c=IN IP4 atlanta.example.com
 t=0 0
 m=audio 49170 RTP/AVP 90 91
 a=rtpmap:90 X/8000
 a=rtpmap:91 Y/8000


 F3 200 OK Bob -> Alice

 SIP/2.0 200 OK
 Via: SIP/2.0/TLS atlanta.example.com:5061
  ;branch=z9hG4bK74bf9
  ;received=192.0.2.103
 From: Alice <sips:alice@atlanta.example.com>;tag=1234567
 To: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 1 INVITE
 Contact: <sips:bob@biloxi.example.com>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=bob 2890844527 2890844527 IN IP4 biloxi.example.com
 s=
 c=IN IP4 biloxi.example.com
 t=0 0
 m=audio 3456 RTP/AVP 90 92
 a=rtpmap:90 X/8000
 a=rtpmap:92 Z/8000


 F6 200 OK Alice -> Bob

 SIP/2.0 200 OK
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bK874bk
  ;received=192.0.2.105
 To: Alice <sips:alice@atlanta.example.com>;tag=1234567
 From: Bob <sips:bob@biloxi.example.com>;tag=23431
 Call-ID: 12345600@atlanta.example.com
 CSeq: 712 INVITE
 Contact: <sips:a8342043f@atlanta.example.com;gr>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces, gruu
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=alice 2890844526 2890844526 IN IP4 atlanta.example.com
 s=
 c=IN IP4 atlanta.example.com
 t=0 0
 m=audio 49170 RTP/AVP 90 91
 a=rtpmap:90 X/8000
 a=rtpmap:91 Y/8000
 a=active


 F7 INVITE Bob -> Music Source

 INVITE sips:music@source.example.com SIP/2.0
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bKnashds9
 Max-Forwards: 70
 From: Bob <sips:bob@biloxi.example.com>;tag=02134
 To: Music Source <sips:music@source.example.com>
 Call-ID: 4802029847@biloxi.example.com
 CSeq: 1 INVITE
 Contact: <sips:bob@biloxi.example.com>
 Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY
 Supported: replaces, gruu
 Content-Type: application/sdp
 Content-Length: [omitted]

 v=0
 o=bob 2890844534 2890844534 IN IP4 atlanta.example.com
 s=
 c=IN IP4 atlanta.example.com
 t=0 0
 m=audio 49170 RTP/AVP 90 91 92
 a=rtpmap:90 X/8000
 a=rtpmap:91 Y/8000
 a=rtpmap:92 x-reserved/8000
 a=recvonly


 F8 200 OK Music Source -> Bob

 SIP/2.0 200 OK
 Via: SIP/2.0/TLS biloxi.example.com:5061
  ;branch=z9hG4bKnashds9
  ;received=192.0.2.105
 From: Bob <sips:bob@biloxi.example.com>;tag=02134
 To: Music Source <sips:music@source.example.com>;tag=56323
 Call-ID: 4802029847@biloxi.example.com
 Contact: <sips:music@source.example.com>;automaton
      ;+sip.byeless;+sip.rendering="no"
 CSeq: 1 INVITE
 Content-Length: [omitted]

 v=0
 o=MusicSource 2890844576 2890844576 IN IP4 source.example.com
 s=
 c=IN IP4 source.example.com
 t=0 0
 m=audio 49170 RTP/AVP 91
 a=rtpmap:91 Y/8000
 a=sendonly
]]></artwork>
</figure>

</section>

</section>

<section title="Dialog/Session Timers" anchor="timers-section">

<t>
The executing UA may discover that either the remote UA or the MOH
source wishes to use dialog/session liveness
timers.<xref target="RFC4028"/>
Since the timers verify the liveness of dialogs, not
sessions (despite the terminology of <xref target="RFC4028"/>), the
executing UA can support the timers on each dialog (to the remote UA
and to the MOH source) independently.
(If the executing UA becomes obliged to initiate a refresh
transaction, it must send an offerless UPDATE or re-INVITE, as if it sends an
offer, the remote element has the opportunity to provide an answer
which is different from its previous SDP, which could not easily be
conveyed to the other remote element.)
</t>

</section>

<section title="When the Media Stream Directionality is &quot;inactive&quot;" anchor="direction-inactive">

<t>
The directionality of the media stream in the SDP offer in an INVITE
or re-INVITE to the music source can be "inactive" if the SDP offer
from the remote UA was "sendonly" or "inactive".  Generally, this
happens when the remote UA also has put the call on hold and provided
a directionality of "sendonly".  In this situation, the executing UA
can omit establishing the dialog with the music source (or can
terminate the existing dialog with the music source).
</t>

<t>
If the executing UA uses this optimization, it creates the SDP answer
itself, with directionality "inactive" and using its own RTP/RTCP
ports, and returns that answer to the remote UA.
</t>

<t>
The executing UA must be prepared for the remote UA to send a
re-INVITE with directionality "active" or "recvonly", in which case
the executing UA must initiate a dialog with the music source, as
described above.
</t>

</section>

<section title="Multiple Media Streams" anchor="multiple-streams">

<t>
There may be multiple media streams (multiple m= lines) in any of the
the SDPs involved in the dialogs.  As the SDPs are manipulated, each
media description (each starting with an m= line) is manipulated as
described above for a single media stream, largely independently
of the manipulation of the other media streams.  But there are some
elaborations that the executing UA may implement to achieve specific
effects.
</t>

<t>
If the executing UA desires to present only certain media types as
on-hold media, when passing the offer SDP through, it can reject any
particular media streams by setting the port number in the m= line to
zero.<xref target="RFC3264"/>
This ensures that the answer SDP will also have a
rejection for that m= line.
</t>

<t>
If the executing UA wishes to provide its own on-hold media for a
particular m= line, it can do so by providing the answer information
for that m= line.  The executing UA may decide to do this when the
offer SDP is received (by modifying the m= line to rejected state when
sending it to the music source), or upon receiving the answer from the
music source and discovering that the m= line has been rejected.
</t>

<t>
The executing UA may not want to pass a rejected m= line from the
music source to the remote UA (when the remote UA provided a
non-rejected m= line), and instead provide an answer with
directionality "inactive" (and specifying its own RTP/RTCP ports).
</t>

</section>

</section>

<section title="Advantages" anchor="advantages">

<t>
This technique for providing music-on-hold has advantages over other
methods now in use:

<list style="numbers">

<t>
The original dialog is not transferred to another UA, so the "remote
endpoint URI" displayed by the remote endpoint's user interface and
dialog event package<xref target="RFC4235"/> does not change during
the call, as contrasted to the method in
<xref target="RFC5359"/> section 2.3.
This URI is usually displayed to the user as the the name and number
of the other party on the call, and it is desirable for it not to change
to that of the MOH server.
</t>

<t>
Compared to <xref target="RFC5359"/>, this method does not
require use of an out-of-dialog REFER, which is not otherwise used
much in SIP.
Out-of-dialog REFERs may not be routed correctly, since neither the
From nor Contact URI of the original dialog may route correctly to the remote UA.
Also, out-of-dialog requests to UA URIs may not be handled correctly
by authorization mechanisms.
</t>

<t>
The music-on-hold media are sent directly from the music-on-hold source
to the remote UA, rather than being relayed through the executing UA.
This reduces the computational load on the executing UA and can reduce the load on
the network (by eliminating "hairpinning" of the media through the link serving
the executing UA).
</t>

<t>
The remote UA sees, in the incoming SDP, the address/port that the MOH
source will send MOH media from (assuming that the MOH source follows
the convention of sending its media from its advertised media listening
address/port).
Thus the remote UA will render the MOH media
even if it is filtering incoming media based on originating
address as a media security measure.
</t>

<t>
The technique requires relatively simple manipulation of SDP, and
in particular: (1) does not require a SIP element to modify unrelated SDP to be
acceptable to be sent within an already established sequence of SDP (a
problem with <xref target="I-D.ietf-sipping-service-examples-11"/> section 2.3), and
(2) does not require converting an SDP answer into an SDP offer
(which was a problem with the -00 version of this document, as well as
with  <xref target="I-D.ietf-sipping-service-examples-11"/>).
</t>

</list>

</t>

</section>

<section title="Caveats" anchor="caveats">

<section title="Offering All Available Media Formats" anchor="codec-mgmt">

<t>
Unnecessary failures can happen if SDP offerers do not always offer all media
formats that they support.
Doing so is considered best practice
(<xref target="RFC6337"/> sections 5.1 and 5.3), but some
SIP elements offer only formats that have already been in use in the dialog.
</t>

<t>
An example of how omitting media formats in an offer can lead to
failure is as follows:
Suppose that the UAs in <xref target="message-flow"/> each support the
following media formats:

<list style="empty">
<t>Alice supports formats X and Y</t>
<t>Bob supports formats X and Z</t>
<t>Music Source supports formats Y and Z</t>
</list>

In this case, the SDP exchanges are:

<list style="numbers">

<t>Alice calls Bob:<vspace/>
Alice offers X and Y (message F1)<vspace/>
Bob answers X (F3)
</t>

<t>Bob puts Alice on hold:<vspace/>
Alice (via Bob) offers X and Y (F6 and F7)<vspace/>
Music Source (via Bob) answers Y (F8 and F10)
</t>

<t>Bob takes Alice off hold:<vspace/>
Bob offers X and Z (F11)<vspace/>
Alice answers X (F12)
</t>

</list>

Note that in exchange 2, if Alice assumes that because only format X
is currently in use that she should offer only X, the exchange fails.
In exchange 3, Bob offers formats X and Z, even though neither is
in use at the time (because Bob is not involved in the media streams).
</t>

</section>

<section title="Handling Re-INVITES in a B2BUA" anchor="reinvite">

<t>
Many UAs provide MOH in the interval during which it is processing a
blind transfer, between receiving the REFER and receiving the final
response to the stimulated INVITE.
This process involves switching the user's interface between three
media sources: 
(1) the session of the original dialog,
(2) the session with the MOH server,
and (3) the session of the new dialog;
it involves a number of race conditions that must be handled
correctly.
If the UA is a B2BUA whose "other side" is maintaining a single dialog
with another UA, each switching of media sources potentially causes a
re-INVITE transaction within the other-side dialog.
Since re-INVITEs take time and must be sequenced correctly
(<xref target="RFC3261"/> section 14), such a B2BUA must allow the events
on each side to be non-synchronous and must coordinate them
correctly.
Failing to do so will lead to "glare" errors (491 or 500), leaving the
other-side UA not rendering the correct session.
</t>

</section>

</section>

<section title="Security Considerations" anchor="security">

  <section title="Network security" anchor="network-security">
	<t>Some mechanism outside the scope of this document must
	inform the executing UA of the MOH server that it should use.
	Care must be exercised in selecting the MOH server, because
	signaling information which is part of the original dialog will be
	transmitted along the path from the executing UA to the server.
	If the path between the executing UA and the 
	server is not entirely contained within every network
	domain that contains the executing UA, the signaling between the
	UA and the server may be protected by different network
	security than is applied to the original dialog.</t>

	<t>Care must also be exercised because media information that
	is part of the original dialog will be transmitted along the
	path between the remote UA and the server.  If the path
	between the remote UA and the server does not pass through the
	same network domains as the path between the remote UA and the
	executing UA, the media between the UA and the server may be
	protected by different network security than is applied to the
	original dialog.</t>

	<t>These requirements may be satisfied by selecting a MOH
	server that is in the same administrative and network domain
	as the executing UA, and whose path to all external addresses
	is the same as the UA's path to those addresses.</t>
  </section>

  <section title="SIP (signaling) security" anchor="signal-security">

    <t>The executing UA and the MOH server will usually be within the same
    administrative domain and the SIP signaling path between them will
    lie entirely within that domain.  In this case, the administrator of
    the domain should configure the UA and server to apply to to the
    dialog between them a level of security that is
    appropriate for the administrative domain.</t>

    <t>If the executing UA and the MOH server are not within the same
    administrative domain, the SIP signaling between them should be at
    least as secure as the SIP signaling between the executing UA and
    the remote UA.  Thus, the MOH server should support all of the SIP
    security facilities that are supported by the executing UA, and
    the executing UA should use in its dialog with the MOH server all
    SIP security facilities that are used in its dialog with the
    remote UA.</t>

  </section>

  <section title="RTP (media) security" anchor="media-security">

    <t>The RTP for the MOH media will pass directly between the MOH
    server and the remote UA, and thus may pass outside the
    administrative domain of the executing UA.  While it is uncommon
    for the contents of the MOH media to be sensitive (and the remote
    UA will not usually be generating RTP when it is on-hold), the MOH
    RTP should be at least as secure as the RTP between the executing
    UA and the remote UA.  In order to make this possible, the MOH
    server should support all of
    the RTP security facilities that are supported by the executing
    UA.</t>

    <t>
      It is possible that the remote UA and the MOH server support an
      RTP security facility that the executing UA does not support,
      and that it is desirable to use this facility for the MOH RTP.
      To enable doing so, the executing UA should pass the SDP between the
      remote UA and the MOH server completely, not omitting elements
      that it does not understand.
    </t>

  </section>

  <section title="Media filtering" anchor="media-filtering">

    <t>Some UAs filter incoming RTP based on the address of origin
    as a media security measure, refusing to render the contents of
    RTP packets that originate from an address that is not shown in
    the remote SDP as an RTP destination address.  The remote UA in
    the original dialog
    may use this form of media filtering, and if the executing UA does not
    update the SDP to inform the remote UA of the source address of
    the MOH media, the remote UA may not render the MOH media.  Note
    that the executing UA has no means for detecting that the remote
    UA uses media filtering, so the executing UA must assume that any
    remote UA uses media filtering.</t>

    <t>The technique described in this
    document ensures that any UA that should render MOH media will be
    informed of the source address of the media via the SDP that it
    receives.  This allows such UAs to filter media without
    interfering with MOH operation.</t>

  </section>

</section>

<section title="Acknowledgments" anchor="ack">

<t>
The original version of this proposal was derived from
<xref target="I-D.ietf-sipping-service-examples-11"/> section 2.3
and the similar implementation of MOH in the Snom UA.
Significant improvements to the sequence of operations, allowing
improvements to the SDP handling, were suggested by
Venkatesh<xref target="venkatesh"/>.
</t>

<t>
John Elwell<xref target="elwell"/> pointed out the need for the executing
UA to pass through re-INVITEs/UPDATEs in order to allow ICE
negotiation,
suggested mentioning the role of RTCP listening ports,
suggested the possibility of omitting the dialog to the music
source if the directionality would be "inactive", and pointed that if
there are multiple media streams, the executing UA may want to select which
streams receive MOH.
</t>

<t>
Paul Kyzivat<xref target="kyzivat-1"/><xref target="kyzivat-2"/> pointed
out the difficulties regarding reuse of payload type numbers
and considerations that could be used to avoid those difficulties,
leading to the writing of <xref target="payload"/>.
</t>

<t>
Paul Kyzivat suggested adding <xref target="codec-mgmt"/>
showing why offerers should always include all supported formats.
</t>

<t>
M. Ranganathan pointed out the difficulties experienced by a B2BUA
(<xref target="reinvite"/>) due to the multiple changes of media source.
</t>

<t>
<xref target="codec-mgmt"/> was significantly clarified based on
advice from Attila Sipos<xref target="sipos"/>.
</t>

<t>
The need to discuss dialog/session
timers[<xref target="timers-section"/>] was pointed out by Rifaat
Shekh-Yusef<xref target="shekh-yusef"/>.
</t>

<t>
Robert Sparks clarified the purpose of the "Best Common Practice" status,
leading to revising the intended status of this document to
"Informational".[<xref target="status"/>]
</t>

<t>
  In his Secdir review, Stephen Kent pointed out that the Security
  Considerations should discuss the use of SIP and SDP security features
  by the MOH server.
</t>

<t>
  Numerous improvements to the text were due to reviewers, including Rifaat
  Shekh-Yusef and Richard Barnes.
</t>

</section>

<section title="Revision History" anchor="revision">

<t>[Note to RFC Editor:  Please remove this entire section upon
publication as an RFC.]</t>

<section title="Changes from draft-worley-service-example-00 to draft-worley-service-example-01" anchor="changes-00-01">

<t>
Removed the original "Example Message Flow" and promoted the
"Alternative Example Message Flow" to replace it because of a number
of flaws that were found during the discussion of -00 on the SIPPING
mailing list.
</t>

<t>
Described the use of the sip.rendering feature parameter to indicate
on-hold status.
</t>

</section>

<section title="Changes from draft-worley-service-example-01 to draft-worley-service-example-02" anchor="changes-01-02">

<t>
Added discussion of passing though re-INVITEs and UPDATEs.
</t>

<t>
Added discussion of payload type numbers.
</t>

<t>
Added Acknowledgments section.
</t>

</section>

<section title="Changes from draft-worley-service-example-02 to draft-worley-service-example-03" anchor="changes-02-03">

<t>
Added <xref target="codec-mgmt"/> showing the importance of the
offerer always including all supported media formats.
</t>

<t>
Updated references.
</t>

<t>
Revised handling of payload type numbers when passing offer to MOH
server <xref target="payload"/>, based on observations by Paul Kyzivat.
</t>

</section>

<section title="Changes from draft-worley-service-example-03 to draft-worley-service-example-04" anchor="changes-03-04">

<t>
Added <xref target="reinvite"/> discussing handling of re-INVITEs by
B2BUAs when using this method.
</t>

<t>
Added "avoidance of out-of-dialog REFER" as an advantage.<xref target="advantages"/>
</t>

<t>
Added "automaton", "sip.rendering", and "sip.byeless" feature tags to
the Contact URI of the Music Server in the examples.<xref target="RFC4235"/><xref target="RFC3840"/>
</t>

<t>
Added initial discussion of dialog/session timer support.<xref target="timers-section"/>
</t>

<t>
Revised handling of payload type numbers based on further observations
by Paul Kyzivat<xref target="kyzivat-2"/>.
</t>

</section>

<section title="Changes from draft-worley-service-example-04 to draft-worley-service-example-05" anchor="changes-04-05">

<t>
Changed references to "SPIT" to refer to "media security", per
suggestion by Scott Lawrence.
</t>

<t>
Removed reference to the idea of having the executing UA not maintain
session timers itself, but rather, passing through session timer
negotiation and updates.
Examination showed this idea to be much more complex to implement than
having the executing UA terminate session timers itself for both
dialogs.
(Suggested by Rifaat Shekh-Yusef.)
</t>

<t>
On advice from Robert Sparks, changed the "intended status" from "BCP"
to "Informational", and added a section to explain the change.
</t>

<t>
Noted that the rule on not reusing payload type numbers is undesirable because
it complicates third-party operations (as noted by
Paul Kyzivat<xref target="kyzivat-3"/>).
</t>

</section>

<section title="Changes from draft-worley-service-example-05 to draft-worley-service-example-06" anchor="changes-05-06">

<t>Updated author's contact information.</t>

<t>On suggestion from John Elwell, added mention that the Music
Source's SDP address/port implies its RTCP address/port, which will
be used to receive RTCP.</t>

<t>Updated references to <xref target="RFC5359"/> and
<xref target="I-D.ietf-sipping-service-examples-11"/> to specify the sections of
documents, which are the ones that discuss music on hold.</t>

</section>

<section title="Changes from draft-worley-service-example-06 to draft-worley-service-example-07" anchor="changes-06-07">

<t>Update reference to <xref target="RFC6337"/> to refer to
the -18 version.</t>

</section>

<section title="Changes from draft-worley-service-example-07 to draft-worley-service-example-08" anchor="changes-07-08">

<t>
Sections <xref target="direction-inactive"/> and
<xref target="multiple-streams"/> added at the suggestion of John Elwell.
</t>

</section>

<section title="Changes from draft-worley-service-example-08 to draft-worley-service-example-09" anchor="changes-08-09">

<t>Update reference to <xref target="RFC6337"/> to refer to
RFC 6337.</t>

</section>

<section title="Changes from draft-worley-service-example-09 to draft-worley-service-example-10" anchor="changes-09-10">

<t>Renew Internet-Draft, no changes.</t>

</section>

<section title="Changes from draft-worley-service-example-10 to draft-worley-service-example-11" anchor="changes-10-11">

<t>Renew Internet-Draft, no changes.</t>

</section>

<section title="Changes from draft-worley-service-example-11 to draft-worley-service-example-12" anchor="changes-11-12">

<t>Numerous improvements resulting from Rifaat Shekh-Yusef's review,
includng:</t>

<t>
  Adding examples for how the executing UA processes
  INVITE-with-Replaces and REFER directed toward the dialog with the
  remote UA.
</t>

<t>
  Recommending a 403 response to a re-INVITE/UPDATE request from the MOH server
  if the UA knows that it need not be acted upon.
</t>

</section>

<section title="Changes from draft-worley-service-example-12 to draft-worley-service-example-13" anchor="changes-12-13">

<t>
  Improvements resulting from Richard Barnes' review.
</t>

<t>
  Update the Acknowledgments to credit the reviewers.
</t>

</section>

<section title="Changes from draft-worley-service-example-13 to draft-worley-service-example-14" anchor="changes-13-14">

<t>
  Update RFC and Internet-Draft references to use tags giving their
  numbers/names rather than describing their contents, as suggested in
  the Secdir review by Stephen Kent.
</t>

<t>
  As suggested in the Secdir review by Stephen Kent, add sections to Security
  Considerations regarding use of SIP and SDP security by the MOH server.
</t>

</section>

</section>

</middle>

<back>

<references title="Normative References">

  &rfc3261;
  &rfc3264;
  &rfc4028;
  &rfc4566;

</references>

<references title="Informative References">

  &rfc3840;
  &rfc4235;
  &rfc4961;
  &rfc5245;
  &rfc5359;
  &rfc6337;

<reference anchor="elwell">
<!-- Elwell's e-mail -->
    <front>
	<title>Subject: [Sipping] RE: I-D Action:draft-worley-service-example-00.txt</title>
        <author initials="J." surname="Elwell"><organization/></author>
	<date month="November" year="2007"/>
    </front>
    <seriesInfo name="IETF Sipping mailing list" value="msg14678" />
    <format type="TXT"
            target="http://www1.ietf.org/mail-archive/web/sipping/current/msg14678.html" />
</reference>

<reference anchor="I-D.ietf-sipping-service-examples-11">
<!-- draft-ietf-sipping-service-examples-11 -->
<!-- Note that this reference is specifically to the -11 version, and so
     should not be updated. -->
    <front>
	<title>Session Initiation Protocol Service Examples</title>
        <author initials="A." surname="Johnston"><organization/></author>
        <author initials="R." surname="Sparks"><organization/></author>
        <author initials="C." surname="Cunningham"><organization/></author>
        <author initials="S." surname="Donovan"><organization/></author>
        <author initials="K." surname="Summers"><organization/></author>
	<date month="October" year="2006"/>
    </front>
    <seriesInfo name="I-D" value="draft-ietf-sipping-service-examples-11" />
    <format type="TXT"
            target="http://www.ietf.org/internet-drafts/draft-ietf-sipping-service-examples-11.txt" />
</reference>

<reference anchor="kyzivat-1">
<!-- Kyzivat's e-mail #1 -->
    <front>
	<title>Subject: Re: [Sipping] I-D ACTION:draft-ietf-sipping-service-examples-11.txt</title>
        <author initials="P." surname="Kyzivat"><organization/></author>
	<date month="October" year="2006"/>
    </front>
    <seriesInfo name="IETF Sipping mailing list" value="msg12181" />
    <format type="TXT"
            target="http://www1.ietf.org/mail-archive/web/sipping/current/msg12181.html" />
</reference>

<reference anchor="kyzivat-2">
<!-- Kyzivat's e-mail #2 -->
    <front>
	<title>[Sip-implementors] draft-worley-service-example-02</title>
        <author initials="P." surname="Kyzivat"><organization/></author>
	<date month="September" year="2008"/>
    </front>
    <seriesInfo name="sip-implementors mailing list" value="020426" />
    <format type="TXT"
            target="https://lists.cs.columbia.edu/pipermail/sip-implementors/2008-September/020426.html" />
</reference>

<reference anchor="kyzivat-3">
<!-- Kyzivat's e-mail #3 -->
    <front>
	<title>[Sip-implementors] draft-worley-service-example-02</title>
        <author initials="P." surname="Kyzivat"><organization/></author>
	<date month="September" year="2008"/>
    </front>
    <seriesInfo name="sip-implementors mailing list" value="020387" />
    <format type="TXT"
            target="https://lists.cs.columbia.edu/pipermail/sip-implementors/2008-September/020387.html" />
</reference>

<reference anchor="shekh-yusef">
<!-- Rifaat Shekh-Yusef's e-mail -->
    <front>
	<title>[sipcore]  draft-worley-service-example-03</title>
        <author surname="Rifaat Shekh-Yusef"><organization/></author>
	<date month="July" year="2009"/>
    </front>
    <seriesInfo name="IETF Sipcore mailing list" value="msg00580" />
    <format type="TXT"
            target="http://www.ietf.org/mail-archive/web/sipcore/current/msg00580.html" />
</reference>

<reference anchor="sipos">
<!-- Attila Sipos' e-mail -->
    <front>
	<title>RE: [Sip-implementors] draft-worley-service-example-02</title>
        <author surname="Attila Sipos"><organization/></author>
	<date month="March" year="2009"/>
    </front>
    <seriesInfo name="sip-implementors mailing list" value="022002" />
    <format type="TXT"
            target="https://lists.cs.columbia.edu/pipermail/sip-implementors/2009-March/022002.html" />
</reference>

<reference anchor="venkatesh">
<!-- Venkatesh's e-mail -->
    <front>
	<title>Subject: Re: [Sipping] I-D ACTION:draft-ietf-sipping-service-examples-11.txt</title>
        <author surname="Venkatesh"><organization/></author>
	<date month="October" year="2006"/>
    </front>
    <seriesInfo name="IETF Sipping mailing list" value="msg12180" />
    <format type="TXT"
            target="http://www1.ietf.org/mail-archive/web/sipping/current/msg12180.html" />
</reference>

</references>

</back>

</rfc>
