idnits 2.17.1 draft-mlichvar-ntp-interleaved-modes-01.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 : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == Line 176 has weird spacing: '... Server t2 ...' -- The document date (December 12, 2017) is 2325 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) == Outdated reference: A later version (-04) exists of draft-ietf-ntp-data-minimization-01 Summary: 0 errors (**), 0 flaws (~~), 3 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Internet Engineering Task Force M. Lichvar 3 Internet-Draft Red Hat 4 Intended status: Standards Track A. Malhotra 5 Expires: June 15, 2018 Boston University 6 December 12, 2017 8 NTP Interleaved Modes 9 draft-mlichvar-ntp-interleaved-modes-01 11 Abstract 13 This document extends the specification of Network Time Protocol 14 (NTP) version 4 in RFC 5905 with special modes called the NTP 15 interleaved modes, that enable NTP servers to provide their clients 16 and peers with more accurate transmit timestamps that are available 17 only after transmitting NTP packets. More specifically, this 18 document describes three modes: interleaved client/server, 19 interleaved symmetric, and interleaved broadcast. 21 Status of This Memo 23 This Internet-Draft is submitted in full conformance with the 24 provisions of BCP 78 and BCP 79. 26 Internet-Drafts are working documents of the Internet Engineering 27 Task Force (IETF). Note that other groups may also distribute 28 working documents as Internet-Drafts. The list of current Internet- 29 Drafts is at https://datatracker.ietf.org/drafts/current/. 31 Internet-Drafts are draft documents valid for a maximum of six months 32 and may be updated, replaced, or obsoleted by other documents at any 33 time. It is inappropriate to use Internet-Drafts as reference 34 material or to cite them other than as "work in progress." 36 This Internet-Draft will expire on June 15, 2018. 38 Copyright Notice 40 Copyright (c) 2017 IETF Trust and the persons identified as the 41 document authors. All rights reserved. 43 This document is subject to BCP 78 and the IETF Trust's Legal 44 Provisions Relating to IETF Documents 45 (https://trustee.ietf.org/license-info) in effect on the date of 46 publication of this document. Please review these documents 47 carefully, as they describe your rights and restrictions with respect 48 to this document. Code Components extracted from this document must 49 include Simplified BSD License text as described in Section 4.e of 50 the Trust Legal Provisions and are provided without warranty as 51 described in the Simplified BSD License. 53 1. Introduction 55 RFC 5905 [RFC5905] describes the operations of NTPv4 in basic client/ 56 server, symmetric, and broadcast mode. The transmit timestamp is one 57 of the four timestamps included in every NTP packet used for time 58 synchronization. A packet that strictly follows RFC 5905, i.e. it 59 contains a transmit timestamp corresponding to the packet itself, is 60 said to be in basic mode. 62 There are, at least, four options where a transmit timestamp can be 63 captured i.e. by NTP daemon, by network drivers, or at the MAC or 64 physical layer of the OSI model. A typical transmit timestamp in a 65 software NTP implementation in the basic mode is the one captured by 66 the NTP daemon using the system clock, before the computation of 67 message digest and before the packet is passed to the operating 68 system, and does not include any processing and queuing delays in the 69 system, network drivers, and hardware. These delays may add a 70 significant error to the offset and network delay measured by clients 71 and peers of the server. 73 For best accuracy, the transmit timestamp should be captured as close 74 to the wire as possible, but that is difficult to implement in the 75 current packet since this timestamp is available only after the 76 packet transmission. The protocol described in RFC 5905 does not 77 specify any mechanism for the server to provide its clients and peers 78 with this more accurate timestamp. 80 Different mechanisms could be used to exchange this more accurate 81 timestamp. This document describes interleaved modes, in which an 82 NTP packet contains a transmit timestamp corresponding to the 83 previous packet that was sent to the client or peer. This transmit 84 timestamp could be captured at one of the any four places mentioned 85 above. More specifically, this document: 87 1. Introduces and specifies a new interleaved client/server mode. 89 2. Specifies the interleaved symmetric mode based on the NTP 90 reference implementation with some modifications. 92 3. Specifies the interleaved broadcast mode based purely on the NTP 93 reference implementation. 95 The protocol does not change the NTP packet header format. Only the 96 semantics of some timestamp fields is different. NTPv4 that supports 97 client/server and broadcast interleaved modes is compatible with 98 NTPv4 without this capability as well as with all previous NTP 99 versions. 101 The protocol requires both servers and clients/peers to keep some 102 state specific to the interleaved mode. It prevents traffic 103 amplification that would be possible if the timestamp was sent in a 104 separate message in order to keep the servers stateless. 106 This document assumes familiarity with RFC 5905. 108 1.1. Requirements Language 110 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 111 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 112 document are to be interpreted as described in RFC 2119 [RFC2119]. 114 2. Interleaved Client/server mode 116 The interleaved client/server mode is similar to the basic client/ 117 server mode. The only difference between the two modes is in the 118 meaning of the transmit and origin timestamp fields. 120 A client request in the basic mode has an origin timestamp equal to 121 the transmit timestamp from the previous server response, or is zero. 122 A server response in the basic mode has an origin timestamp equal to 123 the transmit timestamp from the client's request. The transmit 124 timestamps correspond to the packets in which they are included. 126 A client request in the interleaved mode has an origin timestamp 127 equal to the receive timestamp from the previous server response. A 128 server response in the interleaved mode has an origin timestamp equal 129 to the receive timestamp from the client's request. The transmit 130 timestamps correspond to the previous packets that were sent to the 131 server or client. 133 A server which supports the interleaved mode needs to save pairs of 134 local receive and transmit timestamps. The server SHOULD discard old 135 timestamps to limit the amount of memory needed to support clients 136 using the interleaved mode. The server MAY separate the timestamps 137 by IP addresses, but it SHOULD NOT separate them by port numbers, 138 i.e. clients are allowed to change their source port between 139 requests. 141 When the server receives a request, it SHOULD compare the origin 142 timestamp with all receive timestamps it has saved (for the IP 143 address). If a match is found, the server SHOULD respond with a 144 packet in the interleaved mode, which contains the transmit timestamp 145 corresponding to the packet which had the matching receive timestamp. 146 If no match is found, the server MUST NOT respond in the interleaved 147 mode. The server MAY always respond in the basic mode. In both 148 cases, the server SHOULD save the new receive and transmit 149 timestamps. 151 Both servers and clients that support the interleaved mode MUST NOT 152 send a packet that has a transmit timestamp equal to the receive 153 timestamp in order to reliably detect whether received packets 154 conform to the interleaved mode. 156 The first request from a client is always in the basic mode and so is 157 the server response. It has a zero origin timestamp and zero receive 158 timestamp. Only when the client receives a valid response from the 159 server, it will be able to send a request in the interleaved mode. 160 The client SHOULD limit the number of requests in the interleaved 161 mode per server response to prevent processing of very old timestamps 162 in case a large number of packets is lost. 164 An example of packets in a client/server exchange using the 165 interleaved mode is shown in Figure 1. The packets in the basic and 166 interleaved mode are indicated with B and I respectively. The 167 timestamps t1', t3' and t11' point to the same transmissions as t1, 168 t3 and t11, but they may be less accurate. The first exchange is in 169 the basic mode followed by a second exchange in the interleaved mode. 170 For the third exchange, the client request is in the interleaved 171 mode, but the server response is in the basic mode, because the 172 server did not have the pair of timestamps t6 and t7 (e.g. they were 173 dropped to save timestamps for other clients using the interleaved 174 mode). 176 Server t2 t3 t6 t7 t10 t11 177 -----+----+----------------+----+----------------+----+----- 178 / \ / \ / \ 179 Client / \ / \ / \ 180 --+----------+----------+----------+----------+----------+-- 181 t1 t4 t5 t8 t9 t12 183 Mode: B B I I I B 184 +----+ +----+ +----+ +----+ +----+ +----+ 185 Org | 0 | | t1'| | t2 | | t4 | | t6 | | t5 | 186 Rx | 0 | | t2 | | t4 | | t6 | | t8 | |t10 | 187 Tx | t1'| | t3'| | t1 | | t3 | | t5 | |t11'| 188 +----+ +----+ +----+ +----+ +----+ +----+ 190 Figure 1: Packet timestamps in interleaved client/server mode 192 When the client receives a response, it performs all tests described 193 in RFC 5905, except now the sanity check for bogus packet needs to 194 compare the origin timestamp with both transmit and receive 195 timestamps from the request in order to be able to detect if the 196 response is in the basic or interleaved mode. The client SHOULD NOT 197 update its NTP state when an invalid response is received to not lose 198 the timestamps which will be needed to complete a measurement when 199 the following response in the interleaved mode is received. 201 If the packet passed the tests and conforms to the interleaved mode, 202 the client can compute the offset and delay using the formulas from 203 RFC 5905 and one of two different sets of timestamps. The first set 204 is RECOMMENDED for clients that filter measurements based on the 205 delay. The corresponding timestamps from Figure 1 are written in 206 parentheses. 208 T1 - local transmit timestamp of the previous request (t1) 210 T2 - remote receive timestamp from the previous response (t2) 212 T3 - remote transmit timestamp from the latest response (t3) 214 T4 - local receive timestamp of the previous response (t4) 216 The second set gives a more accurate measurement of the current 217 offset, but the delay is much more sensitive to a frequency error 218 between the server and client due to a much longer interval between 219 T1 and T4. 221 T1 - local transmit timestamp of the latest request (t5) 223 T2 - remote receive timestamp from the latest response (t6) 225 T3 - remote transmit timestamp from the latest response (t3) 227 T4 - local receive timestamp of the previous response (t4) 229 Clients MAY filter measurements based on the mode. The maximum 230 number of dropped measurements in the basic mode SHOULD be limited in 231 case the server does not support or is not able to respond in the 232 interleaved mode. Clients that filter measurements based on the 233 delay will implicitly prefer measurements in the interleaved mode 234 over the basic mode, because they have a shorter delay due to a more 235 accurate transmit timestamp (T3). 237 The server MAY limit saving of the receive and transmit timestamps to 238 requests which have an origin timestamp specific to the interleaved 239 mode in order to not waste resources on clients using the basic mode. 241 Such an optimization will delay the first interleaved response of the 242 server to a client by one exchange. 244 A check for a non-zero origin timestamp works with clients that 245 implement NTP data minimization [I-D.ietf-ntp-data-minimization]. To 246 detect requests in the basic mode from clients that do not implement 247 the data minimization, the server can encode in low-order bits of the 248 receive and transmit timestamps below precision of the clock a bit 249 indicating whether the timestamp is a receive timestamp. If the 250 server receives a request with a non-zero origin timestamp which does 251 not indicate it is receive timestamp of the server, the request is in 252 the basic mode and it is not necessary to save the new receive and 253 transmit timestamp. 255 3. Interleaved Symmetric mode 257 The interleaved symmetric mode uses the same principles as the 258 interleaved client/server mode. A packet in the interleaved 259 symmetric mode has a transmit timestamp which corresponds to the 260 previous packet sent to the peer and an origin timestamp equal to the 261 receive timestamp from the last packet received from the peer. 263 In order to prevent the peer from matching the transmit timestamp 264 with an incorrect packet when the peers' transmissions do not 265 alternate (e.g. they use different polling intervals) and a previous 266 packet was lost, the use of the interleaved mode in symmetric 267 associations requires additional restrictions. 269 Peers which have an association need to count valid packets received 270 between their transmissions to determine in which mode a packet 271 should be formed. A valid packet in this context is a packet which 272 passed all NTP tests for duplicate, replayed, bogus, and 273 unauthenticated packets. Other received packets may update the NTP 274 state to allow the (re)initialization of the association, but they do 275 not change the selection of the mode. 277 A peer A SHOULD send a peer B a packet in the interleaved mode only 278 when the following conditions are met: 280 1. The peer A has an active association with the peer B which was 281 specified with an option enabling the interleaved mode, OR the 282 peer A received at least one valid packet in the interleaved mode 283 from the peer B. 285 2. The peer A did not send a packet to the peer B since it received 286 the last valid packet from the peer B. 288 3. The previous packet that the peer A sent to the peer B was the 289 only response to a packet received from the peer B. 291 An example of packets exchanged in a symmetric association is shown 292 in Figure 2. The minimum polling interval of the peer A is twice as 293 long as the maximum polling interval of the peer B. The first 294 packets sent by the peers are in the basic mode. The second and 295 third packet sent by the peer A is in the interleaved mode. The 296 second packet sent by the peer B is in the interleaved mode, but the 297 following packets sent by the peer are in the basic mode, because 298 multiple responses are sent per request. 300 Peer A t2 t3 t6 t8 t9 t12 t14 t15 301 -----+--+--------+-----------+--+--------+-----------+--+----- 302 / \ / / \ / / \ 303 Peer B / \ / / \ / / \ 304 --+--------+--+-----------+--------+--+-----------+--------+-- 305 t1 t4 t5 t7 t10 t11 t13 t16 307 Mode: B B I B I B B I 308 +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ 309 Org | 0 | | t1'| | t2 | | t3'| | t4 | | t3 | | t3 | |t10 | 310 Rx | 0 | | t2 | | t4 | | t4 | | t8 | |t10 | |t10 | |t14 | 311 Tx | t1'| | t3'| | t1 | | t7'| | t3 | |t11'| |t13'| | t9 | 312 +----+ +----+ +----+ +----+ +----+ +----+ +----+ +----+ 314 Figure 2: Packet timestamps in interleaved symmetric mode 316 If the peer A has no association with the peer B and it responds with 317 symmetric passive packets, it does not need to count the packets in 318 order to meet the restrictions, because each request has at most one 319 response. The peer SHOULD process the requests in the same way as a 320 server which supports the interleaved client/server mode. It MUST 321 NOT respond in the interleaved mode if the request was not in the 322 interleaved mode. 324 The peers SHOULD compute the offset and delay using one the two sets 325 of timestamps specified in the client/server section. They MAY 326 switch between them to minimize the interval between T1 and T4 in 327 order to reduce the error in the measured delay. 329 4. Interleaved Broadcast mode 331 A packet in the interleaved broadcast mode contains two transmit 332 timestamps. One corresponds to the packet itself and is saved in the 333 transmit timestamp field. The other corresponds to the previous 334 packet and is saved in the origin timestamp field. The packet is 335 compatible with the basic mode, which uses a zero origin timestamp. 337 A client which does not support the interleaved mode ignores the 338 origin timestamp and processes all packets as if they were in the 339 basic mode. 341 A client which supports the interleaved mode SHOULD check if the 342 origin timestamp is not zero to detect packets in the interleaved 343 mode. The client SHOULD also compare the origin timestamp with the 344 transmit timestamp from the previous packet to detect lost packets. 345 If the difference is larger than a specified maximum (e.g. 1 second), 346 the packet SHOULD NOT be used for synchronization. 348 The client SHOULD compute the offset using the origin timestamp from 349 the received packet and the local receive timestamp of the previous 350 packet. If the client needs to measure the network delay, it SHOULD 351 use the interleaved client/server mode. 353 5. Acknowledgements 355 The interleaved modes described in this document are based on the 356 reference NTP implementation written by David Mills. 358 The authors would like to thank Kristof Teichel for his useful 359 comments. 361 6. IANA Considerations 363 This memo includes no request to IANA. 365 7. Security Considerations 367 Security issues that apply to the basic modes apply also to the 368 interleaved modes. They are described in The Security of NTP's 369 Datagram Protocol [SECNTP]. 371 Clients and peers SHOULD NOT leak the receive timestamp in packets 372 sent to other peers or clients (e.g. as a reference timestamp) to 373 prevent off-path attackers from easily getting the origin timestamp 374 needed to make a valid response in the interleaved mode. 376 Clients SHOULD randomize all bits of both receive and transmit 377 timestamps, as recommended for the transmit timestamp in the NTP 378 client data minimization [I-D.ietf-ntp-data-minimization], to make it 379 more difficult for off-path attackers to guess the origin timestamp. 381 Protecting symmetric associations in the interleaved mode against 382 replay attacks is even more difficult than in the basic mode, because 383 the NTP state needs to be protected not only between the reception 384 and transmission in order to send the peer a packet with a valid 385 origin timestamp, but all the time to not lose the timestamps which 386 will be needed to complete a measurement when the following packet in 387 the interleaved mode is received. 389 8. References 391 8.1. Normative References 393 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 394 Requirement Levels", BCP 14, RFC 2119, 395 DOI 10.17487/RFC2119, March 1997, 396 . 398 [RFC5905] Mills, D., Martin, J., Ed., Burbank, J., and W. Kasch, 399 "Network Time Protocol Version 4: Protocol and Algorithms 400 Specification", RFC 5905, DOI 10.17487/RFC5905, June 2010, 401 . 403 8.2. Informative References 405 [I-D.ietf-ntp-data-minimization] 406 Franke, D. and A. Malhotra, "NTP Client Data 407 Minimization", draft-ietf-ntp-data-minimization-01 (work 408 in progress), July 2017. 410 [SECNTP] Malhotra, A., Gundy, M., Varia, M., Kennedy, H., Gardner, 411 J., and S. Goldberg, "The Security of NTP's Datagram 412 Protocol", 2016, . 414 Authors' Addresses 416 Miroslav Lichvar 417 Red Hat 418 Purkynova 115 419 Brno 612 00 420 Czech Republic 422 Email: mlichvar@redhat.com 424 Aanchal Malhotra 425 Boston University 426 111 Cummington St 427 Boston 02215 428 USA 430 Email: aanchal4@bu.edu