<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY RFC1323 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.1323.xml">
<!ENTITY RFC3022 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.3022.xml">
<!ENTITY RFC4787 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.4787.xml">
<!ENTITY RFC5382 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.5382.xml">
<!ENTITY RFC5424 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.5424.xml">
<!ENTITY RFC6056 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6056.xml">
<!ENTITY RFC6145 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6145.xml">
<!ENTITY RFC6146 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6146.xml">
<!ENTITY RFC6191 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6191.xml">
<!ENTITY RFC6269 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6269.xml">
<!ENTITY RFC6302 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6302.xml">
<!ENTITY RFC6333 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6333.xml">
<!ENTITY RFC6335 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6335.xml">
<!ENTITY RFC6346 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6346.xml">
<!ENTITY RFC6431 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6431.xml">
<!ENTITY RFC6540 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6540.xml">
<!ENTITY RFC6598 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6598.xml">
<!ENTITY RFC6877 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6877.xml">
<!ENTITY RFC6887 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6887.xml">
<!ENTITY RFC6888 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.6888.xml">
<!ENTITY RFC7011 PUBLIC ""
"http://xml.resource.org/public/rfc/bibxml/reference.RFC.7011.xml">
]>
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="info" docName="draft-chen-sunset4-cgn-port-allocation-05"
     ipr="trust200902">
  <front>
    <title abbrev="Port Allocation Methods">Analysis of NAT64 Port Allocation
    Methods for Shared IPv4 Addresses</title>

    <author fullname="Gang Chen" initials="G. Chen" surname="Chen">
      <organization>China Mobile</organization>

      <address>
        <postal>
          <street>53A,Xibianmennei Ave.,</street>

          <street>Xuanwu District,</street>

          <city>Beijing</city>

          <code>100053</code>

          <country>P.R. China</country>
        </postal>

        <email>phdgang@gmail.com</email>
      </address>
    </author>
    
    <author initials="W." surname="Li" fullname="Weibo Li">
      <organization>China Telecom</organization>
      <address>
        <postal>
          <street>109, Zhongshan Ave. West, Tianhe District</street>
          <city>Guangzhou</city>
          <region></region>
          <code>510630</code>
          <country>P.R. China</country>
        </postal>
        <phone></phone>
        <email>mweiboli@gmail.com</email>
      </address>
    </author>

    <author fullname="Tina Tsou" initials="T." surname="Tsou">
      <organization>Huawei Technologies</organization>

      <address>
        <postal>
          <street>Bantian, Longgang District</street>

          <city>Shenzhen</city>

          <code>518129</code>

          <country>P.R. China</country>
        </postal>

        <phone/>

        <email>tina.tsou.zouting@huawei.com</email>
      </address>
    </author>
    
    <author initials="J." surname="Huang" fullname="James Huang">
      <organization>Huawei Technologies</organization>
      <address>
        <postal>
          <street>Bantian, Longgang District</street>

          <city>Shenzhen</city>

          <code>518129</code>

          <country>P.R. China</country>
        </postal>
        <phone></phone>
        <email>James.huang@huawei.com</email>
      </address>
    </author>

    <author fullname="Tom Taylor" initials="T." surname="Taylor">
      <organization>PT Taylor Consulting</organization>

      <address>
        <postal>
          <street/>

          <city>Ottawa</city>

          <region>Ontario</region>

          <code/>

          <country>Canada</country>
        </postal>

        <phone/>

        <email>tom.taylor.stds@gmail.com</email>

        <!-- uri and facsimile elements may also be added -->
      </address>
    </author>

    <date/>

    <abstract>
      <t>This document enumerates methods of port assignment in Carrier Grade
      NATs (CGNs), focused particularly on NAT64 environments. A theoretical
      framework of different NAT port allocation methods is described. The memo
      is intended to clarify and focus the port allocation discussion and
      propose an integrated view of the considerations for selection of the port
      allocation mechanism in a given deployment.</t> 
    </abstract>
  </front>

  <middle>
    <section anchor="intro" title="Introduction">
      <t>As a resdult of the depletion of IPv4 addresses, Carrier Grade NAT
(CGN) has
      been adopted by ISPs to expand IPv4 spaces. CGN maps IP addresses from
      one address realm to another, relying upon the mechanism of multiplexing
      multiple subscribers' connections over a smaller number of shared IPv4
      addresses to provide connectivity to end hosts. <xref
      target="RFC6888"/> specifies a number of CGN requirements. A
      network-based NAT is implied by several approaches to IPv6 transition
      including DS-Lite <xref target="RFC6333"/>, NAT64 (<xref
      target="RFC6145"/> and <xref target="RFC6146"/>), and NAT444. All of
      these would likely fall within the scope of the CGN requirements
      document <xref target="RFC6888"/>.</t>

      <t>The first part of this memo (<xref target="princip"/>) focusses on the
      topic of IPv6 migration. When NAPT is involved, <xref target="princip"/>
      elaborates on the considerations for address sharing and particularly port
      assignment in the NAT64 environment, where IPv6-only nodes are connected
      to external dual-stack or IPv4 networks.</t> 

      <t><xref target="bulkAlloc"/> looks more closely at dynamic bulk
      assignment of ports to individual subscriber sites, particularly as a
      means of log volume reduction. The proposals made in this section are
      applicable to the CGN environment in general, independently of the
      particular flavour of translation being used.</t>

      <t>The considerations in this document do not apply where the CGN does
      only Network Address Translation (NAT) <xref target="RFC3022"/>. In this
      scenario, there is no concern about port assignment. Similarly, this
      document does not apply where encapsulation rather than translation is
      used as the IPv6 transition method.</t> 
      
    </section>

    <!-- intro -->

    <section anchor="princip"
             title="Considerations For the Choice of Port Allocation Methods">
             
      <t>For port allocations on NAT64, several aspects may have to be
      considered when selecting a suitable method. Here is a list of the
      potential considerations, which are covered in more detail below. 
      <list style="symbols">
        <t>specific features of port usage in a NAT64 environment;</t>

        <t>classification of different port allocation methods;</t>

        <t>port allocation to improve connectivity;</t>

        <t>port allocation to optimize log volume;</t>

        <t>port allocation to enhance security.</t>
      </list></t>

      <t>Both analysis and relevant experimental results are presented in the
      sub-sections that follow.</t>

      <section anchor="princip_1" title="Port Consumption on NAT64">
      
        <t>China Mobile did a test comparison of port consumption on NAT64 and
        NAT44. Top100 websites (referring to Alexa statistics) were assessed to
        evaluate status of port usage on NAT44 and NAT64 respectively. China
        Mobile observed that the port consumption per session on NAT64 is
