idnits 2.17.1 draft-ietf-avtext-multiple-clock-rates-06.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 (October 22, 2012) is 4194 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: April 25, 2013 October 22, 2012 8 Support for Multiple Clock Rates in an RTP Session 9 draft-ietf-avtext-multiple-clock-rates-06 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 April 25, 2013. 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 (with RTCP) . . . . . . . . . . . . . . . . . . 7 61 4.2. RTP Sender (without RTCP) . . . . . . . . . . . . . . . . 7 62 4.3. RTP Receiver . . . . . . . . . . . . . . . . . . . . . . . 8 63 5. Security Considerations . . . . . . . . . . . . . . . . . . . 8 64 6. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 8 65 7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 8 66 8. References . . . . . . . . . . . . . . . . . . . . . . . . . . 8 67 8.1. Normative References . . . . . . . . . . . . . . . . . . . 8 68 8.2. Informative References . . . . . . . . . . . . . . . . . . 9 69 Appendix A. Using a Fixed Clock Rate . . . . . . . . . . . . . . 9 70 Appendix B. Behavior of Legacy Implementations . . . . . . . . . 10 71 B.1. libccrtp 2.0.2 . . . . . . . . . . . . . . . . . . . . . . 10 72 B.2. libmediastreamer0 2.6.0 . . . . . . . . . . . . . . . . . 10 73 B.3. libpjmedia 1.0 . . . . . . . . . . . . . . . . . . . . . . 10 74 B.4. Android RTP stack 4.0.3 . . . . . . . . . . . . . . . . . 10 75 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 10 77 1. Introduction 79 The clock rate is a parameter of the payload format. It is often 80 defined as been the same as the sampling rate but it is not always 81 the case (see e.g. the G722 and MPA audio codecs [RFC3551]). 83 An RTP sender can switch between different payloads during the 84 lifetime of an RTP session and because clock rates are defined by 85 payload types, it is possible that the clock rate also varies during 86 an RTP session. Schulzrinne, et al. [RFC3550] lists using multiple 87 clock rates as one of the reasons to not use different payloads on 88 the same SSRC but unfortunately this advice was not always followed 89 and some RTP implementations change the payload in the same SSRC even 90 if the different payloads use different clock rates. 92 This creates three problems: 94 o The method used to calculate the RTP timestamp field in an RTP 95 packet is underspecified. 97 o When the same SSRC is used for different clock rates, it is 98 difficult to know what clock rate was used for the RTP timestamp 99 field in an RTCP SR packet. 101 o When the same SSRC is used for different clock rates, it is 102 difficult to know what clock rate was used for the interarrival 103 jitter field in an RTCP RR packet. 105 Table 1 contains a non-exhaustive list of fields in RTCP packets that 106 uses a clock rate as unit: 108 +---------------------+------------------+-----------+ 109 | Field name | RTCP packet type | Reference | 110 +---------------------+------------------+-----------+ 111 | RTP timestamp | SR | [RFC3550] | 112 | Interarrival jitter | RR | [RFC3550] | 113 | min_jitter | XR Summary Block | [RFC3611] | 114 | max_jitter | XR Summary Block | [RFC3611] | 115 | mean_jitter | XR Summary Block | [RFC3611] | 116 | dev_jitter | XR Summary Block | [RFC3611] | 117 | Interarrival jitter | IJ | [RFC5450] | 118 | RTP timestamp | SMPTETC | [RFC5484] | 119 | Jitter | RSI Jitter Block | [RFC5760] | 120 | Median jitter | RSI Stats Block | [RFC5760] | 121 +---------------------+------------------+-----------+ 123 Table 1 125 This document first tries to list in Section 3 and subsections all of 126 the algorithms known to be used in existing RTP implementations at 127 the time of writing. These sections are not normative. 129 Section 4 and subsections then recommend a unique algorithm that 130 modifies RFC 3550. These sections are normative. 132 2. Terminology 134 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 135 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 136 document are to be interpreted as described in RFC 2119 [RFC2119]. 137 In addition, this document uses the following terms: 139 Clock rate The multiplier used to convert from a wallclock value 140 in seconds to an equivalent RTP timestamp value 141 (without the fixed random offset). Note that RFC 3550 142 uses various terms like "clock frequency", "media 143 clock rate", "timestamp unit", "timestamp frequency", 144 and "RTP timestamp clock rate" as synonymous to clock 145 rate. 147 RTP Sender A logical network element that sends RTP packets, 148 sends RTCP SR packets, and receives RTCP RR packets. 150 RTP Receiver A logical network element that receives RTP packets, 151 receives RTCP SR packets, and sends RTCP RR packets. 153 3. Legacy RTP 155 The following sections describe the various ways legacy RTP 156 implementations behave when multiple clock rates are used. Legacy 157 RTP refers to RFC 3550 without the modifications introduced by this 158 document. 160 3.1. Different SSRC 162 One way of managing multiple clock rates is to use a different SSRC 163 for each different clock rate, as in this case there is no ambiguity 164 on the clock rate used by fields in the RTCP packets. This method 165 also seems to be the original intent of RTP as can be deduced from 166 points 2 and 3 of section 5.2 of RFC 3550. 168 On the other hand changing the SSRC can be a problem for some 169 implementations designed to work only with unicast IP addresses, 170 where having multiple SSRCs is considered a corner case. Lip 171 synchronization can also be a problem in the interval between the 172 beginning of the new stream and the first RTCP SR packet. This is 173 not different than what happen at the beginning of the RTP session 174 but it can be more annoying for the end-user. 176 3.2. Same SSRC 178 The simplest way of managing multiple clock rates is to use the same 179 SSRC for all the payload types regardless of the clock rates. 181 Unfortunately there is no clear definition on how the RTP timestamp 182 should be calculated in this case. The following subsections present 183 the algorithms used in the field. 185 3.2.1. Monotonic timestamps 187 This method of calculating the RTP timestamp ensures that the value 188 increases monotonically. The formula used by this method is as 189 follows: 191 timestamp = previous_timestamp 192 + (current_capture_time - previous_capture_time) 193 * current_clock_rate 195 The problem with this method is that the jitter calculation on the 196 receiving side gives an invalid result during the transition between 197 two clock rates, as shown in Table 2. The capture and arrival time 198 are in seconds, starting at the beginning of the capture of the first 199 packet; clock rate is in Hz; the RTP timestamp does not include the 200 random offset; the transit, jitter, and average jitter use the clock 201 rate as unit. 203 +-------+-------+-----------+---------+---------+--------+----------+ 204 | Capt. | Clock | RTP | Arrival | Transit | Jitter | Average | 205 | time | rate | timestamp | time | | | jitter | 206 +-------+-------+-----------+---------+---------+--------+----------+ 207 | 0 | 8000 | 0 | 0.1 | 800 | | | 208 | 0.02 | 8000 | 160 | 0.12 | 800 | 0 | 0 | 209 | 0.04 | 8000 | 320 | 0.14 | 800 | 0 | 0 | 210 | 0.06 | 8000 | 480 | 0.16 | 800 | 0 | 0 | 211 | 0.08 | 16000 | 800 | 0.18 | 2080 | 480 | 30 | 212 | 0.1 | 16000 | 1120 | 0.2 | 2080 | 0 | 28 | 213 | 0.12 | 16000 | 1440 | 0.22 | 2080 | 0 | 26 | 214 | 0.14 | 8000 | 1600 | 0.24 | 320 | 720 | 70 | 215 | 0.16 | 8000 | 1760 | 0.26 | 320 | 0 | 65 | 216 +-------+-------+-----------+---------+---------+--------+----------+ 218 Table 2 220 Calculating the correct transit time on the receiving side can be 221 done by using the following formulas: 223 1. current_capture_time = (current_timestamp - previous_timestamp) / 224 current_clock_rate + previous_capture_time 226 2. transit = current_clock_rate * (arrival_time - 227 current_capture_time) 229 3. previous_capture_time = current_capture_time 231 The main problem with this method, in addition to the fact that the 232 jitter calculation described in RFC 3550 cannot be used, is that is 233 it dependent on the previous RTP packets, packets that can be 234 reordered or lost in the network. 236 3.2.2. Non-monotonic timestamps 238 An alternate way of generating the RTP timestamps is to use the 239 following formula: 241 timestamp = capture_time * clock_rate 243 With this formula, the jitter calculation is correct but the RTP 244 timestamp values are no longer increasing monotonically as shown in 245 Table 3. RFC 3550 states that "[t]he sampling instant MUST be 246 derived from a clock that increments monotonically[...]" but nowhere 247 says that the RTP timestamp must increment monotonically. 249 +-------+-------+-----------+---------+---------+--------+----------+ 250 | Capt. | Clock | RTP | Arrival | Transit | Jitter | Average | 251 | time | rate | timestamp | time | | | jitter | 252 +-------+-------+-----------+---------+---------+--------+----------+ 253 | 0 | 8000 | 0 | 0.1 | 800 | | | 254 | 0.02 | 8000 | 160 | 0.12 | 800 | 0 | 0 | 255 | 0.04 | 8000 | 320 | 0.14 | 800 | 0 | 0 | 256 | 0.06 | 8000 | 480 | 0.16 | 800 | 0 | 0 | 257 | 0.08 | 16000 | 1280 | 0.18 | 1600 | 0 | 0 | 258 | 0.1 | 16000 | 1600 | 0.2 | 1600 | 0 | 0 | 259 | 0.12 | 16000 | 1920 | 0.22 | 1600 | 0 | 0 | 260 | 0.14 | 8000 | 1120 | 0.24 | 800 | 0 | 0 | 261 | 0.16 | 8000 | 1280 | 0.26 | 800 | 0 | 0 | 262 +-------+-------+-----------+---------+---------+--------+----------+ 264 Table 3 266 The advantage with this method is that it works with the jitter 267 calculation described in RFC 3550, as long as the correct clock rates 268 are used. It seems that this is what most implementations are using. 270 4. Recommendations 272 The following subsections describe behavioral recommendations for RTP 273 senders (with and without RTCP) and RTP receivers. 275 4.1. RTP Sender (with RTCP) 277 An RTP Sender with RTCP turned on MUST use a different SSRC for each 278 different clock rate. An RTCP BYE MUST be sent and a new SSRC MUST 279 be used if the clock rate switches back to a value already seen in 280 the RTP stream. 282 To accelerate lip synchronization, the next compound RTCP packet sent 283 by the RTP sender MUST contain multiple SR packets, the first one 284 containing the mapping for the current clock rate and the next SR 285 packets containing the mapping for the other clock rates seen during 286 the last period. 288 The RTP extension defined in Perkins & Schierl [RFC6051] MAY be used 289 to accelerate the synchronization. 291 4.2. RTP Sender (without RTCP) 293 An RTP Sender with RTCP turned off (i.e. by setting the RS and RR 294 bandwidth modifiers [RFC3556] to 0) SHOULD use a different SSRC for 295 each different clock rate but MAY use different clock rates on the 296 same SSRC as long as the RTP timestamp is calculated as explained 297 below: 299 Each time the clock rate changes, the start_offset and capture_start 300 values are calculated with the following formulas: 302 start_offset += (capture_time - capture_start) * previous_clock_rate 303 capture_start = capture_time 305 For the first RTP packet, the values are initialized with the 306 following values: 308 start_offset = random_initial_offset 309 capture_start = capture_time 311 After eventually updating these values, the RTP timestamp is 312 calculated with the following formula: 314 timestamp = (capture_time - capture_start) * clock_rate 315 + start_offset 317 Note that in all the formulas, capture_time is the first instant the 318 new timestamp rate is used. 320 4.3. 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 5. Security Considerations 333 This document is not believed to effect the security of the RTP 334 sessions described here in any way. 336 6. IANA Considerations 338 This document requires no IANA actions. 340 7. Acknowledgements 342 Thanks to Colin Perkins, Ali C. Begen, Harald Alvestrand, Qin Wu and 343 Magnus Westerlund for their comments, suggestions and questions that 344 helped to improve this document. 346 Thanks to Robert Sparks and the attendees of SIPit 26 for the survey 347 on multiple clock rates interoperability. 349 This document was written with the xml2rfc tool described in Rose 350 [RFC2629]. 352 8. References 354 8.1. Normative References 356 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 357 Requirement Levels", BCP 14, RFC 2119, March 1997. 359 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 360 Jacobson, "RTP: A Transport Protocol for Real-Time 361 Applications", STD 64, RFC 3550, July 2003. 363 8.2. Informative References 365 [I-D.ietf-avt-variable-rate-audio] 366 Wenger, S. and C. Perkins, "RTP Timestamp Frequency for 367 Variable Rate Audio Codecs", 368 draft-ietf-avt-variable-rate-audio-00 (work in progress), 369 October 2004. 371 [RFC2629] Rose, M., "Writing I-Ds and RFCs using XML", RFC 2629, 372 June 1999. 374 [RFC3551] Schulzrinne, H. and S. Casner, "RTP Profile for Audio and 375 Video Conferences with Minimal Control", STD 65, RFC 3551, 376 July 2003. 378 [RFC3556] Casner, S., "Session Description Protocol (SDP) Bandwidth 379 Modifiers for RTP Control Protocol (RTCP) Bandwidth", 380 RFC 3556, July 2003. 382 [RFC3611] Friedman, T., Caceres, R., and A. Clark, "RTP Control 383 Protocol Extended Reports (RTCP XR)", RFC 3611, 384 November 2003. 386 [RFC5450] Singer, D. and H. Desineni, "Transmission Time Offsets in 387 RTP Streams", RFC 5450, March 2009. 389 [RFC5484] Singer, D., "Associating Time-Codes with RTP Streams", 390 RFC 5484, March 2009. 392 [RFC5760] Ott, J., Chesterfield, J., and E. Schooler, "RTP Control 393 Protocol (RTCP) Extensions for Single-Source Multicast 394 Sessions with Unicast Feedback", RFC 5760, February 2010. 396 [RFC6051] Perkins, C. and T. Schierl, "Rapid Synchronisation of RTP 397 Flows", RFC 6051, November 2010. 399 Appendix A. Using a Fixed Clock Rate 401 An alternate way of fixing the multiple clock rates issue was 402 proposed in [I-D.ietf-avt-variable-rate-audio]. This document 403 proposed to define a unified clock rate, but the proposal was 404 rejected at IETF 61. 406 Appendix B. Behavior of Legacy Implementations 408 B.1. libccrtp 2.0.2 410 This library uses the formula described in Section 3.2.2. 412 Note that this library uses gettimeofday(2) which is not guaranteed 413 to increment monotonically, like when the clock is adjusted by NTP. 415 B.2. libmediastreamer0 2.6.0 417 This library (which uses the oRTP library) uses the formula described 418 in Section 3.2.2. 420 Note that in some environments this library uses gettimeofday(2) 421 which is not guaranteed to increment monotonically. 423 B.3. libpjmedia 1.0 425 This library uses the formula described in Section 3.2.2. 427 B.4. Android RTP stack 4.0.3 429 This library changes the SSRC each time the format changes, as 430 described in Section 3.1. 432 Authors' Addresses 434 Marc Petit-Huguenin 435 Unaffiliated 437 Email: petithug@acm.org 439 Glen Zorn (editor) 440 Network Zen 441 227/358 Thanon Sanphawut 442 Bang Na, Bangkok 10260 443 Thailand 445 Phone: +66 (0) 909-201060 446 Email: glenzorn@gmail.com