idnits 2.17.1 draft-ietf-avtext-multiple-clock-rates-02.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 (January 3, 2012) is 4490 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 AVTEXT M. Petit-Huguenin 3 Internet-Draft Unaffiliated 4 Updates: 3550 (if approved) January 3, 2012 5 Intended status: Standards Track 6 Expires: July 6, 2012 8 Support for multiple clock rates in an RTP session 9 draft-ietf-avtext-multiple-clock-rates-02 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 July 6, 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 . . . . . . . . . . . . . . . . . . . . . . . . . 4 53 2. Legacy RTP . . . . . . . . . . . . . . . . . . . . . . . . . . 5 54 2.1. Different SSRC . . . . . . . . . . . . . . . . . . . . . . 5 55 2.2. Same SSRC . . . . . . . . . . . . . . . . . . . . . . . . 5 56 2.2.1. Monotonic timestamps . . . . . . . . . . . . . . . . . 5 57 2.2.2. Non-monotonic timestamps . . . . . . . . . . . . . . . 6 58 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 7 59 4. Recommendations . . . . . . . . . . . . . . . . . . . . . . . 7 60 4.1. RTP Sender . . . . . . . . . . . . . . . . . . . . . . . . 8 61 4.2. RTP Receiver . . . . . . . . . . . . . . . . . . . . . . . 9 62 5. Interoperability Analysis . . . . . . . . . . . . . . . . . . 9 63 6. Security Considerations . . . . . . . . . . . . . . . . . . . 9 64 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 9 65 8. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . 9 66 9. References . . . . . . . . . . . . . . . . . . . . . . . . . . 10 67 9.1. Normative References . . . . . . . . . . . . . . . . . . . 10 68 9.2. Informative References . . . . . . . . . . . . . . . . . . 10 69 Appendix A. Using a fixed clock rate . . . . . . . . . . . . . . 11 70 Appendix B. Behavior of legacy implementations . . . . . . . . . 11 71 B.1. libccrtp 2.0.2 . . . . . . . . . . . . . . . . . . . . . . 11 72 B.2. libmediastreamer0 2.6.0 . . . . . . . . . . . . . . . . . 11 73 B.3. libpjmedia 1.0 . . . . . . . . . . . . . . . . . . . . . . 11 74 B.4. Android RTP stack 4.0.3 . . . . . . . . . . . . . . . . . 11 75 Appendix C. Release notes . . . . . . . . . . . . . . . . . . . . 11 76 C.1. Modifications between 77 draft-ietf-avtext-multiple-clock-rates-02 and 78 draft-ietf-avtext-multiple-clock-rates-01 . . . . . . . . 11 79 C.2. Modifications between 80 draft-ietf-avtext-multiple-clock-rates-01 and 81 draft-ietf-avtext-multiple-clock-rates-00 . . . . . . . . 12 82 C.3. Modifications between 83 draft-ietf-avtext-multiple-clock-rates-00 and 84 draft-petithuguenin-avtext-multiple-clock-rates-01 . . . . 12 85 C.4. Modifications between 86 draft-petithuguenin-avtext-multiple-clock-rates-01 and 87 draft-petithuguenin-avtext-multiple-clock-rates-00 . . . . 12 88 C.5. Modifications between 89 draft-petithuguenin-avtext-multiple-clock-rates-00 and 90 draft-petithuguenin-avt-multiple-clock-rates-03 . . . . . 12 91 C.6. Modifications between 92 draft-petithuguenin-avt-multiple-clock-rates-03 and 93 draft-petithuguenin-avt-multiple-clock-rates-02 . . . . . 12 94 C.7. Modifications between 95 draft-petithuguenin-avt-multiple-clock-rates-02 and 96 draft-petithuguenin-avt-multiple-clock-rates-01 . . . . . 12 97 C.8. Modifications between 98 draft-petithuguenin-avt-multiple-clock-rates-01 and 99 draft-petithuguenin-avt-multiple-clock-rates-00 . . . . . 13 100 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . . 13 102 1. Introduction 104 The clock rate is a parameter of the payload format. It is often 105 defined as been the same as the sampling rate but it is not always 106 the case (see e.g. the G722 and MPA audio codecs in [RFC3551]). 108 An RTP sender can switch between different payloads during the 109 lifetime of an RTP session and because clock rates are defined by 110 payload types, it is possible that the clock rate also varies during 111 an RTP session. RTP [RFC3550] lists using multiple clock rates as 112 one of the reasons to not use different payloads on the same SSRC but 113 unfortunately this advice was not always followed and some RTP 114 implementations change the payload in the same SSRC even if the 115 different payloads use different clock rates. 117 This creates three problems: 118 o The method used to calculate the RTP timestamp field in an RTP 119 packet is underspecified. 120 o When the same SSRC is used for different clock rates, it is 121 difficult to know what clock rate was used for the RTP timestamp 122 field in an RTCP SR packet. 123 o When the same SSRC is used for different clock rates, it is 124 difficult to know what clock rate was used for the interarrival 125 jitter field in an RTCP RR packet. 127 Table 1 contains a non-exhaustive list of fields in RTCP packets that 128 uses a clock rate as unit: 130 +---------------------+------------------+-----------+ 131 | Field name | RTCP packet type | Reference | 132 +---------------------+------------------+-----------+ 133 | RTP timestamp | SR | [RFC3550] | 134 | Interarrival jitter | RR | [RFC3550] | 135 | min_jitter | XR Summary Block | [RFC3611] | 136 | max_jitter | XR Summary Block | [RFC3611] | 137 | mean_jitter | XR Summary Block | [RFC3611] | 138 | dev_jitter | XR Summary Block | [RFC3611] | 139 | Interarrival jitter | IJ | [RFC5450] | 140 | RTP timestamp | SMPTETC | [RFC5484] | 141 | Jitter | RSI Jitter Block | [RFC5760] | 142 | Median jitter | RSI Stats Block | [RFC5760] | 143 +---------------------+------------------+-----------+ 145 Table 1 147 This document first tries to list in Section 2 and subsections all 148 known algorithms used in existing RTP implementations at the time of 149 writing. This sections are not normative. 151 Section 4 and subsections then recommend a unique algorithm that 152 modifies [RFC3550]. This sections are normative. 154 Section 5 and subsections then analyze what happen when the legacy 155 algorithms listed in Section 2 are used with the new algorithm listed 156 in Section 4. This sections are not normative. 158 2. Legacy RTP 160 The following sections describe the various ways legacy RTP 161 implementations behave when multiple clock rates are used. Legacy 162 RTP refers to RFC 3550 without the modifications introduced by this 163 document. 165 2.1. Different SSRC 167 One way of managing multiple clock rates is to use a different SSRC 168 for each different clock rate, as in this case there is no ambiguity 169 on the clock rate used by fields in the RTCP packets. This method 170 also seems to be the original intent of RTP as can be deduced from 171 points 2 and 3 of section 5.2 of RFC 3550. 173 On the other hand changing the SSRC can be a problem for some 174 implementations designed to work only with unicast IP addresses, 175 where having multiple SSRCs is considered a corner case. Lip 176 synchronization can also be a problem in the interval between the 177 beginning of the new stream and the first RTCP SR packet. This is 178 not different than what happen at the beginning of the RTP session 179 but it can be more annoying for the end-user. 181 2.2. Same SSRC 183 The simplest way of managing multiple clock rates is to use the same 184 SSRC for all the payload types regardless of the clock rates. 186 Unfortunately there is no clear definition on how the RTP timestamp 187 should be calculated in this case. The following subsections present 188 the algorithms used in the field. 190 2.2.1. Monotonic timestamps 192 This method of calculating the RTP timestamp ensures that the value 193 increases monotonically. The formula used by this method is as 194 follow: 196 timestamp = previous_timestamp + (current_capture_time - 197 previous_capture_time) * current_clock_rate 198 The problem with this method is that the jitter calculation on the 199 receiving side gives invalid result during the transition between two 200 clock rates, as shown in Table 2. The capture and arrival time are 201 in seconds, starting at the beginning of the capture of the first 202 packet; clock rate is in Hz; the RTP timestamp does not include the 203 random offset; the transit, jitter, and average jitter use the clock 204 rate as unit. 206 +-------+-------+-----------+---------+---------+--------+----------+ 207 | Capt. | Clock | RTP | Arrival | Transit | Jitter | Average | 208 | time | rate | timestamp | time | | | jitter | 209 +-------+-------+-----------+---------+---------+--------+----------+ 210 | 0 | 8000 | 0 | 0.1 | 800 | | | 211 | 0.02 | 8000 | 160 | 0.12 | 800 | 0 | 0 | 212 | 0.04 | 8000 | 320 | 0.14 | 800 | 0 | 0 | 213 | 0.06 | 8000 | 480 | 0.16 | 800 | 0 | 0 | 214 | 0.08 | 16000 | 800 | 0.18 | 2080 | 480 | 30 | 215 | 0.1 | 16000 | 1120 | 0.2 | 2080 | 0 | 28 | 216 | 0.12 | 16000 | 1440 | 0.22 | 2080 | 0 | 26 | 217 | 0.14 | 8000 | 1600 | 0.24 | 320 | 720 | 70 | 218 | 0.16 | 8000 | 1760 | 0.26 | 320 | 0 | 65 | 219 +-------+-------+-----------+---------+---------+--------+----------+ 221 Table 2 223 Calculating the correct transit time on the receiving side can be 224 done by using the following formulas: 226 (1) current_time_capture = current_timestamp - previous_timestamp) / 227 current_clock_rate + previous_time_capture 228 (2) transit = current_clock_rate * (time_arrival - 229 current_time_capture) 230 (3) previous_time_capture = current_time_capture 232 The main problem with this method, in addition to the fact that the 233 jitter calculation described in RFC 3550 cannot be used, is that is 234 it dependent on the previous RTP packets, packets that can be 235 reordered or lost in the network. 237 2.2.2. Non-monotonic timestamps 239 An alternate way of generating the RTP timestamps is to use the 240 following formula: 242 timestamp = capture_time * clock_rate 244 With this formula, the jitter calculation is correct but the RTP 245 timestamp values are no longer increasing monotonically as shown in 246 Table 3. RFC 3550 states that "[t]he sampling instant MUST be 247 derived from a clock that increments monotonically[...]" but nowhere 248 says that the RTP timestamp must increment monotonically. 250 +-------+-------+-----------+---------+---------+--------+----------+ 251 | Capt. | Clock | RTP | Arrival | Transit | Jitter | Average | 252 | time | rate | timestamp | time | | | jitter | 253 +-------+-------+-----------+---------+---------+--------+----------+ 254 | 0 | 8000 | 0 | 0.1 | 800 | | | 255 | 0.02 | 8000 | 160 | 0.12 | 800 | 0 | 0 | 256 | 0.04 | 8000 | 320 | 0.14 | 800 | 0 | 0 | 257 | 0.06 | 8000 | 480 | 0.16 | 800 | 0 | 0 | 258 | 0.08 | 16000 | 1280 | 0.18 | 1600 | 0 | 0 | 259 | 0.1 | 16000 | 1600 | 0.2 | 1600 | 0 | 0 | 260 | 0.12 | 16000 | 1920 | 0.22 | 1600 | 0 | 0 | 261 | 0.14 | 8000 | 1120 | 0.24 | 800 | 0 | 0 | 262 | 0.16 | 8000 | 1280 | 0.26 | 800 | 0 | 0 | 263 +-------+-------+-----------+---------+---------+--------+----------+ 265 Table 3 267 The advantage with this method is that it works with the jitter 268 calculation described in RFC 3550, as long as the correct clock rates 269 are used. It seems that this is what most implementations are using. 271 3. Terminology 273 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 274 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 275 document are to be interpreted as described in [RFC2119]. 277 Clock rate: The multiplier used to convert from a wallclock value in 278 seconds to an equivalent RTP timestamp value (without the fixed 279 random offset). Note that RFC 3550 uses various terms like "clock 280 frequency", "media clock rate", "timestamp unit", "timestamp 281 frequency", and "RTP timestamp clock rate" as synonymous to clock 282 rate. 283 RTP Sender: A logical network element that sends RTP packets, sends 284 RTCP SR packets, and receives RTCP RR packets. 285 RTP Receiver: A logical network element that receives RTP packets, 286 receives RTCP SR packets, and sends RTCP RR packets. 288 4. Recommendations 289 4.1. RTP Sender 291 An RTP Sender with RTCP turned off (i.e. by setting the RS and RR 292 bandwidth modifiers defined in [RFC3556] to 0) SHOULD use a different 293 SSRC for each different clock rate but MAY use different clock rates 294 on the same SSRC as long as the RTP timestamp without the random 295 offset is calculated as explained below: 297 [[This was designed to help VoIP implementations who anyway never 298 cared about RTCP. Do we want to keep this?]] 300 Each time the clock rate changes, the start_offset and capture_start 301 values are calculated with the following formulas: 303 start_offset = (capture_time - capture_start) * previous_clock_rate 304 capture_start = capture_time 306 For the first RTP packet, the values are initialized with the 307 following formulas: 309 start_offset = 0 310 capture_start = capture_time 312 After eventually updating this values, the RTP timestamp is 313 calculated with the following formula: 315 timestamp = (capture_time - capture_start) * clock_rate + 316 start_offset 318 Note that in all the formulas, capture_time is the first instant the 319 new timestamp rate is used. 321 An RTP Sender with RTCP turned on MUST use a different SSRC for each 322 different clock rate. An RTCP BYE MUST be sent and a new SSRC MUST 323 be used if the clock rate switches back to a value already seen in 324 the RTP stream. 326 To accelerate lip synchronization, the next compound RTCP packet sent 327 by the RTP sender MUST contain multiple SR packets, the first one 328 containing the mapping for the current clock rate and the next SR 329 packets containing the mapping for the other clock rates seen during 330 the last period. 332 [[Some legacy implementations may dislike receiving multiple SR 333 packets. What should we do?]] 335 The RTP extension defined in [RFC6051] MAY be used to accelerate the 336 synchronization. 338 4.2. RTP Receiver 340 An RTP Receiver MUST calculate the jitter using the following 341 formula: 343 D(i,j) = (arrival_time_j * clock_rate_i - timestamp_j) - 344 (arrival_time_i * clock_rate_i - timestamp_i) 346 An RTP Receiver MUST be able to handle a compound RTCP packet with 347 multiple SR packets. 349 For interoperability with legacy RTP implementations, an RTP receiver 350 MAY use the information in two consecutive SR packets to calculate 351 the clock rate used, i.e. if Ni is the NTP timestamp for the SR 352 packet i, Ri the RTP timestamp for the SR packet i and Nj and Rj the 353 NTP timestamp and RTP timestamp for the previous SR packet j, then 354 the clock rate can be guessed as the closest to (Ri - Rj) / (Ni - 355 Nj). 357 5. Interoperability Analysis 359 The next subsections analyze the various combinations between legacy 360 RTP implementations and RTP implementations that follow this document 361 specifications. 363 TBD 365 6. Security Considerations 367 TBD 369 7. IANA Considerations 371 No IANA considerations. 373 8. Acknowledgements 375 Thanks to Colin Perkins, Ali C. Begen and Magnus Westerlund for their 376 comments, suggestions and questions that helped to improve this 377 document. 379 Thanks to Robert Sparks and the attendees of SIPit 26 for the survey 380 on multiple clock rates interoperability. 382 This document was written with the xml2rfc tool described in 383 [RFC2629]. 385 9. References 387 9.1. Normative References 389 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 390 Requirement Levels", BCP 14, RFC 2119, March 1997. 392 [RFC3550] Schulzrinne, H., Casner, S., Frederick, R., and V. 393 Jacobson, "RTP: A Transport Protocol for Real-Time 394 Applications", STD 64, RFC 3550, July 2003. 396 9.2. Informative References 398 [RFC2629] Rose, M., "Writing I-Ds and RFCs using XML", RFC 2629, 399 June 1999. 401 [RFC3551] Schulzrinne, H. and S. Casner, "RTP Profile for Audio and 402 Video Conferences with Minimal Control", STD 65, RFC 3551, 403 July 2003. 405 [RFC3556] Casner, S., "Session Description Protocol (SDP) Bandwidth 406 Modifiers for RTP Control Protocol (RTCP) Bandwidth", 407 RFC 3556, July 2003. 409 [RFC3611] Friedman, T., Caceres, R., and A. Clark, "RTP Control 410 Protocol Extended Reports (RTCP XR)", RFC 3611, 411 November 2003. 413 [RFC5450] Singer, D. and H. Desineni, "Transmission Time Offsets in 414 RTP Streams", RFC 5450, March 2009. 416 [RFC5484] Singer, D., "Associating Time-Codes with RTP Streams", 417 RFC 5484, March 2009. 419 [RFC5760] Ott, J., Chesterfield, J., and E. Schooler, "RTP Control 420 Protocol (RTCP) Extensions for Single-Source Multicast 421 Sessions with Unicast Feedback", RFC 5760, February 2010. 423 [RFC6051] Perkins, C. and T. Schierl, "Rapid Synchronisation of RTP 424 Flows", RFC 6051, November 2010. 426 [uRTR] Wenger, S. and C. Perkins, "RTP Timestamp Frequency for 427 Variable Rate Audio Codecs", 428 draft-ietf-avt-variable-rate-audio-00 (work in progress), 429 October 2004. 431 Appendix A. Using a fixed clock rate 433 An alternate way of fixing the multiple clock rates issue was 434 proposed in [uRTR]. This document proposed to define a unified clock 435 rate, but the proposal was rejected at IETF 61. 437 Appendix B. Behavior of legacy implementations 439 B.1. libccrtp 2.0.2 441 This library uses the formula described in Section 2.2.2. 443 Note that this library uses gettimeofday(2) which is not guaranteed 444 to increment monotonically, like when the clock is adjusted by NTP. 446 B.2. libmediastreamer0 2.6.0 448 This library (which uses the oRTP library) uses the formula described 449 in Section 2.2.2. 451 Note that in some environments this library uses gettimeofday(2) 452 which is not guaranteed to increment monotonically. 454 B.3. libpjmedia 1.0 456 This library uses the formula described in Section 2.2.2. 458 B.4. Android RTP stack 4.0.3 460 This library changes the SSRC each time the format changes, as 461 described in Section 2.1. 463 Appendix C. Release notes 465 This section must be removed before publication as an RFC. 467 C.1. Modifications between draft-ietf-avtext-multiple-clock-rates-02 468 and draft-ietf-avtext-multiple-clock-rates-01 470 o Readded the non-monotonic methods that was removed in a previous 471 version. 473 o Added analysis of FOSS RTP stacks. 474 o Changed author affiliation. 475 o Added AVTEXT area. 477 C.2. Modifications between draft-ietf-avtext-multiple-clock-rates-01 478 and draft-ietf-avtext-multiple-clock-rates-00 480 o New text says that the algorithms listed are the one currently 481 known. 482 o Explains capture_time. 483 o Nits. 485 C.3. Modifications between draft-ietf-avtext-multiple-clock-rates-00 486 and draft-petithuguenin-avtext-multiple-clock-rates-01 488 o Changed capture_state to capture_start. 490 C.4. Modifications between 491 draft-petithuguenin-avtext-multiple-clock-rates-01 and 492 draft-petithuguenin-avtext-multiple-clock-rates-00 494 o Clarified the goals for this documents 495 o Removed the non-monotonic method (replaced by Magnus formula). 496 o Moved the "RTP Sender and RTP Receiver section inside a new 497 "Recommendations" section. 498 o Inserted the new Sender formula inside the Recommendation section. 499 o Inserted the new jitter formula in the RTP Receiver section. 500 o Emptied the Analysis sections. 502 C.5. Modifications between 503 draft-petithuguenin-avtext-multiple-clock-rates-00 and 504 draft-petithuguenin-avt-multiple-clock-rates-03 506 o Initial release for avtext WG. 508 C.6. Modifications between 509 draft-petithuguenin-avt-multiple-clock-rates-03 and 510 draft-petithuguenin-avt-multiple-clock-rates-02 512 o Updated RFC reference. 514 C.7. Modifications between 515 draft-petithuguenin-avt-multiple-clock-rates-02 and 516 draft-petithuguenin-avt-multiple-clock-rates-01 518 o Having multiple SRs in a compound RTCP packet is OK. 520 o If RTCP is used, must send a BYE and not reuse the SSRC. 521 o Removed resolved notes. 522 o Acknowledged SIPit 26 survey. 523 o Fixed some nits. 525 C.8. Modifications between 526 draft-petithuguenin-avt-multiple-clock-rates-01 and 527 draft-petithuguenin-avt-multiple-clock-rates-00 529 o Complete rewrite as a Standard Track I-D modifying RFC 3550. 531 Author's Address 533 Marc Petit-Huguenin 534 Unaffiliated 536 Email: petithug@acm.org