roughly
        only half that on NAT44. 43 percent of top100 websites have AAAA
records,
        therefore the NAT64 didn't have to assign ports to the traffic going to
        those websites. The results may be different if more services (e.g.
game,
        web-mail, etc) are considered. But it is apparent that the effects of
        port saving on NAT64 will be amplified by increasing native IPv6
        support.</t> 

        <t>Apart from the above observation, port allocation can be tuned
        according to the phase of IPv6 migration. As more content providers
        and services become available over IPv6, the utilization of NAT64 goes
        down since fewer destinations require translation progressing. Thus as
        IPv6 migration proceeds, it will be possible to relax the multiplexing
        ratio of IPv4 address sharing.</t>
      </section>

      <!-- princip_1 -->

      <section anchor="princip_2"
               title="Classification of Port Allocation Models">
               
        <t>This section lists several models to allocate the port information
        in NAT64 equipment. It also describes example cases for each
        allocation model.</t>

        <section anchor="princip_2_1" title="Stateful vs. Stateless">
        
          <t>
          <list style="symbols">
            <t>Stateful 
            <vspace blankLines="1"/> 
            The stateful NAT can be implemented either by static address
            translation or dynamic address translation. 
            <vspace blankLines="1"/> 
            In the case of static address assignment, a one-to-one address
            mapping for hosts between a IPv6 network address and an IPv4
            network address is pre-configured on the NAT operation. This case
            normally occurs when a server is deployed in a IPv6 domain. The
            static configuration ensures stable inbound connectivity. 
            <vspace blankLines="1"/> 
            Dynamic address assignment would periodically free the binding so
            that the global address could be recycled for later use. This
            increases the efficiency of usage of IPv4 addresses.</t> 

            <t>Stateless 
            <vspace blankLines="1"/> 
            Stateless NAT is performed in compliance with <xref
            target="RFC6145"/>. The public IPv4 address is required to be
            embedded in the IPv6 address. Thus the NAT64 can directly extract
            the address and has no need to record mapping states.</t> 
          </list></t>

          <t>A promising usage of stateless NAT may appear in the data centre
          environment where IPv6 server pools receive inbound connections from
          IPv4 users externally <xref target="I-D.anderson-v6ops-siit-dc"/>.
          NAT usage in other cases may be controversial. First off, the static
          one-to-one mapping does not address the issue of IPv4 depletion.
          Secondly, it introduces a dependency between IPv4 and IPv6 addressing.
          That creates new limitations since a change of IPv4 address will cause
          renumbering of IPv6 addresses.</t> 
          
        </section>

        <!-- princip_2_1 -->

        <section anchor="princip_2_2" title="Dynamic vs. Static">
        
          <t>Port assignment can be dynamic (ports allocated on demand) or
          static (ports allocated as part of the configuration process). 
          <list style="symbols">
            <t>Dynamic assignment 
            <vspace blankLines="1"/> 
            NAT64 normally uses dynamic assignment, since this achieves higher
            port utilization. Port allocations can be made with per-session or
            per-customer granularity. Per-session assignment is configured on
            the NAT64 by default since it maximizes port utilization. However,
            this can result in a heavy log volume that may have to be recorded
            for lawful interception systems. To mitigate that concern, the NAT64
            may dynamically allocate a port range for each connected subscriber.
            This will significantly reduce log volume. 
            <vspace blankLines="1"/> 
            A proper port-range configuration may have to take into account two
            considerations: 
            <list style="letters">
              <t>The number of session initiations for each subscriber. A
              subscriber normally uses multiple applications
              simultaneously, e.g. map, online video or game. The number
              of concurrent sessions is essential to determine the number
              of ports the subscriber needs. The China Mobile study mentioned
              earlier observed that the average number of sessions
              consumed by one user's device was around 200 to 300 ports.
              Several devices may appear behind a CPE. Based on this
