﻿<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC2119 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC1078 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1078.xml">
<!ENTITY RFC2140 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2140.xml">
<!ENTITY RFC3124 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.3124.xml">
<!ENTITY RFC5681 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.5681.xml">
<!ENTITY RFC6093 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6093.xml">
<!ENTITY RFC6356 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6356.xml">
<!ENTITY RFC6555 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6555.xml">
<!ENTITY RFC6824 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6824.xml">
<!ENTITY RFC6994 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6994.xml">
<!ENTITY I-D.hildebrand-spud-prototype SYSTEM
"http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.draft-hildebrand-spud-prototype-03.xml">
<!ENTITY I-D.briscoe-tcpm-inner-space SYSTEM
"http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.draft-briscoe-tcpm-inner-space-01.xml">
<!ENTITY I-D.ietf-rmcat-coupled-cc SYSTEM
"http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.draft-ietf-rmcat-coupled-cc-00.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc toc="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc iprnotified="no" ?>
<?rfc strict="no" ?>
<rfc category="exp" docName="draft-welzl-irtf-iccrg-tcp-in-udp-00"
    ipr="trust200902">
    <front>
        <title abbrev="TiU">TCP in UDP</title>
        
        <author fullname="Michael Welzl" initials="M." surname="Welzl">
            <organization>University of Oslo</organization>
            
            <address>
                <postal>
                    <street>PO Box 1080 Blindern</street>
                    
                    <city>Oslo</city>
                    
                    <code>N-0316</code>
                    
                    <country>Norway</country>
                </postal>
                
                <email>michawe@ifi.uio.no</email>
            </address>
        </author>
        
        <author fullname="Safiqul Islam" initials="S.I." surname="Islam">
            <organization>University of Oslo</organization>
            <address>
                <postal>
                    <street>PO Box 1080 Blindern</street>
                    <!-- Reorder these if your country does things differently -->
                    <code>N-0316</code>
                    <city>Oslo</city>
                    <region></region>
                    <country>Norway</country>
                </postal>
                <phone>+47 22 84 08 37</phone>
                <email>safiquli@ifi.uio.no</email>
                <!-- uri and facsimile elements may also be added -->
            </address>
        </author>

    <author fullname="Kristian Hiorth" initials="K." surname="Hiorth">
      <organization>University of Oslo</organization>
      <address>
        <postal>
          <street>PO Box 1080 Blindern</street>
          <city>Oslo</city>
          <region></region>
          <code>N-0316</code>
          <country>Norway</country>
        </postal>
        <email>kristahi@ifi.uio.no</email>
      </address>
    </author>
        
        <author fullname="Jianjie You" initials="J." surname="You">
            <organization>Huawei</organization>
            
            <address>
                <postal>
                    <street>101 Software Avenue, Yuhua District</street>
                    
                    <city>Nanjing</city>
                    
                    <code>210012</code>
                    
                    <country>China</country>
                </postal>
                
                <email>youjianjie@huawei.com</email>
            </address>
        </author>
        
        <date year="2016" />
        
        <area>IRTF</area>
        
        <workgroup>Internet Congestion Control Research Group</workgroup>
        
        <keyword>RFC</keyword>
        
        <keyword>Request for Comments</keyword>
        
        <keyword>I-D</keyword>
        
        <keyword>Internet-Draft</keyword>
        
        <keyword>TCP</keyword>
        
        <keyword>UDP</keyword>
        
        <abstract>
            <t>This document specifies a method to encapsulate multiple TCP connections
                using only one UDP port number pair. Doing so allows for a relatively
                easy implementation of coupled congestion control for the TCP connections.
                This can have several performance benefits, and it makes it possible to precisely
                assign a share of the congestion window to the connections based on priorities.
                It also enables use of
                UDP-based NAT traversal techniques, and it can act as a framework for
                experimentation with novel changes to the TCP standard.</t>
        </abstract>
        
        <note title="Requirements Language ">
            <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
                "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
                document are to be interpreted as described in <xref
                    target="RFC2119"></xref>.</t>
        </note>
    </front>
    
    <middle>
        <section anchor="intro" title="Introduction">
            <t>
                Note that this document is written in a style that should facilitate quick reading
                by focusing on the key changes from prior similar proposals. A future version
                of this document will provide more details about the parts that are
                "inherited" from such prior work.
            </t>
            <t>
                TCP-in-UDP (TiU) is based on <xref target="Che13"></xref>. It differs from it in
                that:
                <list style="symbols">
                    <t>Other than <xref target="Che13"></xref>, TiU encapsulates
                    multiple TCP connections using the same UDP port number pair. TCP port numbers are
                    preserved; a single well-known UDP port is
                        used for TiU. If TiU is implemented in the kernel, this allows using normal TCP
                        sockets, where enabling the usage of TiU could be
                        done via a socket option, for example.
                        <!-- or via a system configuration, affecting
                        existing TCP implementations without requiring to change their implementation.
                         -->
                    </t>
                    <t>The header format is slightly different to allow representing a TCP connection with
                        a few bits that are encoded across the original TCP header's "Reserved" field
                        and the URG (Urgent) flag to encode a Connection ID. With this encoding, similar
                        to the encapsulation
                        in <xref target="Che13"></xref>, the total TiU header size does not exceed
                        the original TCP header size.
                    </t>
                    <t>A (TiU-encapsulated) TCP SYN uses a newly defined TCP option to establish
                        the mapping between a Connection ID and the original TCP port number pair.
                    </t>
                    <t>A method to couple the congestion controls of the TCP connections is
                        presented. This coupling can have various performance benefits (explained
                        in detail in <xref target="usage"/>) and allows to precisely allocate a desired
                        share to one of the coupled TCP connections based on a priority from the
                        application. Coupled congestion control is possible in TiU
                        because the common preceding
                        UDP header makes it reasonable to assume that the connections traverse
                        the same network bottleneck. This is not necessarily a correct assumption
                        when the outer header's port numbers differ due to mechanisms like
                        Equal-Cost Multi-Path (ECMP). Note that ECMP can have performance
                        benefits which TiU eliminates. This trade-off is also discussed in
                        Section <xref target="usage"/>.
                    </t>
                    <t>This document provides some new and/or somewhat different explanations:
                        <xref target="implementation"/> discusses how TiU support can work with preceding
                        extra information such as a SPUD header (<xref target="I-D.hildebrand-spud-prototype"/>) without exceeding the MTU
                        and elaborates on a possible method of implementating
                        TiU including robust "Happy Eyeballing".
                    </t>
                </list>
            </t>
            <t>TiU inherits all the benefits of <xref target="Che13"></xref> and a
                preceding similar proposal, <xref target="Den08"></xref>. It adds
                potential benefits that are due to coupled congestion control, and it adds
                the potential disadvantage of not being able to benefit from ECMP. In short,
                the benefits and features of TiU that are already explained in detail in
                <xref target="Che13"></xref> and <xref target="Den08"></xref> are:
                
                <list style="symbols">
                    <t>To establish direct communication between two devices that are both
                        behind NAT gateways, Interactive Connectivity Establishment (ICE)
                        [RFC5245] is used to create the necessary mappings in both NAT
                        gateways, and ICE can have higher success rates using
                        UDP [RFC5128].
                    </t>
                    <t>TCP options, as required for Multipath TCP <xref target="RFC6824"/>, for example, are
                        expected to work more reliably because middleboxes will be less able
                        to interfere with them.
                    </t>
                    <t>Because the packet format allows the first octet to be in the range
                        0x0-0x3 (as is the case for a STUN [RFC5389] packet, where the
                        most significant two bits are
                        always zero), the UDP port number pair used by TiU can be used to
                        exchange STUN packets with a STUN server that is unaware of TiU.
                    </t>
                    <t>Following the method described in <xref target="Che13"></xref>
                        and <xref target="Den08"></xref>,
                        other transport protocols than TCP (e.g., SCTP) could be
                        UDP-encapsulated in a similar fashion. With TiU, the
                        same outer UDP port number pair could be used for different
                        encapsulated protocols at the same time.
                    </t>
                </list>
            </t>
            <t><xref target="Che13"></xref> also lists a disadvantage of UDP-encapsulating
                TCP packets: because NAT gateways typically use shorter timeouts for UDP
                port mappings than they do for TCP port mappings, long-lived UDP-encapsulated
                TCP connections will need to send more frequent keepalive
                packets than native TCP connections. TiU inherits this problem too, although
                using a single five-tuple for multiple TCP connections alleviates it by reducing
                the chance of experiencing long periods of silence.
            </t>


        </section>
        
        
        <section title="More related work">
            <t>
                The TCPMUX mechanism in <xref target="RFC1078"></xref>
                multiplexes
                TCP connections under the same outer transport port number; it does however
                not preserve the port numbers of the original TCP connections, and no method
                to couple congestion controls is described in <xref target="RFC1078"></xref>.
            </t>
            
            <t>
                TiU's congestion control coupling follows the style of RTP application congestion
                control coupling in <xref target="I-D.ietf-rmcat-coupled-cc"></xref> which is
                designed to be easy to implement, and to minimize the number of changes that need to
                be made to the underlying congestion control mechanisms.
                This method was shown to yield several benefits in <xref target="fse"></xref>. 
                TiU's congestion control
                requires slightly deeper changes to the TCP's congestion control, making
                it harder to implement than <xref target="I-D.ietf-rmcat-coupled-cc"></xref>, but
                it is still a much smaller code change than the Congestion Manager <xref target="RFC3124"/>.
            </t>
            
            <t>
                Combining congestion controls as TiU does it has some similarities with Ensemble
                Sharing in <xref target="RFC2140"/>, which however only concerns initial
                values of variables used by new connections and does not share the congestion
                window (cwnd), which is
                the variable of interest in TiU. The cwnd variable is shared across ongoing connections
				in <xref target="ETCP"></xref> and <xref target="EFCM"></xref>, and the mechanism
				described in <xref target="ccc"/> resembles the mechanisms in these works, but
				neither <xref target="ETCP" /> nor <xref target="EFCM" /> address the problem of ECMP.
            </t>

            <t>
                Coupled congestion control has also been specified for Multipath TCP <xref target="RFC6356"/>.
                MPTCP's coupled congestion control combines the congestion controls of subflows
                that may traverse different paths, whereas TiU builds on the assumption that
                all its encapsulated TCP connections traverse the same path. This makes the
                two methods for coupled congestion control very different, even though they both
                aim at emulating the behavior of a single TCP connection in the case where all
                flows traverse the same network bottleneck.
            </t>

        </section>
        
        <section title="Specification">
            <t>TiU uses a header that is very similar to the header format in <xref target="Den08"></xref>
                and <xref target="Che13"></xref>, where it is explained in greater detail.
                It consists of a UDP header that is followed by a slightly altered TCP header.
                The UDP source and destination ports are semantically different from
                <xref target="Den08"></xref> and <xref target="Che13"></xref>: TiU uses a
                single well-known UDP port, and multiple TCP connections use the same
                UDP port number pair. The encapsulated
                TCP header is changed to fit into a UDP packet without increasing the MSS; this is
                achieved by removing the TCP source and destination ports,
                the Urgent Pointer and the (now unnecessary) TCP checksum. Moreover, the order
                of fields is changed to move the Data Offset field to the beginning
                of the UDP payload. This allows using it to identify other encapsulated content
                such as a STUN packet: for TCP, the Data Offset must be at least 5, i.e. the
                most-significant four bits of the first octet of the UDP payload are
                in the range 0x5-0xF, whereas this is not the case for other protocols
                (e.g., STUN requires these bits to be 0). The altered TCP header for TiU is shown below:
            </t>
            <t>
                <figure align="left" anchor="EncapsTCPheader" title="Encapsulated TCP-in-UDP Header Format (the first 8 bytes are the UDP header)">
                    <artwork align="center"><![CDATA[
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Length             |           Checksum            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data | Conn  |C|E|C|A|P|R|S|F|                               |
| Offset|  ID   |W|C|I|C|S|S|Y|I|            Window             |
|       |       |R|E|D|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      (Optional) Options                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                    ]]></artwork>
<!--                    		<postamble>Figure 1: Encapsulated TCP-in-UDP Header Format (the first 8 bytes are the UDP header)</postamble>
-->
                </figure>
            </t>

            <t>
                Different from <xref target="Den08"></xref> and <xref target="Che13"></xref>,
                the least-significant four bits of the first octet and a bit that replaces
                the URG bit in the next octet together form a five-bit "Connection ID" (Conn ID).
                TiU maintains the port numbers of the TCP connections that it encapsulates;
                the Connection ID is a way to encode the port number information
                with a few unused header bits. It
                uniquely identifies a port number pair of a TCP connection that is encapsulated
                with TiU. Using these five bits, TiU can combine up to 32 TCP connections with
                one UDP port number pair.
            </t>
            <t> The TiU-TCP SYN and SYN/ACK packets look slightly little different, because
            they need to establish
                the mapping between the Connection ID and the port numbers that are used
                by TiU-encapsulated TCP connections:
            </t>
                        <t>
                <figure align="left" anchor="EncapsTCPSYNheader" title="Encapsulated TCP-in-UDP SYN and SYN/ACK Packet Header Format">
                    <artwork align="center"><![CDATA[
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Length             |           Checksum            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |Re-    |C|E| |A|P|R|S|F|                               |
| Offset|served |W|C|0|C|S|S|Y|I|            Window             |
|       |       |R|E| |K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Acknowledgment Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Encapsulated Source Port    | Encapsulated Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Options                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                    ]]></artwork>
<!--                    		<postamble>Figure 2: Encapsulated TCP-in-UDP SYN and SYN/ACK Packet Header Format</postamble>
 -->
                </figure>
            </t>


            <t>The Encapsulated Source Port and Encapsulated Destination Port are
            the port numbers of the TCP connection. To create this header, an implementation
            can simply swap the
            position of the original TCP header's port number fields with the position
            of the Data Offset / Reserved / Flags / Window fields.</t>
            
            <t>Every TiU SYN or TiU SYN-ACK
            packet also carries at least the TiU-Setup TCP option. This option contains a Connection ID number.
            On a SYN packet, it is the Connection ID that the sender intends to use in future packets to
            represent the Encapsulated Source Port and Encapsulated Destination Port. On a SYN/ACK packet,
            it confirms that such usage is accepted by the recipient of the SYN. A special value of 255
            is used to signify an error, upon which TiU will no longer be used (i.e., the next packet is
            expected to be a non-encapsulated TCP packet). The TiU-Setup TCP option is defined as follows:
                <figure align="left" anchor="TiUSetupTCPOption" title="TiU Setup TCP Option">
                    <artwork align="center"><![CDATA[
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Kind          |    Length     |     ExID                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Connection ID |
+-+-+-+-+-+-+-+-+
                    ]]></artwork>
