idnits 2.17.1 draft-ietf-taps-impl-05.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 : ---------------------------------------------------------------------------- ** There are 7 instances of too long lines in the document, the longest one being 41 characters in excess of 72. ** The abstract seems to contain references ([I-D.ietf-taps-arch]), which it shouldn't. Please replace those with straight textual mentions of the documents in question. ** The document seems to lack a both a reference to RFC 2119 and the recommended RFC 2119 boilerplate, even if it appears to use RFC 2119 keywords. RFC 2119 keyword, line 1202: '... Implementations SHOULD ensure that th...' Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (November 04, 2019) is 1633 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- == Missing Reference: 'SUBCATEGORY' is mentioned on line 1502, but not defined -- Looks like a reference, but probably isn't: '1' on line 2161 -- Looks like a reference, but probably isn't: '2' on line 2170 -- Looks like a reference, but probably isn't: '3' on line 2172 -- Looks like a reference, but probably isn't: '4' on line 2180 == Unused Reference: 'Trickle' is defined on line 2061, but no explicit reference was found in the text == Outdated reference: A later version (-19) exists of draft-ietf-taps-arch-04 == Outdated reference: A later version (-26) exists of draft-ietf-taps-interface-04 ** Obsolete normative reference: RFC 7540 (Obsoleted by RFC 9113) == Outdated reference: A later version (-34) exists of draft-ietf-quic-transport-23 -- Obsolete informational reference (is this intentional?): RFC 5245 (Obsoleted by RFC 8445, RFC 8839) Summary: 4 errors (**), 0 flaws (~~), 6 warnings (==), 6 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 TAPS Working Group A. Brunstrom, Ed. 3 Internet-Draft Karlstad University 4 Intended status: Informational T. Pauly, Ed. 5 Expires: May 7, 2020 Apple Inc. 6 T. Enghardt 7 TU Berlin 8 K-J. Grinnemo 9 Karlstad University 10 T. Jones 11 University of Aberdeen 12 P. Tiesel 13 TU Berlin 14 C. Perkins 15 University of Glasgow 16 M. Welzl 17 University of Oslo 18 November 04, 2019 20 Implementing Interfaces to Transport Services 21 draft-ietf-taps-impl-05 23 Abstract 25 The Transport Services architecture [I-D.ietf-taps-arch] defines a 26 system that allows applications to use transport networking protocols 27 flexibly. This document serves as a guide to implementation on how 28 to build such a system. 30 Status of This Memo 32 This Internet-Draft is submitted in full conformance with the 33 provisions of BCP 78 and BCP 79. 35 Internet-Drafts are working documents of the Internet Engineering 36 Task Force (IETF). Note that other groups may also distribute 37 working documents as Internet-Drafts. The list of current Internet- 38 Drafts is at https://datatracker.ietf.org/drafts/current/. 40 Internet-Drafts are draft documents valid for a maximum of six months 41 and may be updated, replaced, or obsoleted by other documents at any 42 time. It is inappropriate to use Internet-Drafts as reference 43 material or to cite them other than as "work in progress." 45 This Internet-Draft will expire on May 7, 2020. 47 Copyright Notice 49 Copyright (c) 2019 IETF Trust and the persons identified as the 50 document authors. All rights reserved. 52 This document is subject to BCP 78 and the IETF Trust's Legal 53 Provisions Relating to IETF Documents 54 (https://trustee.ietf.org/license-info) in effect on the date of 55 publication of this document. Please review these documents 56 carefully, as they describe your rights and restrictions with respect 57 to this document. Code Components extracted from this document must 58 include Simplified BSD License text as described in Section 4.e of 59 the Trust Legal Provisions and are provided without warranty as 60 described in the Simplified BSD License. 62 Table of Contents 64 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3 65 2. Implementing Connection Objects . . . . . . . . . . . . . . . 4 66 3. Implementing Pre-Establishment . . . . . . . . . . . . . . . 4 67 3.1. Configuration-time errors . . . . . . . . . . . . . . . . 5 68 3.2. Role of system policy . . . . . . . . . . . . . . . . . . 6 69 4. Implementing Connection Establishment . . . . . . . . . . . . 6 70 4.1. Candidate Gathering . . . . . . . . . . . . . . . . . . . 8 71 4.1.1. Gathering Endpoint Candidates . . . . . . . . . . . . 8 72 4.1.2. Structuring Options as a Tree . . . . . . . . . . . . 9 73 4.1.3. Branch Types . . . . . . . . . . . . . . . . . . . . 11 74 4.2. Branching Order-of-Operations . . . . . . . . . . . . . . 13 75 4.3. Sorting Branches . . . . . . . . . . . . . . . . . . . . 14 76 4.4. Candidate Racing . . . . . . . . . . . . . . . . . . . . 15 77 4.4.1. Delayed . . . . . . . . . . . . . . . . . . . . . . . 16 78 4.4.2. Failover . . . . . . . . . . . . . . . . . . . . . . 17 79 4.5. Completing Establishment . . . . . . . . . . . . . . . . 17 80 4.5.1. Determining Successful Establishment . . . . . . . . 18 81 4.6. Establishing multiplexed connections . . . . . . . . . . 18 82 4.7. Handling racing with "unconnected" protocols . . . . . . 19 83 4.8. Implementing listeners . . . . . . . . . . . . . . . . . 19 84 4.8.1. Implementing listeners for Connected Protocols . . . 20 85 4.8.2. Implementing listeners for Unconnected Protocols . . 20 86 4.8.3. Implementing listeners for Multiplexed Protocols . . 20 87 5. Implementing Sending and Receiving Data . . . . . . . . . . . 21 88 5.1. Sending Messages . . . . . . . . . . . . . . . . . . . . 21 89 5.1.1. Message Properties . . . . . . . . . . . . . . . . . 21 90 5.1.2. Send Completion . . . . . . . . . . . . . . . . . . . 23 91 5.1.3. Batching Sends . . . . . . . . . . . . . . . . . . . 23 92 5.2. Receiving Messages . . . . . . . . . . . . . . . . . . . 23 93 5.3. Handling of data for fast-open protocols . . . . . . . . 24 94 6. Implementing Message Framers . . . . . . . . . . . . . . . . 24 95 6.1. Defining Message Framers . . . . . . . . . . . . . . . . 25 96 6.2. Sender-side Message Framing . . . . . . . . . . . . . . . 26 97 6.3. Receiver-side Message Framing . . . . . . . . . . . . . . 26 98 7. Implementing Connection Management . . . . . . . . . . . . . 27 99 7.1. Pooled Connection . . . . . . . . . . . . . . . . . . . . 28 100 7.2. Handling Path Changes . . . . . . . . . . . . . . . . . . 28 101 8. Implementing Connection Termination . . . . . . . . . . . . . 29 102 9. Cached State . . . . . . . . . . . . . . . . . . . . . . . . 30 103 9.1. Protocol state caches . . . . . . . . . . . . . . . . . . 30 104 9.2. Performance caches . . . . . . . . . . . . . . . . . . . 31 105 10. Specific Transport Protocol Considerations . . . . . . . . . 32 106 10.1. TCP . . . . . . . . . . . . . . . . . . . . . . . . . . 33 107 10.2. UDP . . . . . . . . . . . . . . . . . . . . . . . . . . 34 108 10.3. TLS . . . . . . . . . . . . . . . . . . . . . . . . . . 35 109 10.4. DTLS . . . . . . . . . . . . . . . . . . . . . . . . . . 37 110 10.5. HTTP . . . . . . . . . . . . . . . . . . . . . . . . . . 37 111 10.6. QUIC . . . . . . . . . . . . . . . . . . . . . . . . . . 38 112 10.7. HTTP/2 transport . . . . . . . . . . . . . . . . . . . . 39 113 10.8. SCTP . . . . . . . . . . . . . . . . . . . . . . . . . . 39 114 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 42 115 12. Security Considerations . . . . . . . . . . . . . . . . . . . 42 116 12.1. Considerations for Candidate Gathering . . . . . . . . . 42 117 12.2. Considerations for Candidate Racing . . . . . . . . . . 42 118 13. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 42 119 14. References . . . . . . . . . . . . . . . . . . . . . . . . . 43 120 14.1. Normative References . . . . . . . . . . . . . . . . . . 43 121 14.2. Informative References . . . . . . . . . . . . . . . . . 44 122 Appendix A. Additional Properties . . . . . . . . . . . . . . . 45 123 A.1. Properties Affecting Sorting of Branches . . . . . . . . 45 124 Appendix B. Reasons for errors . . . . . . . . . . . . . . . . . 45 125 Appendix C. Existing Implementations . . . . . . . . . . . . . . 46 126 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 47 128 1. Introduction 130 The Transport Services architecture [I-D.ietf-taps-arch] defines a 131 system that allows applications to use transport networking protocols 132 flexibly. The interface such a system exposes to applications is 133 defined as the Transport Services API [I-D.ietf-taps-interface]. 134 This API is designed to be generic across multiple transport 135 protocols and sets of protocols features. 137 This document serves as a guide to implementation on how to build a 138 system that provides a Transport Services API. It is the job of an 139 implementation of a Transport Services system to turn the requests of 140 an application into decisions on how to establish connections, and 141 how to transfer data over those connections once established. The 142 terminology used in this document is based on the Architecture 143 [I-D.ietf-taps-arch]. 145 2. Implementing Connection Objects 147 The connection objects that are exposed to applications for Transport 148 Services are: 150 o the Preconnection, the bundle of properties that describes the 151 application constraints on the transport; 153 o the Connection, the basic object that represents a flow of data in 154 either direction between the Local and Remote Endpoints; 156 o and the Listener, a passive waiting object that delivers new 157 Connections. 159 Preconnection objects should be implemented as bundles of properties 160 that an application can both read and write. Once a Preconnection 161 has been used to create an outbound Connection or a Listener, the 162 implementation should ensure that the copy of the properties held by 163 the Connection or Listener is immutable. This may involve performing 164 a deep-copy if the application is still able to modify properties on 165 the original Preconnection object. 167 Connection objects represent the interface between the application 168 and the implementation to manage transport state, and conduct data 169 transfer. During the process of establishment (Section 4), the 170 Connection will be unbound to a specific transport flow, since there 171 may be multiple candidate Protocol Stacks being raced. Once the 172 Connection is established, the object should be considered mapped to 173 a specific Protocol Stack. The notion of a Connection maps to many 174 different protocols, depending on the Protocol Stack. For example, 175 the Connection may ultimately represent the interface into a TCP 176 connection, a TLS session over TCP, a UDP flow with fully-specified 177 local and remote endpoints, a DTLS session, a SCTP stream, a QUIC 178 stream, or an HTTP/2 stream. 180 Listener objects are created with a Preconnection, at which point 181 their configuration should be considered immutable by the 182 implementation. The process of listening is described in 183 Section 4.8. 185 3. Implementing Pre-Establishment 187 During pre-establishment the application specifies the Endpoints to 188 be used for communication as well as its preferences via Selection 189 Properties and, if desired, also Connection Properties. Generally, 190 Connection Properties should be configured as early as possible, as 191 they may serve as input to decisions that are made by the 192 implementation (the Capacity Profile may guide usage of a protocol 193 offering scavenger-type congestion control, for example). In the 194 remainder of this document, we only refer to Selection Properties 195 because they are the more typical case and have to be handled by all 196 implementations. 198 The implementation stores these objects and properties as part of the 199 Preconnection object for use during connection establishment. For 200 Selection Properties that are not provided by the application, the 201 implementation must use the default values specified in the Transport 202 Services API ([I-D.ietf-taps-interface]). 204 3.1. Configuration-time errors 206 The transport system should have a list of supported protocols 207 available, which each have transport features reflecting the 208 capabilities of the protocol. Once an application specifies its 209 Transport Parameters, the transport system should match the required 210 and prohibited properties against the transport features of the 211 available protocols. 213 In the following cases, failure should be detected during pre- 214 establishment: 216 o The application requested Protocol Properties that include 217 requirements or prohibitions that cannot be satisfied by any of 218 the available protocols. For example, if an application requires 219 "Configure Reliability per Message", but no such protocol is 220 available on the host running the transport system, e.g., because 221 SCTP is not supported by the operating system, this should result 222 in an error. 224 o The application requested Protocol Properties that are in conflict 225 with each other, i.e., the required and prohibited properties 226 cannot be satisfied by the same protocol. For example, if an 227 application prohibits "Reliable Data Transfer" but then requires 228 "Configure Reliability per Message", this mismatch should result 229 in an error. 231 It is important to fail as early as possible in such cases in order 232 to avoid allocating resources, e.g., to endpoint resolution, only to 233 find out later that there is no protocol that satisfies the 234 requirements. 236 3.2. Role of system policy 238 The properties specified during pre-establishment have a close 239 connection to system policy. The implementation is responsible for 240 combining and reconciling several different sources of preferences 241 when establishing Connections. These include, but are not limited 242 to: 244 1. Application preferences, i.e., preferences specified during the 245 pre-establishment via Selection Properties. 247 2. Dynamic system policy, i.e., policy compiled from internally and 248 externally acquired information about available network 249 interfaces, supported transport protocols, and current/previous 250 Connections. Examples of ways to externally retrieve policy- 251 support information are through OS-specific statistics/ 252 measurement tools and tools that reside on middleboxes and 253 routers. 255 3. Default implementation policy, i.e., predefined policy by OS or 256 application. 258 In general, any protocol or path used for a connection must conform 259 to all three sources of constraints. Any violation of any of the 260 layers should cause a protocol or path to be considered ineligible 261 for use. For an example of application preferences leading to 262 constraints, an application may prohibit the use of metered network 263 interfaces for a given Connection to avoid user cost. Similarly, the 264 system policy at a given time may prohibit the use of such a metered 265 network interface from the application's process. Lastly, the 266 implementation itself may default to disallowing certain network 267 interfaces unless explicitly requested by the application and allowed 268 by the system. 270 It is expected that the database of system policies and the method of 271 looking up these policies will vary across various platforms. An 272 implementation should attempt to look up the relevant policies for 273 the system in a dynamic way to make sure it is reflecting an accurate 274 version of the system policy, since the system's policy regarding the 275 application's traffic may change over time due to user or 276 administrative changes. 278 4. Implementing Connection Establishment 280 The process of establishing a network connection begins when an 281 application expresses intent to communicate with a remote endpoint by 282 calling Initiate. (At this point, any constraints or requirements 283 the application may have on the connection are available from pre- 284 establishment.) The process can be considered complete once there is 285 at least one Protocol Stack that has completed any required setup to 286 the point that it can transmit and receive the application's data. 288 Connection establishment is divided into two top-level steps: 289 Candidate Gathering, to identify the paths, protocols, and endpoints 290 to use, and Candidate Racing, in which the necessary protocol 291 handshakes are conducted so that the transport system can select 292 which set to use. This document structures candidates for racing as 293 a tree. 295 The most simple example of this process might involve identifying the 296 single IP address to which the implementation wishes to connect, 297 using the system's current default interface or path, and starting a 298 TCP handshake to establish a stream to the specified IP address. 299 However, each step may also vary depending on the requirements of the 300 connection: if the endpoint is defined as a hostname and port, then 301 there may be multiple resolved addresses that are available; there 302 may also be multiple interfaces or paths available, other than the 303 default system interface; and some protocols may not need any 304 transport handshake to be considered "established" (such as UDP), 305 while other connections may utilize layered protocol handshakes, such 306 as TLS over TCP. 308 Whenever an implementation has multiple options for connection 309 establishment, it can view the set of all individual connection 310 establishment options as a single, aggregate connection 311 establishment. The aggregate set conceptually includes every valid 312 combination of endpoints, paths, and protocols. As an example, 313 consider an implementation that initiates a TCP connection to a 314 hostname + port endpoint, and has two valid interfaces available (Wi- 315 Fi and LTE). The hostname resolves to a single IPv4 address on the 316 Wi-Fi network, and resolves to the same IPv4 address on the LTE 317 network, as well as a single IPv6 address. The aggregate set of 318 connection establishment options can be viewed as follows: 320 Aggregate [Endpoint: www.example.com:80] [Interface: Any] [Protocol: TCP] 321 |-> [Endpoint: 192.0.2.1:80] [Interface: Wi-Fi] [Protocol: TCP] 322 |-> [Endpoint: 192.0.2.1:80] [Interface: LTE] [Protocol: TCP] 323 |-> [Endpoint: 2001:DB8::1.80] [Interface: LTE] [Protocol: TCP] 325 Any one of these sub-entries on the aggregate connection attempt 326 would satisfy the original application intent. The concern of this 327 section is the algorithm defining which of these options to try, 328 when, and in what order. 330 4.1. Candidate Gathering 332 The step of gathering candidates involves identifying which paths, 333 protocols, and endpoints may be used for a given Connection. This 334 list is determined by the requirements, prohibitions, and preferences 335 of the application as specified in the Selection Properties. 337 4.1.1. Gathering Endpoint Candidates 339 Both Local and Remote Endpoint Candidates must be discovered during 340 connection establishment. To support ICE, or similar protocols, that 341 involve out-of-band indirect signalling to exchange candidates with 342 the Remote Endpoint, it's important to be able to query the set of 343 candidate Local Endpoints, and give the protocol stack a set of 344 candidate Remote Endpoints, before it attempts to establish 345 connections. 347 4.1.1.1. Local Endpoint candidates 349 The set of possible Local Endpoints is gathered. In the simple case, 350 this merely enumerates the local interfaces and protocols, allocates 351 ephemeral source ports. For example, a system that has WiFi and 352 Ethernet and supports IPv4 and IPv6 might gather four candidate 353 locals (IPv4 on Ethernet, IPv6 on Ethernet, IPv4 on WiFi, and IPv6 on 354 WiFi) that can form the source for a transient. 356 If NAT traversal is required, the process of gathering Local 357 Endpoints becomes broadly equivalent to the ICE candidate gathering 358 phase [RFC5245]. The endpoint determines its server reflexive Local 359 Endpoints (i.e., the translated address of a local, on the other side 360 of a NAT) and relayed locals (e.g., via a TURN server or other 361 relay), for each interface and network protocol. These are added to 362 the set of candidate Local Endpoints for this connection. 364 Gathering Local Endpoints is primarily a local operation, although it 365 might involve exchanges with a STUN server to derive server reflexive 366 locals, or with a TURN server or other relay to derive relayed 367 locals. It does not involve communication with the Remote Endpoint. 369 4.1.1.2. Remote Endpoint Candidates 371 The Remote Endpoint is typically a name that needs to be resolved 372 into a set of possible addresses that can be used for communication. 373 Resolving the Remote Endpoint is the process of recursively 374 performing such name lookups, until fully resolved, to return the set 375 of candidates for the remote of this connection. 377 How this is done will depend on the type of the Remote Endpoint, and 378 can also be specific to each Local Endpoint. A common case is when 379 the Remote Endpoint is a DNS name, in which case it is resolved to 380 give a set of IPv4 and IPv6 addresses representing that name. Some 381 types of remote might require more complex resolution. Resolving the 382 Remote Endpoint for a peer-to-peer connection might involve 383 communication with a rendezvous server, which in turn contacts the 384 peer to gain consent to communicate and retrieve its set of candidate 385 locals, which are returned and form the candidate remote addresses 386 for contacting that peer. 388 Resolving the remote is not a local operation. It will involve a 389 directory service, and can require communication with the remote to 390 rendezvous and exchange peer addresses. This can expose some or all 391 of the candidate locals to the remote. 393 4.1.2. Structuring Options as a Tree 395 When an implementation responsible for connection establishment needs 396 to consider multiple options, it should logically structure these 397 options as a hierarchical tree. Each leaf node of the tree 398 represents a single, coherent connection attempt, with an Endpoint, a 399 Path, and a set of protocols that can directly negotiate and send 400 data on the network. Each node in the tree that is not a leaf 401 represents a connection attempt that is either underspecified, or 402 else includes multiple distinct options. For example. when 403 connecting on an IP network, a connection attempt to a hostname and 404 port is underspecified, because the connection attempt requires a 405 resolved IP address as its remote endpoint. In this case, the node 406 represented by the connection attempt to the hostname is a parent 407 node, with child nodes for each IP address. Similarly, an 408 implementation that is allowed to connect using multiple interfaces 409 will have a parent node of the tree for the decision between the 410 paths, with a branch for each interface. 412 The example aggregate connection attempt above can be drawn as a tree 413 by grouping the addresses resolved on the same interface into 414 branches: 416 || 417 +==========================+ 418 | www.example.com:80/Any | 419 +==========================+ 420 // \\ 421 +==========================+ +==========================+ 422 | www.example.com:80/Wi-Fi | | www.example.com:80/LTE | 423 +==========================+ +==========================+ 424 || // \\ 425 +====================+ +====================+ +======================+ 426 | 192.0.2.1:80/Wi-Fi | | 192.0.2.1:80/LTE | | 2001:DB8::1.80/LTE | 427 +====================+ +====================+ +======================+ 429 The rest of this section will use a notation scheme to represent this 430 tree. The parent (or trunk) node of the tree will be represented by 431 a single integer, such as "1". Each child of that node will have an 432 integer that identifies it, from 1 to the number of children. That 433 child node will be uniquely identified by concatenating its integer 434 to it's parents identifier with a dot in between, such as "1.1" and 435 "1.2". Each node will be summarized by a tuple of three elements: 436 Endpoint, Path, and Protocol. The above example can now be written 437 more succinctly as: 439 1 [www.example.com:80, Any, TCP] 440 1.1 [www.example.com:80, Wi-Fi, TCP] 441 1.1.1 [192.0.2.1:80, Wi-Fi, TCP] 442 1.2 [www.example.com:80, LTE, TCP] 443 1.2.1 [192.0.2.1:80, LTE, TCP] 444 1.2.2 [2001:DB8::1.80, LTE, TCP] 446 When an implementation views this aggregate set of connection 447 attempts as a single connection establishment, it only will use one 448 of the leaf nodes to transfer data. Thus, when a single leaf node 449 becomes ready to use, then the entire connection attempt is ready to 450 use by the application. Another way to represent this is that every 451 leaf node updates the state of its parent node when it becomes ready, 452 until the trunk node of the tree is ready, which then notifies the 453 application that the connection as a whole is ready to use. 455 A connection establishment tree may be degenerate, and only have a 456 single leaf node, such as a connection attempt to an IP address over 457 a single interface with a single protocol. 459 1 [192.0.2.1:80, Wi-Fi, TCP] 461 A parent node may also only have one child (or leaf) node, such as a 462 when a hostname resolves to only a single IP address. 464 1 [www.example.com:80, Wi-Fi, TCP] 465 1.1 [192.0.2.1:80, Wi-Fi, TCP] 467 4.1.3. Branch Types 469 There are three types of branching from a parent node into one or 470 more child nodes. Any parent node of the tree must only use one type 471 of branching. 473 4.1.3.1. Derived Endpoints 475 If a connection originally targets a single endpoint, there may be 476 multiple endpoints of different types that can be derived from the 477 original. The connection library should order the derived endpoints 478 according to application preference, system policy and expected 479 performance. 481 DNS hostname-to-address resolution is the most common method of 482 endpoint derivation. When trying to connect to a hostname endpoint 483 on a traditional IP network, the implementation should send DNS 484 queries for both A (IPv4) and AAAA (IPv6) records if both are 485 supported on the local link. The algorithm for ordering and racing 486 these addresses should follow the recommendations in Happy Eyeballs 487 [RFC8305]. 489 1 [www.example.com:80, Wi-Fi, TCP] 490 1.1 [2001:DB8::1.80, Wi-Fi, TCP] 491 1.2 [192.0.2.1:80, Wi-Fi, TCP] 492 1.3 [2001:DB8::2.80, Wi-Fi, TCP] 493 1.4 [2001:DB8::3.80, Wi-Fi, TCP] 495 DNS-Based Service Discovery can also provide an endpoint derivation 496 step. When trying to connect to a named service, the client may 497 discover one or more hostname and port pairs on the local network 498 using multicast DNS. These hostnames should each be treated as a 499 branch which can be attempted independently from other hostnames. 500 Each of these hostnames may also resolve to one or more addresses, 501 thus creating multiple layers of branching. 503 1 [term-printer._ipp._tcp.meeting.ietf.org, Wi-Fi, TCP] 504 1.1 [term-printer.meeting.ietf.org:631, Wi-Fi, TCP] 505 1.1.1 [31.133.160.18.631, Wi-Fi, TCP] 507 4.1.3.2. Alternate Paths 509 If a client has multiple network interfaces available to it, such as 510 mobile client with both Wi-Fi and Cellular connectivity, it can 511 attempt a connection over either interface. This represents a branch 512 point in the connection establishment. Like with derived endpoints, 513 the interfaces should be ranked based on preference, system policy, 514 and performance. Attempts should be started on one interface, and 515 then on other interfaces successively after delays based on expected 516 round-trip-time or other available metrics. 518 1 [192.0.2.1:80, Any, TCP] 519 1.1 [192.0.2.1:80, Wi-Fi, TCP] 520 1.2 [192.0.2.1:80, LTE, TCP] 522 This same approach applies to any situation in which the client is 523 aware of multiple links or views of the network. Multiple Paths, 524 each with a coherent set of addresses, routes, DNS server, and more, 525 may share a single interface. A path may also represent a virtual 526 interface service such as a Virtual Private Network (VPN). 528 The list of available paths should be constrained by any requirements 529 or prohibitions the application sets, as well as system policy. 531 4.1.3.3. Protocol Options 533 Differences in possible protocol compositions and options can also 534 provide a branching point in connection establishment. This allows 535 clients to be resilient to situations in which a certain protocol is 536 not functioning on a server or network. 538 This approach is commonly used for connections with optional proxy 539 server configurations. A single connection may be allowed to use an 540 HTTP-based proxy, a SOCKS-based proxy, or connect directly. These 541 options should be ranked and attempted in succession. 543 1 [www.example.com:80, Any, HTTP/TCP] 544 1.1 [192.0.2.8:80, Any, HTTP/HTTP Proxy/TCP] 545 1.2 [192.0.2.7:10234, Any, HTTP/SOCKS/TCP] 546 1.3 [www.example.com:80, Any, HTTP/TCP] 547 1.3.1 [192.0.2.1:80, Any, HTTP/TCP] 549 This approach also allows a client to attempt different sets of 550 application and transport protocols that may provide preferable 551 characteristics when available. For example, the protocol options 552 could involve QUIC [I-D.ietf-quic-transport] over UDP on one branch, 553 and HTTP/2 [RFC7540] over TLS over TCP on the other: 555 1 [www.example.com:443, Any, Any HTTP] 556 1.1 [www.example.com:443, Any, QUIC/UDP] 557 1.1.1 [192.0.2.1:443, Any, QUIC/UDP] 558 1.2 [www.example.com:443, Any, HTTP2/TLS/TCP] 559 1.2.1 [192.0.2.1:443, Any, HTTP2/TLS/TCP] 561 Another example is racing SCTP with TCP: 563 1 [www.example.com:80, Any, Any Stream] 564 1.1 [www.example.com:80, Any, SCTP] 565 1.1.1 [192.0.2.1:80, Any, SCTP] 566 1.2 [www.example.com:80, Any, TCP] 567 1.2.1 [192.0.2.1:80, Any, TCP] 569 Implementations that support racing protocols and protocol options 570 should maintain a history of which protocols and protocol options 571 successfully established, on a per-network basis (see Section 9.2). 572 This information can influence future racing decisions to prioritize 573 or prune branches. 575 4.2. Branching Order-of-Operations 577 Branch types must occur in a specific order relative to one another 578 to avoid creating leaf nodes with invalid or incompatible settings. 579 In the example above, it would be invalid to branch for derived 580 endpoints (the DNS results for www.example.com) before branching 581 between interface paths, since usable DNS results on one network may 582 not necessarily be the same as DNS results on another network due to 583 local network entities, supported address families, or enterprise 584 network configurations. Implementations must be careful to branch in 585 an order that results in usable leaf nodes whenever there are 586 multiple branch types that could be used from a single node. 588 The order of operations for branching, where lower numbers are acted 589 upon first, should be: 591 1. Alternate Paths 593 2. Protocol Options 595 3. Derived Endpoints 597 Branching between paths is the first in the list because results 598 across multiple interfaces are likely not related to one another: 599 endpoint resolution may return different results, especially when 600 using locally resolved host and service names, and which protocols 601 are supported and preferred may differ across interfaces. Thus, if 602 multiple paths are attempted, the overall connection can be seen as a 603 race between the available paths or interfaces. 605 Protocol options are checked next in order. Whether or not a set of 606 protocol, or protocol-specific options, can successfully connect is 607 generally not dependent on which specific IP address is used. 608 Furthermore, the protocol stacks being attempted may influence or 609 altogether change the endpoints being used. Adding a proxy to a 610 connection's branch will change the endpoint to the proxy's IP 611 address or hostname. Choosing an alternate protocol may also modify 612 the ports that should be selected. 614 Branching for derived endpoints is the final step, and may have 615 multiple layers of derivation or resolution, such as DNS service 616 resolution and DNS hostname resolution. 618 For example, if the application has indicated both a preference for 619 WiFi over LTE and for a feature only available in SCTP, branches will 620 be first sorted accord to path selection, with WiFi at the top. 621 Then, branches with SCTP will be sorted to the top within their 622 subtree according to the properties influencing protocol selection. 623 However, if the implementation has cached the information that SCTP 624 is not available on the path over WiFi, there is no SCTP node in the 625 WiFi subtree. Here, the path over WiFi will be tried first, and, if 626 connection establishment succeeds, TCP will be used. So the 627 Selection Property of preferring WiFi takes precedence over the 628 Property that led to a preference for SCTP. 630 1. [www.example.com:80, Any, Any Stream] 631 1.1 [192.0.2.1:80, Wi-Fi, Any Stream] 632 1.1.1 [192.0.2.1:80, Wi-Fi, TCP] 633 1.2 [192.0.3.1:80, LTE, Any Stream] 634 1.2.1 [192.0.3.1:80, LTE, SCTP] 635 1.2.2 [192.0.3.1:80, LTE, TCP] 637 4.3. Sorting Branches 639 Implementations should sort the branches of the tree of connection 640 options in order of their preference rank. Leaf nodes on branches 641 with higher rankings represent connection attempts that will be raced 642 first. Implementations should order the branches to reflect the 643 preferences expressed by the application for its new connection, 644 including Selection Properties, which are specified in 645 [I-D.ietf-taps-interface]. 647 In addition to the properties provided by the application, an 648 implementation may include additional criteria such as cached 649 performance estimates, see Section 9.2, or system policy, see 650 Section 3.2, in the ranking. Two examples of how Selection and 651 Connection Properties may be used to sort branches are provided 652 below: 654 o "Interface Instance or Type": If the application specifies an 655 interface type to be preferred or avoided, implementations should 656 rank paths accordingly. If the application specifies an interface 657 type to be required or prohibited, we expect an implementation to 658 not include the non-conforming paths into the three. 660 o "Capacity Profile": An implementation may use the Capacity Profile 661 to prefer paths optimized for the application's expected traffic 662 pattern according to cached performance estimates, see 663 Section 9.2: 665 * Scavenger: Prefer paths with the highest expected available 666 bandwidth, based on observed maximum throughput 668 * Low Latency/Interactive: Prefer paths with the lowest expected 669 Round Trip Time 671 * Constant-Rate Streaming: Prefer paths that can satisfy the 672 requested Stream Send or Stream Receive Bitrate, based on 673 observed maximum throughput 675 Implementations should process properties in the following order: 676 Prohibit, Require, Prefer, Avoid. If Selection Properties contain 677 any prohibited properties, the implementation should first purge 678 branches containing nodes with these properties. For required 679 properties, it should only keep branches that satisfy these 680 requirements. Finally, it should order branches according to 681 preferred properties, and finally use avoided properties as a 682 tiebreaker. 684 4.4. Candidate Racing 686 The primary goal of the Candidate Racing process is to successfully 687 negotiate a protocol stack to an endpoint over an interface--to 688 connect a single leaf node of the tree--with as little delay and as 689 few unnecessary connections attempts as possible. Optimizing these 690 two factors improves the user experience, while minimizing network 691 load. 693 This section covers the dynamic aspect of connection establishment. 694 While the tree described above is a useful conceptual and 695 architectural model, an implementation does not know what the full 696 tree may become up front, nor will many of the possible branches be 697 used in the common case. 699 There are three different approaches to racing the attempts for 700 different nodes of the connection establishment tree: 702 1. Immediate 704 2. Delayed 705 3. Failover 707 Each approach is appropriate in different use-cases and branch types. 708 However, to avoid consuming unnecessary network resources, 709 implementations should not use immediate racing as a default 710 approach. 712 The timing algorithms for racing should remain independent across 713 branches of the tree. Any timers or racing logic is isolated to a 714 given parent node, and is not ordered precisely with regards to other 715 children of other nodes. 717 4.4.1. Delayed 719 Delayed racing can be used whenever a single node of the tree has 720 multiple child nodes. Based on the order determined when building 721 the tree, the first child node will be initiated immediately, 722 followed by the next child node after some delay. Once that second 723 child node is initiated, the third child node (if present) will begin 724 after another delay, and so on until all child nodes have been 725 initiated, or one of the child nodes successfully completes its 726 negotiation. 728 Delayed racing attempts occur in parallel. Implementations should 729 not terminate an earlier child connection attempt upon starting a 730 secondary child. 732 The delay between starting child nodes should be based on the 733 properties of the previously started child node. For example, if the 734 first child represents an IP address with a known route, and the 735 second child represents another IP address, the delay between 736 starting the first and second IP addresses can be based on the 737 expected retransmission cadence for the first child's connection 738 (derived from historical round-trip-time). Alternatively, if the 739 first child represents a branch on a Wi-Fi interface, and the second 740 child represents a branch on an LTE interface, the delay should be 741 based on the expected time in which the branch for the first 742 interface would be able to establish a connection, based on link 743 quality and historical round-trip-time. 745 Any delay should have a defined minimum and maximum value based on 746 the branch type. Generally, branches between paths and protocols 747 should have longer delays than branches between derived endpoints. 748 The maximum delay should be considered with regards to how long a 749 user is expected to wait for the connection to complete. 751 If a child node fails to connect before the delay timer has fired for 752 the next child, the next child should be started immediately. 754 4.4.2. Failover 756 If an implementation or application has a strong preference for one 757 branch over another, the branching node may choose to wait until one 758 child has failed before starting the next. Failure of a leaf node is 759 determined by its protocol negotiation failing or timing out; failure 760 of a parent branching node is determined by all of its children 761 failing. 763 An example in which failover is recommended is a race between a 764 protocol stack that uses a proxy and a protocol stack that bypasses 765 the proxy. Failover is useful in case the proxy is down or 766 misconfigured, but any more aggressive type of racing may end up 767 unnecessarily avoiding a proxy that was preferred by policy. 769 4.5. Completing Establishment 771 The process of connection establishment completes when one leaf node 772 of the tree has completed negotiation with the remote endpoint 773 successfully, or else all nodes of the tree have failed to connect. 774 The first leaf node to complete its connection is then used by the 775 application to send and receive data. 777 It is useful to process success and failure throughout the tree by 778 child nodes reporting to their parent nodes (towards the trunk of the 779 tree). For example, in the following case, if 1.1.1 fails to 780 connect, it reports the failure to 1.1. Since 1.1 has no other child 781 nodes, it also has failed and reports that failure to 1. Because 1.2 782 has not yet failed, 1 is not considered to have failed. Since 1.2 783 has not yet started, it is started and the process continues. 784 Similarly, if 1.1.1 successfully connects, then it marks 1.1 as 785 connected, which propagates to the trunk node 1. At this point, the 786 connection as a whole is considered to be successfully connected and 787 ready to process application data 789 1 [www.example.com:80, Any, TCP] 790 1.1 [www.example.com:80, Wi-Fi, TCP] 791 1.1.1 [192.0.2.1:80, Wi-Fi, TCP] 792 1.2 [www.example.com:80, LTE, TCP] 793 ... 795 If a leaf node has successfully completed its connection, all other 796 attempts should be made ineligible for use by the application for the 797 original request. New connection attempts that involve transmitting 798 data on the network should not be started after another leaf node has 799 completed successfully, as the connection as a whole has been 800 established. An implementation may choose to let certain handshakes 801 and negotiations complete in order to gather metrics to influence 802 future connections. Similarly, an implementation may choose to hold 803 onto fully established leaf nodes that were not the first to 804 establish for use as part of a Pooled Connection, see Section 7.1, or 805 in future connections. In both cases, keeping additional connections 806 is generally not recommended since those attempts were slower to 807 connect and may exhibit less desirable properties. 809 4.5.1. Determining Successful Establishment 811 Implementations may select the criteria by which a leaf node is 812 considered to be successfully connected differently on a per-protocol 813 basis. If the only protocol being used is a transport protocol with 814 a clear handshake, like TCP, then the obvious choice is to declare 815 that node "connected" when the last packet of the three-way handshake 816 has been received. If the only protocol being used is an 817 "unconnected" protocol, like UDP, the implementation may consider the 818 node fully "connected" the moment it determines a route is present, 819 before sending any packets on the network, see further Section 4.7. 821 For protocol stacks with multiple handshakes, the decision becomes 822 more nuanced. If the protocol stack involves both TLS and TCP, an 823 implementation could determine that a leaf node is connected after 824 the TCP handshake is complete, or it can wait for the TLS handshake 825 to complete as well. The benefit of declaring completion when the 826 TCP handshake finishes, and thus stopping the race for other branches 827 of the tree, is that there will be less burden on the network from 828 other connection attempts. On the other hand, by waiting until the 829 TLS handshake is complete, an implementation avoids the scenario in 830 which a TCP handshake completes quickly, but TLS negotiation is 831 either very slow or fails altogether in particular network conditions 832 or to a particular endpoint. To avoid the issue of TLS possibly 833 failing, the implementation should not generate a Ready event for the 834 Connection until TLS is established. 836 If all of the leaf nodes fail to connect during racing, i.e. none of 837 the configurations that satisfy all requirements given in the 838 Transport Parameters actually work over the available paths, then the 839 transport system should notify the application with an InitiateError 840 event. An InitiateError event should also be generated in case the 841 transport system finds no usable candidates to race. 843 4.6. Establishing multiplexed connections 845 Multiplexing several Connections over a single underlying transport 846 connection requires that the Connections to be multiplexed belong to 847 the same Connection Group (as is indicated by the application using 848 the Clone call). When the underlying transport connection supports 849 multi-streaming, the Transport System can map each Connection in the 850 Connection Group to a different stream. Thus, when the Connections 851 that are offered to an application by the Transport System are 852 multiplexed, the Transport System may implement the establishment of 853 a new Connection by simply beginning to use a new stream of an 854 already established transport connection and there is no need for a 855 connection establishment procedure. This, then, also means that 856 there may not be any "establishment" message (like a TCP SYN), but 857 the application can simply start sending or receiving. Therefore, 858 when the Initiate action of a Transport System is called without 859 Messages being handed over, it cannot be guaranteed that the other 860 endpoint will have any way to know about this, and hence a passive 861 endpoint's ConnectionReceived event may not be called upon an active 862 endpoint's Inititate. Instead, calling the ConnectionReceived event 863 may be delayed until the first Message arrives. 865 4.7. Handling racing with "unconnected" protocols 867 While protocols that use an explicit handshake to validate a 868 Connection to a peer can be used for racing multiple establishment 869 attempts in parallel, "unconnected" protocols such as raw UDP do not 870 offer a way to validate the presence of a peer or the usability of a 871 Connection without application feedback. An implementation should 872 consider such a protocol stack to be established as soon as a local 873 route to the peer endpoint is confirmed. 875 However, if a peer is not reachable over the network using the 876 unconnected protocol, or data cannot be exchanged for any other 877 reason, the application may want to attempt using another candidate 878 Protocol Stack. The implementation should maintain the list of other 879 candidate Protocol Stacks that were eligible to use. In the case 880 that the application signals that the initial Protocol Stack is 881 failing for some reason and that another option should be attempted, 882 the Connection can be updated to point to the next candidate Protocol 883 Stack. This can be viewed as an application-driven form of Protocol 884 Stack racing. 886 4.8. Implementing listeners 888 When an implementation is asked to Listen, it registers with the 889 system to wait for incoming traffic to the Local Endpoint. If no 890 Local Endpoint is specified, the implementation should either use an 891 ephemeral port or generate an error. 893 If the Selection Properties do not require a single network interface 894 or path, but allow the use of multiple paths, the Listener object 895 should register for incoming traffic on all of the network interfaces 896 or paths that conform to the Properties. The set of available paths 897 can change over time, so the implementation should monitor network 898 path changes and register and de-register the Listener across all 899 usable paths. When using multiple paths, the Listener is generally 900 expected to use the same port for listening on each. 902 If the Selection Properties allow multiple protocols to be used for 903 listening, and the implementation supports it, the Listener object 904 should register across the eligble protocols for each path. This 905 means that inbound Connections delivered by the implementation may 906 have heterogeneous protocol stacks. 908 4.8.1. Implementing listeners for Connected Protocols 910 Connected protocols such as TCP and TLS-over-TCP have a strong 911 mapping between the Local and Remote Endpoints (five-tuple) and their 912 protocol connection state. These map well into Connection objects. 913 Whenever a new inbound handshake is being started, the Listener 914 should generate a new Connection object and pass it to the 915 application. 917 4.8.2. Implementing listeners for Unconnected Protocols 919 Unconnected protocols such as UDP and UDP-lite generally do not 920 provide the same mechanisms that connected protocols do to offer 921 Connection objects. Implementations should wait for incoming packets 922 for unconnected protocols on a listening port and should perform 923 five-tuple matching of packets to either existing Connection objects 924 or the creation of new Connection objects. On platforms with 925 facilities to create a "virtual connection" for unconnected protocols 926 implementations should use these mechanisms to minimise the handling 927 of datagrams intended for already created Connection objects. 929 4.8.3. Implementing listeners for Multiplexed Protocols 931 Protocols that provide multiplexing of streams into a single five- 932 tuple can listen both for entirely new connections (a new HTTP/2 933 stream on a new TCP connection, for example) and for new sub- 934 connections (a new HTTP/2 stream on an existing connection). If the 935 abstraction of Connection presented to the application is mapped to 936 the multiplexed stream, then the Listener should deliver new 937 Connection objects in the same way for either case. The 938 implementation should allow the application to introspect the 939 Connection Group marked on the Connections to determine the grouping 940 of the multiplexing. 942 5. Implementing Sending and Receiving Data 944 The most basic mapping for sending a Message is an abstraction of 945 datagrams, in which the transport protocol naturally deals in 946 discrete packets. Each Message here corresponds to a single 947 datagram. Generally, these will be short enough that sending and 948 receiving will always use a complete Message. 950 For protocols that expose byte-streams, the only delineation provided 951 by the protocol is the end of the stream in a given direction. Each 952 Message in this case corresponds to the entire stream of bytes in a 953 direction. These Messages may be quite long, in which case they can 954 be sent in multiple parts. 956 Protocols that provide the framing (such as length-value protocols, 957 or protocols that use delimiters) provide data boundaries that may be 958 longer than a traditional packet datagram. Each Message for framing 959 protocols corresponds to a single frame, which may be sent either as 960 a complete Message, or in multiple parts. 962 5.1. Sending Messages 964 The effect of the application sending a Message is determined by the 965 top-level protocol in the established Protocol Stack. That is, if 966 the top-level protocol provides an abstraction of framed messages 967 over a connection, the receiving application will be able to obtain 968 multiple Messages on that connection, even if the framing protocol is 969 built on a byte-stream protocol like TCP. 971 5.1.1. Message Properties 973 o Lifetime: this should be implemented by removing the Message from 974 its queue of pending Messages after the Lifetime has expired. A 975 queue of pending Messages within the transport system 976 implementation that have yet to be handed to the Protocol Stack 977 can always support this property, but once a Message has been sent 978 into the send buffer of a protocol, only certain protocols may 979 support de-queueing a message. For example, TCP cannot remove 980 bytes from its send buffer, while in case of SCTP, such control 981 over the SCTP send buffer can be exercised using the partial 982 reliability extension [RFC8303]. When there is no standing queue 983 of Messages within the system, and the Protocol Stack does not 984 support removing a Message from its buffer, this property may be 985 ignored. 987 o Priority: this represents the ability to prioritize a Message over 988 other Messages. This can be implemented by the system re-ordering 989 Messages that have yet to be handed to the Protocol Stack, or by 990 giving relative priority hints to protocols that support 991 priorities per Message. For example, an implementation of HTTP/2 992 could choose to send Messages of different Priority on streams of 993 different priority. 995 o Ordered: when this is false, it disables the requirement of in- 996 order-delivery for protocols that support configurable ordering. 998 o Idempotent: when this is true, it means that the Message can be 999 used by mechanisms that might transfer it multiple times - e.g., 1000 as a result of racing multiple transports or as part of TCP Fast 1001 Open. 1003 o Final: when this is true, it means that a transport connection can 1004 be closed immediately after its transmission. 1006 o Corruption Protection Length: when this is set to any value other 1007 than -1, it limits the required checksum in protocols that allow 1008 limiting the checksum length (e.g. UDP-Lite). 1010 o Transmission Profile: TBD - because it's not final in the API yet. 1011 Old text follows: when this is set to "Interactive/Low Latency", 1012 the Message should be sent immediately, even when this comes at 1013 the cost of using the network capacity less efficiently. For 1014 example, small messages can sometimes be bundled to fit into a 1015 single data packet for the sake of reducing header overhead; such 1016 bundling should not be used. For example, in case of TCP, the 1017 Nagle algorithm should be disabled when Interactive/Low Latency is 1018 selected as the capacity profile. Scavenger/Bulk can translate 1019 into usage of a congestion control mechanism such as LEDBAT, and/ 1020 or the capacity profile can lead to a choice of a DSCP value as 1021 described in [I-D.ietf-taps-minset]). 1023 o Singular Transmission: when this is true, the application requests 1024 to avoid transport-layer segmentation or network-layer 1025 fragmentation. Some transports implement network-layer 1026 fragmentation avoidance (Path MTU Discovery) without exposing this 1027 functionality to the application; in this case, only transport- 1028 layer segmentation should be avoided, by fitting the message into 1029 a single transport-layer segment or otherwise failing. Otherwise, 1030 network-layer fragmentation should be avoided--e.g. by requesting 1031 the IP Don't Fragment bit to be set in case of UDP(-Lite) and IPv4 1032 (SET_DF in [RFC8304]). 1034 5.1.2. Send Completion 1036 The application should be notified whenever a Message or partial 1037 Message has been consumed by the Protocol Stack, or has failed to 1038 send. The meaning of the Message being consumed by the stack may 1039 vary depending on the protocol. For a basic datagram protocol like 1040 UDP, this may correspond to the time when the packet is sent into the 1041 interface driver. For a protocol that buffers data in queues, like 1042 TCP, this may correspond to when the data has entered the send 1043 buffer. 1045 5.1.3. Batching Sends 1047 Since sending a Message may involve a context switch between the 1048 application and the transport system, sending patterns that involve 1049 multiple small Messages can incur high overhead if each needs to be 1050 enqueued separately. To avoid this, the application should have a 1051 way to indicate a batch of Send actions, during which time the 1052 implementation will hold off on processing Messages until the batch 1053 is complete. This can also help context switches when enqueuing data 1054 in the interface driver if the operation can be batched. 1056 5.2. Receiving Messages 1058 Similar to sending, Receiving a Message is determined by the top- 1059 level protocol in the established Protocol Stack. The main 1060 difference with Receiving is that the size and boundaries of the 1061 Message are not known beforehand. The application can communicate in 1062 its Receive action the parameters for the Message, which can help the 1063 implementation know how much data to deliver and when. For example, 1064 if the application only wants to receive a complete Message, the 1065 implementation should wait until an entire Message (datagram, stream, 1066 or frame) is read before delivering any Message content to the 1067 application. This requires the implementation to understand where 1068 messages end, either via a supplied deframer or because the top-level 1069 protocol in the established Protocol Stack preserves message 1070 boundaries; if, on the other hand, the top-level protocol only 1071 supports a byte-stream and no deframers were supported, the 1072 application must specify the minimum number of bytes of Message 1073 content it wants to receive (which may be just a single byte) to 1074 control the flow of received data. 1076 If a Connection becomes finished before a requested Receive action 1077 can be satisfied, the implementation should deliver any partial 1078 Message content outstanding, or if none is available, an indication 1079 that there will be no more received Messages. 1081 5.3. Handling of data for fast-open protocols 1083 Several protocols allow sending higher-level protocol or application 1084 data within the first packet of their protocol establishment, such as 1085 TCP Fast Open [RFC7413] and TLS 1.3 [RFC8446]. This approach is 1086 referred to as sending Zero-RTT (0-RTT) data. This is a desirable 1087 property, but poses challenges to an implementation that uses racing 1088 during connection establishment. 1090 If the application has 0-RTT data to send in any protocol handshakes, 1091 it needs to provide this data before the handshakes have begun. When 1092 racing, this means that the data should be provided before the 1093 process of connection establishment has begun. If the application 1094 wants to send 0-RTT data, it must indicate this to the implementation 1095 by setting the Idempotent send parameter to true when sending the 1096 data. In general, 0-RTT data may be replayed (for example, if a TCP 1097 SYN contains data, and the SYN is retransmitted, the data will be 1098 retransmitted as well), but racing means that different leaf nodes 1099 have the opportunity to send the same data independently. If data is 1100 truly idempotent, this should be permissible. 1102 Once the application has provided its 0-RTT data, an implementation 1103 should keep a copy of this data and provide it to each new leaf node 1104 that is started and for which a 0-RTT protocol is being used. 1106 It is also possible that protocol stacks within a particular leaf 1107 node use 0-RTT handshakes without any idempotent application data. 1108 For example, TCP Fast Open could use a Client Hello from TLS as its 1109 0-RTT data, shortening the cumulative handshake time. 1111 0-RTT handshakes often rely on previous state, such as TCP Fast Open 1112 cookies, previously established TLS tickets, or out-of-band 1113 distributed pre-shared keys (PSKs). Implementations should be aware 1114 of security concerns around using these tokens across multiple 1115 addresses or paths when racing. In the case of TLS, any given ticket 1116 or PSK should only be used on one leaf node. If implementations have 1117 multiple tickets available from a previous connection, each leaf node 1118 attempt must use a different ticket. In effect, each leaf node will 1119 send the same early application data, yet encoded (encrypted) 1120 differently on the wire. 1122 6. Implementing Message Framers 1124 Message Framers are pieces of code that define simple transformations 1125 between application Message data and raw transport protocol data. A 1126 Framer can encapsulate or encode outbound Messages, and decapsulate 1127 or decode inbound data into Messages. 1129 While many protocols can be represented as Message Framers, for the 1130 purposes of the Transport Services interface these are ways for 1131 applications or application frameworks to define their own Message 1132 parsing to be included within a Connection's Protocol Stack. As an 1133 example, TLS can serve the purpose of framing data over TCP, but is 1134 exposed as a protocol natively supported by the Transport Services 1135 interface. 1137 Most Message Framers fall into one of two categories: 1139 o Header-prefixed record formats, such as a basic Type-Length-Value 1140 (TLV) structure 1142 o Delimiter-separated formats, such as HTTP/1.1. 1144 Common Message Framers can be provided by the Transport Services 1145 implementation, but an implemention ought to allow custom Message 1146 Framers to be defined by the application or some other piece of 1147 software. This section describes one possible interface for defining 1148 Message Framers as an example. 1150 6.1. Defining Message Framers 1152 A Message Framer is primarily defined by the set of code that handles 1153 events for a framer implementation, specifically how it handles 1154 inbound and outbound data parsing. The piece of code that implements 1155 custom framing logic will be referred to as the "framer 1156 implementation", which may be provided by the Transport Services 1157 implementation or the application itself. The Message Framer refers 1158 to the object or piece of code within the main Connection 1159 implementation that delivers events to the custom framer 1160 implementation whenever data is ready to be parsed or framed. 1162 When a Connection establishment attempt begins, an event can be 1163 delivered to notify the framer implementation that a new Connection 1164 is being created. Similarly, a stop event can be delivered when a 1165 Connection is being torn down. The framer implementation can use the 1166 Connection object to look up specific properties of the Connection or 1167 the network being used that may influence how to frame Messages. 1169 MessageFramer -> Start(Connection) 1170 MessageFramer -> Stop(Connection) 1172 When a Message Framer generates a "Start" event, the framer 1173 implementation has the opportunity to start writing some data prior 1174 to the Connection delivering its "Ready" event. This allows the 1175 implementation to communicate control data to the remote endpoint 1176 that can be used to parse Messages. 1178 MessageFramer.MakeConnectionReady(Connection) 1180 At any time if the implementation encounters a fatal error, it can 1181 also cause the Connection to fail and provide an error. 1183 MessageFramer.FailConnection(Connection, Error) 1185 Before an implementation marks a Message Framer as ready, it can also 1186 dynamically add a protocol or framer above it in the stack. This 1187 allows protocols like STARTTLS, that need to add TLS conditionally, 1188 to modify the Protocol Stack based on a handshake result. 1190 otherFramer := NewMessageFramer() 1191 MessageFramer.PrependFramer(Connection, otherFramer) 1193 6.2. Sender-side Message Framing 1195 Message Framers generate an event whenever a Connection sends a new 1196 Message. 1198 MessageFramer -> NewSentMessage 1200 Upon receiving this event, a framer implementation is responsible for 1201 performing any necessary transformations and sending the resulting 1202 data to the next protocol. Implementations SHOULD ensure that there 1203 is a way to pass the original data through without copying to improve 1204 performance. 1206 MessageFramer.Send(Connection, Data) 1208 To provide an example, a simple protocol that adds a length as a 1209 header would receive the "NewSentMessage" event, create a data 1210 representation of the length of the Message data, and then send a 1211 block of data that is the concatenation of the length header and the 1212 original Message data. 1214 6.3. Receiver-side Message Framing 1216 In order to parse a received flow of data into Messages, the Message 1217 Framer notifies the framer implementation whenever new data is 1218 available to parse. 1220 MessageFramer -> HandleReceivedData 1222 Upon receiving this event, the framer implementation can inspect the 1223 inbound data. The data is parsed from a particular cursor 1224 representing the unprocessed data. The application requests a 1225 specific amount of data it needs to have available in order to parse. 1226 If the data is not available, the parse fails. 1228 MessageFramer.Parse(Connection, MinimumIncompleteLength, MaximumLength) -> (Data, MessageContext, IsEndOfMessage) 1230 The framer implementation can directly advance the receive cursor 1231 once it has parsed data to effectively discard data (for example, 1232 discard a header once the content has been parsed). 1234 To deliver a Message to the application, the framer implementation 1235 can either directly deliever data that it has allocated, or deliver a 1236 range of data directly from the underlying transport and 1237 simulatenously advance the receive cursor. 1239 MessageFramer.AdvanceReceiveCursor(Connection, Length) 1240 MessageFramer.DeliverAndAdvanceReceiveCursor(Connection, MessageContext, Length, IsEndOfMessage) 1241 MessageFramer.Deliver(Connection, MessageContext, Data, IsEndOfMessage) 1243 Note that "MessageFramer.DeliverAndAdvanceReceiveCursor" allows the 1244 framer implementation to earmark bytes as part of a Message even 1245 before they are received by the transport. This allows the delivery 1246 of very large Messages without requiring the implementation to 1247 directly inspect all of the bytes. 1249 To provide an example, a simple protocol that parses a length as a 1250 header value would receive the "HandleReceivedData" event, and call 1251 "Parse" with a minimum and maximum set to the length of the header 1252 field. Once the parse succeeded, it would call 1253 "AdvanceReceiveCursor" with the length of the header field, and then 1254 call "DeliverAndAdvanceReceiveCursor" with the length of the body 1255 that was parsed from the header, marking the new Message as complete. 1257 7. Implementing Connection Management 1259 Once a Connection is established, the Transport Services system 1260 allows applications to interact with the Connection by modifying or 1261 inspecting Connection Properties. A Connection can also generate 1262 events in the form of Soft Errors. 1264 The set of Connection Properties that are supported for setting and 1265 getting on a Connection are described in [I-D.ietf-taps-interface]. 1266 For any properties that are generic, and thus could apply to all 1267 protocols being used by a Connection, the Transport System should 1268 store the properties in a generic storage, and notify all protocol 1269 instances in the Protocol Stack whenever the properties have been 1270 modified by the application. For protocol-specfic properties, such 1271 as the User Timeout that applies to TCP, the Transport System only 1272 needs to update the relevant protocol instance. 1274 If an error is encountered in setting a property (for example, if the 1275 application tries to set a TCP-specific property on a Connection that 1276 is not using TCP), the action should fail gracefully. The 1277 application may be informed of the error, but the Connection itself 1278 should not be terminated. 1280 The Transport Services implementation should allow protocol instances 1281 in the Protocol Stack to pass up arbitrary generic or protocol- 1282 specific errors that can be delivered to the application as Soft 1283 Errors. These allow the application to be informed of ICMP errors, 1284 and other similar events. 1286 7.1. Pooled Connection 1288 For protocols that employ request/response pairs and do not require 1289 in-order delivery of the responses, like HTTP, the transport 1290 implementation may distribute interactions across several underlying 1291 transport connections. For these kinds of protocols, implementations 1292 may hide the connection management and only expose a single 1293 Connection object and the individual requests/responses as messages. 1294 These Pooled Connections can use multiple connections or multiple 1295 streams of multi-streaming connections between endpoints, as long as 1296 all of these satisfy the requirements, and prohibitions specified in 1297 the Selection Properties of the Pooled Connection. This enables 1298 implementations to realize transparent connection coalescing, 1299 connection migration, and to perform per-message endpoint and path 1300 selection by choosing among these underlying connections. 1302 7.2. Handling Path Changes 1304 When a path change occurs, the Transport Services implementation is 1305 responsible for notifying Protocol Instances in the Protocol Stack. 1306 If the Protocol Stack includes a transport protocol that supports 1307 multipath connectivity, an update to the available paths should 1308 inform the Protocol Instance of the new set of paths that are 1309 permissible based on the Selection Properties passed by the 1310 application. A multipath protocol can establish new subflows over 1311 new paths, and should tear down subflows over paths that are no 1312 longer available. Pooled Connections Section 7.1 may add or remove 1313 underlying transport connections in a similar manner. If the 1314 Protocol Stack includes a transport protocol that does not support 1315 multipath, but support migrating between paths, the update to 1316 available paths can be used as the trigger to migrating the 1317 connection. For protocols that do not support multipath or 1318 migration, the Protocol Instances may be informed of the path change, 1319 but should not be forcibly disconnected if the previously used path 1320 becomes unavailable. An exception to this case is if the System 1321 Policy changes to prohibit traffic from the Connection based on its 1322 properties, in which case the Protocol Stack should be disconnected. 1324 8. Implementing Connection Termination 1326 With TCP, when an application closes a connection, this means that it 1327 has no more data to send (but expects all data that has been handed 1328 over to be reliably delivered). However, with TCP only, "close" does 1329 not mean that the application will stop receiving data. This is 1330 related to TCP's ability to support half-closed connections. 1332 SCTP is an example of a protocol that does not support such half- 1333 closed connections. Hence, with SCTP, the meaning of "close" is 1334 stricter: an application has no more data to send (but expects all 1335 data that has been handed over to be reliably delivered), and will 1336 also not receive any more data. 1338 Implementing a protocol independent transport system means that the 1339 exposed semantics must be the strictest subset of the semantics of 1340 all supported protocols. Hence, as is common with all reliable 1341 transport protocols, after a Close action, the application can expect 1342 to have its reliability requirements honored regarding the data it 1343 has given to the Transport System, but it cannot expect to be able to 1344 read any more data after calling Close. 1346 Abort differs from Close only in that no guarantees are given 1347 regarding data that the application has handed over to the Transport 1348 System before calling Abort. 1350 As explained in Section 4.6, when a new stream is multiplexed on an 1351 already existing connection of a Transport Protocol Instance, there 1352 is no need for a connection establishment procedure. Because the 1353 Connections that are offered by the Transport System can be 1354 implemented as streams that are multiplexed on a transport protocol's 1355 connection, it can therefore not be guaranteed that one Endpoint's 1356 Initiate action provokes a ConnectionReceived event at its peer. 1358 For Close (provoking a Finished event) and Abort (provoking a 1359 ConnectionError event), the same logic applies: while it is desirable 1360 to be informed when a peer closes or aborts a Connection, whether 1361 this is possible depends on the underlying protocol, and no 1362 guarantees can be given. With SCTP, the transport system can use the 1363 stream reset procedure to cause a Finish event upon a Close action 1364 from the peer [NEAT-flow-mapping]. 1366 9. Cached State 1368 Beyond a single Connection's lifetime, it is useful for an 1369 implementation to keep state and history. This cached state can help 1370 improve future Connection establishment due to re-using results and 1371 credentials, and favoring paths and protocols that performed well in 1372 the past. 1374 Cached state may be associated with different Endpoints for the same 1375 Connection, depending on the protocol generating the cached content. 1376 For example, session tickets for TLS are associated with specific 1377 endpoints, and thus should be cached based on a Connection's hostname 1378 Endpoint (if applicable). On the other hand, performance 1379 characteristics of a path are more likely tied to the IP address and 1380 subnet being used. 1382 9.1. Protocol state caches 1384 Some protocols will have long-term state to be cached in association 1385 with Endpoints. This state often has some time after which it is 1386 expired, so the implementation should allow each protocol to specify 1387 an expiration for cached content. 1389 Examples of cached protocol state include: 1391 o The DNS protocol can cache resolution answers (A and AAAA queries, 1392 for example), associated with a Time To Live (TTL) to be used for 1393 future hostname resolutions without requiring asking the DNS 1394 resolver again. 1396 o TLS caches session state and tickets based on a hostname, which 1397 can be used for resuming sessions with a server. 1399 o TCP can cache cookies for use in TCP Fast Open. 1401 Cached protocol state is primarily used during Connection 1402 establishment for a single Protocol Stack, but may be used to 1403 influence an implementation's preference between several candidate 1404 Protocol Stacks. For example, if two IP address Endpoints are 1405 otherwise equally preferred, an implementation may choose to attempt 1406 a connection to an address for which it has a TCP Fast Open cookie. 1408 Applications must have a way to flush protocol cache state if 1409 desired. This may be necessary, for example, if application-layer 1410 identifiers rotate and clients wish to avoid linkability via 1411 trackable TLS tickets or TFO cookies. 1413 9.2. Performance caches 1415 In addition to protocol state, Protocol Instances should provide data 1416 into a performance-oriented cache to help guide future protocol and 1417 path selection. Some performance information can be gathered 1418 generically across several protocols to allow predictive comparisons 1419 between protocols on given paths: 1421 o Observed Round Trip Time 1423 o Connection Establishment latency 1425 o Connection Establishment success rate 1427 These items can be cached on a per-address and per-subnet 1428 granularity, and averaged between different values. The information 1429 should be cached on a per-network basis, since it is expected that 1430 different network attachments will have different performance 1431 characteristics. Besides Protocol Instances, other system entities 1432 may also provide data into performance-oriented caches. This could 1433 for instance be signal strength information reported by radio modems 1434 like Wi-Fi and mobile broadband or information about the battery- 1435 level of the device. Furthermore, the system may cache the observed 1436 maximum throughput on a path as an estimate of the available 1437 bandwidth. 1439 An implementation should use this information, when possible, to 1440 determine preference between candidate paths, endpoints, and protocol 1441 options. Eligible options that historically had significantly better 1442 performance than others should be selected first when gathering 1443 candidates (see Section 4.1) to ensure better performance for the 1444 application. 1446 The reasonable lifetime for cached performance values will vary 1447 depending on the nature of the value. Certain information, like the 1448 connection establishment success rate to a Remote Endpoint using a 1449 given protocol stack, can be stored for a long period of time (hours 1450 or longer), since it is expected that the capabilities of the Remote 1451 Endpoint are not changing very quickly. On the other hand, Round 1452 Trip Time observed by TCP over a particular network path may vary 1453 over a relatively short time interval. For such values, the 1454 implementation should remove them from the cache more quickly, or 1455 treat older values with less confidence/weight. 1457 10. Specific Transport Protocol Considerations 1459 Each protocol that can run as part of a Transport Services 1460 implementation defines both its API mapping as well as implementation 1461 details. API mappings for a protocol apply most to Connections in 1462 which the given protocol is the "top" of the Protocol Stack. For 1463 example, the mapping of the "Send" function for TCP applies to 1464 Connections in which the application directly sends over TCP. If 1465 HTTP/2 is used on top of TCP, the HTTP/2 mappings take precendence. 1467 Each protocol has a notion of Connectedness. Possible values for 1468 Connectedness are: 1470 o Unconnected. Unconnected protocols do not establish explicit 1471 state between endpoints, and do not perform a handshake during 1472 Connection establishment. 1474 o Connected. Connected protocols establish state between endpoints, 1475 and perform a handshake during Connection establishment. The 1476 handshake may be 0-RTT to send data or resume a session, but 1477 bidirectional traffic is required to confirm connectedness. 1479 o Multiplexing Connected. Multiplexing Connected protocols share 1480 properties with Connected protocols, but also explictly support 1481 opening multiple application-level flows. This means that they 1482 can support cloning new Connection objects without a new explicit 1483 handshake. 1485 Protocols also define a notion of Data Unit. Possible values for 1486 Data Unit are: 1488 o Byte-stream. Byte-stream protocols do not define any Message 1489 boundaries of their own apart from the end of a stream in each 1490 direction. 1492 o Datagram. Datagram protocols define Message boundaries at the 1493 same level of transmission, such that only complete (not partial) 1494 Messages are supported. 1496 o Message. Message protocols support Message boundaries that can be 1497 sent and received either as complete or partial Messages. Maximum 1498 Message lengths can be defined, and Messages can be partially 1499 reliable. 1501 Below, primitives in the style of 1502 "CATEGORY.[SUBCATEGORY].PRIMITIVENAME.PROTOCOL" (e.g., 1503 "CONNECT.SCTP") refer to the primitives with the same name in section 1504 4 of [RFC8303]. For further implementation details, the description 1505 of these primitives in [RFC8303] points to section 3, which refers 1506 back the specifications for each protocol. This back-tracking method 1507 applies to all elements of [I-D.ietf-taps-minset] (see appendix D of 1508 [I-D.ietf-taps-interface]): they are listed in appendix A of 1509 [I-D.ietf-taps-minset] with an implementation hint in the same style, 1510 pointing back to section 4 of [RFC8303]. 1512 10.1. TCP 1514 Connectedness: Connected 1516 Data Unit: Byte-stream 1518 API mappings for TCP are as follows: 1520 Connection Object: TCP connections between two hosts map directly to 1521 Connection objects. 1523 Initiate: CONNECT.TCP. Calling "Initiate" on a TCP Connection 1524 causes it to reserve a local port, and send a SYN to the Remote 1525 Endpoint. 1527 InitiateWithSend: CONNECT.TCP with parameter "user message". Early 1528 idempotent data is sent on a TCP Connection in the SYN, as TCP 1529 Fast Open data. 1531 Ready: A TCP Connection is ready once the three-way handshake is 1532 complete. 1534 InitiateError: Failure of CONNECT.TCP. TCP can throw various errors 1535 during connection setup. Specifically, it is important to handle 1536 a RST being sent by the peer during the handshake. 1538 ConnectionError: Once established, TCP throws errors whenever the 1539 connection is disconnected, such as due to receiving a RST from 1540 the peer; or hitting a TCP retransmission timeout. 1542 Listen: LISTEN.TCP. Calling "Listen" for TCP binds a local port and 1543 prepares it to receive inbound SYN packets from peers. 1545 ConnectionReceived: TCP Listeners will deliver new connections once 1546 they have replied to an inbound SYN with a SYN-ACK. 1548 Clone: Calling "Clone" on a TCP Connection creates a new Connection 1549 with equivalent parameters. The two Connections are otherwise 1550 independent. 1552 Send: SEND.TCP. TCP does not on its own preserve Message 1553 boundaries. Calling "Send" on a TCP connection lays out the bytes 1554 on the TCP send stream without any other delineation. Any Message 1555 marked as Final will cause TCP to send a FIN once the Message has 1556 been completely written, by calling CLOSE.TCP immediately upon 1557 successful termination of SEND.TCP. 1559 Receive: With RECEIVE.TCP, TCP delivers a stream of bytes without 1560 any Message delineation. All data delivered in the "Received" or 1561 "ReceivedPartial" event will be part of a single stream-wide 1562 Message that is marked Final (unless a Message Framer is used). 1563 EndOfMessage will be delivered when the TCP Connection has 1564 received a FIN (CLOSE-EVENT.TCP or ABORT-EVENT.TCP) from the peer. 1566 Close: Calling "Close" on a TCP Connection indicates that the 1567 Connection should be gracefully closed (CLOSE.TCP) by sending a 1568 FIN to the peer and waiting for a FIN-ACK before delivering the 1569 "Closed" event. 1571 Abort: Calling "Abort" on a TCP Connection indicates that the 1572 Connection should be immediately closed by sending a RST to the 1573 peer (ABORT.TCP). 1575 10.2. UDP 1577 Connectedness: Unconnected 1579 Data Unit: Datagram 1581 API mappings for UDP are as follows: 1583 Connection Object: UDP connections represent a pair of specific IP 1584 addresses and ports on two hosts. 1586 Initiate: CONNECT.UDP. Calling "Initiate" on a UDP Connection 1587 causes it to reserve a local port, but does not generate any 1588 traffic. 1590 InitiateWithSend: Early data on a UDP Connection does not have any 1591 special meaning. The data is sent whenever the Connection is 1592 Ready. 1594 Ready: A UDP Connection is ready once the system has reserved a 1595 local port and has a path to send to the Remote Endpoint. 1597 InitiateError: UDP Connections can only generate errors on 1598 initiation due to port conflicts on the local system. 1600 ConnectionError: Once in use, UDP throws "soft errors" (ERROR.UDP(- 1601 Lite)) upon receiving ICMP notifications indicating failures in 1602 the network. 1604 Listen: LISTEN.UDP. Calling "Listen" for UDP binds a local port and 1605 prepares it to receive inbound UDP datagrams from peers. 1607 ConnectionReceived: UDP Listeners will deliver new connections once 1608 they have received traffic from a new Remote Endpoint. 1610 Clone: Calling "Clone" on a UDP Connection creates a new Connection 1611 with equivalent parameters. The two Connections are otherwise 1612 independent. 1614 Send: SEND.UDP(-Lite). Calling "Send" on a UDP connection sends the 1615 data as the payload of a complete UDP datagram. Marking Messages 1616 as Final does not change anything in the datagram's contents. 1617 Upon sending a UDP datagram, some relevant fields and flags in the 1618 IP header can be controlled: DSCP (SET_DSCP.UDP(-Lite)), DF in 1619 IPv4 (SET_DF.UDP(-Lite)) and ECN flag (SET_ECN.UDP(-Lite)). 1621 Receive: RECEIVE.UDP(-Lite). UDP only delivers complete Messages to 1622 "Received", each of which represents a single datagram received in 1623 a UDP packet. Upon receiving a UDP datagram, the ECN flag from 1624 the IP header can be obtained (GET_ECN.UDP(-Lite)). 1626 Close: Calling "Close" on a UDP Connection (ABORT.UDP(-Lite)) 1627 releases the local port reservation. 1629 Abort: Calling "Abort" on a UDP Connection (ABORT.UDP(-Lite)) is 1630 identical to calling "Close". 1632 10.3. TLS 1634 The mapping of a TLS stream abstraction into the application is 1635 equivalent to the contract provided by TCP (see Section 10.1), and 1636 builds upon many of the actions of TCP connections. 1638 Connectedness: Connected 1640 Data Unit: Byte-stream 1642 Connection Object: Connection objects represent a single TLS 1643 connection running over a TCP connection between two hosts. 1645 Initiate: Calling "Initiate" on a TLS Connection causes it to first 1646 initiate a TCP connection. Once the TCP protocol is Ready, the 1647 TLS handshake will be performed as a client (starting by sending a 1648 "client_hello", and so on). 1650 InitiateWithSend: Early idempotent data is supported by TLS 1.3, and 1651 sends encrypted application data in the first TLS message when 1652 performing session resumption. For older versions of TLS, or if a 1653 session is not being resumed, the initial data will be delayed 1654 until the TLS handshake is complete. TCP Fast Option can also be 1655 enabled automatically. 1657 Ready: A TLS Connection is ready once the underlying TCP connection 1658 is Ready, and TLS handshake is also complete and keys have been 1659 established to encrypt application data. 1661 InitiateError: In addition to TCP initiation errors, TLS can 1662 generate errors during its handshake. Examples of error include a 1663 failure of the peer to successfully authenticate, the peer 1664 rejecting the local authentication, or a failure to match versions 1665 or algorithms. 1667 ConnectionError: TLS connections will generate TCP errors, or errors 1668 due to failures to rekey or decrypt received messages. 1670 Listen: Calling "Listen" for TLS listens on TCP, and sets up 1671 received connections to perform server-side TLS handshakes. 1673 ConnectionReceived: TLS Listeners will deliver new connections once 1674 they have successfully completed both TCP and TLS handshakes. 1676 Clone: As with TCP, calling "Clone" on a TLS Connection creates a 1677 new Connection with equivalent parameters. The two Connections 1678 are otherwise independent. 1680 Send: Like TCP, TLS does not preserve message boundaries. Although 1681 application data is framed natively in TLS, there is not a general 1682 guarantee that these TLS messages represent semantically 1683 meaningful application stream boundaries. Rather, sending data on 1684 a TLS Connection only guarantees that the application data will be 1685 transmitted in an encrypted form. Marking Messages as Final 1686 causes a "close_notify" to be generated once the data has been 1687 written. 1689 Receive: Like TCP, TLS delivers a stream of bytes without any 1690 Message delineation. The data is decrypted prior to being 1691 delivered to the application. If a "close_notify" is received, 1692 the stream-wide Message will be delivered with EndOfMessage set. 1694 Close: Calling "Close" on a TLS Connection indicates that the 1695 Connection should be gracefully closed by sending a "close_notify" 1696 to the peer and waiting for a corresponding "close_notify" before 1697 delivering the "Closed" event. 1699 Abort: Calling "Abort" on a TCP Connection indicates that the 1700 Connection should be immediately closed by sending a 1701 "close_notify", optionally preceded by "user_canceled", to the 1702 peer. Implementations do not need to wait to receive 1703 "close_notify" before delivering the "Closed" event. 1705 10.4. DTLS 1707 DTLS follows the same behavior as TLS (Section 10.3), with the 1708 notable exception of not inheriting behavior directly from TCP. 1709 Differences from TLS are detailed below, and all cases not explicitly 1710 mentioned should be considered the same as TLS. 1712 Connectedness: Connected 1714 Data Unit: Datagram 1716 Connection Object: Connection objects represent a single DTLS 1717 connection running over a set of UDP ports between two hosts. 1719 Initiate: Calling "Initiate" on a DTLS Connection causes it reserve 1720 a UDP local port, and begin sending handshake messages to the peer 1721 over UDP. These messages are reliable, and will be automatically 1722 retransmitted. 1724 Ready: A DTLS Connection is ready once the TLS handshake is complete 1725 and keys have been established to encrypt application data. 1727 Send: Sending over DTLS does preserve message boundaries in the same 1728 way that UDP datagrams do. Marking a Message as Final does send a 1729 "close_notify" like TLS. 1731 Receive: Receiving over DTLS delivers one decrypted Message for each 1732 received DTLS datagram. If a "close_notify" is received, a 1733 Message will be delivered that is marked as Final. 1735 10.5. HTTP 1737 HTTP requests and responses map naturally into Messages, since they 1738 are delineated chunks of data with metadata that can be sent over a 1739 transport. To that end, HTTP can be seen as the most prevalent 1740 framing protocol that runs on top of streams like TCP, TLS, etc. 1742 In order to use a transport Connection that provides HTTP Message 1743 support, the establishment and closing of the connection can be 1744 treated as it would without the framing protocol. Sending and 1745 receiving of Messages, however, changes to treat each Message as a 1746 well-delineated HTTP request or response, with the content of the 1747 Message representing the body, and the Headers being provided in 1748 Message metadata. 1750 Connectedness: Multiplexing Connected 1752 Data Unit: Message 1754 Connection Object: Connection objects represent a flow of HTTP 1755 messages between a client and a server, which may be an HTTP/1.1 1756 connection over TCP, or a single stream in an HTTP/2 connection. 1758 Initiate: Calling "Initiate" on an HTTP connection intiates a TCP or 1759 TLS connection as a client. 1761 Clone: Calling "Clone" on an HTTP Connection opens a new stream on 1762 an existing HTTP/2 connection when possible. If the underlying 1763 version does not support multiplexed streams, calling "Clone" 1764 simply creates a new parallel connection. 1766 Send: When an application sends an HTTP Message, it is expected to 1767 provide HTTP header values as a MessageContext in a canonical 1768 form, along with any associated HTTP message body as the Message 1769 data. The HTTP header values are encoded in the specific version 1770 format upon sending. 1772 Receive: HTTP Connections deliver Messages in which HTTP header 1773 values attached to MessageContexts, and HTTP bodies in Message 1774 data. 1776 Close: Calling "Close" on an HTTP Connection will only close the 1777 underlying TLS or TCP connection if the HTTP version does not 1778 support multiplexing. For HTTP/2, for example, closing the 1779 connection only closes a specific stream. 1781 10.6. QUIC 1783 QUIC provides a multi-streaming interface to an encrypted transport. 1784 Each stream can be viewed as equivalent to a TLS stream over TCP, so 1785 a natural mapping is to present each QUIC stream as an individual 1786 Connection. The protocol for the stream will be considered Ready 1787 whenever the underlying QUIC connection is established to the point 1788 that this stream's data can be sent. For streams after the first 1789 stream, this will likely be an immediate operation. 1791 Closing a single QUIC stream, presented to the application as a 1792 Connection, does not imply closing the underlying QUIC connection 1793 itself. Rather, the implementation may choose to close the QUIC 1794 connection once all streams have been closed (often after some 1795 timeout), or after an individual stream Connection sends an Abort. 1797 Connectedness: Multiplexing Connected 1799 Data Unit: Stream 1801 Connection Object: Connection objects represent a single QUIC stream 1802 on a QUIC connection. 1804 10.7. HTTP/2 transport 1806 Similar to QUIC (Section 10.6), HTTP/2 provides a multi-streaming 1807 interface. This will generally use HTTP as the unit of Messages over 1808 the streams, in which each stream can be represented as a transport 1809 Connection. The lifetime of streams and the HTTP/2 connection should 1810 be managed as described for QUIC. 1812 It is possible to treat each HTTP/2 stream as a raw byte-stream 1813 instead of a carrier for HTTP messages, in which case the Messages 1814 over the streams can be represented similarly to the TCP stream (one 1815 Message per direction, see Section 10.1). 1817 Connectedness: Multiplexing Connected 1819 Data Unit: Stream 1821 Connection Object: Connection objects represent a single HTTP/2 1822 stream on a HTTP/2 connection. 1824 10.8. SCTP 1826 Connectedness: Connected 1828 Data Unit: Message 1830 API mappings for SCTP are as follows: 1832 Connection Object: Connection objects represent a flow of SCTP 1833 messages between a client and a server, which may be an SCTP 1834 association or a stream in a SCTP association. How to map 1835 Connection objects to streams is described in [NEAT-flow-mapping]; 1836 in the following, a similar method is described. To map 1837 Connection objects to SCTP streams without head-of-line blocking 1838 on the sender side, both the sending and receiving SCTP 1839 implementation must support message interleaving [RFC8260]. Both 1840 SCTP implementations must also support stream reconfiguration. 1841 Finally, both communicating endpoints must be aware of this 1842 intended multiplexing; [NEAT-flow-mapping] describes a way for a 1843 Transport System to negotiate the stream mapping capability using 1844 SCTP's adaptation layer indication, such that this functionality 1845 would only take effect if both ends sides are aware of it. The 1846 first flow, for which the SCTP association has been created, will 1847 always use stream id zero. All additional flows are assigned to 1848 unused stream ids in growing order. To avoid a conflict when both 1849 endpoints map new flows simultaneously, the peer which initiated 1850 the transport connection will use even stream numbers whereas the 1851 remote side will map its flows to odd stream numbers. Both sides 1852 maintain a status map of the assigned stream numbers. Generally, 1853 new streams must consume the lowest available (even or odd, 1854 depending on the side) stream number; this rule is relevant when 1855 lower numbers become available because Connection objects 1856 associated to the streams are closed. 1858 Initiate: If this is the only Connection object that is assigned to 1859 the SCTP association or stream mapping has not been negotiated, 1860 CONNECT.SCTP is called. Else, a new stream is used: if there are 1861 enough streams available, "Initiate" is just a local operation 1862 that assigns a new stream number to the Connection object. The 1863 number of streams is negotiated as a parameter of the prior 1864 CONNECT.SCTP call, and it represents a trade-off between local 1865 resource usage and the number of Connection objects that can be 1866 mapped without requiring a reconfiguration signal. When running 1867 out of streams, ADD_STREAM.SCTP must be called. 1869 InitiateWithSend: If this is the only Connection object that is 1870 assigned to the SCTP association or stream mapping has not been 1871 negotiated, CONNECT.SCTP is called with the "user message" 1872 parameter. Else, a new stream is used (see "Initiate" for how to 1873 handle running out of streams), and this just sends the first 1874 message on a new stream. 1876 Ready: "Initiate" or "InitiateWithSend" returns without an error, 1877 i.e. SCTP's four-way handshake has completed. If an association 1878 with the peer already exists, and stream mapping has been 1879 negotiated and enough streams are available, a Connection Object 1880 instantly becomes Ready after calling "Initiate" or 1881 "InitiateWithSend". 1883 InitiateError: Failure of CONNECT.SCTP. 1885 ConnectionError: TIMEOUT.SCTP or ABORT-EVENT.SCTP. 1887 Listen: LISTEN.SCTP. If an association with the peer already exists 1888 and stream mapping has been negotiated, "Listen" just expects to 1889 receive a new message on a new stream id (chosen in accordance 1890 with the stream number assignment procedure described above). 1892 ConnectionReceived: LISTEN.SCTP returns without an error (a result 1893 of successful CONNECT.SCTP from the peer), or, in case of stream 1894 mapping, the first message has arrived on a new stream (in this 1895 case, "Receive" is also invoked). 1897 Clone: Calling "Clone" on an SCTP association creates a new 1898 Connection object and assigns it a new stream number in accordance 1899 with the stream number assignment procedure described above. If 1900 there are not enough streams available, ADD_STREAM.SCTP must be 1901 called. 1903 Priority (Connection): When this value is changed, or a Message with 1904 Message Property "Priority" is sent, and there are multiple 1905 Connection objects assigned to the same SCTP association, 1906 CONFIGURE_STREAM_SCHEDULER.SCTP is called to adjust the priorities 1907 of streams in the SCTP association. 1909 Send: SEND.SCTP. Message Properties such as "Lifetime" and 1910 "Ordered" map to parameters of this primitive. 1912 Receive: RECEIVE.SCTP. The "partial flag" of RECEIVE.SCTP invokes a 1913 "ReceivedPartial" event. 1915 Close: If this is the only Connection object that is assigned to the 1916 SCTP association, CLOSE.SCTP is called. Else, the Connection object 1917 is one out of several Connection objects that are assigned to the 1918 same SCTP assocation, and RESET_STREAM.SCTP must be called, which 1919 informs the peer that the stream will no longer be used for mapping 1920 and can be used by future "Initiate", "InitiateWithSend" or "Listen" 1921 calls. At the peer, the event RESET_STREAM-EVENT.SCTP will fire, 1922 which the peer must answer by issuing RESET_STREAM.SCTP too. The 1923 resulting local RESET_STREAM-EVENT.SCTP informs the transport system 1924 that the stream number can now be re-used by the next "Initiate", 1925 "InitiateWithSend" or "Listen" calls. 1927 Abort: If this is the only Connection object that is assigned to the 1928 SCTP association, ABORT.SCTP is called. Else, the Connection object 1929 is one out of several Connection objects that are assigned to the 1930 same SCTP assocation, and shutdown proceeds as described under 1931 "Close". 1933 11. IANA Considerations 1935 RFC-EDITOR: Please remove this section before publication. 1937 This document has no actions for IANA. 1939 12. Security Considerations 1941 12.1. Considerations for Candidate Gathering 1943 Implementations should avoid downgrade attacks that allow network 1944 interference to cause the implementation to select less secure, or 1945 entirely insecure, combinations of paths and protocols. 1947 12.2. Considerations for Candidate Racing 1949 See Section 5.3 for security considerations around racing with 0-RTT 1950 data. 1952 An attacker that knows a particular device is racing several options 1953 during connection establishment may be able to block packets for the 1954 first connection attempt, thus inducing the device to fall back to a 1955 secondary attempt. This is a problem if the secondary attempts have 1956 worse security properties that enable further attacks. 1957 Implementations should ensure that all options have equivalent 1958 security properties to avoid incentivizing attacks. 1960 Since results from the network can determine how a connection attempt 1961 tree is built, such as when DNS returns a list of resolved endpoints, 1962 it is possible for the network to cause an implementation to consume 1963 significant on-device resources. Implementations should limit the 1964 maximum amount of state allowed for any given node, including the 1965 number of child nodes, especially when the state is based on results 1966 from the network. 1968 13. Acknowledgements 1970 This work has received funding from the European Union's Horizon 2020 1971 research and innovation programme under grant agreement No. 644334 1972 (NEAT). 1974 This work has been supported by Leibniz Prize project funds of DFG - 1975 German Research Foundation: Gottfried Wilhelm Leibniz-Preis 2011 (FKZ 1976 FE 570/4-1). 1978 This work has been supported by the UK Engineering and Physical 1979 Sciences Research Council under grant EP/R04144X/1. 1981 This work has been supported by the Research Council of Norway under 1982 its "Toppforsk" programme through the "OCARINA" project. 1984 Thanks to Stuart Cheshire, Josh Graessley, David Schinazi, and Eric 1985 Kinnear for their implementation and design efforts, including Happy 1986 Eyeballs, that heavily influenced this work. 1988 14. References 1990 14.1. Normative References 1992 [I-D.ietf-taps-arch] 1993 Pauly, T., Trammell, B., Brunstrom, A., Fairhurst, G., 1994 Perkins, C., Tiesel, P., and C. Wood, "An Architecture for 1995 Transport Services", draft-ietf-taps-arch-04 (work in 1996 progress), July 2019. 1998 [I-D.ietf-taps-interface] 1999 Trammell, B., Welzl, M., Enghardt, T., Fairhurst, G., 2000 Kuehlewind, M., Perkins, C., Tiesel, P., Wood, C., and T. 2001 Pauly, "An Abstract Application Layer Interface to 2002 Transport Services", draft-ietf-taps-interface-04 (work in 2003 progress), July 2019. 2005 [I-D.ietf-taps-minset] 2006 Welzl, M. and S. Gjessing, "A Minimal Set of Transport 2007 Services for End Systems", draft-ietf-taps-minset-11 (work 2008 in progress), September 2018. 2010 [RFC7413] Cheng, Y., Chu, J., Radhakrishnan, S., and A. Jain, "TCP 2011 Fast Open", RFC 7413, DOI 10.17487/RFC7413, December 2014, 2012 . 2014 [RFC7540] Belshe, M., Peon, R., and M. Thomson, Ed., "Hypertext 2015 Transfer Protocol Version 2 (HTTP/2)", RFC 7540, 2016 DOI 10.17487/RFC7540, May 2015, 2017 . 2019 [RFC8260] Stewart, R., Tuexen, M., Loreto, S., and R. Seggelmann, 2020 "Stream Schedulers and User Message Interleaving for the 2021 Stream Control Transmission Protocol", RFC 8260, 2022 DOI 10.17487/RFC8260, November 2017, 2023 . 2025 [RFC8303] Welzl, M., Tuexen, M., and N. Khademi, "On the Usage of 2026 Transport Features Provided by IETF Transport Protocols", 2027 RFC 8303, DOI 10.17487/RFC8303, February 2018, 2028 . 2030 [RFC8304] Fairhurst, G. and T. Jones, "Transport Features of the 2031 User Datagram Protocol (UDP) and Lightweight UDP (UDP- 2032 Lite)", RFC 8304, DOI 10.17487/RFC8304, February 2018, 2033 . 2035 [RFC8305] Schinazi, D. and T. Pauly, "Happy Eyeballs Version 2: 2036 Better Connectivity Using Concurrency", RFC 8305, 2037 DOI 10.17487/RFC8305, December 2017, 2038 . 2040 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 2041 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 2042 . 2044 14.2. Informative References 2046 [I-D.ietf-quic-transport] 2047 Iyengar, J. and M. Thomson, "QUIC: A UDP-Based Multiplexed 2048 and Secure Transport", draft-ietf-quic-transport-23 (work 2049 in progress), September 2019. 2051 [NEAT-flow-mapping] 2052 "Transparent Flow Mapping for NEAT (in Workshop on Future 2053 of Internet Transport (FIT 2017))", n.d.. 2055 [RFC5245] Rosenberg, J., "Interactive Connectivity Establishment 2056 (ICE): A Protocol for Network Address Translator (NAT) 2057 Traversal for Offer/Answer Protocols", RFC 5245, 2058 DOI 10.17487/RFC5245, April 2010, 2059 . 2061 [Trickle] "Trickle - Rate Limiting YouTube Video Streaming (ATC 2062 2012)", n.d.. 2064 14.3. URIs 2066 [1] https://developer.apple.com/documentation/network 2068 [2] https://github.com/NEAT-project/neat 2070 [3] https://www.neat-project.org 2072 [4] https://github.com/fg-inet/python-asyncio-taps 2074 Appendix A. Additional Properties 2076 This appendix discusses implementation considerations for additional 2077 parameters and properties that could be used to enhance transport 2078 protocol and/or path selection, or the transmission of messages given 2079 a Protocol Stack that implements them. These are not part of the 2080 interface, and may be removed from the final document, but are 2081 presented here to support discussion within the TAPS working group as 2082 to whether they should be added to a future revision of the base 2083 specification. 2085 A.1. Properties Affecting Sorting of Branches 2087 In addition to the Protocol and Path Selection Properties discussed 2088 in Section 4.3, the following properties under discussion can 2089 influence branch sorting: 2091 o Bounds on Send or Receive Rate: If the application indicates a 2092 bound on the expected Send or Receive bitrate, an implementation 2093 may prefer a path that can likely provide the desired bandwidth, 2094 based on cached maximum throughput, see Section 9.2. The 2095 application may know the Send or Receive Bitrate from metadata in 2096 adaptive HTTP streaming, such as MPEG-DASH. 2098 o Cost Preferences: If the application indicates a preference to 2099 avoid expensive paths, and some paths are associated with a 2100 monetary cost, an implementation should decrease the ranking of 2101 such paths. If the application indicates that it prohibits using 2102 expensive paths, paths that are associated with a cost should be 2103 purged from the decision tree. 2105 Appendix B. Reasons for errors 2107 The Transport Services API [I-D.ietf-taps-interface] allows for the 2108 several generic error types to specify a more detailed reason as to 2109 why an error occurred. This appendix lists some of the possible 2110 reasons. 2112 o InvalidConfiguration: The transport properties and endpoints 2113 provided by the application are either contradictory or 2114 incomplete. Examples include the lack of a remote endpoint on an 2115 active open or using a multicast group address while not 2116 requesting a unidirectional receive. 2118 o NoCandidates: The configuration is valid, but none of the 2119 available transport protocols can satisfy the transport properties 2120 provided by the application. 2122 o ResolutionFailed: The remote or local specifier provided by the 2123 application can not be resolved. 2125 o EstablishmentFailed: The TAPS system was unable to establish a 2126 transport-layer connection to the remote endpoint specified by the 2127 application. 2129 o PolicyProhibited: The system policy prevents the transport system 2130 from performing the action requested by the application. 2132 o NotCloneable: The protocol stack is not capable of being cloned. 2134 o MessageTooLarge: The message size is too big for the transport 2135 system to handle. 2137 o ProtocolFailed: The underlying protocol stack failed. 2139 o InvalidMessageProperties: The message properties are either 2140 contradictory to the transport properties or they can not be 2141 satisfied by the transport system. 2143 o DeframingFailed: The data that was received by the underlying 2144 protocol stack could not be deframed. 2146 o ConnectionAborted: The connection was aborted by the peer. 2148 o Timeout: Delivery of a message was not possible after a timeout. 2150 Appendix C. Existing Implementations 2152 This appendix gives an overview of existing implementations, at the 2153 time of writing, of transport systems that are (to some degree) in 2154 line with this document. 2156 o Apple's Network.framework: 2158 * [A very brief introduction should be added] 2160 * Documentation: https://developer.apple.com/documentation/ 2161 network [1] 2163 o NEAT: 2165 * NEAT is the output of the European H2020 research project 2166 "NEAT"; it is a user-space library for protocol-independent 2167 communication on top of TCP, UDP and SCTP, with many more 2168 features such as a policy manager. 2170 * Code: https://github.com/NEAT-project/neat [2] 2172 * NEAT project: https://www.neat-project.org [3] 2174 o PyTAPS: 2176 * A TAPS implementation based on Python asyncio, offering 2177 protocol-independent communication to applications on top of 2178 TCP, UDP and TLS, with support for multicast. 2180 * Code: https://github.com/fg-inet/python-asyncio-taps [4] 2182 Authors' Addresses 2184 Anna Brunstrom (editor) 2185 Karlstad University 2186 Universitetsgatan 2 2187 651 88 Karlstad 2188 Sweden 2190 Email: anna.brunstrom@kau.se 2192 Tommy Pauly (editor) 2193 Apple Inc. 2194 One Apple Park Way 2195 Cupertino, California 95014 2196 United States of America 2198 Email: tpauly@apple.com 2200 Theresa Enghardt 2201 TU Berlin 2202 Marchstrasse 23 2203 10587 Berlin 2204 Germany 2206 Email: theresa@inet.tu-berlin.de 2208 Karl-Johan Grinnemo 2209 Karlstad University 2210 Universitetsgatan 2 2211 651 88 Karlstad 2212 Sweden 2214 Email: karl-johan.grinnemo@kau.se 2215 Tom Jones 2216 University of Aberdeen 2217 Fraser Noble Building 2218 Aberdeen, AB24 3UE 2219 UK 2221 Email: tom@erg.abdn.ac.uk 2223 Philipp S. Tiesel 2224 TU Berlin 2225 Einsteinufer 25 2226 10587 Berlin 2227 Germany 2229 Email: philipp@tiesel.net 2231 Colin Perkins 2232 University of Glasgow 2233 School of Computing Science 2234 Glasgow G12 8QQ 2235 United Kingdom 2237 Email: csp@csperkins.org 2239 Michael Welzl 2240 University of Oslo 2241 PO Box 1080 Blindern 2242 0316 Oslo 2243 Norway 2245 Email: michawe@ifi.uio.no