<?xml version="1.0" encoding="utf-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.0.31 -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC6891 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.6891.xml">
<!ENTITY RFC7766 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7766.xml">
<!ENTITY RFC7828 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7828.xml">
<!ENTITY RFC2119 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC1035 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.1035.xml">
<!ENTITY RFC7858 SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.7858.xml">
<!ENTITY I-D.ietf-dnssd-push SYSTEM "http://xml2rfc.ietf.org/public/rfc/bibxml3/reference.I-D.ietf-dnssd-push.xml">
]>

<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>

<rfc ipr="trust200902" docName="draft-bellis-dnsop-session-signal-02" category="std">

  <front>
    <title>DNS Session Signaling</title>

    <author initials="R." surname="Bellis" fullname="Ray Bellis">
      <organization abbrev="ISC">Internet Systems Consortium, Inc.</organization>
      <address>
        <postal>
          <street>950 Charter Street</street>
          <city>Redwood City</city>
          <code>CA 94063</code>
          <country>USA</country>
        </postal>
        <phone>+1 650 423 1200</phone>
        <email>ray@isc.org</email>
      </address>
    </author>
    <author initials="S." surname="Cheshire" fullname="Stuart Cheshire">
      <organization>Apple Inc.</organization>
      <address>
        <postal>
          <street>1 Infinite Loop</street>
          <city>Cupertino</city>
          <code>CA 95014</code>
          <country>USA</country>
        </postal>
        <phone>+1 408 974 3207</phone>
        <email>cheshire@apple.com</email>
      </address>
    </author>
    <author initials="J." surname="Dickinson" fullname="John Dickinson">
      <organization abbrev="Sinodun">Sinodun Internet Technologies</organization>
      <address>
        <postal>
          <street>Magadalen Centre</street> <street>Oxford Science Park</street>
          <city>Oxford</city>
          <code>OX4 4GA</code>
          <country>United Kingdom</country>
        </postal>
        <email>jad@sinodun.com</email>
      </address>
    </author>
    <author initials="S." surname="Dickinson" fullname="Sara Dickinson">
      <organization abbrev="Sinodun">Sinodun Internet Technologies</organization>
      <address>
        <postal>
          <street>Magadalen Centre</street> <street>Oxford Science Park</street>
          <city>Oxford</city>
          <code>OX4 4GA</code>
          <country>United Kingdom</country>
        </postal>
        <email>sara@sinodun.com</email>
      </address>
    </author>
    <author initials="A." surname="Mankin" fullname="Allison Mankin">
      <organization>Salesforce</organization>
      <address>
        <email>allison.mankin@gmail.com</email>
      </address>
    </author>
    <author initials="T." surname="Pusateri" fullname="Tom Pusateri">
      <organization>Unaffiliated</organization>
      <address>
        <phone>+1 843 473 7394</phone>
        <email>pusateri@bangj.com</email>
      </address>
    </author>

    <date year="2016" month="July"/>

    <area>Internet</area>
    <workgroup>DNSOP Working Group</workgroup>
    <keyword>Internet-Draft</keyword>

    <abstract>


<t>The EDNS(0) Extension Mechanism for DNS <xref target="RFC6891"/> is explicitly
defined to only have “per-message” semantics.  This document defines a
new Session Signaling Opcode used to carry persistent “per-session”
type-length-values (TLVs), and defines an initial set of TLVs used to
manage session timeouts and termination.</t>



    </abstract>


  </front>

  <middle>


<section anchor="introduction" title="Introduction">

<t>The use of transports other than UDP for DNS is being increasingly specified, 
for example, DNS-over-TCP <xref target="RFC7766"/>, DNS-over-TLS <xref target="RFC7858"/> and recent
work on DNS Push Notifications <xref target="I-D.ietf-dnssd-push"/>. Such transports frequently
use persistent, long-lived sessions and therefore when using them for transporting 
DNS messages it is of benefit to have a mechanism
that can establish parameters associated with those sessions, such as timeouts.
In such situations it is also advantageous to support server initiated messages.</t>