observation, 
              1000 ports per subscriber household will provide enough room for
              multiple active users.  Administrators should monitor usage to 
              adjust this number if users are being limited by this number,
              or if usage is so low that fewer ports would be sufficient.</t>

              <t>Impacts on NAT64 capacity. Preassigned port ranges occupy
              memory even when there are unused ports. Therefore, the
              operator should be cautious about the impact of port-range
              reservation on the capacity for attempted concurrent
              sessions, especially in the case of a centralized NAT64 CGN
              serving numerous subscribers.</t>
            </list>
            </t>

            <t>Static assignment 
            <vspace blankLines="1"/> 
            Static assignment makes port reservations in bulk for each internal
            address before subscriber connection. The assigned ports can be in
            either a contiguous port range or a non-contiguous port range for
            the sake of defense against port-guessing attacks (see <xref
            target="bulkAlloc_2"/>). Log recording may not be necessary due to
            the stable mapping relations. Considerations of the interaction
            between port-range allocation and capacity impact are also
            applicable in the case of static assignment.
            <xref target="I-D.donley-behave-deterministic-cgn"/>
            describes a deterministic algorithm to assign a port range for an
            internal IP address pool in a sequence.</t> 
          </list>
          </t>
          
        </section>

        <!-- princip_2_2 -->

        <section anchor="princip_2_3" title="Centralized vs. Distributed">
        
          <t>There is an increasing need to connect NAT64 with downstream
          NAT46-capable devices to support IPv4 users/applications on an
          IPv6-only path. Several solutions have been proposed in this area,
          e.g., 464xlat <xref target="RFC6877"/>, MAP-T <xref
          target="I-D.ietf-softwire-map-t"/> and 4rd <xref
          target="I-D.ietf-softwire-4rd"/>. Port allocation can be categorized
          as a centralized assignment on NAT64 or as a port delegation
          distributed to downstream devices (e.g, Customer Edge connected with
          NAT64). 
          <list style="symbols">
            <t>Centralized Assignment 
            <vspace blankLines="1"/> 
            A centralized method makes port assignments once IP flows come to
            the NAT64. The allocation policy is enforced on a centralized point.
            Either a dynamic or static port assignment is made for received
            sessions.</t> 

            <t>Distributed Assignment 
            <vspace blankLines="1"/> 
            NAT64 can also delegate the pre-allocated port range to customer
            edge devices. That can be achieved through additional out-of-band
            provisioning signals (e.g., <xref target="I-D.ietf-pcp-port-set"/>,
            <xref target="I-D.ietf-softwire-map-dhcp"/>). The distributed model
            normally is performed A+P style <xref target="RFC6346"/> for static
            port assignment. The NAT64 should also hold the corresponding
            mapping in order to validate port usage in the outgoing direction
            and route inbound packets. Delegated port ranges shift NAT64 port
            computations/states into downstream devices. The detailed benefits
            of this approach are documented in <xref 
            target="I-D.ietf-softwire-stateless-4v6-motivation"/>.</t> 
          </list>
          </t>
        </section>

        <!-- princip_2_3 -->
        
      </section>

      <!-- princip_2 -->

      <section anchor="princip_3" title="Port Allocation Solutions">
      
        <section anchor="princip_3_1" title="Other Transition Technologies">
        
          <t>In other work, stateful NAT64 <xref target="RFC6146"/> uses
          bindings between IPv4 and IPv6 addresses that may be either static
          or dynamic. <xref target="RFC6146"/> describes a process where the
          dynamic binding is created by an outgoing packet, but it may also be
          created by other means such as a Port Control Protocol request (see
          <xref target="princip_3_3"/>). Lookin beyond
          NAT64 for the moment, DS-Lite <xref target="RFC6333"/> refers to the
          cautions in <xref target="RFC6269"/> but does not specify any port
          allocation method. Both technologies assume a centralized model.</t>

          <t>The specifications for both transition methods thus allow
          implementations to use the proposals made in <xref
          target="bulkAlloc"/> (and <xref 
          target="I-D.donley-behave-deterministic-cgn"/>).</t>
          
        </section>

        <!-- princip_3_1 -->

        <section anchor="princip_3_2"
                 title="Current Work On Stateless Transition Technologies">
                 
          <t>The port allocation solutions that are being specified at the
          time of writing of this document are all variations on the static
          distributed model, to minimize the amount of state that has to be
          held in the network. The proposals made in <xref
          target="bulkAlloc"/> do not apply to the
          current work in progress because that work has gone in another
          direction. That work includes: 
          <list style="symbols">
            <t>Light-weight 4over6 (LW4o6 <xref 
            target="I_D.ietf-softwire-lw4over6"/>), which requires the CPE to be
            configured explicitly with the shared IPv4 address and port set it
            will use on the WAN side of its NAT44 function. The border router is
            configured with the same information, reducing the state it must
            hold from per-session to per-subscriber amounts.</t> 

            <t>Mapping of Address and Port with Encapsulation (MAP-E <xref
            target="I-D.ietf-softwire-map"/>) and the experimental
            specifications Mapping of Address and Port with Translation
            (MAP-T <xref target="I-D.ietf-softwire-map-t"/>) and 4rd <xref
            target="I-D.ietf-softwire-4rd"/>, already mentioned. These rely
            on an algorithmic embedding of WAN-side IPv4 address and
            assigned port set within the IPv6 prefix assigned to each CPE.
            Both the CPE and the border router must be configured with this
            information. However, the algorithm is designed to aggregate
            routing information such that the amount of state carried by the
            border router is of a lower order of magnitude than even the
            per-subscriber level.</t>
          </list>
          </t>

          <t>MAP-E also supports a 1-1 mapping mode, where the IPv4 and IPv6
          addresses assigned to a CPE are independent. This can be helpful in
          transition, but, as with LW4o6, raises the amount of state in the
          network back to the per-subscriber level.</t>

          <t>For a packet destined to a host outside the MAP domain from which
          the packet originated: MAP-E and 4rd treat the packet as an IPv4
          over IPv6 tunnel via the border router.</t>

          <t>MAP-T uses stateless mapping in the sense of <xref
          target="princip_2_1"/> by embedding the destination IPv4 address
          within the IPv6 address of the packet sent to the border router.</t>
          
        </section>

        <!-- princip_3_2 -->

        <section anchor="princip_3_3" title="Port Control Protocol (PCP)">
        
          <t>The Port Control Protocol (PCP, <xref target="RFC6887"/>) can be
          used to reserve a single port or a port set <xref
          target="I-D.ietf-pcp-port-set"/> for applications. It requires that
          the NAT be collocated with a PCP server function. PCP provides an
          out-of-band signalling mechanism for coordinating dynamic allocation
          of ports between hosts and the border router.</t>
          
        </section>

        <!-- princip_3_3 -->
        
      </section>

      <!-- princip_3 -->

      <section anchor="princip_4" title="Specific Considerations">
      
        <section anchor="princip_4_1" title="Log Volume Optimization">
        
          <t><xref target="RFC6269"/> has provided a thoughtful analysis on
          the issues of IP sharing. It points out that IP sharing may impact
          law enforcement since source address information will be lost during
          the translation. Network administrators have to log the mapping
          status for each connection in order to identify a specific user
          associated with an IP address in a particular time slot. The storage
          of log information may post a challenge to operators, since it
          requires additional resources and data inspection processes to
          identify users. For concrete details of what should be logged, see
          Section 3.1 of <xref target="I-D.ietf-behave-syslog-nat-logging"/>.
          The actual logging may use either IPFIX <xref target="RFC7011"/> or
          Syslog <xref target="RFC5424"/> depending on the operator's
          requirements.</t>

          <t>It is desirable to reduce the volume of the logged information.
          Referring to the classification of port allocation methods given
          above, dynamic assignments can be managed on either a per-session or
          per-customer granularity. The coarser granularity will lead to lower
          log volume storage. A test was made by recording the log information
          from 200,000 subscribers in the Chinese network for 60 days. The
          volume of recorded information reached up to 42.5 terabytes with
          per-session logging in the raw format. The volume could be reduced
          to 10.6 terabytes with gzip format. Compared with that, it only
          occupied 40.6 gigabytes, three orders of magnitude smaller volume,
          with per-customer logging in the raw format. With static allocation,
          of course, no logs at all are required.</t> 

          <t>On the other hand, the lower logging volumes are associated with
          lower efficiency of port utilization. A port allocation based on
          per-customer granularity has to retain vacant ports in order to
          avoid traffic overflow. The efficiency can be evaluated by port
          utilization rate, and will be even lower if the static port
          allocation method is used. Inactive users may also impact the
          efficiency.</t>

          <t><xref target="tab_test"/> summarizes the test results using
          Syslog. The ports were pre-allocated to customers regardless of
          online or offline status.</t>

          <texttable anchor="tab_test"
                     title="Estimated Log Volumes For 200,000 Users Over 60
