idnits 2.17.1 draft-ietf-avtext-multiple-clock-rates-04.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The draft header indicates that this document updates RFC3550, but the abstract doesn't seem to mention this, which it should. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year (Using the creation date from RFC3550, updated by this document, for RFC5378 checks: 1998-04-07) -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (April 23, 2012) is 4376 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Obsolete informational reference (is this intentional?): RFC 2629 (Obsoleted by RFC 7749) Summary: 0 errors (**), 0 flaws (~~), 1 warning (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group M. Petit-Huguenin 3 Internet-Draft Unaffiliated 4 Updates: 3550 (if approved) G. Zorn, Ed. 5 Intended status: Standards Track Network Zen 6 Expires: October 25, 2012 April 23, 2012 8 Support for Multiple Clock Rates in an RTP Session 9 draft-ietf-avtext-multiple-clock-rates-04 11 Abstract 13 This document clarifies the RTP specification when different clock 14 rates are used in an RTP session. It also provides guidance on how 15 to interoperate with legacy RTP implementations that use multiple 16 clock rates. 18 Status of this Memo 20 This Internet-Draft is submitted in full conformance with the 21 provisions of BCP 78 and BCP 79. 23 Internet-Drafts are working documents of the Internet Engineering 24 Task Force (IETF). Note that other groups may also distribute 25 working documents as Internet-Drafts. The list of current Internet- 26 Drafts is at http://datatracker.ietf.org/drafts/current/. 28 Internet-Drafts are draft documents valid for a maximum of six months 29 and may be updated, replaced, or obsoleted by other documents at any 30 time. It is inappropriate to use Internet-Drafts as reference 31 material or to cite them other than as "work in progress." 33 This Internet-Draft will expire on October 25, 2012. 35 Copyright Notice 37 Copyright (c) 2012 IETF Trust and the persons identified as the 38 document authors. All rights reserved. 40 This document is subject to BCP 78 and the IETF Trust's Legal 41 Provisions Relating to IETF Documents 42 (http://trustee.ietf.org/license-info) in effect on the date of 43 publication of this document. Please review these documents 44 carefully, as they describe your rights and restrictions with respect 45 to this document. Code Components extracted from this document must 46 include Simplified BSD License text as described in Section 4.e of 47 the Trust Legal Provisions and are provided without warranty as 48 described in the Simplified BSD License. 50 Table of Contents 52 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 53 2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 4 54 3. Legacy RTP . . . . . . . . . . . . . . . . . . . . . . . . . . 4 55 3.1. Different SSRC . . . . . . . . . . . . . . . . . . . . . . 4 56 3.2. Same SSRC . . . . . . . . . . . . . . . . . . . . . . . . 5 57 3.2.1. Monotonic timestamps . . . . . . . . . . . . . . . . . 5 58 3.2.2. Non-monotonic timestamps . . . . . . . . . . . . . . . 6 59 4. Recommendations . . . . . . . . . . . . . . . . . . . . . . . 7 60 4.1. RTP Sender . . . . . . . . . . . . . . . . . . . . . . . . 7 61 4.2. RTP Receiver . . . . . . . . . . . . . . . . . . . . . . . 8 62 5. Security Considerations . . . . . . . . . . . . . . . . . . . 8 63 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 8 64 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 8 65 8. References . . . . . . . . . . . . . . . . . . . . . . . . . . 9 66 8.1. Normative References . . . . . . . . . . . . . . . . . . . 9 67 8.2. Informative References . . . . . . . . . . . . . . . . . . 9 68 Appendix A. Using a fixed clock rate . . . . . . . . . . . . . . 10 69 Appendix B. Behavior of Legacy Implementations . . . . . . . . . 10 70 B.1. libccrtp 2.0.2 . . . . . . . . . . . . . . . . . . . . . . 10 71 B.2. libmediastreamer0 2.6.0 . . . . . . . . . . . . . . . . . 10 72 B.3. libpjmedia 1.0 . . . . . . . . . . . . . . . . . . . . . . 10 73 B.4. Android RTP stack 4.0.3 . . . . . . . . . . . . . . . . . 10 74 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 10 76 1. Introduction 78 The clock rate is a parameter of the payload format. It is often 79 defined as been the same as the sampling rate but it is not always 80 the case (see e.g. the G722 and MPA audio codecs [RFC3551]). 82 An RTP sender can switch between different payloads during the 83 lifetime of an RTP session and because clock rates are defined by 84 payload types, it is possible that the clock rate also varies during 85 an RTP session. Schulzrinne, et al. [RFC3550] lists using multiple 86 clock rates as one of the reasons to not use different payloads on 87 the same SSRC but unfortunately this advice was not always followed 88 and some RTP implementations change the payload in the same SSRC even 89 if the different payloads use different clock rates. 91 This creates three problems: 93 o The method used to calculate the RTP timestamp field in an RTP 94 packet is underspecified. 96 o When the same SSRC is used for different clock rates, it is 97 difficult to know what clock rate was used for the RTP timestamp 98 field in an RTCP SR packet. 100 o When the same SSRC is used for different clock rates, it is 101 difficult to know what clock rate was used for the interarrival 102 jitter field in an RTCP RR packet. 104 Table 1 contains a non-exhaustive list of fields in RTCP packets that 105 uses a clock rate as unit: 107 +---------------------+------------------+-----------+ 108 | Field name | RTCP packet type | Reference | 109 +---------------------+------------------+-----------+ 110 | RTP timestamp | SR | [RFC3550] | 111 | Interarrival jitter | RR | [RFC3550] | 112 | min_jitter | XR Summary Block | [RFC3611] | 113 | max_jitter | XR Summary Block | [RFC3611] | 114 | mean_jitter | XR Summary Block | [RFC3611] | 115 | dev_jitter | XR Summary Block | [RFC3611] | 116 | Interarrival jitter | IJ | [RFC5450] | 117 | RTP timestamp | SMPTETC | [RFC5484] | 118 | Jitter | RSI Jitter Block | [RFC5760] | 119 | Median jitter | RSI Stats Block | [RFC5760] | 120 +---------------------+------------------+-----------+ 122 Table 1 124 This document first tries to list in Section 3 and subsections all of 125 the algorithms known to be used in existing RTP implementations at 126 the time of writing. These sections are not normative. 128 Section 4 and subsections then recommend a unique algorithm that 129 modifies RFC 3550. These sections are normative. 131 2. Terminology 133 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 134 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 135 document are to be interpreted as described in RFC 2119 [RFC2119]. 136 In addition, this document uses the following terms: 138 Clock rate The multiplier used to convert from a wallclock value 139 in seconds to an equivalent RTP timestamp value 140 (without the fixed random offset). Note that RFC 3550 141 uses various terms like "clock frequency", "media 142 clock rate", "timestamp unit", "timestamp frequency", 143 and "RTP timestamp clock rate" as synonymous to clock 144 rate. 146 RTP Sender A logical network element that sends RTP packets, 147 sends RTCP SR packets, and receives RTCP RR packets. 149 RTP Receiver A logical network element that receives RTP packets, 150 receives RTCP SR packets, and sends RTCP RR packets. 152 3. Legacy RTP 154 The following sections describe the various ways legacy RTP 155 implementations behave when multiple clock rates are used. Legacy 156 RTP refers to RFC 3550 without the modifications introduced by this 157 document. 159 3.1. Different SSRC 161 One way of managing multiple clock rates is to use a different SSRC 162 for each different clock rate, as in this case there is no ambiguity 163 on the clock rate used by fields in the RTCP packets. This method 164 also seems to be the original intent of RTP as can be deduced from 165 points 2 and 3 of section 5.2 of RFC 3550. 167 On the other hand changing the SSRC can be a problem for some 168 implementations designed to work only with unicast IP addresses, 169 where having multiple SSRCs is considered a corner case. Lip 170 synchronization can also be a problem in the interval between the 171 beginning of the new stream and the first RTCP SR packet. This is 172 not different than what happen at the beginning of the RTP session 173 but it can be more annoying for the end-user. 175 3.2. Same SSRC 177 The simplest way of managing multiple clock rates is to use the same 178 SSRC for all the payload types regardless of the clock rates. 180 Unfortunately there is no clear definition on how the RTP timestamp 181 should be calculated in this case. The following subsections present 182 the algorithms used in the field. 184 3.2.1. Monotonic timestamps 186 This method of calculating the RTP timestamp ensures that the value 187 increases monotonically. The formula used by this method is as 188 follows: 190 timestamp = previous_timestamp 191 + (current_capture_time - previous_capture_time) 192 * current_clock_rate 194 The problem with this method is that the jitter calculation on the 195 receiving side gives an invalid result during the transition between 196 two clock rates, as shown in Table 2. The capture and arrival time 197 are in seconds, starting at the beginning of the capture of the first 198 packet; clock rate is in Hz; the RTP timestamp does not include the 199 random offset; the transit, jitter, and average jitter use the clock 200 rate as unit. 202 +-------+-------+-----------+---------+---------+--------+----------+ 203 | Capt. | Clock | RTP | Arrival | Transit | Jitter | Average | 204 | time | rate | timestamp | time | | | jitter | 205 +-------+-------+-----------+---------+---------+--------+----------+ 206 | 0 | 8000 | 0 | 0.1 | 800 | | | 207 | 0.02 | 8000 | 160 | 0.12 | 800 | 0 | 0 | 208 | 0.04 | 8000 | 320 | 0.14 | 800 | 0 | 0 | 209 | 0.06 | 8000 | 480 | 0.16 | 800 | 0 | 0 | 210 | 0.08 | 16000 | 800 | 0.18 | 2080 | 480 | 30 | 211 | 0.1 | 16000 | 1120 | 0.2 | 2080 | 0 | 28 | 212 | 0.12 | 16000 | 1440 | 0.22 | 2080 | 0 | 26 | 213 | 0.14 | 8000 | 1600 | 0.24 | 320 | 720 | 70 | 214 | 0.16 | 8000 | 1760 | 0.26 | 320 | 0 | 65 | 215 +-------+-------+-----------+---------+---------+--------+----------+ 217 Table 2 219 Calculating the correct transit time on the receiving side can be 220 done by using the following formulas: 222 1. current_time_capture = current_timestamp - previous_timestamp) / 223 current_clock_rate + previous_time_capture 225 2. transit = current_clock_rate * (time_arrival - 226 current_time_capture) 228 3. previous_time_capture = current_time_capture 230 The main problem with this method, in addition to the fact that the 231 jitter calculation described in RFC 3550 cannot be used, is that is 232 it dependent on the previous RTP packets, packets that can be 233 reordered or lost in the network. 235 3.2.2. Non-monotonic timestamps 237 An alternate way of generating the RTP timestamps is to use the 238 following formula: 240 timestamp = capture_time * clock_rate 242 With this formula, the jitter calculation is correct but the RTP 243 timestamp values are no longer increasing monotonically as shown in 244 Table 3. RFC 3550 states that "[t]he sampling instant MUST be 245 derived from a clock that increments monotonically[...]" but nowhere 246 says that the RTP timestamp must increment monotonically. 248 +-------+-------+-----------+---------+---------+--------+----------+ 249 | Capt. | Clock | RTP | Arrival | Transit | Jitter | Average | 250 | time | rate | timestamp | time | | | jitter | 251 +-------+-------+-----------+---------+---------+--------+----------+ 252 | 0 | 8000 | 0 | 0.1 | 800 | | | 253 | 0.02 | 8000 | 160 | 0.12 | 800 | 0 | 0 | 254 | 0.04 | 8000 | 320 | 0.14 | 800 | 0 | 0 | 255 | 0.06 | 8000 | 480 | 0.16 | 800 | 0 | 0 | 256 | 0.08 | 16000 | 1280 | 0.18 | 1600 | 0 | 0 | 257 | 0.1 | 16000 | 1600 | 0.2 | 1600 | 0 | 0 | 258 | 0.12 | 16000 | 1920 | 0.22 | 1600 | 0 | 0 | 259 | 0.14 | 8000 | 1120 | 0.24 | 800 | 0 | 0 | 260 | 0.16 | 8000 | 1280 | 0.26 | 800 | 0 | 0 | 261 +-------+-------+-----------+---------+---------+--------+----------+ 263 Table 3 265 The advantage with this method is that it works with the jitter 266 calculation described in RFC 3550, as long as the correct clock rates 267 are used. It seems that this is what most implementations are using. 269 4. Recommendations 271 4.1. RTP Sender 273 An RTP Sender with RTCP turned off (i.e. by setting the RS and RR 274 bandwidth modifiers [RFC3556] to 0) SHOULD use a different SSRC for 275 each different clock rate but MAY use different clock rates on the 276 same SSRC as long as the RTP timestamp without the random offset is 277 calculated as explained below: 279 [[This was designed to help VoIP implementations who anyway never 280 cared about RTCP. Do we want to keep this?]] 282 Each time the clock rate changes, the start_offset and capture_start 283 values are calculated with the following formulas: 285 start_offset = (capture_time - capture_start) * previous_clock_rate 286 capture_start = capture_time 288 For the first RTP packet, the values are initialized with the 289 following values: 291 start_offset = 0 292 capture_start = capture_time 294 After eventually updating these values, the RTP timestamp is 295 calculated with the following formula: 297 timestamp = (capture_time - capture_start) * clock_rate + 298 start_offset 300 Note that in all the formulas, capture_time is the first instant the 301 new timestamp rate is used. 303 An RTP Sender with RTCP turned on MUST use a different SSRC for each 304 different clock rate. An RTCP BYE MUST be sent and a new SSRC MUST 305 be used if the clock rate switches back to a value already seen in 306 the RTP stream. 308 To accelerate lip synchronization, the next compound RTCP packet sent 309 by the RTP sender MUST contain multiple SR packets, the first one 310 containing the mapping for the current clock rate and the next SR 311 packets containing the mapping for the other clock rates seen during 312 the last period. 314 [[Some legacy implementations may dislike receiving multiple SR 315 packets. What should we do?]] 317 The RTP extension defined in Perkins & Schierl [RFC6051] MAY be used 318 to accelerate the synchronization. 320 4.2. RTP Receiver 322 An RTP Receiver MUST calculate the jitter using the following 323 formula: 325 D(i,j) = (arrival_time_j * clock_rate_i - timestamp_j) - 326 (arrival_time_i * clock_rate_i - timestamp_i) 328 An RTP Receiver MUST be able to handle a compound RTCP packet with 329 multiple SR packets. 331 For interoperability with legacy RTP implementations, an RTP receiver 332 MAY use the information in two consecutive SR packets to calculate 333 the clock rate used, i.e. if Ni is the NTP timestamp for the SR 334 packet i, Ri the RTP timestamp for the SR packet i and Nj and Rj the 335 NTP timestamp and RTP timestamp for the previous SR packet j, then 336 the clock rate can be guessed as the closest to (Ri - Rj) / (Ni - 337 Nj). 339 5. Security Considerations 341 TBD 343 6. IANA Considerations 345 This document requires no IANA actions. 347 7. Acknowledgements 349 Thanks to Colin Perkins, Ali C. Begen and Magnus Westerlund for their 350 comments, suggestions and questions that helped to improve this 351 document. 353 Thanks to Robert Sparks and the attendees of SIPit 26 for the survey 354 on multiple clock rates interoperability. 356 This document was written with the xml2rfc tool described in Rose 357 [RFC2629]. 359 8. References 361 8.1. Normative References 363 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 364 Requirement Levels", BCP 14, RFC 2119, March 1997. 366 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 367 Jacobson, "RTP: A Transport Protocol for Real-Time 368 Applications", STD 64, RFC 3550, July 2003. 370 8.2. Informative References 372 [I-D.ietf-avt-variable-rate-audio] 373 Wenger, S. and C. Perkins, "RTP Timestamp Frequency for 374 Variable Rate Audio Codecs", 375 draft-ietf-avt-variable-rate-audio-00 (work in progress), 376 October 2004. 378 [RFC2629] Rose, M., "Writing I-Ds and RFCs using XML", RFC 2629, 379 June 1999. 381 [RFC3551] Schulzrinne, H. and S. Casner, "RTP Profile for Audio and 382 Video Conferences with Minimal Control", STD 65, RFC 3551, 383 July 2003. 385 [RFC3556] Casner, S., "Session Description Protocol (SDP) Bandwidth 386 Modifiers for RTP Control Protocol (RTCP) Bandwidth", 387 RFC 3556, July 2003. 389 [RFC3611] Friedman, T., Caceres, R., and A. Clark, "RTP Control 390 Protocol Extended Reports (RTCP XR)", RFC 3611, 391 November 2003. 393 [RFC5450] Singer, D. and H. Desineni, "Transmission Time Offsets in 394 RTP Streams", RFC 5450, March 2009. 396 [RFC5484] Singer, D., "Associating Time-Codes with RTP Streams", 397 RFC 5484, March 2009. 399 [RFC5760] Ott, J., Chesterfield, J., and E. Schooler, "RTP Control 400 Protocol (RTCP) Extensions for Single-Source Multicast 401 Sessions with Unicast Feedback", RFC 5760, February 2010. 403 [RFC6051] Perkins, C. and T. Schierl, "Rapid Synchronisation of RTP 404 Flows", RFC 6051, November 2010. 406 Appendix A. Using a fixed clock rate 408 An alternate way of fixing the multiple clock rates issue was 409 proposed in [I-D.ietf-avt-variable-rate-audio]. This document 410 proposed to define a unified clock rate, but the proposal was 411 rejected at IETF 61. 413 Appendix B. Behavior of Legacy Implementations 415 B.1. libccrtp 2.0.2 417 This library uses the formula described in Section 3.2.2. 419 Note that this library uses gettimeofday(2) which is not guaranteed 420 to increment monotonically, like when the clock is adjusted by NTP. 422 B.2. libmediastreamer0 2.6.0 424 This library (which uses the oRTP library) uses the formula described 425 in Section 3.2.2. 427 Note that in some environments this library uses gettimeofday(2) 428 which is not guaranteed to increment monotonically. 430 B.3. libpjmedia 1.0 432 This library uses the formula described in Section 3.2.2. 434 B.4. Android RTP stack 4.0.3 436 This library changes the SSRC each time the format changes, as 437 described in Section 3.1. 439 Authors' Addresses 441 Marc Petit-Huguenin 442 Unaffiliated 444 Email: petithug@acm.org 445 Glen Zorn (editor) 446 Network Zen 447 227/358 Thanon Sanphawut 448 Bang Na, Bangkok 10260 449 Thailand 451 Phone: +66 (0) 87-0404617 452 Email: glenzorn@gmail.com