<t>The EDNS(0) Extension Mechanism for DNS <xref target="RFC6891"/> is explicitly
defined to only have “per-message” semantics. Whilst EDNS(0) has been used to 
signal at least one session related parameter (the EDNS TCP KeepAlive option
<xref target="RFC7828"/>) the result is less than optimal due to the restrictions
imposed by the EDNS(0) semantics and the lack of server initiated signalling.
This document defines a new Session Signaling Opcode used to carry persistent
“per-session” type-length-values (TLVs), and defines an initial set of TLVs used to
manage session timeouts and termination.</t>

<t>With EDNS(0), multiple options may be packed into a single OPT RR, and
there is no generalized mechanism for a client to be able to tell
whether a server has processed or otherwise acted upon each individual
option within the combined OPT RR.  The specifications for each
individual option need to define how each different option is to be
acknowledged, if necessary.</t>

<t>With Session Signaling, in contrast, each Session Signaling operation is
communicated in its own separate DNS message, and the RCODE in the
response indicates the success or failure of that operation.</t>

<t>It should be noted that the message format for Session Signaling
operations (see <xref target="format"/>) differs from the DNS packet format used for
standard queries and responses, in that it has a shorter header (four
octets instead of usual twelve octets).</t>

</section>
<section anchor="terminology" title="Terminology">

<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"/>.</t>

<t>The terms “initiator” and “responder” correspond respectively to the
initial sender and subsequent receiver of a Session Signaling TLV,
regardless of which was the “client” and “server” in the usual DNS sense.</t>

<t>The term “sender” may apply to either an initiator or responder.</t>

<t>The term “session” in the context of this document means the exchange of
DNS messages using an end-to-end transport protocol where:</t>

<t><list style="symbols">
  <t>The connection between client and server is persistent and relatively
long-lived (i.e. minutes or hours, rather than seconds).</t>
  <t>Either end of the connection may initiate messages to the other</t>
  <t>Messages are delivered in order</t>
</list></t>

</section>
<section anchor="protocol-details" title="Protocol Details">

<t>Session Signaling messages MUST only be carried in protocols and in
environments where a session may be established according to the
definition above.  Standard DNS over TCP <xref target="RFC1035"/>, and DNS over TLS
<xref target="RFC7858"/> are suitable protocols.  DNS over plain UDP is not
appropriate since it fails on the requirement for in-order message
delivery, and, in the presence of NAT gateways and firewalls with short UDP
timeouts, it fails to provide a persistent bi-directional communication
channel unless an excessive amount of keepalive traffic is used.</t>

<t>Session Signaling messages relate only to the specific session in which
they are being carried.  Where a middle box (e.g. a DNS proxy,
forwarder, or session multiplexer) is in the path the message MUST NOT
be blindly forwarded in either direction by that middle box.  This does
not preclude the use of these messages in the presence of a NAT box that
rewrites IP-layer or transport-layer headers but otherwise maintains the
effect of a single session.</t>

<t>A client MAY attempt to initiate Session Signaling messages at any time on
a connection; receiving a NOTIMP response in reply indicates that the
server does not implement Session Signaling, and the client SHOULD NOT
issue further Session Signaling messages on that connection.</t>

<t>A server SHOULD NOT initiate Session Signaling messages until a
client-initiated Session Signaling message is received first,
unless in an environment where it is known in advance by other
means that both client and server support Session Signaling.
This requirement is to ensure that the clients that do not support
Session Signaling do not receive unsolicited inbound Session Signaling
messages that they would not know how to handle.</t>

<section anchor="lifecycle" title="Session Lifecycle">

<t>A session begins when a client makes a new connection to a server.</t>

<t>The client may perform as many DNS operations as it wishes on the newly
created connection. Operations SHOULD be pipelined (i.e., the client
doesn’t need wait for a reply before sending the next message).
The server MUST act on messages in the order they are received, but
responses to those messages MAY be sent out of order, if appropriate.</t>

<t>When a server implementing this specification receives a new connection
from a client, it MUST begin by internally assigning an initial idle
timeout of 30 seconds to that connection.  At both servers and clients,
the generation or reception of any complete DNS message, including DNS
requests, responses, updates, or Session Signaling messages, resets the
idle timer for that connection (see <xref target="RFC7766"/>).</t>