Days">
            <ttcol align="left">Port Allocation Method</ttcol>

            <ttcol align="left">Log Granularity</ttcol>

            <ttcol align="left">Estimated Log Volume</ttcol>

            <ttcol align="left">Port Utilization</ttcol>

            <c>Dynamic NAPT</c>

            <c>Per-session</c>

            <c>42.5 terabytes</c>

            <c>100%</c>

            <c>Dynamic port-range</c>

            <c>Per-customer</c>

            <c>40.6 Gigabytes</c>

            <c>75%</c>

            <c>Deterministic NAT, MAP-T, 4rd</c>

            <c>None</c>

            <c>None</c>

            <c>(60% * 75%) = 45%</c>
          </texttable>

          <t>Note: 75% is the estimated port utilization ratio per active
          subscriber. 60% is the estimated ratio of active subscribers to the
          total number of subscribers.</t>

          <t>The data shown in <xref target="tab_test"/> roughly demonstrates
          the tradeoff between port utilization and log volume reduction.
          Administrators may consider the following factors to determine their
          own solution: 
          <list style="symbols">
            <t>average connectivity per customer per day;</t>

            <t>peak connectivity per day;</t>

            <t>the number of public IPv4 addresses available to the
            NAT64;</t>

            <t>application demands for specific ports;</t>

            <t>processing capabilities of the NAT64;</t>

            <t>tolerable log volume.</t>
          </list></t>
        </section>

        <!-- princip_4_1 -->

        <section anchor="princip_4_2" title="Connectivity State Optimization">
        
          <t>It has been observed that port consumption is significantly
          increased once subscribers land on a web page for video on demand,
          an online game, or map services. In those cases, multiple TCP
          connections may be initiated to optimize the performance of data
          transmissions for video download and message exchange. Given the
          video traffic growth trend, this likely presents a challenge for
          network operators who need to optimize connectivity states and avoid
          port depletion. Those optimizations may even affect the method of
          port-range allocation, because a subscriber is only allowed to use a
          pre-configured port resource.</t>

          <t>Two optimizations may be considered: 
          <list style="symbols">
            <t>Reducing the TIME-WAIT state. The user's behavior normally
            correlates with system performance. It is rather common that
            users change video channels often. Investigations have shown
            that 60% of videos are watched for less than 20% of their
            duration. The user's access patterns may leave a number of the
            TIME-WAIT states. Therefore, acceleration of TIME-WAIT state
            transitions could increase the efficiency of port utilization.
            <xref target="RFC6191"/> defines a mechanism for reducing
            TIME-WAIT state by proposing TCP timestamps and sequence
            numbers. 
            <vspace blankLines="1"/> 
            <xref target="I-D.penno-behave-rfc4787-5382-5508-bis"/> recommended
            applying <xref target="RFC6191"/> and PAWS (Protect Against Wrapped
            Sequence numbers, described in <xref target="RFC1323"/>) to NAT.
            This may also be a way to improve port utilization.</t> 

            <t>Another possibility is to use Address-Dependent Mapping or
            Address and Port-Dependent Mapping <xref target="RFC4787"/> to
            increase port utilization. This feature has already been
            implemented on a vendor-specific basis. However, it should be
            noted that REQ-7 and REQ-12 in <xref target="RFC6888"/> may
            reduce the incentive to use anything but the Address-Independent
            Mapping behaviour recommended by <xref target="RFC4787"/>.</t>
          </list>
          </t>
          
        </section>

        <!-- princip_4_2 -->

        <section anchor="princip_4_3" title="Port Randomization">
        
          <t>Port randomization is a feature to enhance the defense against
          hijacking of flows. <xref target="RFC6056"/> specifies that:
          <list style="empty">
            <t>"A NAPT that does not implement port preservation (<xref
            target="RFC4787"/>, <xref target="RFC5382"/>) should obfuscate
            selection of the ephemeral port of a packet when it is changed
            during translation of that packet."</t> 
          </list>
          A NAPT based on per-session allocation normally follows this
          recommendation. </t> 

          <t>See <xref target="seccons"/> for a fuller discussion of port
          randomization.</t>
          
        </section>

        <!-- princip_4_3 -->
        
      </section>

      <!-- princip_4 -->
      
    </section>

    <!-- princip -->

    <section anchor="bulkAlloc"
             title="Considerations For the Dynamic Assignment of Port-Ranges">
             
      <section anchor="bulkAlloc_1" title="Motivation">
      
        <t>During the IPv6 transition period, large-scale NAT devices may be
        introduced, e.g. DS-Lite AFTR, NAT64. When a NAT device needs to set
        up a new connection for a given internal address behind the NAT, it
        needs to create a new mapping entry for the new connection, which will
        contain source IP address, source port or ICMP identifier, converted
        source IP address, converted source port, protocol (TCP/UDP), etc.</t>

        <t>For various reasons it is necessary to log these mappings. Some
        high performance NAT devices may need to create a large amount of new
        sessions per second. As seen in <xref target="princip_4_1"/>, if the
        logs are generated for each mapping entry, the log traffic could reach
        tens of megabytes per second or more, which would be a problem for log
        generation, transmission and storage. (The per-session volumes in
        <xref target="tab_test"/> amount to 42 bytes per served subscriber per
        second. The volumes reported in the introduction to <xref 
        target="I-D.donley-behave-deterministic-cgn"/> for U.S.
        users are even higher, around 58 bytes per second per subscriber
        served.)</t>

        <t><xref target="RFC6888"/>, REQ-13, REQ-14, and REQ-15 deal
        explicitly with port allocation schemes and logging. However, it is
        recognized that these are conflicting requirements, requiring a
        tradeoff between the efficiency with which ports are used and the rate
        of generation of log records.</t>

        <t>Allocating a range of N ports at once reduces the log volume by a
        factor of N, while also reducing port utilization by a factor which
        varies with the address sharing ratio and other configuration
        parameters. This provides a clear motivation to use dynamic allocation
        of port-ranges rather than individual ports when it is possible to do
        so while maintaining a satisfactory level of port utilization (and by
        implication, shared global IPv4 address utilization).</t>

        <t>Dynamic allocation of port ranges may be used either as the sole
        strategy for port allocation on the NAPT, or as a supplement to an
        initial static allocation.</t>
        
      </section>

      <!-- bulkAlloc_1 -->

      <section anchor="bulkAlloc_2"
               title="Implementation Issues -- Port Randomization and
