<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!-- One method to get references from the online citation libraries.
     There has to be one entity for each item to be referenced.
     An alternate method (rfc include) is described in the references. -->

<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC6555 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6555.xml">
<!ENTITY RFC6724 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6724.xml">
<!ENTITY RFC7413 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7413.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<!-- used by XSLT processors -->
<!-- For a complete list and description of processing instructions (PIs),
     please see http://xml.resource.org/authoring/README.html. -->
<!-- Below are generally applicable Processing Instructions (PIs) that most I-Ds might want to use.
     (Here they are set differently than their defaults in xml2rfc v1.32) -->
<?rfc strict="yes" ?>
<!-- give errors regarding ID-nits and DTD validation -->
<!-- control the table of contents (ToC) -->
<?rfc toc="yes"?>
<!-- generate a ToC -->
<?rfc tocdepth="4"?>
<!-- the number of levels of subsections in ToC. default: 3 -->
<!-- control references -->
<?rfc symrefs="yes"?>
<!-- use symbolic references tags, i.e, [RFC2119] instead of [1] -->
<?rfc sortrefs="yes" ?>
<!-- sort the reference entries alphabetically -->
<!-- control vertical white space
     (using these PIs as follows is recommended by the RFC Editor) -->
<?rfc compact="yes" ?>
<!-- do not start each main section on a new page -->
<?rfc subcompact="no" ?>
<!-- keep one blank line between list items -->
<!-- end of list of popular I-D processing instructions -->
<rfc ipr="trust200902"
    updates=""
    obsoletes=""
    category="std"
    docName="draft-pauly-v6ops-happy-eyeballs-update-01">

  <!-- category values: std, bcp, info, exp, and historic -->

  <!-- ***** FRONT MATTER ***** -->

  <front>
    <!-- The abbreviated title is used in the page header - it is only necessary if the
         full title is longer than 39 characters -->

    <title>An Update to Happy Eyeballs</title>

    <!-- add 'role="editor"' below for the editors if appropriate -->

    <author fullname="Tommy Pauly" initials="T." surname="Pauly">
      <organization>Apple Inc.</organization>

      <address>
        <postal>
          <street>1 Infinite Loop</street>
          <city>Cupertino</city>
          <region>California</region>
          <code>95014</code>
          <country>US</country>
        </postal>

        <phone></phone>
        <email>tpauly@apple.com</email>
      </address>
    </author>

	<author fullname="David Schinazi" initials="D." surname="Schinazi">
		<organization>Apple Inc.</organization>

		<address>
			<postal>
				<street>1 Infinite Loop</street>
				<city>Cupertino</city>
				<region>California</region>
				<code>95014</code>
				<country>US</country>
			</postal>

			<phone></phone>
			<email>dschinazi@apple.com</email>
		</address>
	</author>