<!--                    		<postamble>Figure 3: TiU Setup TCP option</postamble>
-->
                </figure>
             The option follows the format for Experimental TCP Options defined in <xref target="RFC6994"/>.
             It has Kind=253, Length=5, an ExID that is with value TBD (see <xref target="iana"/>) and the Connection ID.
             The Connection ID is an 8-bit field
             for easier parsing, but only values 0-31 are valid Connection IDs (because the Connection
             ID in non - SYN or SYN/ACK TiU packets is only 5 bit long).
            </t>
        </section>


        <section title="Protocol operation and implementation notes" anchor='implementation'>
            <t>There can be several ways to implement TCP-in-UDP. The following gives an
                overview of how a TiU implementation can operate. This description matches
                the implementation described in <xref target="implementationstatus"/>.
            </t>
            
            <t>A goal of TiU is to achieve congestion control coupling with a simple
                implementation that minimizes changes to existing code. It is thus recommendable
                to implement TiU in the kernel, as a change to the existing kernel TCP code. The changes
                fall in two basic categories:
                <list style="symbols">
                    <t>Encapsulation and decapsulation: this is code that should, in the simplest
                        case, operate just before a TCP segment is transmitted. Based on e.g.
                        a socket option that enables/disables TiU, the TCP segment is changed
                        into the TiU header format (Figure 1). In case it is a TCP SYN or TCP SYN/ACK
                        packet, the header format is
                        defined as in Figure 2, and the TiU-Setup TCP
                        option is appended. This packet is then transmitted. For decapsulation,
                        the reverse mechanism applies, upon reception of a UDP packet that uses
                        destination port XXX (TBD, see <xref target="iana"/>). Both hosts keep a list of encapsulated TCP port numbers
                        and their corresponding Connection IDs. In case a SYN packet requests using a
                        Connection ID that is already reserved, an error (Connection ID value 255
                        in the TiU Setup TCP option)
                        must be signified to the other end in a TiU-encapsulated TCP SYN/ACK, and
                        encapsulation must be disabled on all further TCP packets. Similarly, when
                        receiving a TiU SYN/ACK with an error, a TCP sender must stop encapsulating
                        TCP packets.
                    </t>
                    <t>Coupled congestion control: this is code that influences the congestion
						control of TCP. <xref target="ccc"/> describes a simple coupled congestion
						control algorithm that can be applied to couple TCP connections and assign
						them a share of the total congestion window that is based on a priority.
                    </t>
                </list>
                The TCP port number space usage
                on the host is left unchanged: the original code can reserve TCP ports as it
                always did. Except for the TiU encapsulation compressing the port numbers into
                a Connection ID field, TCP ports should be used similar to normal TCP operation.
                A TCP port that is in use by a TiU-encapsulated TCP connection must therefore
                not be made available to non-encapsulated TCP connections, and vice versa.
            </t>
			<t>For each TCP connection, two variables must be configured: 1) TiU-ENABLE, which is a boolean,
			deciding whether to use TiU or not, and 2) Priority, which is a value, e.g. from 1 to 10, that is used
			by the coupled congestion control algorithm to assign an appropriate share of the total cwnd
			to the connection. Priority values are local and their range does
			not matter for this algorithm: the algorithm works with a flow's priority portion of the
			sum of all priority values.  
   			The configuration of the two per-connection variables
			can be implemented in various ways, e.g. through an API option.
			</t>

            <t>
                With these code changes in place, TiU can operate as follows, assuming no previous
                TiU connections have been made between a specific host pair and a client tries
                to connect to a server:
                <list style="symbols">
                    <t>An application uses an API option to request TiU operation. The kernel
                        then sends out a TiU TCP SYN that contains a TiU-Setup
                        TCP option. This packet header contains the encapsulated TCP port numbers
                        (source port A and destination port B) and the Connection ID X.
                    </t>
                    <t>The server listens on UDP port XXX (TBD, see <xref target="iana"/>). Upon receiving a packet on
                        this port, it knows that it is a TiU packet and decodes it, handing
                        the resulting TCP packet over to "normal" TCP processing. The TiU-Setup
                        TCP option allows the server to associate future TiU
                        packets containing Connection ID X with ports A and B. The server sends its response
                        as a TiU SYN-ACK.
                    </t>
                    <t>TCP operates as normal from here on, but packets are TiU-encapsulated
                        before sending them out and decapsulated upon reception, using Connection ID X.
                        Both hosts associate TiU packets carrying Connection ID X with a local identifier that matches
                        ports A and B, just like they would associate non-encapsulated TCP packets with the same
                        local identifier when seeing ports A and B in the TCP header.
                    </t>
                    <t>If an application on either side of the TiU connection wants to connect to a
                        destination host on the other side and
                        requests TiU operation, the kernel
                        sends out another TiU TCP SYN, this time containing a different TCP source port number
                        and either the same or
                        a different destination port number (C and D), and a TiU-Setup TCP option with
                        Connection ID Y. From now
                        on, packets carrying Connection ID Y will be associated with ports C and D on
                        both hosts. Otherwise, TiU operation continues as described above.
                    </t>
                    <t> Now, because there are two or more connections available between the same host pair, coupled congestion
                        control begins to operate for all outgoing TiU packets (see <xref target="ccc"/> for details). This is a local
                        operation, applying the priority values that were configured to use for the TiU-encapsulated
                        TCP connections.
                    </t>
                </list>                
            </t>
            
            <t>
                Unless it is known that UDP packets with destination port number XXX (TBD, see <xref target="iana"/>) can be used without problems on the
                path between two communicating hosts, it is advisable for TiU implementations to contain methods to
                fall back to non-encapsulated ("raw") TCP communication. Such fall-back must be supported for
                the case of Connection ID collisions anyway. Middleboxes have been known to track TCP connections
                <xref target="Honda11"/>, and falling back to communication with raw TCP packets without ever using a raw
                TCP SYN - SYN/ACK handshake may lead to problems with such devices. The following method is recommended
                to efficiently fall back to raw TCP communication:
				<list style="symbols">
                    <t>After sending out a TiU SYN packet, additionally send a raw TCP SYN packet.
                    </t>
                    <t>After sending out a TiU SYN/ACK packet, additionally send a raw TCP SYN/ACK packet.
                    </t>
                    <t>Upon receiving a TiU SYN packet, after responding with a TiU SYN/ACK packet and raw TCP SYN/ACK packet,
                    immediately store the encapsulated port numbers and Connection ID. As long
                    as a TiU connection is ongoing, ignore any additional incoming TCP SYN or TCP SYN/ACK packets from the same host that carry port numbers
                    matching the stored encapsulated port numbers. Otherwise, process TCP SYN or TCP SYN/ACK packets as normal.
                    </t>
                </list>
                This method ensures that the TCP SYN / SYN/ACK handshake is visible to middleboxes and allows to immediately switch back to raw TCP
                communication in case of failures. If implemented on both sides as described above and no TiU SYN or TiU SYN/ACK packet arrives, yet a
                TCP SYN or TCP SYN/ACK packet does, this can only mean that the other host does not support TiU, a UDP packet was dropped, or
                the UDP and TCP packets were reordered in transit. Reordering in the host (e.g., a server responding to a TCP SYN before
                it responds to a TiU SYN) can be a problem for similar methods (e.g. <xref target="RFC6555"/>), but it can be eliminated by prescribing the processing order as above.
			</t>
            <t>
                Because TCP does not preserve message boundaries and the size of the TCP header can vary depending on the options that are used,
                it is also no problem to precede the TCP header in the UDP packet with a different header (e.g. SPUD <xref target="I-D.hildebrand-spud-prototype"/>)
                without exceeding the known MTU limit.
                When creating a TCP segment, a TCP sender needs to consider the length of this header when calculating the segment size, just like it
                would consider the length of a TCP option. For this to work, the usage
                of other headers such as SPUD in-between the UDP header and the TiU header must therefore be known to both the sender-side and receiver-side code that
                processes TiU.
			</t>

        </section>
        

        <section title="Coupled congestion control" anchor='ccc'>
        <t>For each TCP connection c, the algorithm described below receives cwnd and ssthresh as input and stores the following information:
			<list style="symbols">
			  <t>the Connection ID.</t>
			  <t>a priority P(c) -- e.g., an integer value in the range from 1 (unimportant) to 10 (very important).</t>
			  <t>The previously used cwnd used by the connection c, ccc_cwnd(c).</t>
			  <t>The previously used ssthresh used by the connection c, ccc_ssthresh(c).</t>
			</list>
		</t>                
              <t>Three global variables S_CWND, S_SSTHRESH and S_P are used to represent the sum of all the ccc_cwnd values, ccc_sshtresh values and
              priorities of all TCP connections, respectively. S_CWND and S_SSTHRESH are used to update the cwnd and ssthresh values for all connections.</t>
            
            
            