Port-Range Deallocation">

        <t>When the user sends out the first packet, a port resource pool
        is allocated for the user, e.g., assigning ports 2001~2300 of a public
        IP address to the user's resource pool. Only one log should be
        generated for this port block. When the NAT needs to set up a new
        mapping entry for the user, it can use a port in the user's resource
        pool and the corresponding public IP address. If the user needs more
        port resources, the NAT can allocate another port block, e.g., ports
        3501~3800, to the user's resource pool. Again, just one log needs to
        be generated for this port block.</t>

        <t><xref target="I-D.bajko-pripaddrassign"/> takes this idea further
        by allocating non-contiguous sets of ports using a pseudorandom
        function. Scattering the allocated ports in this way provides a modest
        barrier to port guessing attacks. The use of randomization is
        discussed further in <xref target="seccons"/>.</t>

        <t>Suppose now that a given internal address has been assigned more
        than one block of ports. The individual sessions using ports within a
        port block will start and end at different times. If no ports in some
        port block are used for some configurable time, the NAT can remove the
        port block from the resource pool allocated to a given internal
        address, and make it available for other users. In theory, it is
        unnecessary to log deallocations of blocks of ports, because the ports
        in deallocated blocks will not be used again until the blocks are
        reallocated. However, the deallocation may be logged when it occurs to
        add robustness to troubleshooting or other procedures.</t>

        <t>The deallocation procedure presents a number of difficulties in
        practice. The first problem is the choice of timeout value for the
        block. If idle timers are applied for the individual mappings
        (sessions) within the block, and these conform to the recommendations
        for NAT behaviour for the protocol concerned, then the additional time
        that might be configured as a guard for the block as a whole need not
        be more than a few minutes. The block timer in this case serves only
        as a slightly more conservative extension of the individual session
        idle timers. If, instead, a single idle timer is used for the whole
        block, it must itself conform to the recommendations for the protocol
        with which that block of ports is associated. For example, REQ-5 of
        <xref target="RFC5382"/> requires an idle timer expiry duration of at
        least 2 hours and 4 minutes for TCP. The suggestions made in <xref
        target="princip_4_2"/> may be considered for reducing this time.</t>

        <t>The next issue with port block deallocation is the conflict between
        the desire to randomize port allocation and the desire to make unused
        resources available to other internal addresses. As mentioned above,
        ideally port selection will take place over the entire set of blocks
        allocated to the internal address. However, taken to its fullest
        extent, such a policy will minimize the probability that all ports in
        any given block are idle long enough for it to be released.</t>

        <t>As an alternative, it is suggested that when choosing which block
        to select a port from, the NAT should omit from its range of choice
        the block that has been idle the longest, unless no ports are
        available in any of the other blocks. The expression "block that has
        been idle the longest" designates the block in which the time since
        the last packet was observed in any of its sessions, in either
        direction, is earlier than the corresponding time in any of the other
        blocks assigned to that internal address. As <xref target="RFC6269"/>
        points out, port randomization is just one security measure of
        several, and the loss of randomness incurred by the suggested
        procedure is justified by the increased utilization of port resources
        it allows.</t>
        
      </section>

      <!-- bulkAlloc_2 -->

      <section anchor="bulkAlloc_3" title="Issues Of Traceability">
      
        <t>Section 12 of <xref target="RFC6269"/> provides a good discussion
        of the traceability issue. Complete traceability given the NAT logging
        practices proposed in this draft requires that the remote destination
        record the source port of a request along with the source address (and
        presumably protocol, if not implicit) <xref target="RFC6302"/>. In
