<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
  <!ENTITY rfc791 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.0791.xml'>
  <!ENTITY rfc1034 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1034.xml'>
  <!ENTITY rfc1035 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1035.xml'>
  <!ENTITY rfc1123 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1123.xml'>
  <!ENTITY rfc1996 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1996.xml'>
  <!ENTITY rfc2181 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2181.xml'>
  <!ENTITY rfc2308 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2308.xml'>
  <!ENTITY rfc2460 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2460.xml'>
  <!ENTITY rfc2671 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2671.xml'>
  <!ENTITY rfc2672 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2672.xml'>
  <!ENTITY rfc3226 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3226.xml'>
  <!ENTITY rfc3258 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3258.xml'>
  <!ENTITY rfc3596 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3596.xml'>
  <!ENTITY rfc3901 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3901.xml'>
  <!ENTITY rfc4033 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4033.xml'>
  <!ENTITY rfc4035 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4035.xml'>
  <!ENTITY rfc4472 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4472.xml'>
  <!ENTITY rfc4786 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4786.xml'>
  <!ENTITY rfc4892 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4892.xml'>
  <!ENTITY rfc5625 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5625.xml'>
  <!ENTITY rfc6891 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.6891.xml'>
  <!ENTITY rfc7129 PUBLIC ''
    'http://xml.resource.org/public/rfc/bibxml/reference.RFC.7129.xml'>
]>