<section title="Example algorithm" anchor='example-alg'>
     <t>This algorithm emulates the behavior of a single TCP connection by choosing one connection
     as the connection that dictates the increase / decrease behavior for the aggregate.
     It was designed to be as simple as possible.
     In the algorithm description below, abbreviations are used to refer to the phases of
     TCP congestion control as defined in <xref target="RFC5681"/>: SS refers to Slow Start,
     CA refers to Congestion Avoidance and FR refers to Fast Recovery.
     </t>
     <t>For simplicity, this algorithm refrains from changing cwnd when a connection is in FR.
     SS should not happen as long as ACKs arrive. Hence, the algorithm ensures that the
     aggregate's behavior is only dictated by SS when all connections are in the SS phase.</t>
  <t>
  <list style="format (%d)">
    <t>When a connection c starts, it adds its priority P(c) to S_P. If it is the very first connection
    that uses the outer UDP port number pair, it also sets S_CWND to its own cwnd. After that, 
    		the connection's globally known cwnd and ssthresh values (ccc_cwnd(c) and ccc_ssthresh(c))
    		are updated, and the
    		connection updates its own cwnd and ssthresh values to be equal to ccc_cwnd(c) and ccc_ssthresh(c).

        <figure align="left">
        <artwork align="left">
            <![CDATA[ 
  S_P = S_P + P(c)
  ccc_cwnd(c) = P(c) * S_CWND / S_P
  ccc_ssthresh(c) = ssthresh
  if (S_SSTHRESH > 0)
    ccc_ssthresh(c) = P(c) * S_SSTHRESH / S_P
  end if
  // Update c's own cwnd and ssthresh for immediate use:
  send ccc_cwnd(c) and ccc_ssthresh(c) to the connection c
             ]]>
        </artwork>
        </figure>    
    </t>
    <t>When a connection c stops, its entry is removed. S_P is recalculated.</t>  

      <t>Every time the congestion controller of a connection c calculates a new cwnd, the connection calls UPDATE, which carries out the tasks listed below to derive the new cwnd
      and ssthresh values for all the connections. Since we intend to emulate the behavior of one connection, we designate one of the
      connections as the "Coordinating Connection" (CoCo). Whenever the coordinating connection calls UPDATE, S_CWND and S_SSTHRESH
      are additionally updated to reflect the current sum of
      all stored ccc_cwnd and ccc_ssthresh values. Initially, there is only one connection and this connection automatically becomes
      the CoCo. It updates S_CWND to its own cwnd and sets S_SSTHRESH to 0.</t>

      <t> WHEN a non-CoCo connection c CALLS UPDATE......
      <figure align="left">
      <artwork align="left">
      <![CDATA[
  if(all of the connections including CoCo are in CA but c is in FR)
     c becomes the new CoCo.
  else
     if(c is in CA or SS)
        c's cwnd is assigned its previously stored ccc_cwnd value. ]]>
      </artwork>
      </figure>
      </t>
      
      <t> WHEN c(CoCo) CALLS UPDATE......
        <figure align="left">
            <artwork align="left">
              <![CDATA[
  if (c is in CA)
      if(cwnd >= ccc_cwnd(c)) // cwnd has increased
         S_CWND = S_CWND + cwnd - ccc_cwnd(c)
      else
         S_CWND = S_CWND * cwnd / ccc_cwnd(c)
      end if
      ccc_cwnd(c) = P(c) * S_CWND / S_P
      ccc_ssthresh(c) = ssthresh
      if (S_SSTHRESH > 0)
         ccc_ssthresh(c) = P(c) * S_SSTHRESH / S_P
      end if
      // Update c's own cwnd and ssthresh for immediate use:
      send ccc_cwnd(c) and ccc_ssthresh(c) to the connection c
  end if    

  else if (c is in FR)
      S_SSTHRESH = S_CWND/2

  else if (c is in SS)
      if (all other connections are in SS)
         S_SSTHRESH = S_CWND/2
         S_CWND = S_CWND * cwnd / ccc_cwnd(c)
         ccc_cwnd(c) = P(c) * S_CWND / S_P
         // Update c's own cwnd for immediate use:
         send ccc_cwnd(c) to the connection c
      else                      
         make any other connection which is not in SS the CoCo
      end if
  end if]]>
            </artwork>
        </figure>
    </t>
  </list></t>

 </section>            
</section>
        
        <section title="Usage considerations" anchor='usage'>
            <t>
            TiU cannot work with applications that require the Urgent pointer (which is not recommended for
            use by new applications anyway <xref target="RFC6093"/>, but should be consider if TiU
            is implemented in a way that allows it to be applied onto existing applications; telnet
            is a well-known example of an application that uses this functionality). It enables use
            of TCP with methods such as SPUD <xref target="I-D.hildebrand-spud-prototype"/>. It can also
            be used as a method to experimentally test new TCP functionality in the presence of middleboxes
            that would otherwise create problems (as some have been known to do <xref target="Honda11"/>).
            TCP option space is getting scarce, in particular on TCP SYN and TCP SYN/ACK packets. Rather
            than stretching the Data Offset field on TCP SYN / TCP SYN/ACK packets (which was considered
            for TiU design), it is recommended to use one of the other proposed mechanisms to stretch
            option space, e.g. "Inner Space" <xref target="I-D.briscoe-tcpm-inner-space"/>.
            </t>

            <t>
            Reasons to use TiU include the benefits of <xref target="Che13"></xref> and <xref target="Den08"></xref>
            that were discussed in <xref target="intro"/>. TiU has the disadvantage of disabling ECMP for the
            TCP connections that it encapsulates. This can reduce the capacity usage of these TCP connections.
            It has the advantage of being able to apply coupled congestion control, which can provide
            precise congestion window assignment based on a priority. Other benefits of TiU's coupled congestion control are:
            <list style="symbols">
                    <t>Reduced average loss and queuing delay (because the competition between the encapsulated TCP connections is avoided)
                    </t>
                    <t>Even in the absence of prioritization, better fairness between the TiU-encapsulated TCP connections
                    </t>
                    <t>No need for new TiU connections to slow start up to a reasonable cwnd value that ongoing TiU connections already have:
                    a connection can immediately be assigned its share of the aggregate's total cwnd. This can significantly reduce
                    the completion time of short connections.
                    </t>
			</list>            
            </t>
            
			<t>
			All of these benefits only play out when there are more than one TCP connections.
			Some of the benefits in the list above are more significant when some transfers are short. Moreover, short
			transfers are less likely than long ones to saturate the capacity of a path, reducing the chance to
			benefit from ECMP (which TiU eliminates). This makes the usage of TiU especially attractive in situations
			where some transfers are short.
			</t>
            
        </section>    


        <section title="Implementation status" anchor='implementationstatus'>
            <t>The University of Oslo is currently working on a FreeBSD kernel implementation of
                TCP-in-UDP.</t>
        </section>

        
        <section title="IANA Considerations" anchor='iana'>
            <t>This document specifies a new TCP option that uses the shared
   experimental options format <xref target="RFC6994"/>. No value has yet been assigned
   for ExID.</t>
            <t>This document requires a well-known UDP port (referred to as port XXX in this document). Due to the highly experimental
            nature of TiU, this document is being shared with the community to solicit comments before requesting such a port number.</t>
        </section>
        
        <section title="Security Considerations">
            <t>We have not thought about security yet. This will surely be fun!
            </t>
        </section>
        
        <section title="Acknowledgement">
            <t>This work has received funding from Huawei Technologies Co., Ltd., and the European Union's Horizon 2020 research and
   innovation programme under grant agreement No. 644334 (NEAT). The
   views expressed are solely those of the author(s).</t>
        </section>
    </middle>
    
    <back>
        <references title="Normative References">
            &RFC2119;
            
        </references>
        
        <references title="Informative References">
            
            &RFC1078;
            
            <reference anchor="Che13" target="">
                <front>
                    <title>Encapsulation of TCP and other Transport Protocols over UDP</title>
                    <author fullname="S. Cheshire" initials="S." surname="Cheshire"></author>
                    <author fullname="J. Graessley" initials="J." surname="Graessley"></author>
                    <author fullname="R. McGuire" initials="R." surname="McGuire"></author>
                    <date month="June" year="2013" />
                </front>
                
                <seriesInfo name="Internet-draft"
                value="draft-cheshire-tcp-over-udp-00" />
            </reference>
            
            <reference anchor="Den08" target="">
                <front>
                    <title>UDP-Encapsulated Transport Protocols</title>
                    
                    <author fullname="R. Denis-Courmont" initials="R." surname="Denis-Courmont"></author>
                    
                    <date month="July" year="2008" />
                </front>
                
                <seriesInfo name="Internet-draft"
                value="draft-denis-udp-transport-00" />
            </reference>
            
            &I-D.ietf-rmcat-coupled-cc;
            
            &I-D.hildebrand-spud-prototype;
            
            &I-D.briscoe-tcpm-inner-space;
            
            &RFC2140;
            
            &RFC3124;
            
            &RFC5681;

			&RFC6093;

            &RFC6356;

            &RFC6555;

            &RFC6824;
            
			&RFC6994;

            
            <reference anchor="fse">
                <front>
                    <title>Coupled Congestion Control for RTP Media</title>
                    <author initials="S.I." surname="Islam" fullname="S. Islam"> </author>
                    <author initials="M.W." surname="Welzl" fullname="M. Welzl" > </author>
                    <author initials="S.G." surname="Gjessing" fullname="S Gjessing" > </author>
                    <author initials="N.K." surname="Khademi" fullname="N Khademi" > </author>
                    <date year="2014" />
                </front>
                <seriesInfo name="ACM SIGCOMM Capacity Sharing Workshop (CSWS 2014) and ACM SIGCOMM CCR 44(4) 2014; extended version available as a technical report from http://safiquli.at.ifi.uio.no/paper/fse-tech-report.pdf" value="" />
            </reference>
            
            <reference anchor="ETCP">
                <front>
                    <title>Effects of ensemble-TCP</title>
                    <author initials="L.H." surname="Eggert" fullname="L. Eggert"> </author>
                    <author initials="J.H." surname="Heidemann" fullname="J. Heidemann" > </author>
                    <author initials="J.T." surname="Joe" fullname="J. Touch" > </author>
                    <date year="2000" />
                </front>
                <seriesInfo name="ACM SIGCOMM Computer Communication Review (2000)" value="" />
            </reference>
            
            
                <reference anchor="EFCM">
                <front>
                    <title>Analysis and performance evaluation of the EFCM common congestion controller for TCP connections</title>
                    <author initials="M.S." surname="Savoric" fullname="M. Savoric"> </author>
                    <author initials="H.K." surname="Karl" fullname="H. Karl" > </author>
                    <author initials="M.S." surname="Schlager" fullname="M. Schlager" > </author>
                    <author initials="T.P." surname="Poschwatta" fullname="T. Poschwatta" > </author>
                    <author initials="A.W." surname="Wolisz" fullname="A. Wolisz" > </author> 
                    <date year="2005" />
                </front>
                <seriesInfo name="Computer Networks (2005)" value="" />
         </reference>

    <reference anchor="Honda11" target="">
      <front>
        <title>Is it still possible to extend TCP?</title>
        <author initials="M." surname="Honda"/>
        <author initials="Y." surname="Nishida"/>
        <author initials="C." surname="Raiciu"/>
        <author initials="A." surname="Greenhalgh"/>
        <author initials="M." surname="Handley"/>
        <author initials="H." surname="Tokuda"/>
        <date month="November" year="2011"/>
      </front>
      <seriesInfo name="Proc. of ACM Internet Measurement Conference" value="(IMC) '11"/>
    </reference>

            
            
        </references>        
    </back>
</rfc>