<date/>

    <!-- If the month and year are both specified and are the current ones, xml2rfc will fill
         in the current day for you. If only the current year is specified, xml2rfc will fill
     in the current day and month for you. If the year is not the current one, it is
     necessary to specify at least a month (xml2rfc assumes day="1" if not specified for the
     purpose of calculating the expiry date).  With drafts it is normally sufficient to
     specify just the year. -->

    <!-- Meta-data Declarations -->

    <area>General</area>

    <workgroup>Network</workgroup>

    <abstract>
      <t>"Happy Eyeballs" (RFC6555) is the name for a technique of reducing user-visible delays on dual-stack hosts. Since one address family (IPv4 or IPv6) may be blocked, broken, or sub-optimal on a network, clients that attempt connections for both address families in parallel have a higher chance of establishing a connection sooner. Now that this approach has been deployed at scale and measured for several years, the algorithm specification can be refined to improve its reliability and generalization.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
		<t>"Happy Eyeballs" <xref target="RFC6555"/> is the name for a technique of reducing user-visible delays on dual-stack hosts. Since one address family (IPv4 or IPv6) may be blocked, broken, or sub-optimal on a network, clients that attempt connections for both address families in parallel have a higher chance of establishing a connection sooner. Now that this approach has been deployed at scale and measured for several years, the algorithm specification can be refined to improve its reliability and generalization.</t>
		<t>This document recommends an algorithm of racing resolved addresses that has several stages of ordering and racing to avoid delays to the user whenever possible, while preferring the use of IPv6. Specifically, it discusses how to handle DNS queries when starting a connection on a dual-stack client, how to create an ordered list of addresses to which to attempt connections, and how to race the connection attempts.</t>
      <section title="Requirements Language">
        <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in "Key words for use in RFCs to Indicate Requirement Levels" <xref target="RFC2119">RFC 2119</xref>.</t>
      </section>
    </section>

	<section title="Overview">
		<t>This document defines a method of connection establishment, defined as "Happy Eyeballs Connection Setup". This approach has several distinct phases:</t>
		<t><list style="hanging" hangIndent="6">
			<t hangText="1.">Initiation of asynchronous DNS queries [<xref target="dns"/>]</t>
			<t hangText="2.">Sorting of resolved addresses [<xref target="sorting"/>]</t>
			<t hangText="3.">Initiation of asynchronous connection attempts [<xref target="attempts"/>]</t>
			<t hangText="4.">Establishment of one connection, which cancels all other attempts</t>
		</list></t>
        <t>Note that this document assumes that the host address preference policy favors IPv6 over IPv4. If the host is configured differently, the recommendations in this document can be easily adapted.</t>
	</section>

    <section title="Hostname Resolution Query Handling" anchor="dns">
		<t>When a client has both IPv4 and IPv6 connectivity, and is trying to establish a connection with a named host, it needs to send out both AAAA and A DNS queries. Both queries SHOULD be made as soon after one another as possible, with the AAAA query made first, immediately followed by the A query.</t>
		<t>Implementations MUST NOT wait for both families of answers to return before attempting connection establishment. If one query fails to return, or takes significantly longer to return, waiting for the second address family can significantly delay the connection establishment of the first one. Therefore, the client MUST treat DNS resolution as asynchronous. Note that if the platforms does not offer an asynchronous DNS API, this behavior can be simulated by making two separate synchronous queries on different threads, one per address family. If the AAAA query returns first, the first IPv6 connection attempt MUST be immediately started. If the A query returns first, the client SHOULD wait for a short time for the AAAA response. This delay will be referred to as the "Resolution Delay". The RECOMMENDED value for the Resolution Delay is 50 milliseconds. If the AAAA response is received within the Resolution Delay period, the client MUST immediately start the IPv6 connection attempt. If, at the end of the Resolution Delay period, the AAAA response has not been received but the A response has been received, the client SHOULD proceed to Sorting Addresses [<xref target="sorting"/>] and staggered connection attempts [<xref target="attempts"/>] using only the IPv4 addresses returned so far. If the AAAA response arrives while these connection attempts are in progress, but before any connection has been established, then the newly received IPv6 addresses are incorporated into the list of available candidate addresses [<xref target="changes"/>] and the process of connection attempts will continue with the IPv6 addresses added, until one connection is established.</t>
		<section title="Handling Multiple DNS Server Addresses">
			<t>If multiple DNS server addresses are configured for the current network, the client may have the option of sending its DNS queries over IPv4 or IPv6. In keeping with the Happy Eyeballs approach, queries SHOULD be sent over IPv6 first (note that this is not referring to the sending of AAAA or A queries, but rather the address of the DNS server itself). If DNS queries sent to the IPv6 address do not receive responses, that address may be marked as penalized, and queries can be sent to other DNS server addresses.</t>
			<t>As native IPv6 deployments become more prevalent, and IPv4 addresses are exhausted, it is expected that IPv6 connectivity will have preferential treatment within networks. If a DNS server is configured to be accessible over IPv6, IPv6 should be assumed to be the preferred address family.</t>
		</section>
    </section>

	<section title="Sorting Addresses" anchor="sorting">
		<t>Before attempting to connect to any of the resolved addresses, the client should define the order in which to start the attempts. Once the order has been defined, the client can use a simple algorithm for racing each option after a short delay [<xref target="attempts"/>]. It is important that the ordered list involves all addresses from both families, as this allows the client to get the racing effect of Happy Eyeballs for the entire list, not just the first IPv4 and first IPv6 addresses.</t>
		<t>First, the client MUST sort the addresses using Destination Address Selection (<xref target="RFC6724"/>, Section 6).</t>
        <t>If the client is stateful and has history of expected round-trip times (RTT) for the routes to access each address, it SHOULD add a Destination Address Selection rule between rules 8 and 9 that prefers addresses with lower RTTs. If the client keeps track of which addresses it has used in the past, it SHOULD add another destination address selection rule between the RTT rule and rule 9, which prefers used addresses over unused ones. This helps servers that use the client's IP address for authentication, as is the case for TCP Fast Open (<xref target="RFC7413"/>) and some HTTP cookies. This historical data MUST NOT be used across networks, and SHOULD be flushed on network changes.</t>
        <t>Next, the client SHOULD modify the ordered list to interleave address families. Whichever address family is first in the list should be followed by an address of the other address family; that is, if the first address in the sorted list is IPv6, then the first IPv4 address should be moved up in the list to be second in the list. An implementation MAY want to favor one address family more by allowing multiple addresses of that family to be attempted before trying the other family. The number of contiguous addresses of the first address family will be referred to as the "First Address Family Count", and can be a configurable value.</t>
	</section>
	<section title="Connection Attempts" anchor="attempts">
		<t>Once the list of addresses has been constructed, the client will attempt to make connections. In order to avoid unreasonable network load, connection attempts SHOULD NOT be made simultaneously. Instead, one connection attempt to a single address is started first, followed by the others in the list, one at a time. Starting a new connection attempt does not affect previous attempts, as multiple connection attempts may occur in parallel. Once one of the connection attempts succeeds (generally when the TCP handshake completes), all other connections attempts that have not yet succeeded SHOULD be cancelled. Any address that was not yet attempted as a connection SHOULD be ignored.</t>
		<t>A simple implementation can have a fixed delay for how long to wait before starting the next connection attempt. This delay is referred to as the "Connection Attempt Delay". One recommended value for this delay is 250 milliseconds. If the client has historical RTT data, it can also use the expected RTT to choose a more nuanced delay value. The recommended formula for calculating the delay after starting a connection attempt is: MAX( 1.25 * RTT_MEAN + 4 * RTT_VARIANCE, 2 * RTT_MEAN ), where the RTT values are based on the statistics for previous address used. If the TCP implementation leverages historical RTT data to compute SYN timeout, these algorithms should match so that a new attempt will be started at the same time as the previous is sending its second TCP SYN.</t>
	</section>

	<section title="DNS Answer Changes during Happy Eyeballs Connection Setup" anchor="changes">
		<t>If, during the course of connection establishment, the DNS answers change either by adding resolved addresses, or removing previously resolved addresses (for example, due to expiry of the TTL on that DNS record), the client should react based on its current progress.</t>
		<t>If an address is removed from the list that already had a connection attempt started, the connection attempt SHOULD NOT be cancelled, but rather be allowed to continue. If the removed address had not yet had a connection attempt started, it SHOULD be removed from the list of addresses to try.</t>
		<t>If an address is added to the list, it should be sorted into the list of addresses not yet attempted according to the rules above (<xref target="sorting"/>).</t>
	</section>

	<section title="Summary of Configurable Values">
		<t>The values that may be configured as defaults on a client for use in Happy Eyeballs are as follows:</t>
		<t><list style="symbols">
			<t>Resolution Delay (<xref target="dns"/>): The time to wait for a AAAA response after receiving an A response. RECOMMENDED at 50 milliseconds.</t>
			<t>First Address Family Count (<xref target="sorting"/>): The number of addresses belonging to the first address family (such as IPv6) that should be attempted before attempting another address family. RECOMMENDED as 1, or 2 to more aggressively favor one address family.</t>
			<t>Connection Attempt Delay (<xref target="attempts"/>): The time to wait between connection attempts in the absence of RTT data. RECOMMENDED at 250 milliseconds.</t>
		</list></t>
	</section>

	<section anchor="Security" title="Security Considerations">
		<t>This memo has no direct security considerations.</t>
	</section>

    <section anchor="IANA" title="IANA Considerations">
      <t>This memo includes no request to IANA.</t>
    </section>