<t>If, at any time during the life of the connection,
half the idle-timeout value (i.e., 15 seconds by default) elapses
without any DNS messages being sent or received on a connection,
then the connection is considered stale and the client MUST take action.
When this happens the client MUST either send at least one new message
to reset the idle timer – such as a Session Signaling Idle Timeout message
(see <xref target="idletimeout"/>), or any other valid DNS message – or close the connection.</t>

<t>If, at any time during the life of the connection,
the full idle-timeout value (i.e., 30 seconds by default) elapses
without any DNS messages being sent or received on a connection,
then the connection is considered delinquent and the server SHOULD
forcibly terminate the connection. For sessions over TCP (or over TLS-over-TCP),
to avoid the burden of having a connection in TIME-WAIT state, instead of
closing the connection gracefully with a TCP FIN the server SHOULD abort
the connection with a TCP RST. (In the Sockets API this is achieved by
setting the SO_LINGER option to zero before closing the socket.)</t>

<t>If the client wishes to keep an idle connection open for longer than
the default duration without having to send traffic every 15 seconds,
then it uses the Session Signaling
Idle Timeout message to request a longer idle timeout (see <xref target="idletimeout"/>).</t>

<t>A client is not required to wait until half of the idle-timeout value
before closing a connection. A client MAY close a connection at any time,
at the client’s discretion, if it has no further need for the connection at that time.</t>

</section>
<section anchor="format" title="Message Format">

<t>A Session Signaling message begins with the
first 4 octets of the standard DNS message header <xref target="RFC1035"/>,
with the Opcode field set to the Session Signaling Opcode.
A Session Signaling message does not contain
the QDCOUNT, ANCOUNT, NSCOUNT and ARCOUNT fields
fields used in standard DNS queries and responses.
This 4-octet header is followed by a single Session Signaling TLV.</t>

<figure><artwork><![CDATA[
                                             1   1   1   1   1   1
     0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |                          MESSAGE ID                           |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |QR |    Opcode     |            Z              |     RCODE     |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |                                                               |
   /                           TLV-DATA                            /
   /                                                               /
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
]]></artwork></figure>

<t>The MESSAGE ID, QR, Opcode and RCODE fields have their usual meanings <xref target="RFC1035"/>.</t>

<t>The Z bits are currently unused, and SHOULD be set to zero (0) in
requests and responses unless re-defined in a later specification.</t>

</section>
<section anchor="message-handling" title="Message Handling">

<t>On a connection between a client and server that support Session Signaling,
either end may unilaterally send Session Signaling
messages at any point in the lifetime of a session,
and therefore either client or server may be the initiator of a message.
The initiator MUST set the value of the QR bit in the DNS header to zero
(0), and the responder MUST set it to one (1).</t>

<t>«TODO: Specify behaviour on receipt of a message from an initiator with the QR
bit set to 1, etc.»</t>

<t>Every Session Signaling request message MUST elicit a response (which
MUST have the same ID in the DNS message header as in the request).</t>

<t>« RB: should the presence of a SS message create a “sequencing point”,
such that all pending responses must be answered?
SC: I do not believe so. We can define an explicit SS “sequencing point”
opcode for this if necessary. »</t>

<t>The RCODE value in a response uses a subset of the standard
(non-extended) RCODE values from the IANA DNS RCODEs registry,
interpreted as follows:</t>

<texttable>
      <ttcol align='right'>Code</ttcol>
      <ttcol align='left'>Mnemonic</ttcol>
      <ttcol align='left'>Description</ttcol>
      <c>0</c>
      <c>NOERROR</c>
      <c>TLV processed successfully</c>
      <c>1</c>
      <c>FORMERR</c>
      <c>TLV format error</c>
      <c>4</c>
      <c>NOTIMP</c>
      <c>Session Signaling not supported</c>
      <c>5</c>
      <c>REFUSED</c>
      <c>TLV declined for policy reasons</c>
</texttable>

</section>
<section anchor="tlv-format" title="TLV Format">