addition, the logs at each
        end must be timestamped, and the clocks must be synchronized within a
        certain degree of accuracy. Here is one reason for the guard timing on
        block release, to increase the tolerable level of clock skew between
        the two ends.</t>

        <t>Where source port logging can be enabled, this memo strongly urges
        the operators to do so. Similarly, intrusion detection systems should
        capture source port as well as source address of suspect packets.</t>

        <t>In some cases <xref target="RFC6269"/>, a server may not record the
        source port of a connection. To allow traceability, the NAT device
        needs to record the destination IP address of a connection. As <xref
        target="RFC6269"/> points out, this will provide an incomplete
        solution to the issue of traceability because multiple users of the
        same shared public IP address may access the service at the same time.
        From the point of view of this draft, in such situations the game is
        lost, so to speak, and port allocation at the NAT might as well be
        completely dynamic.</t>

        <t>The final possibility to consider is where the NAT does not do 
        per-session logging even given the possibility that the remote end is
        failing to capture source ports. In that case, the port allocation
        strategy proposed in this section can be used. The impact on
        traceability is that analysis of the logs would yield only the list of
        all internal addresses mapped to a given public address during the
        period of time concerned. This has an impact on privacy as well as
        traceability, depending on the follow-up actions taken.</t> 
      </section>

      <!-- bulkAlloc_3 -->

      <section anchor="bulkAlloc_4" title="Other Considerations">
      
        <t><xref target="RFC6269"/> notes several issues introduced by the use
        of dynamic as opposed to static port assignment. For example, Section
        12.2 of that document notes the effect on authentication procedures.
        These issues must be resolved, but are not specific to the dynamic
        port-range allocation strategy.</t>
        
      </section>

      <!-- bulkAlloc_4 -->
      
    </section>

    <!-- bulkAlloc -->

    <section anchor="seccons" title="Security Considerations">
    
      <t>The discussion which follows addresses an issue that is particularly
      relevant to the strategies described in <xref target="bulkAlloc"/>
      of this document. The security considerations
      applicable to NAT operation for various protocols as documented in, for
      example, <xref target="RFC4787"/> and <xref target="RFC5382"/> also
      apply to this proposal.</t>

      <t><xref target="RFC6056"/> summarizes the TCP port-guessing attack, by
      means of which an attacker can hijack one end of a TCP connection. One
      mitigating measure is to make the source port number used for a TCP
      connection less predictable. <xref target="RFC6056"/> provides various
      algorithms for this purpose.</t>

      <t>As Section 3.1 of that RFC notes: "...provided adequate algorithms
      are in use, the larger the range from which ephemeral ports are
      selected, the smaller the chances of an attacker are to guess the
      selected port number." Conversely, the reduced range sizes proposed by
      the present document increase the attacker's chances of guessing
      correctly. This result cannot be totally avoided. However, mitigating
      measures to improve this situation can be taken both at port block
      assignment time and when selecting individual ports from the blocks that
      have been allocated to a given user.</t>

      <t>At assignment time, one possibility is to assign ports as non-
      contiguous sets of values as proposed in <xref
      target="I-D.bajko-pripaddrassign"/>. However, this approach creates a
      lot of complexity for operations, and the pseudo randomization can
      create uncertainty when the accuracy of logs is important to protect
      someone's life or liberty.</t>

      <t>Alternatively, the NAT can assign blocks of contiguous ports.
      However, at assignment time the NAT could attempt to randomize its
      choice of which of the available idle blocks it would assign to a given
      user. This strategy has to be traded off against the desirability of
      minimizing the chance of conflict between what <xref target="RFC6056"/>
      calls "transport protocol instances" by assigning the most-idle block,
      as suggested in <xref target="bulkAlloc"/>. A compromise policy might be
      to assign blocks only if they have been idle for a certain amount of
      time whenever possible, and select pseudorandomly between the blocks
      available according to this criterion. In this case it is suggested that
      the time value used be greater than the guard timing mentioned in <xref
      target="bulkAlloc"/>, and that no block should ever be reassigned until
      it has been idle at least for the duration given by the guard timer.</t>

      <t>Note that with the possible exception of cryptographically-based port
      allocations, attackers could reverse-engineer algorithmically-derived
      port allocations to either target a specific subscriber or to spoof
      traffic to make it appear to have been generated by a specific
      subscriber. However, this is exactly the same level of security that the
      subscriber would experience in the absence of CGN. CGN is not intended
      to provide additional security by obscurity.</t>

      <t>While the block assignment strategy can provide some mitigation of
      the port guessing attack, the largest contribution will come from
      pseudo-randomization at port selection time. <xref target="RFC6056"/>
      provides a number of algoriths for achieving this pseudo-randomization.
      When the available ports are contained in blocks which are not in
      general consecutive, the algorithms clearly need some adaptation. The
      task is complicated by the fact that the number of blocks allocated to
      the user may vary over time. Adaptation is left as an exercise for the
      implementor.</t>
      
    </section>

    <!-- seccons -->

    <section anchor="iana" title="IANA Considerations">
    
      <t>This document makes no request of IANA.</t>
      
    </section>

    <!-- iana -->

    <section anchor="acks" title="Acknowledgements">
    
      <t>This document is the result of a merger of the original 
      draft-chen-sunset4-cgn-port-allocation and
      draft-tsou-behave-natx4-log-reduction. Version -02 of draft-chen
      contains the following acknowledgements:
      
      <list style="empty">
        <t>The author would like to thank Lee Howard and Simon Perreault for
        their helpful comments.</t>
        
        <t>Many thanks to Wesley George and Marc Blanchet encourage the author
        to continue this work.</t>
      </list></t>
      
      <t>The authors of draft-tsou-behave-natx4-log-reduction have their own
      thanks to give. Mohamed Boucadair reviewed the initial document and
      provided useful comments to improve it. Reinaldo Penno, Joel Jaeggli,
      and Dan Wing provided comments on the subsequent version that resulted
      in major revisions. Serafim Petsis provided encouragement to publication
      after a hiatus of two years.</t>
      
      <t>The present version of the document benefited from further 
      comments by Lee Howard.</t>
      
    </section>

    <!-- acks -->
  </middle>

  <back>
    <references title="Normative References">
      &RFC6056;

      &RFC6145;

      &RFC6146;

      &RFC6269;

      &RFC6888;
    </references>

    <references title="Informative References">
      &RFC1323;
      
      &RFC3022;

      &RFC4787;

      &RFC5382;

      &RFC5424;

      &RFC6191;

      &RFC6302;

      &RFC6333;

      &RFC6346;

      &RFC6877;

      &RFC6887;

      &RFC7011;

      <reference anchor="I-D.anderson-v6ops-siit-dc">
        <front>
          <title>SIIT-DC: Stateless IP/ICMP Translation