<rfc category="info" ipr="trust200902"
  docName="draft-ietf-dnsop-respsize-15">

  <?rfc toc="yes" ?>
  <?rfc symrefs="yes" ?>
  <?rfc sortrefs="yes"?>
  <?rfc iprnotified="no" ?>
  <?rfc strict="yes" ?>

  <front>
    <title>DNS Referral Response Size Issues</title>

    <author initials="P." surname="Vixie" fullname="Paul Vixie">
      <organization>Farsight Security, Inc.</organization>
      <address>
        <postal>
          <street>155 Bovet Road, #476</street>
          <city>San Mateo</city>
          <region>CA</region>
          <code>94402</code>
          <country>USA</country>
        </postal>
        <phone>+1 650 489 7919</phone>
        <email>vixie@farsightsecurity.com</email>
      </address>
    </author>

    <author initials="A." surname="Kato" fullname="Akira Kato">
      <organization>Keio University/WIDE Project</organization>
      <address>
        <postal>
          <street>Graduate School of Media Design</street>
          <street>4-1-1 Hiyoshi</street>
          <city>Kohoku</city>
          <region>Yokohama</region>
          <code>223-8526</code>
          <country>Japan</country>
        </postal>
        <phone>+81 45 564 2490</phone>
        <email>kato@wide.ad.jp</email>
      </address>
    </author>

    <author initials='J.' surname="Abley" fullname='Joe Abley'>
      <organization>Dyn, Inc.</organization>
      <address>
        <postal>
          <street>470 Moore Street</street>
          <city>London</city>
          <region>ON</region>
          <code>N6C 2C2</code>
          <country>Canada</country>
        </postal>
        <phone>+1 519 670 9327</phone>
        <email>jabley@dyn.com</email>
      </address>
    </author>

    <date day="13" month="February" year="2014"/>

    <abstract>
      <t>With a mandated default minimum maximum UDP message size
	of 512 octets, the DNS protocol presents some special
	problems for zones wishing to expose a moderate or high
	number of authority servers (NS resource records).  This
	document explains the operational issues caused by, or
	related to this response size limit, and suggests ways to
	optimize the use of this limited space.  Guidance is offered
	to DNS server implementors and to DNS zone administrators.</t>
    </abstract>
  </front>

  <middle>
    <section title="Terminology">
      <t>This document uses terminology specific to the Domain Name
        System (DNS), including the following common abbreviations:

        <list style="hanging">
          <t hangText="A:">A resource record type used to specify an IPv4
            address <xref target="RFC1034"/></t>

          <t hangText="AAAA:">A resource record type used to specify
            an IPv6 address <xref target="RFC3596"/></t>

          <t hangText="CNAME:">A resource record type used to define a
            canonical name <xref target="RFC1034"/></t>

          <t hangText="DNAME:">A resource record type used to map
            a DNS subtree onto another domain <xref target="RFC2672"/></t>

	  <t hangText="DNSSEC:">DNS Security Extensions <xref
	    target="RFC4033"/></t>

          <t hangText="DO:">"DNS OK" -- a flag in the EDNS header used
	    to signal the ability to use DNSSEC <xref target="RFC4035"/></t>

	  <t hangText="EDNS:">Extension mechanisms for DNS <xref
	    target="RFC6891"/></t>

          <t hangText="EDNS0:">EDNS version 0 <xref target="RFC6891"/></t>

          <t hangText="MTU:">Maximum Transmission Unit, the maximum
	    size for a datagram to be forwarded on an interface
	    without needing fragmentation <xref target="RFC0791"/>
	    <xref target="RFC2460"/></t>

          <t hangText="NS:">A resource record type used to specify
	    a nameserver on either side of a zone cut <xref
	    target="RFC1034"/></t>

	  <t hangText="RR:">Resource Record <xref target="RFC1034"/></t>

	  <t hangText="RRSet:">Resource Record Set <xref
	    target="RFC1034"/></t>

          <t hangText="TC:">A bit in the DNS message header used to
	    indicate that the message has been truncated <xref
	    target="RFC1034"/></t>
	</list>
      </t>

      <t>In an exchange of DNS messages between two hosts, this document
        refers to the host sending a DNS request as the initiator, and
        the host sending a DNS response as the responder.</t>
    </section>

    <section title="Introduction and Overview">
      <t>The original DNS standard limited the UDP message size to
	512 octets (see Section 4.2.1 of <xref target="RFC1035"/>).
	Even though this limitation was due to the required minimum
	IP reassembly limit for IPv4, it became a hard DNS protocol
	limit and is not implicitly relaxed by changes in a network
	layer protocol, e.g. by the larger minimum MTU specified
	in IPv6 <xref target="RFC2460"/> than in IPv4 <xref
	target="RFC0791"/>.</t>

      <t>The EDNS protocol extension starting with version 0 permits
	larger responses by mutual agreement of the initiator and
	responder (see Section 4.3 and Section 6.2 of <xref
	target="RFC6891"/>), and it is recommended to support EDNS.
	The 512 octets UDP message size limit will remain in practical
	effect until substantially all DNS servers and resolvers
	support EDNS.</t>

      <t>Since DNS responses include a copy of the request, the
        space available for response data is somewhat less than the
        full 512 octets.  Negative responses are quite small, but
        for positive and referral responses, every octet must be
        carefully and sparingly allocated.  While the response size
        of positive responses is also a concern in <xref
        target="RFC3226"/>, this document specifically addresses
        referral response size.</t>

      <t>While more than fourteen years passed since the publication
	of the original EDNS0 document <xref target="RFC2671"/>,
	measurements conducted at the M Root Server in May 2012
	suggested that only around 65% of initiators support it.  This
	fraction was consistent with similar measurements conducted
	in 2010 and 2011. The long tail of EDNS deployment may
	eventually be measured in decades.</t>

      <t>DNS initiators and responders that support DNSSEC <xref
	target="RFC4033"/>, and signal a desire to use it, can expect
	larger response sizes in the case where those responses
	contain DNSSEC RRSets. EDNS support in DNSSEC-aware initiators
	and responders can be assumed, since the desire to use
	DNSSEC is signalled using the DO flag in the EDNS0 header.</t>

      <t>Even in scenarios where EDNS support in initiators and
	responders can be assumed, e.g. in the case of messages
	exchanged using DNSSEC, or at some future time where EDNS
	deployment can be considered ubiquitous, there will still
	be cases when MTU limitations or IP fragmentation/reassembly
	problems in firewalls and other middleboxes will cause EDNS
	failures which lead to non-extended DNS retries.  A smaller
	referral response will always be better than a larger one
	if the same end result can be achieved either way.  See
	<xref target="RFC5625"/>, <xref target="SAC035"/>, and
	Section 6.2.6 of <xref target="RFC6891"/> for further
	discussion.</t>
    </section>

    <section title="Delegation Details">
      <section title="Relevant Protocol Elements">
        <t>A positive delegation response will include the following
          elements:</t>

        <texttable>
          <ttcol>Section</ttcol>
          <ttcol>Description</ttcol>

          <c>Header Section</c>
          <c>Fixed length (12 octets)</c>

          <c>Question Section</c>
          <c>Original query (name, class, type)</c>

          <c>Answer Section</c>
          <c>Empty, or a CNAME/DNAME chain</c>

          <c>Authority Section</c>
          <c>NS RRSet (name server names)</c>

          <c>Additional Section</c>
          <c>A and AAAA RRSets (name server addresses)</c>
        </texttable>

        <t>If the total size of the UDP response exceeds 512 octets
          or the size advertised in EDNS, and if the data that does
          not fit was "required", then the TC bit will be set to
          indicate truncation.  This will usually cause the
          requester to retry using TCP, depending on what information
          was desired and what information was omitted.  For example,
          truncation in the authority section is of no interest to
          a stub resolver who only plans to consume the answer
          section.  If a retry using TCP is needed, the total cost
          of the transaction is much higher.  See Section 6.1.3.2
          of <xref target="RFC1123"/> for details on the requirement
          that UDP be attempted before falling back to TCP.</t>

	<t>RRSets are are never sent partially unless the TC bit
	  is set to indicate truncation.  When the TC bit is set,
	  the final apparent RRSet in the final non-empty section
	  must be considered "possibly damaged" (see Section 6.2
	  of <xref target="RFC1035"/> and Section 9 of <xref
	  target="RFC2181"/>).</t>

        <t>With or without truncation, the glue present in the
          additional data section should be considered "possibly
          incomplete", and requesters should be prepared to re-query
          for any damaged or missing RRSets.  Note that truncation
          of the additional data section might not be signaled via
          the TC bit since additional data is often optional (see
          discussion in Appendix B of <xref target="RFC4472"/>).</t>

        <t>DNS label compression allows the component labels of a
          domain name to be instantiated exactly once per DNS
	  message, and then referenced with a two-octet "pointer"
	  from other locations in that same DNS message (see Section
	  4.1.4 of <xref target="RFC1035"/>).  If all name server
	  names in a message share a common parent domain (for
	  example, all of them are in the "ROOT-SERVERS.NET" domain),
	  then more space will be available for incompressible data
	  (such as name server addresses).</t>

        <t>The query name can be as long as 255 octets of network
          data.  In this worst case scenario, the question section
          will be 259 octets in size, which would leave only 240
          octets for the authority and additional sections (after
          deducting 12 octets for the fixed length header) in a
          referral.</t>
      </section>

      <section title="Advice to Zone Administrators">
	<t>Average and maximum question section sizes can be predicted
	  by the zone administrator, since they will know what names
	  actually exist and can measure which ones are queried for
	  most often.  Note that if the zone contains any wildcards,
	  it is possible for maximum length queries to require
	  positive responses, but that it is reasonable to expect
	  truncation and TCP retry in that case.  For cost and
	  performance reasons, the majority of requests should be
	  satisfied without truncation or TCP retry.</t>

	<t>Some queries for non-existant names can be large. If
	  DNSSEC is not being used this is unlikely to pose a problem
	  since unsigned negative responses need not contain any
	  answer, authority or additional records.  See Section 2.1
	  of <xref target="RFC2308"/> for more information about
	  the format of negative responses without DNSSEC. Negative
	  responses from DNSSEC-signed zones can be much larger,
	  however, due to the need to provide authenticated denial
	  of existance <xref target="RFC7129"/>.</t>

        <t>The minimum useful number of name servers is two, for
          redundancy (see Section 4.1 of <xref target="RFC1034"/>).
          A zone's name servers should be reachable by all IP
          protocols versions (e.g., IPv4 and IPv6) in common use.
          As long as the servers are well managed, the server serving
          IPv6 might be different from the server serving IPv4
          sharing the same server name.</t>

        <t>The best case is no truncation at all.  This is because
          many requesters will retry using TCP immediately, or will
          automatically requery for RRSets that are possibly
          truncated, without considering whether the omitted data
          was actually necessary.</t>

        <t>Anycast <xref target="RFC3258"/> <xref target="RFC4786"/>
	  is a useful technique for improving performance and
          below the zone cut being described by a delegation is
	  responses.</t>

        <t>While it is irrelevant to the response size issue, all
	  zones have to be served via IPv4 as well as IPv6 to avoid
	  name space fragmentation <xref target="RFC3901"/>.</t>
      </section>

      <section title="Advice to Server Implementors">
        <t>Each NS RR for a zone will add 12 fixed octets (name,
          type, class, ttl, and rdlen) plus 2 to 255 variable octets
          (for the NSDNAME).  Each A RR will require 16 octets, and
          each AAAA RR will require 28 octets.</t>

        <t>While DNS distinguishes between necessary and optional
          resource records, this distinction is according to protocol
          elements necessary to signify facts, and takes no official
          notice of protocol content necessary to ensure correct
          operation.  For example, a name server name that is in or
          below the zone cut being described by a delegation is
          "necessary content", since there is no way to reach that
          zone unless the parent zone's delegation includes "glue
          records" describing that name server's addresses.</t>

        <t>Recall that the TC bit is only set when a required RRSet
          can not be included in its entirety (see Section 9 of
          <xref target="RFC2181"/>).  Even when some of the RRSets
          to be included in the additional section don't fit in the
          response size, the TC bit isn't set.  These RRSets may
          be important for a referral.  Some DNS implementations
          try to resolve these missing glue records separately which
          will introduce extra queries and extra time to resolve a
          given name.</t>

        <t>A delegation response should prioritize glue records as
          follows.

          <list style="hanging">
            <t hangText="first:">All glue RRSets for one name server
              whose name is in or below the zone being delegated,
              or which has multiple address RRSets (currently A and
              AAAA), or preferably both;</t>

            <t hangText="second:">Alternate between adding all glue
              RRSets for any name servers whose names are in or
              below the zone being delegated, and all glue RRSets
              for any name servers who have multiple address RRSets
              (currently A and AAAA);</t>

            <t hangText="thence:">All other glue RRSets, in any
              order.</t>
          </list>

          Whenever there are multiple candidates for a position in
          this priority scheme, one should be chosen on a round-robin
          or fully random basis.  The goal of this priority scheme
          is to offer "necessary" glue first to fill into the
          response if possible.</t>

        <t>If any "necessary" content cannot be fit in the response,
          then it is advisable that the TC bit be set in order to
          force a TCP retry, rather than have the zone be unreachable.
          Note that a parent server's proper response to a query
          for in-child glue or below-child glue is a referral rather
          than an answer, and that this referral must be able to
          contain the in-child or below-child glue, and that in
          outlying cases, only EDNS or TCP will be large enough to
          contain that data.</t>

        <t>The glue record order should be independent of the version
          of IP used in the query because the DNS server might just
          see a query from an intermediate server rather than the
          query from the original client.</t>
      </section>
    </section>

    <section title="Analysis">
      <t>An instrumented protocol trace of a best case delegation
        response is shown in <xref target="protocol_trace"/>.  Note
        that 13 servers are named, and 13 addresses are given.  This
        query was artificially designed to exactly reach the 512
        octets limit.</t>

      <figure anchor="protocol_trace">
        <artwork><![CDATA[
;; flags: qr rd; QUERY: 1, ANS: 0, AUTH: 13, ADDIT: 13
;; QUERY SECTION:
;;  [23456789.123456789.123456789.\
     123456789.123456789.123456789.com A IN]        ;; @80

;; AUTHORITY SECTION:
com.                 172800 NS  E.GTLD-SERVERS.NET.  ;; @112
com.                 172800 NS  F.GTLD-SERVERS.NET.  ;; @128
com.                 172800 NS  G.GTLD-SERVERS.NET.  ;; @144
com.                 172800 NS  H.GTLD-SERVERS.NET.  ;; @160
com.                 172800 NS  I.GTLD-SERVERS.NET.  ;; @176
com.                 172800 NS  J.GTLD-SERVERS.NET.  ;; @192
com.                 172800 NS  K.GTLD-SERVERS.NET.  ;; @208
com.                 172800 NS  L.GTLD-SERVERS.NET.  ;; @224
com.                 172800 NS  M.GTLD-SERVERS.NET.  ;; @240
com.                 172800 NS  A.GTLD-SERVERS.NET.  ;; @256
com.                 172800 NS  B.GTLD-SERVERS.NET.  ;; @272
com.                 172800 NS  C.GTLD-SERVERS.NET.  ;; @288
com.                 172800 NS  D.GTLD-SERVERS.NET.  ;; @304


;; ADDITIONAL SECTION:
A.GTLD-SERVERS.NET.  172800 A   192.5.6.30           ;; @320
B.GTLD-SERVERS.NET.  172800 A   192.33.14.30         ;; @336
C.GTLD-SERVERS.NET.  172800 A   192.26.92.30         ;; @352
D.GTLD-SERVERS.NET.  172800 A   192.31.80.30         ;; @368
E.GTLD-SERVERS.NET.  172800 A   192.12.94.30         ;; @384
F.GTLD-SERVERS.NET.  172800 A   192.35.51.30         ;; @400
G.GTLD-SERVERS.NET.  172800 A   192.42.93.30         ;; @416
H.GTLD-SERVERS.NET.  172800 A   192.54.112.30        ;; @432
I.GTLD-SERVERS.NET.  172800 A   192.43.172.30        ;; @448
J.GTLD-SERVERS.NET.  172800 A   192.48.79.30         ;; @464
K.GTLD-SERVERS.NET.  172800 A   192.52.178.30        ;; @480
L.GTLD-SERVERS.NET.  172800 A   192.41.162.30        ;; @496
M.GTLD-SERVERS.NET.  172800 A   192.55.83.30         ;; @512

;; MSG SIZE  sent: 80  rcvd: 512
]]>
        </artwork>
      </figure>

      <t>For longer query names, the number of address records
        supplied will be lower.  Furthermore, it is only by using
        a common parent name (which is "GTLD-SERVERS.NET." in this
        example) that all 13 addresses are able to fit, due to the
	use of label compression pointers in the last 12 occurrences
	of the parent domain name.  The outputs from the response
	simulator in <xref target="response_simulator"/> (written
	in <xref target="PERL">perl</xref>) shown in <xref
	target="respsize_1"/> and <xref target="respsize_2"/>
	demonstrate these properties.</t>

      <figure anchor="respsize_1">
        <artwork><![CDATA[
% perl respsize.pl a.dns.br b.dns.br c.dns.br d.dns.br
 a.dns.br requires 10 bytes
 b.dns.br requires 4 bytes
 c.dns.br requires 4 bytes
 d.dns.br requires 4 bytes
 # of NS: 4
 For maximum size query (255 byte):
     only A is considered:        # of A is 4 (green)
     A and AAAA are considered:   # of A+AAAA is 3 (yellow)
     preferred-glue A is assumed: # of A is 4, # of AAAA is 3 (yellow)
 For average size query (64 byte):
     only A is considered:        # of A is 4 (green)
     A and AAAA are considered:   # of A+AAAA is 4 (green)
     preferred-glue A is assumed: # of A is 4, # of AAAA is 4 (green)
]]>
        </artwork>
      </figure>

      <figure anchor="respsize_2">
        <artwork><![CDATA[
% perl respsize.pl ns-ext.isc.org ns.psg.com ns.ripe.net ns.eu.int
ns-ext.isc.org requires 16 bytes
ns.psg.com requires 12 bytes
ns.ripe.net requires 13 bytes
ns.eu.int requires 11 bytes
# of NS: 4
For maximum size query (255 byte):
    only A is considered:        # of A is 4 (green)
    A and AAAA are considered:   # of A+AAAA is 3 (yellow)
    preferred-glue A is assumed: # of A is 4, # of AAAA is 2 (yellow)
For average size query (64 byte):
    only A is considered:        # of A is 4 (green)
    A and AAAA are considered:   # of A+AAAA is 4 (green)
    preferred-glue A is assumed: # of A is 4, # of AAAA is 4 (green)
]]>
        </artwork>
      </figure>

      <t>Here we use the term "green" if all address records could
        fit, or "yellow" if two or more could fit, or "orange" if
        only one could fit, or "red" if no address record could
        fit.  It's clear that without a common parent for name server
        names, much space would be lost.  For these examples we use
        an average/common name size of 15 octets, befitting our
        assumption of "GTLD-SERVERS.NET." as our common parent
        name.</t>

      <t>We assume a medium query name size of 64 since that
        is the typical size seen in trace data at the time of this
        writing.  If Internationalized Domain Name (IDN) or any
        other technology that results in larger query names be
        deployed significantly in advance of EDNS, then new
        measurements and new estimates will have to be made.</t>
    </section>

    <section title="Conclusions">
      <t>The current practice of giving all name server names a
        common parent (such as "GTLD-SERVERS.NET." or "ROOT-SERVERS.NET.")
        saves space in DNS responses and allows for more name servers
        to be enumerated than would otherwise be possible, since
        the common parent domain name only appears once in a DNS
        message and is referred to via "compression pointers"
        thereafter.</t>

      <t>If all name server names for a zone share a common parent,
        then it is operationally advisable to make all servers for
        the zone thus served also be authoritative for the zone of
        that common parent.  For example, the root name servers
        (?.ROOT-SERVERS.NET.) can answer authoritatively for the
        ROOT-SERVERS.NET. zone.  This is to ensure that the zone's
        servers always have the zone's name servers' glue available
        when delegating, and will be able to respond with answers
        rather than referrals if a requester who wants that glue
        comes back asking for it.  In this case the name server
        will likely be a "stealth master" -- authoritative but
        not advertised in the glue zone's NS RRSet.  See Section 2
        of <xref target="RFC1996"/> for more information about
        stealth masters.</t>

      <t>Thirteen (13) is the effective maximum number of name server
        names usable with traditional (non-extended) DNS, assuming
        a common parent domain name, and given that implicit referral
        response truncation is undesirable in the average case.</t>

      <t>More than one address record in a protocol family per
        server is inadvisable since the necessary glue RRSets (A
        or AAAA) are atomically indivisible, and will be larger
        than a single resource record.  Larger RRSets are more
        likely to lead to or encounter truncation.</t>

      <t>More than one address record across protocol families is
        less likely to lead to or encounter truncation, partly
        because multiprotocol clients, which are required to handle
        larger RRSets such as AAAA RRs, are more likely to speak
        EDNS, which can use a larger UDP response size limit, and
        partly because the resource records (A and AAAA) are in
        different RRSets and are therefore divisible from each
        other.</t>

      <t>Name server names that are at or below the zone they serve
        are more sensitive to referral response truncation, and
        glue records for them should be considered "more important"
        than other glue records, in the assembly of referral
        responses.</t>
    </section>

    <section title="Security Considerations">
      <t>The recommendations contained in this document have no
        known security implications.</t>
    </section>

    <section title="IANA Considerations">
      <t>This document has no IANA actions.</t>
    </section>

    <section title="Acknowledgements">
      <t>The authors thank Peter Koch, Rob Austein, Mark Andrews,
	Kenji Rikitake, Stephane Bortzmeyer, Olafur Gudmundsson,
	Alfred Hoenes, Alexander Mayrhofer, and Ray Bellis for their
	valuable comments and suggestions.</t>

      <t>This work was supported by the US National Science Foundation
        (research grant SCI-0427144) and DNS-OARC.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      &rfc1034;
      &rfc1035;
      &rfc2181;
    </references>

    <references title="Informative References">
      &rfc791;
      &rfc1123;
      &rfc1996;
      &rfc2308;
      &rfc2460;
      &rfc2671;
      &rfc2672;
      &rfc3226;
      &rfc3258;
      &rfc3596;
      &rfc3901;
      &rfc4033;
      &rfc4035;
      &rfc4472;
      &rfc4786;
      &rfc5625;
      &rfc6891;
      &rfc7129;

      <reference anchor="PERL">
        <front>
          <title>Programming Perl, 3rd ed.</title>
          <author initials="L." surname="Wall">
            <organization/>
            <address/>
          </author>
          <author initials="T." surname="Christiansen">
            <organization/>
          </author>
          <author initials="J." surname="Orwant">
            <organization/>
          </author>
         <date day="1" month="July" year="2000"/>
        </front>
        <seriesInfo name="ISBN" value="0-596-00027-8"/>
      </reference>

      <reference anchor="SAC035">
        <front>
          <title>Test Report: DNSSEC Impact on Broadband Routers and
            Firewalls</title>
          <author initials="R." surname="Bellis">
            <organization/>
          </author>
          <author initials="L." surname="Phifer">
            <organization/>
          </author>
          <date day="1" month="September" year="2008"/>
        </front>
        <seriesInfo name="SAC" value="035"/>
      </reference>
    </references>

    <section title="The response simulator program"
         anchor="response_simulator">
      <figure>
        <artwork><![CDATA[
#!/usr/bin/perl
#
# SYNOPSIS
#    respsize.pl [ -z zone ] fqdn_ns1 fqdn_ns2 ...
#        if all queries are assumed to have a same zone suffix,
#     such as "jp" in JP TLD servers, specify it in -z option
#
use strict;
use Getopt::Std;

my ($sz_msg) = (512);
my ($sz_header, $sz_ptr, $sz_rr_a, $sz_rr_aaaa) = (12, 2, 16, 28);
my ($sz_type, $sz_class, $sz_ttl, $sz_rdlen) = (2, 2, 4, 2);
my (%namedb, $name, $nssect, %opts, $optz);
my $n_ns = 0;

getopt('z', %opts);
if (defined($opts{'z'})) {
    server_name_len($opts{'z'}); # just register it
}

foreach $name (@ARGV) {
    my $len;
    $n_ns++;
    $len = server_name_len($name);
    print "$name requires $len bytes\n";
    $nssect += $sz_ptr + $sz_type + $sz_class + $sz_ttl
            +  $sz_rdlen + $len;
}
print "# of NS: $n_ns\n";
arsect(255, $nssect, $n_ns, "maximum");
arsect(64, $nssect, $n_ns, "average");

sub server_name_len {
    my ($name) = @_;
    my (@labels, $len, $n, $suffix);

    $name =~ tr/A-Z/a-z/;
    @labels = split(/\./, $name);
    $len = length(join('.', @labels)) + 2;
    for ($n = 0; $#labels >= 0; $n++, shift @labels) {
        $suffix = join('.', @labels);
        return length($name) - length($suffix) + $sz_ptr
            if (defined($namedb{$suffix}));
        $namedb{$suffix} = 1;
    }
    return $len;
}

sub arsect {
    my ($sz_query, $nssect, $n_ns, $cond) = @_;
    my ($space, $n_a, $n_a_aaaa, $n_p_aaaa, $ansect);
    $ansect = $sz_query + $sz_type + $sz_class;
    $space = $sz_msg - $sz_header - $ansect - $nssect;
    $n_a = atmost(int($space / $sz_rr_a), $n_ns);
    $n_a_aaaa = atmost(int($space
                           / ($sz_rr_a + $sz_rr_aaaa)), $n_ns);
    $n_p_aaaa = atmost(int(($space - $sz_rr_a * $n_ns)
                           / $sz_rr_aaaa), $n_ns);
    printf "For %s size query (%d byte):\n", $cond, $sz_query;
    printf "    only A is considered:        ";
    printf "# of A is %d (%s)\n", $n_a, &judge($n_a, $n_ns);
    printf "    A and AAAA are considered:   ";
    printf "# of A+AAAA is %d (%s)\n",
           $n_a_aaaa, &judge($n_a_aaaa, $n_ns);
    printf "    preferred-glue A is assumed: ";
    printf "# of A is %d, # of AAAA is %d (%s)\n",
        $n_a, $n_p_aaaa, &judge($n_p_aaaa, $n_ns);
}

sub judge {
    my ($n, $n_ns) = @_;
    return "green" if ($n >= $n_ns);
    return "yellow" if ($n >= 2);
    return "orange" if ($n == 1);
    return "red";
}

sub atmost {
    my ($a, $b) = @_;
    return 0 if ($a < 0);
    return $b if ($a > $b);
    return $a;
}
]]>
        </artwork>
      </figure>
    </section>

    <section title="Editorial Notes">
      <t>This section (and sub-sections) to be removed prior to
        publication.</t>

      <section title="Change History">
        <t>
          <list style="hanging">
            <t hangText="15">Draft resurrected; Joe added as co-author;
              changed Paul's affiliation. Minor wordsmithing to account
              for the passage of time. Terminology section added. Added
              commentary on DNSSEC impact on response sizes and EDNS
              support.</t>
          </list>
        </t>
      </section>
    </section>
  </back>
</rfc>