<section anchor="acknowledgments" title="Acknowledgments">
	<t>The authors thank Dan Wing, Andrew Yourtchenko, and everyone else who worked on the original Happy Eyeballs design (<xref target="RFC6555"/>), Josh Graessley, Stuart Cheshire, and the rest of team at Apple that helped implement and instrument this algorithm, and Jason Fesler and Paul Saab who helped measure and refine this algorithm. The authors would also like to thank Nick Chettle, Paul Hoffman, Philip Homburg, Joe Touch and James Woodyatt for their input and contributions.</t>
</section>

  </middle>

  <!--  *****BACK MATTER ***** -->

  <back>
    <!-- References split into informative and normative -->

    <!-- There are 2 ways to insert reference entries from the citation libraries:
     1. define an ENTITY at the top, and use "ampersand character"RFC2629; here (as shown)
     2. simply use a PI "less than character"?rfc include="reference.RFC.2119.xml"?> here
        (for I-Ds: include="reference.I-D.narten-iana-considerations-rfc2434bis.xml")

     Both are cited textually in the same manner: by using xref elements.
     If you use the PI option, xml2rfc will, by default, try to find included files in the same
     directory as the including file. You can also define the XML_LIBRARY environment variable
     with a value containing a set of directories to search.  These can be either in the local
     filing system or remote ones accessed by http (http://domain/dir/... ).-->

    <references title="Normative References">
      <!--?rfc include="http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml"?-->
      &RFC2119;
	  &RFC6555;
	  &RFC6724;

    </references>

    <references title="Informative References">

        &RFC7413;

    </references>
    <section title="Differences from RFC6555">
        <t>"Happy Eyeballs: Success with Dual-Stack Hosts" <xref target="RFC6555"/> mostly concentrates on how to stagger connections to a hostname that has an AAAA and an A record. This document additionally discusses:
    <list style="symbols">
          <t>how to perform DNS queries to obtain these addresses</t>
          <t>how to handle multiple addresses from each address family</t>
          <t>how to handle DNS updates while connections are being raced</t>
          <t>how to leverage historical information</t>
        </list> </t>
    </section>
  </back>
</rfc>