for IPv6 Data Centre Environments (Work in progress)</title>

          <author initials="T." surname="Anderson">
            <organization>Redpill Linpro</organization>
          </author>

          <date month="September" year="2014"/>
        </front>
      </reference>

      <reference anchor="I-D.ietf-softwire-map-t">
        <front>
          <title>Mapping of Address and Port using Translation (MAP-T) (Work
          in progress)</title>

          <author initials="X." surname="Li">
            <organization>CERNET Center/Tsinghua University</organization>
          </author>

          <author initials="C." surname="Bao">
            <organization>CERNET Center/Tsinghua University</organization>
          </author>

          <author initials="W." surname="Dec">
            <organization>Cisco Systems</organization>
          </author>

          <author initials="O." surname="Troan">
            <organization>Cisco Systems</organization>
          </author>

          <author initials="S." surname="Matsushima">
            <organization>SoftBank Telecom</organization>
          </author>

          <author initials="T." surname="Murakami">
            <organization>IP Infusion</organization>
          </author>

          <date month="February" year="2014"/>
        </front>
      </reference>

      <reference anchor="I-D.ietf-softwire-4rd">
        <front>
          <title>IPv4 Residual Deployment via IPv6 - a Stateless Solution
          (4rd) (Work in Progress)</title>

          <author initials="R." surname="Despres">
            <organization>RD-IPtech</organization>
          </author>

          <author initials="S." surname="Jiang">
            <organization>Huawei Technologies Co., Ltd.</organization>
          </author>

          <author initials="R." surname="Penno">
            <organization>Cisco Systems, Inc.</organization>
          </author>

          <author initials="Y." surname="Lee">
            <organization>Comcast</organization>
          </author>

          <author initials="G." surname="Chen">
            <organization>China Mobile</organization>
          </author>

          <author initials="M." surname="Chen">
            <organization>Freebit Co., Ltd.</organization>
          </author>

          <date month="April" year="2014"/>
        </front>
      </reference>

      <reference anchor="I-D.ietf-pcp-port-set">
        <front>
          <title>Port Control Protocol (PCP) Extension for Port Set Allocation
          (Work in Progress)</title>

          <author initials="Q." surname="Sun">
            <organization>China Telecom</organization>
          </author>

          <author initials="M." surname="Boucadair">
            <organization>France Telecom</organization>
          </author>

          <author initials="S." surname="Sivakumar">
            <organization>Cisco Systems</organization>
          </author>

          <author initials="C." surname="Zhou">
            <organization>Huawei Technologies</organization>
          </author>

          <author initials="T." surname="Tsou">
            <organization>Huawei Technologies</organization>
          </author>

          <author initials="S." surname="Perrault">
            <organization>Viagenie</organization>
          </author>

          <date month="July" year="2014"/>
        </front>
      </reference>

      <reference anchor="I-D.ietf-softwire-map-dhcp">
        <front>
          <title>DHCPv6 Options for configuration of Softwire Address and Port
          Mapped Clients (Work in Progress)</title>

          <author initials="T." surname="Mrugalski">
            <organization>ISC</organization>
          </author>

          <author initials="O." surname="Troan">
            <organization>Cisco Systems</organization>
          </author>

          <author initials="W." surname="Dec">
            <organization>Cisco Systems</organization>
          </author>

          <author initials="I." surname="Farrer">
            <organization>Deutsche Telekom AG</organization>
          </author>

          <author initials="S." surname="Perrault">
            <organization>Viagenie</organization>
          </author>

          <author initials="C." surname="Bao">
            <organization>Tsinghua University</organization>
          </author>

          <author initials="L." surname="Yeh">
            <organization>CNNIC</organization>
          </author>

          <author initials="X." surname="Deng">
            <organization>Yingke Law Firm</organization>
          </author>

          <date month="July" year="2014"/>
        </front>
      </reference>

      <reference anchor="I-D.ietf-softwire-stateless-4v6-motivation">
        <front>
          <title>Motivations for Carrier-side Stateless IPv4 over IPv6
Migration Solutions (Expired work in Progress)</title>

          <author initials="M." surname="Boucadair">
            <organization>France Telecom</organization>
          </author>

          <author initials="S." surname="Matsushima">
            <organization>SoftBank Telecom</organization>
          </author>

          <author initials="Y." surname="Lee">
            <organization>Comcast</organization>
          </author>

          <author initials="O." surname="Bonness">
            <organization>Deutsche Telekom</organization>
          </author>

          <author initials="I." surname="Borges">
            <organization>Portugal Telecom</organization>
          </author>

          <author initials="G." surname="Chen">
            <organization>China Mobile</organization>
          </author>

          <date month="November" year="2012"/>
        </front>
      </reference>

      <reference anchor="I_D.ietf-softwire-lw4over6">
        <front>
          <title>Lightweight 4over6: An Extension to the DS-Lite Architecture
          (Work in Progress)</title>

          <author initials="Y." surname="Cui">
            <organization>Tsinghua University</organization>
          </author>

          <author initials="Q." surname="Sun">
            <organization>China Telecom</organization>
          </author>

          <author initials="M." surname="Boucadair">
            <organization>France Telecom</organization>
          </author>

          <author initials="T." surname="Tsou">
            <organization>Huawei Technologies</organization>
          </author>

          <author initials="Y." surname="Lee">
            <organization>Comcast</organization>
          </author>

          <author initials="I." surname="Farrer">
            <organization>Deutsche Telekom AG</organization>
          </author>

          <date month="June" year="2014"/>
        </front>
      </reference>

      <reference anchor="I-D.ietf-softwire-map">
        <front>
          <title>Mapping of Address and Port with Encapsulation (MAP) (Work in
          Progress)</title>

          <author initials="O." surname="Troan">
            <organization>Cisco Systems</organization>
          </author>

          <author initials="W." surname="Dec">
            <organization>Cisco Systems</organization>
          </author>

          <author initials="X." surname="Li">
            <organization>CERNET Center/Tsinghua University</organization>
          </author>

          <author initials="C." surname="Bao">
            <organization>CERNET Center/Tsinghua University</organization>
          </author>

          <author initials="S." surname="Matsushima">
            <organization>SoftBank Telecom</organization>
          </author>

          <author initials="T." surname="Murakami">
            <organization>IP Infusion</organization>
          </author>

          <author initials="T." surname="Taylor">
            <organization>Huawei Technologies</organization>
          </author>

          <date month="January" year="2014"/>
        </front>
      </reference>

      <reference anchor="I-D.ietf-behave-syslog-nat-logging">
        <front>
          <title>Syslog Format for NAT Logging (Work in Progress)</title>

          <author initials="Z." surname="Chen">
            <organization>China Telecom</organization>
          </author>

          <author initials="C." surname="Zhou">
            <organization>Huawei Technologies</organization>
          </author>

          <author initials="T." surname="Tsou">
            <organization>Huawei Technologies</organization>
          </author>

          <author initials="T." surname="Taylor">
            <organization>Huawei Technologies</organization>
          </author>

          <date month="January" year="2014"/>
        </front>
      </reference>

      <reference anchor="I-D.penno-behave-rfc4787-5382-5508-bis">
        <front>
          <title>Network Address Translation (NAT) Behavioral Requirements
          Updates (expired Work in Progress)</title>

          <author initials="R." surname="Penno">
            <organization>Cisco Sysstems</organization>
          </author>

          <author initials="S." surname="Perrault">
            <organization>Viagenie</organization>
          </author>

          <author initials="S." surname="Kamiset">
            <organization>Consultant</organization>
          </author>

          <author initials="M." surname="Boucadair">
            <organization>France Telecom</organization>
          </author>

          <author initials="K." surname="Naito">
            <organization>NTT</organization>
          </author>

          <date month="January" year="2013"/>
        </front>
      </reference>

      <reference anchor="I-D.bajko-pripaddrassign">
        <front>
          <title>Port Restricted IP Address Assignment (expired Work in
          Progress)</title>

          <author initials="G." surname="Bajko">
            <organization>Nokia</organization>
          </author>

          <author initials="T." surname="Savolainen">
            <organization>Nokia</organization>
          </author>

          <author initials="M." surname="Boucadair">
            <organization>France Telecom</organization>
          </author>

          <author initials="P." surname="Levis">
            <organization>France Telecom</organization>
          </author>

          <date month="April" year="2012"/>
        </front>
      </reference>
      
      <reference anchor="I-D.donley-behave-deterministic-cgn">
        <front>
          <title>Deterministic Address Mapping to Reduce Logging in Carrier
Grade NAT Deployments (Work in progress)</title>
          <author initials="C." surname="Donley">
            <organization>CableLabs</organization>
          </author>
          <author initials="C." surname="Grundemann">
            <organization>Internet Society</organization>
          </author>
          <author initials="V." surname="Sarawat">
            <organization>CableLabs</organization>
          </author>
          <author initials="K." surname="Sundaresan">
            <organization>CableLabs</organization>
          </author>
          <author initials="O." surname="Vautrin">
            <organization>Juniper Networks</organization>
          </author>
          <date month="January" year="2014"/>
        </front>
      </reference>

    </references>


  </back>
</rfc>