<figure><artwork><![CDATA[
                                             1   1   1   1   1   1
     0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |                           SSOP-TYPE                           |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |                          SSOP-LENGTH                          |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |                                                               |
   /                           SSOP-DATA                           /
   /                                                               /
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='SSOP-TYPE:'>
  A 16 bit field in network order giving the type of the current Session
Signaling TLV per the IANA DNS Session Signaling Type Codes Registry.</t>
</list></t>

<t>« SC: I changed SESSION-TYPE to SSOP-TYPE because to me SESSION-TYPE read
as “type of session” which it is not. It is Session Signaling Operation Type,
Session Signaling Operation Length, Session Signaling Operation Data. »</t>

<t><list style="hanging">
  <t hangText='SSOP-LENGTH:'>
  A 16 bit field in network order giving the size in octets of
SSOP-DATA.</t>
  <t hangText='SSOP-DATA:'>
  Type-code specific.</t>
</list></t>

</section>
</section>
<section anchor="mandatory-tlvs" title="Mandatory TLVs">

<section anchor="session-management-support-tlvs" title="Session Management Support TLVs">

<section anchor="not-implemented" title="“Not Implemented”">

<t>Since the “NOTIMP” RCODE in the DNS message header is used to indicate lack
of support for the Session Signaling Opcode itself, a different mechanism
is used to indicate lack of support of a specific SSOP-TYPE.
If a server that supports Session Signaling receives a Session Signaling
query message (QR bit zero) with an SSOP-TYPE it does not support, it returns a
response message (QR bit one) containing a single Session Signaling SSOP-NOTIMP TLV (0).
The MESSAGE ID in the message header serves to tell the client which of its
requests was not understood.</t>

<t>The SSOP-NOTIMP TLV has no SSOP-DATA.</t>

</section>
</section>
<section anchor="session-management-tlvs" title="Session Management TLVs">

<section anchor="idletimeout" title="Idle Timeout">

<t>The Idle Timeout TLV (1) is be used by a client to reset a connection’s
idle timer, and at the same time to request what the idle timeout
should be from this point forward in the connection.</t>

<t>The Idle Timeout TLV also MAY be initiated by a server, to unilaterally inform
the client of a new idle timeout this point forward in this connection.</t>

<t>It is not required that the Idle Timeout TLV be used in every session.
While many Session Signaling operations
(such as DNS Push Notifications <xref target="I-D.ietf-dnssd-push"/>)
will be used in conjunction with a long-lived connection, this is not required,
and in some cases the default 30-second timeout may be perfectly appropriate.</t>

<t>The SSOP-DATA for the the Idle Timeout TLV is as follows:</t>

<figure><artwork><![CDATA[
                                             1   1   1   1   1   1
     0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |                         IDLE TIMEOUT                          |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='IDLE TIMEOUT:'>
  the idle timeout for the current session, specified as a 16
bit word in network order in units of 100 milliseconds.
This is the timeout at which the server will forcibly terminate the connection
with a TCP RST (or equivalent for other protocols); after half this interval
the client MUST take action to either preserve the connection, or close it
if it is no longer needed.</t>
</list></t>

<t>In a client-initiated Session Signaling Idle Timeout message, the IDLE TIMEOUT
contains the client’s requested value for the idle timeout.</t>

<t>In a server response to a client-initiated message, the IDLE TIMEOUT
contains the server’s chosen value for the idle timeout, which the client
MUST respect. This is modeled after the DHCP protocol, where the client
requests a certain lease lifetime, but the server is the ultimate authority
for deciding what lease lifetime is actually granted.</t>

<t>In a server-initiated Session Signaling Idle Timeout message, the IDLE TIMEOUT
unilaterally informs the client of the new idle timeout this point forward
in this connection.</t>

<t>In a client response to a server-initiated message, there is no SSOP-DATA.
SSOP-LENGTH is zero.</t>

<t>«TODO: Specify the behaviour when a server sends a 0 IDLE TIMEOUT.»</t>

<t>The Idle Timeout TLV (3) has similar intent to the EDNS TCP Keepalive
Option <xref target="RFC7828"/>.
A client/server pair that supports Session Signaling MUST NOT use the
EDNS TCP KeepAlive option within any message once bi-directional Session
Signaling support has been confirmed.</t>

<t>« SC: And if client or server does use EDNS TCP Keepalive, then other end should…
close connection? Silently ignore? »</t>

</section>
<section anchor="terminate-session" title="Terminate Session">

<t>There may be rare cases where a server is overloaded and wishes to shed
load. If the server simply closes connections, the likely behaviour of
clients is to detect this as a network failure, and reconnect.</t>

<t>To avoid this reconnection implosion, the server sends a Terminate
Session TLV (2) to inform the client of the overload situation.
After sending a Terminate Session TLV the server MUST NOT
send any further messages on the connection.</t>

<t>The Terminate Session TLV (2) MUST NOT be initiated by a client.</t>

<t>«TODO: Specify behaviour if the Terminate Session TLV is initiated by a client.»</t>

<t>Upon receipt of the Terminate Session TLV (2) the client MUST
make note of the reconnect delay for this server, and then immediately
close the connection.</t>

<t>The SSOP-DATA is as follows:</t>

<figure><artwork><![CDATA[
                                             1   1   1   1   1   1
     0   1   2   3   4   5   6   7   8   9   0   1   2   3   4   5
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
   |                        RECONNECT DELAY                        |
   +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
]]></artwork></figure>

<t><list style="hanging">
  <t hangText='RECONNECT DELAY:'>
  a time value, specified as a 16 bit word in network order in units of
100 milliseconds, within which the client MUST NOT establish a new
session to the current server.</t>
</list></t>

<t>The RECOMMENDED value is 10 seconds.  « RB: text required here about
default values for load balancers, etc »</t>

</section>
</section>
</section>
<section anchor="iana-considerations" title="IANA Considerations">

<section anchor="dns-session-signaling-opcode-registration" title="DNS Session Signaling Opcode Registration">

<t>IANA are directed to assign the value TBD for the Session Signaling
Opcode in the DNS OpCodes Registry.</t>

</section>
<section anchor="dns-session-signaling-type-codes-registry" title="DNS Session Signaling Type Codes Registry">

<t>IANA are directed to create the DNS Session Signaling Type Codes
Registry, with initial values as follows:</t>

<texttable>
      <ttcol align='right'>Type</ttcol>
      <ttcol align='left'>Name</ttcol>
      <ttcol align='left'>Status</ttcol>
      <ttcol align='left'>Reference</ttcol>
      <c>0</c>
      <c>SSOP-NOTIMP</c>
      <c>Standard</c>
      <c>RFC-TBD1</c>
      <c>1</c>
      <c>SSOP-Keepalive</c>
      <c>Standard</c>
      <c>RFC-TBD1</c>
      <c>2</c>
      <c>SSOP-Terminate</c>
      <c>Standard</c>
      <c>RFC-TBD1</c>
      <c>3 - 63</c>
      <c>Unassigned, reserved for session management TLVs</c>
      <c>&#160;</c>
      <c>&#160;</c>
      <c>64 - 63487</c>
      <c>Unassigned</c>
      <c>&#160;</c>
      <c>&#160;</c>
      <c>63488 - 64511</c>
      <c>Reserved for local / experimental use</c>
      <c>&#160;</c>
      <c>&#160;</c>
      <c>64512 - 65535</c>
      <c>Reserved for future expansion</c>
      <c>&#160;</c>
      <c>&#160;</c>
</texttable>

<t>Registration of additional Session Signaling Type Codes requires Expert
Review. « RB: definition of process required? »</t>

</section>
</section>
<section anchor="security-considerations" title="Security Considerations">

<t>If this mechanism is to be used with DNS over TLS, then these messages
are subject to the same constraints as any other DNS over TLS messages
and MUST NOT be sent in the clear before the TLS session is established.</t>

</section>
<section anchor="acknowledgements" title="Acknowledgements">

<t>TBW</t>

</section>


  </middle>

  <back>

    <references title='Normative References'>

&RFC6891;
&RFC7766;
&RFC7828;
&RFC2119;
&RFC1035;


    </references>

    <references title='Informative References'>

&RFC7858;
&I-D.ietf-dnssd-push;


    </references>



  </back>
</rfc>

