RFC 7164
RTP and Leap Seconds
RTP and Leap Seconds ๐
RFC 7164, bestie! ๐ This one came out in March 2014 and was written by K. Gross (AVA Networks) and R. van Brandenburg (TNO). It's a Standards Track document, so it's an official Internet standard ๐, with ISSN 2070-1721. It updates RFC 3550, which is the core RTP spec, and its title block doesn't list anything it obsoletes.
Abstract โจ
Okay so this doc is about the messy stuff that happens when RTP sessions run across a Coordinated Universal Time (UTC) leap second ๐. It updates RFC 3550 by explaining how RTP senders and receivers should behave when leap seconds show up. ๐ซถ
Status of This Memo ๐
This is an Internet Standards Track document.
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 5741.
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at http://www.rfc-editor.org/info/rfc7164.
Copyright Notice ๐
Copyright (c) 2014 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
Table of Contents ๐บ๏ธ
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
2. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Leap Seconds . . . . . . . . . . . . . . . . . . . . . . . . 2
3.1. UTC Behavior during a Positive Leap Second . . . . . . . 3
3.2. NTP Behavior during a Positive Leap Second . . . . . . . 3
3.3. POSIX Behavior during a Positive Leap Second . . . . . . 3
3.4. Example of Leap-Second Behaviors . . . . . . . . . . . . 4
4. Receiver Behavior during a Leap Second . . . . . . . . . . . 5
5. Recommendations . . . . . . . . . . . . . . . . . . . . . . . 5
5.1. Sender Reports . . . . . . . . . . . . . . . . . . . . . 6
5.2. RTP Packet Playout . . . . . . . . . . . . . . . . . . . 7
6. Security Considerations . . . . . . . . . . . . . . . . . . . 7
7. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 8
8. References . . . . . . . . . . . . . . . . . . . . . . . . . 8
8.1. Normative References . . . . . . . . . . . . . . . . . . 8
8.2. Informative References . . . . . . . . . . . . . . . . . 8
1. Introduction ๐ธ
Okay, so in some media networking apps, RTP streams get tied to a wall-clock time (an absolute date and time) โฑ๏ธ. This happens by using the NTP timestamp field in the sender report (SR) to make a mapping between RTP timestamps and the wall clock. When there's a wall-clock reference, the playout time for RTP packets is tied to that wall clock. Smooth, continuous media playout needs a smooth, continuous time base, but the wall clock's time base can include leap seconds that don't get rendered smoothly ๐ญ.
This document updates RFC 3550 [1] by giving recommendations for smoothly rendering streamed media that's referenced to common wall clocks. Those clocks don't behave smoothly or continuously when leap seconds happen ๐ฆ.
2. Terminology ๐
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [2] and indicate requirement levels for compliant implementations. ๐
3. Leap Seconds โฐ
The world's scientific time standard is International Atomic Time (TAI), which is based on vibrations of cesium atoms in an atomic clock โ๏ธ. The world's civil time is based on the rotation of the Earth ๐.
In 1972, the civil time standard, Coordinated Universal Time (UTC), was redefined in terms of TAI. That's when the concept of leap seconds was introduced, so UTC could stay synced with the Earth's rotation ๐.
Leap seconds are scheduled by the International Earth Rotation and Reference Systems Service. They may be scheduled at the last day of any month, but they're preferentially scheduled for December and June, and secondarily March and September [6]. Earth's rotation is unpredictable, so leap seconds typically aren't scheduled more than six months in advance ๐ฎ.
Leap seconds don't respect local time and always occur at the end of the UTC day. A leap second can be scheduled to either add or remove a second from the day. A leap second that adds an extra second is known as a positive leap second โ. A leap second that skips a second is known as a negative leap second โ.
Since their introduction in 1972, all leap seconds have been scheduled in June or December, and they have all been positive ๐.
NOTE: The ITU is studying a proposal that could eventually eliminate leap seconds from UTC. As of January 2012, this proposal is expected to be decided no earlier than 2015 [7].
3.1. UTC Behavior during a Positive Leap Second
UTC clocks feature a 61st second at the end of the day when a positive leap second is scheduled. The leap second is designated 23h 59m 60s ๐.
3.2. NTP Behavior during a Positive Leap Second
Under NTP [8], a leap second is inserted at the beginning of the last second of the day. This makes the clock freeze or slow down for one second right before the last second of the affected day. So the last second of the day ends up with a real-time duration of two seconds ๐ซ . Timestamp accuracy gets compromised during this period, because the clock's rate isn't well defined.
3.3. POSIX Behavior during a Positive Leap Second
The POSIX (Portable Operating System Interface) standard [3] requires that leap seconds be omitted from reported time. All days are defined as having 86,400 seconds, but the timebase is defined to be UTC, which is a leap-second-bearing reference ๐ฐ๏ธ. Implementors of POSIX systems get considerable latitude from the standard on how to map POSIX time to UTC.
In many systems, leap seconds are accommodated by repeating the last second of the day. That means a timestamp within the last second of the day is ambiguous, since it can refer to a moment in either of the last two seconds of a day containing a leap second ๐คฏ.
Other systems use the same technique as NTP, freezing or slowing for one second right before the last second of the affected day.
In some cases, leap seconds are accommodated by warping time [5] [4]. That means the length of the second near a leap second is slightly altered โจ.
3.4. Example of Leap-Second Behaviors
Table 1 shows the positive leap second that happened on June 30, 2012, when the offset between TAI and UTC changed from 34 to 35 seconds ๐ . The first column shows RTP timestamps for an 8 kHz audio stream. The second column shows the TAI reference. The following columns show behavior for the leap-second-bearing wall clocks we just talked about. Time values are shown at half-second intervals ๐ง.
+-------+--------------+--------------+--------------+--------------+
| RTP | TAI | UTC | POSIX | NTP |
+-------+--------------+--------------+--------------+--------------+
| 8000 | 00:00:32.500 | 23:59:58.500 | 23:59:58.500 | 23:59:58.500 |
| 12000 | 00:00:33.000 | 23:59:59.000 | 23:59:59.000 | 23:59:59.000 |
| 16000 | 00:00:33.500 | 23:59:59.500 | 23:59:59.500 | 23:59:59.500 |
| 20000 | 00:00:34.000 | 23:59:60.000 | 23:59:59.000 | 00:00:00.000 |
| 24000 | 00:00:34.500 | 23:59:60.500 | 23:59:59.500 | 00:00:00.000 |
| 28000 | 00:00:35.000 | 00:00:00.000 | 00:00:00.000 | 00:00:00.000 |
| 32000 | 00:00:35.500 | 00:00:00.500 | 00:00:00.500 | 00:00:00.500 |
+-------+--------------+--------------+--------------+--------------+
Table 1: Positive Leap-Second Behavior
NOTE: Some NTP implementations don't entirely freeze the clock while the leap second is inserted. Successive calls to get system time return infinitesimally larger time values (e.g., 1 microsecond or 1 nanosecond larger). This is designed to satisfy assumptions that applications may make about time increasing monotonically ๐. This behavior happens in the least-significant bits of the time value, so it isn't typically visible in the human-readable format shown in the table ๐.
NOTE: POSIX implementations vary. The implementation shown here repeats the last second of the affected day. Other implementations mirror NTP behavior or alter the length of a second near the leap second ๐ .
4. Receiver Behavior during a Leap Second ๐ง
Timestamps generated during a leap second may be ambiguous, or they may be interpreted differently by a sender and receiver, or differently by different receivers ๐.
Without prior knowledge of the leap-second schedule, NTP servers and clients may become offset by exactly one second with respect to their UTC reference. This potential discrepancy begins when a leap second occurs and ends when all participants receive a time update from a server or peer. Depending on the system implementation, the offset can last anywhere from a few seconds to a few days ๐๏ธ. A long-lived discrepancy can be particularly disruptive to NTP-referenced RTP streams ๐.
These discrepancies, depending on direction, may cause receivers to think they are receiving RTP packets after they should be played, or to attempt to buffer received data an additional second before playing it. Either situation can cause an interruption in playback ๐ฑ. Some receivers may automatically recognize an unexpected offset and resynchronize to the stream to accommodate it. Once the offset is resolved, such receivers may need to resynchronize again ๐.
5. Recommendations โจ
okay so bestie, here's the big idea ๐ฆ senders and receivers that aren't tied to a wall clock? totally unaffected by leap seconds. no special accommodation needed, they just vibe ๐
RTP implementations that do use a wall-clock reference get a glow-up if they pick a clock whose timescale doesn't include leap seconds ๐ธ IEEE 1588 [9], GPS [10], and other systems that use a TAI [11] reference don't have leap seconds at all. NTP time, operating system clocks, and other UTC-based systems do include leap seconds ๐
ngl there's a sneaky detail here ๐ some TAI-based systems like IEEE 1588 and GPS also send along TAI-to-UTC mapping info. so some receivers can combine the TAI clock with that mapping and whip up a leap-second-bearing UTC clock. the point is: it's the timescale that decides whether a clock bears leap seconds, not how the time was delivered ๐
+-------------------------+---------------------+---------------+
| Reference clock type | Examples | Accommodation |
+-------------------------+---------------------+---------------+
| None | Self clocking | None needed |
| Non-leap-second-bearing | IEEE 1588, GPS, TAI | None needed |
| Leap-second-bearing | NTP | Recommended |
+-------------------------+---------------------+---------------+
Table 2: Recommendations Summary
All participants generating or consuming timestamps tied to a leap-second-bearing reference MUST recognize leap seconds, and they SHOULD have a working communications channel to get notified about leap-second scheduling ๐ a working channel includes a protocol way to tell clocks about an upcoming leap second, like the Leap Indicator in the NTP header [8], plus a way for top-tier clocks to receive leap-second schedule info published by the International Earth Rotation and Reference Systems Service [12] ๐ซถ
Not every network has that channel, though ๐ญ for security or other reasons, leap-second schedules may be configured manually on some networks or clocks. and when a device doesn't reliably get leap-second scheduling info, the failures described in Section 4 may happen ๐
okay here's the drama ๐ฅ positive leap seconds can make NTP timestamps ambiguous, and systems handle them inconsistently. so generating or using NTP timestamps during the entire last second of a day with a scheduled positive leap second SHOULD be avoided โจ note that the period to avoid is two seconds of real time, not one ๐ง in the Table 1 example, the region to avoid is RTP timestamps 12000 through 28000.
negative leap seconds? no drama at all ๐ they don't introduce timestamp ambiguity or other complications, so no special treatment is needed for RTP timestamps during a negative leap second.
and POSIX clocks that use a warping technique to handle leap seconds (see [4] [5]) are not a good choice for an interoperable timestamp reference, so they SHOULD not be used to timestamp RTP streams ๐ โโ๏ธ
5.1. Sender Reports ๐
so to avoid generating or using NTP timestamps during positive leap seconds, RTP senders and receivers should stop sending or using sender reports to sync their clocks around a leap second. instead they lean on their internal clocks until the leap second has passed ๐ซง
RTP senders using a leap-second-bearing reference for timestamps SHOULD NOT generate sender reports containing an originating NTP timestamp near a positive leap second. to keep a consistent RTCP schedule and avoid accidental timeouts, these senders MAY send receiver reports instead of sender reports near the leap second ๐
for suspending sender reports around a leap second, senders MAY assume a positive leap second happens at the end of the last day of every month. (iykyk, it's a simplifying assumption ๐)
receivers consuming leap-second-bearing timestamps SHOULD ignore timestamps in any sender reports generated near a positive leap second ๐
and for ignoring sender reports around a leap second, receivers MAY assume a positive leap second happens at the end of the last day of every month ๐
5.2. RTP Packet Playout ๐
receivers consuming leap-second-bearing timestamps SHOULD take both positive and negative leap seconds in the reference into account when they work out playout time from RTP timestamps in RTP packets. main character energy ๐ โจ
6. Security Considerations ๐
ok this part is serious bestie ๐ญ RTP streams that use a wall-clock reference present an additional attack vector compared to self-clocking streams. manipulating the wall clock at either the sender or the receiver can potentially disrupt streaming ๐
for an RTP stream operating to a leap-second-bearing reference to run reliably across a leap second, the sender and receiver must both be aware of the leap second. it's possible to disrupt a stream by blocking or delaying leap-second notification to one of the participants. streaming can be affected similarly if one participant gets tricked into believing a leap second has been scheduled when there isn't one ๐ฑ these vulnerabilities are present in RFC 3550 [1], and these new recommendations neither make them worse nor better ๐ซ integrity of the leap-second schedule is the responsibility of the operating system and time distribution mechanism, both of which are outside the scope of RFC 3550 [1] and these recommendations ๐ฅ
7. Acknowledgements ๐
the authors would like to thank Steve Allen for his valuable comments that helped improve this document ๐ซถ
8. References ๐
8.1. Normative References
[1] Schulzrinne, H., Casner, S., Frederick, R., and V. Jacobson, "RTP: A Transport Protocol for Real-Time Applications", STD 64, RFC 3550, July 2003. ๐ฆ
[2] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. ๐ธ
8.2. Informative References
[3] IEEE, "Portable Operating System Interface (POSIX)", IEEE Standard 1003.1-2008, December 2008, <http://standards.ieee.org/findstds/standard/1003.1-2008.html>. โจ
[4] Google, Inc., "Time, technology and leaping seconds", September 2011, <http://googleblog.blogspot.com/2011/09/time-technology-and-leaping-seconds.html>. ๐
[5] Kuhn, M., "Coordinated Universal Time with Smoothed Leap Seconds (UTC-SLS)", Work in Progress, January 2006. ๐ง
[6] ITU, "Standard-frequency and time-signal emissions", ITU-R TF.460-6, February 2002, <http://www.itu.int/rec/R-REC-TF.460/>. ๐
[7] ITU, "The future of the UTC time scale", Question ITU-R 236/7, February 2012, <http://www.itu.int/pub/R-QUE-SG07.236-2001>. ๐
[8] Mills, D., Martin, J., Burbank, J., and W. Kasch, "Network Time Protocol Version 4: Protocol and Algorithms Specification", RFC 5905, June 2010. ๐ซถ
[9] IEEE, "IEEE Standard for a Precision Clock Synchronization Protocol for Networked Measurement and Control Systems", IEEE Standard 1588-2008, July 2008, <http://standards.ieee.org/findstds/standard/1588-2008.html>. ๐
[10] Global Positioning Systems Directorate, "Systems Engineering & Integration Interface Specification", September 2011, <http://www.navcen.uscg.gov/pdf/IS-GPS-200F.pdf>. ๐ซง
[11] Bureau International des Poids et Mesures, "International Atomic Time", Navstar GPS Space Segment/Navigation User Segment Interfaces IS-GPS-200, <http://www.bipm.org/en/scientific/tai/tai.html>. ๐
[12] IERS Earth Orientation Centre, "Bulletin C - Product metadata", <http://datacenter.iers.org/web/guest/eop/-/somos/5Rgv/product/16>. ๐
Authors' Addresses
Kevin Gross AVA Networks Boulder, CO US
EMail: kevin.gross@avanw.com
Ray van Brandenburg TNO Brassersplein 2 Delft 2612CT the Netherlands
Phone: +31-88-866-7000 EMail: ray.vanbrandenburg@tno.nl
๐ฆ where this page comes from
- ietf: rfc7164 2014-03
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms