<?xml version="1.0" encoding="UTF-8"?>     
<!-- edited with ultraedia -->     

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
    <!ENTITY rfc1918 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1918.xml'>
    <!ENTITY rfc2119 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml'>
    <!ENTITY rfc2663 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2663.xml'>
    <!ENTITY rfc3493 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3493.xml'>
    <!ENTITY rfc2767 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2767.xml'>
    <!ENTITY rfc4213 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.4213.xml'>
    <!ENTITY rfc2460 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2460.xml'>
    <!ENTITY rfc3338 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3338.xml'>
    <!ENTITY rfc3948 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3948.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 rfc5508 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5508.xml'>
    <!ENTITY rfc5735 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.5735.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 rfc6147 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.6147.xml'>
    <!ENTITY rfc6180 PUBLIC '' 'http://xml.resource.org/public/rfc/bibxml/reference.RFC.6180.xml'>
]>     

<rfc category="std" ipr="pre5378Trust200902" 
     obsoletes="3338, 2767" docName="draft-ietf-behave-v4v6-bih-09">     

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>     

<?rfc toc="yes" ?>     
<?rfc symrefs="yes" ?>     
<?rfc sortrefs="yes"?>     
<?rfc iprnotified="no" ?>     
<?rfc strict="yes" ?>     

    <front>     
        <title abbrev="BIH">     
          Dual Stack Hosts Using "Bump-in-the-Host" (BIH)</title>     

    <author initials="B.Huang" surname="Huang" fullname="Bill Huang" >     
      <organization>China Mobile</organization>     
      <address>     
        <postal>     
          <street>53A,Xibianmennei Ave., </street>     
          <street>Xuanwu District,</street>     
          <city>Beijing</city>     
          <code>100053</code>     
          <country>China</country>     
        </postal>     
        <email>bill.huang@chinamobile.com</email>     
      </address>     
    </author>     


    <author initials="H.Deng" surname="Deng" fullname="Hui Deng">     
      <organization>China Mobile</organization>     
      <address>     
        <postal>     
          <street>53A,Xibianmennei Ave., </street>     
          <street>Xuanwu District,</street>     
          <city>Beijing</city>     
          <code>100053</code>     
          <country>China</country>     
        </postal>     
        <email>denghui02@gmail.com</email>     
      </address>     
    </author>         

    <author initials="T.Savolainen" surname="Savolainen" fullname="Teemu Savolainen">     
      <organization>     Nokia</organization>     
      <address>     
        <postal>     
          <street>     Hermiankatu 12 D </street>     
          <street>     FI-33720 TAMPERE</street>     
          <country>     Finland</country>     
        </postal>     
        <email>     teemu.savolainen@nokia.com</email>     
      </address>     
    </author>     
    
    <date month="January" year="2012"/>
    <workgroup>Behave WG</workgroup>
      
      <abstract>     
        <t>Bump-In-the-Host (BIH) is a host-based
         IPv4 to IPv6 protocol translation mechanism that allows a class of IPv4-only applications
         that work through NATs to communicate with IPv6-only peers. The host on which applications 
         are running may be connected to IPv6-only or dual-stack access networks. 
         BIH hides IPv6 and makes the IPv4-only applications think they are talking with IPv4 peers 
         by local synthesis of IPv4 addresses. This document obsoletes RFC 2767 and RFC 3338.
        </t>     
      </abstract>     
       
    </front>     
  
    <middle>     

    <section title="Introduction">     

       <t>This document describes Bump-in-the-Host (BIH), a successor and combination of
         the Bump-in-the-Stack (BIS)<xref target="RFC2767"/> and
         Bump-in-the-API (BIA) <xref target="RFC3338"/>
         technologies, which enable IPv4-only legacy applications to communicate
         with IPv6-only servers by synthesizing IPv4 addresses from AAAA records. Section 
         8 describes the reasons for making RFC2767 and RFC3338 obsolete.
       </t>

       <t>The supported class of applications includes those that use DNS for IP address
         resolution and that do not embed IP address literals in application-protocol payloads. 
         This  includes legacy client-server applications using the DNS
         that are agnostic to the IP address family used by the destination and that are
         able to do NAT traversal. The synthetic IPv4 addresses shown to applications are 
         taken from the RFC1918 private address pool in order to ensure that possible 
         NAT traversal techniques will be initiated.
       </t>
  
       <t>IETF recommends using dual-stack or tunneling based solutions for IPv6 
         transition and specifically recommends against deployments 
         utilizing double protocol translation.   
         Use of BIH together with a NAT64 is NOT RECOMMENDED <xref target="RFC6180"/>.
       </t>

       <t>BIH includes two major implementation alternatives: a protocol translator 
         between the IPv4 and the IPv6 stacks of
         a host, or an API translator between the IPv4 socket API module and the TCP/IP module. 
         Essentially, IPv4 is translated into IPv6 at the socket API layer or at the IP layer,
         former of which is the recommended implementation alternative.
       </t> 

       <t>When BIH is implemented at the socket API layer, the translator intercepts 
         IPv4 socket API function calls and invokes corresponding IPv6 socket API function calls
         to communicate with IPv6 hosts. 
       </t>

       <t>When BIH is implemented at the network layer the IPv4 packets
         are intercepted and converted to IPv6 using the IP conversion mechanism
         defined in Stateless IP/ICMP Translation Algorithm (SIIT) <xref target="RFC6145"/>.
         The protocol translation has the same benefits and drawbacks as SIIT.
       </t>

       <t>The location of the BIH refers to the location of the protocol translation function. 
	  The location of the IPv4 address and DNS A record synthesis function is orthogonal to the location
          of the protocol translation, and may or may not happen at the same location.</t>
        
       <t>BIH can be used whenever an IPv4-only application needs to 
         communicate with an IPv6-only server, independently of the
         address families supported by the access network. Hence the access network
         can be IPv6-only or dual-stack capable.
       </t>

       <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 <xref target="RFC2119"/> .
       </t>     

       <t>     
         This document uses terms defined in <xref target="RFC2460"/> and <xref target="RFC4213"/>. 
       </t>     
 
       <section title="Terminology">
         <t>
	 <list style="hanging">
             <t hangText="DNS synthesis">
                <vspace blankLines="1"/>
                DNS, A record, synthesis is a process where A type of DNS record is created
                by Extension Name Resolver to contain synthetic IPv4 address.
             </t>

	    <t hangText="Real IPv4 address">
         	<vspace blankLines="1"/>
	  	An IPv4 address of a remote node a host has learned, for example, from
	        DNS response to an A query. 
            </t>

	    <t hangText="Real IPv6 address">
         	<vspace blankLines="1"/>
		An IPv6 address of a remote node a host has learned, for example,
	        from DNS response to an AAAA query. 
            </t>

	    <t hangText="Synthetic IPv4 address">
         	<vspace blankLines="1"/>
		An IPv4 address that has meaning only inside a host and that
                is used to provide IPv4 representation of remote node's real 
	        IPv6 address.
            </t>
	</list>
        </t>
       </section>

       <section title="Acknowledgement of previous work">
         <t>This document is a direct derivative from 
            Kazuaki TSHUCHIYA, Hidemitsu HIGUCHI, and Yoshifumi ATARASHI's Bump-in-the-Stack
            <xref target="RFC2767"/>
            and from Seungyun
            Lee, Myung-Ki Shin, Yong-Jin Kim, Alain Durand, and Erik Nordmark's
            Bump-in-the-API <xref target="RFC3338"/>, which similarly provides 
	    IPv4-only applications on dual-stack hosts the means to operate over IPv6.
            Section 8 covers the changes since those documents.
         </t>          
       </section>
   
    </section>     
	   
   <section title="Components of the Bump-in-the-Host">     
     
    <t>     
      Figure 1 shows the architecture of a host in which BIH is
      implemented as a socket API layer translator, i.e., as a "Bump-in-the-API".
    </t>     
        
 <figure title="Architecture of a dual stack host using protocol translation at socket layer" anchor="fig1">     <artwork>     
   <![CDATA[
               +----------------------------------------------+
               | +------------------------------------------+ |
               | |                                          | |
               | |            IPv4 applications             | |
               | |                                          | |
               | +------------------------------------------+ |
               | +------------------------------------------+ |
               | |           Socket API (IPv4, IPv6)        | |
               | +------------------------------------------+ |
               | +-[ API translator]------------------------+ |
               | | +-----------+ +---------+ +------------+ | |
               | | | Ext. Name | | Address | | Function   | | |
               | | | Resolver  | | Mapper  | | Mapper     | | |
               | | +-----------+ +---------+ +------------+ | |
               | +------------------------------------------+ |
               | +--------------------+ +-------------------+ |
               | |                    | |                   | |
               | |    TCP(UDP)/IPv4   | |   TCP(UDP)/IPv6   | |
               | |                    | |                   | |
               | +--------------------+ +-------------------+ |
               +----------------------------------------------+
    ]]>     </artwork>     </figure>     

    <t>     
      Figure 2 shows the architecture of a host in which BIH is
      implemented as a network layer translator, i.e., a "Bump-in-the-Stack".
    </t>     

   <figure title="Architecture of a dual-stack host using protocol translation at the network layer" anchor="fig2"><artwork><![CDATA[
   +------------------------------------------------------------+
   |  +------------------------------------------+              |
   |  |    IPv4 applications                     |              |
   |  |    Host's main DNS resolver              |              |
   |  +------------------------------------------+              |
   |  +------------------------------------------+              |  
   |  |    TCP/UDP                               |              |
   |  +------------------------------------------+              |
   |  +------------------------------------------+ +---------+  |
   |  |    IPv4                                  | |         |  |
   |  +------------------------------------------+ | Address |  |
   |  +------------------+ +---------------------+ | Mapper  |  |
   |  |    Protocol      | |   Extension Name    | |         |  |
   |  |    Translator    | |   Resolver          | |         |  |
   |  +------------------+ +---------------------+ |         |  |
   |  +------------------------------------------+ |         |  |
   |  |    IPv4 / IPv6                           | |         |  |
   |  +------------------------------------------+ +---------+  |
   +------------------------------------------------------------+
     ]]></artwork></figure>

    <t> Dual stack hosts defined in RFC 4213 <xref target="RFC4213"/> need applications,
      TCP/IP modules and addresses for both IPv4 and IPv6. The proposed
      hosts in this document have an API or network-layer translator to allow
      legacy IPv4 applications to communicate with
      IPv6-only peers.  The BIH architecture
      consists of an Extension Name Resolver, an Address Mapper, and depending on
      implementation either a Function Mapper or a Protocol Translator. It is 
      worth noting that the Extension Name Resolver's placement is orthogonal 
      to the placement of protocol translation. For example, the Extension
      Name Resolver may reside in the socket API while protocol translation takes
      place at the network layer.
    </t>     

     <t>
      The choice between the socket API and the network layer architectures varies case by case.
      While the socket API architecture alternative is the recommended one, it may not always be possible to choose. 
      This may be the case, for example, when the used operating system does not allow modifications
      to be done for API implementations, but does allow addition of virtual network interfaces and 
      related software modules. On the other hand, sometimes it may not be possible to introduce protocol
      translators inside the operating system, but it may be easy to modify implementations
      behind the API provided for applications. The choice of architecture also depends on who is creating
      implementation of BIH. For example, an application framework provider, an operating system provider, 
      and a device vendor may all choose different approaches due their different positions. 
     </t>

     <section title="Function Mapper">     
       
       <t>     
         The function mapper translates an IPv4 socket API function into an IPv6 socket API
         function.
       </t>     

       <t>     
         When detecting IPv4 socket API function calls from IPv4 applications,
         the function mapper MUST intercept the function calls and invoke IPv6 socket API
         functions that correspond to the IPv4 socket API functions.  
       </t>     

       <t>
         The function mapper MUST NOT perform function mapping when the application is initiating 
         communications to the address range used by local synthesis and the address mapping 
         table does not have an entry mathching the address.
       </t>

       <t>See Appendix A for an informational list of functions that would be appropriate to intercept by the function mapper.
       </t>

     </section> 

     <section title="Protocol translator">
     	
       <t>The protocol translator translates IPv4 into IPv6 and vice versa using the IP conversion
          mechanism defined in SIIT <xref target="RFC6145"/>. To avoid 
          unnecessary fragmentation, the host's IPv4 module SHOULD be configured with a small
          enough MTU (MTU of the IPv6 enabled link - 20 bytes).
       </t>

       <t>Protocol translation cannot be performed for IPv4 packets sent to the IPv4 address 
          range used by local synthesis and for which a mapping table entry does not exist. 
          The implementation SHOULD attempt to route such packets via IPv4 interfaces instead.
       </t>

     </section>     
     
     <section title="Extension Name Resolver">     
       
       <t>     
         The Extension Name Resolver (ENR) returns an answer in response to the IPv4 
         application's name resolution request. 
       </t>     

       <t>     
         In the case of the socket API layer implementation alternative, when an IPv4 application
         tries to do a forward lookup to resolve names via the resolver
         library (e.g., gethostbyname()), BIH intercepts the function call and
         instead calls the IPv6 equivalent functions (e.g., getaddrinfo()) that
         will resolve both A and AAAA records. This implementation alternative is name resolution
         protocol agnostic, and hence supports techniques such as "hosts-file",
         NetBIOS, mDNS, and  anything else the underlying operating system uses.
       </t>     

       <t>
         In the case of the network layer implementation alternative, the ENR intercepts the A query and 
         creates an additional AAAA query with similar content. The ENR will then
         collect replies to both A and AAAA queries and, depending on results, either return an A 
         reply unmodified or synthesize a new A reply. 

         If no reply for A query is received after ENR implementation specific timeout, 
	 after reception of positive AAAA response, the ENR MAY choose to proceed as 
	 if there were only AAAA record available for the destination.
       </t>

       <t>The network layer implementation alternative 
         will only be able to catch applications' name resolution requests that result in actual DNS
         queries, hence is more limited when compared to the socket API layer implementation alternative.
         Hence the socket API layer alternative is RECOMMENDED.  
       </t>

       <t>     
         In either implementation alternative, if DNS A record reply contains non-excluded real IPv4 
   	 addresses the ENR MUST NOT synthesize IPv4 addresses. 
       </t>     

       <t>   
         The ENR asks the address mapper to assign a synthetic IPv4 address corresponding to each received IPv6 address 
         if the A record query resulted in negative response, all received real IPv4 addresses were excluded, or the A 
         query timed out. The timeout value is implementation specific and may be short in order to provide
         good user experience.
        </t>
        
       <t>      
         In the case of the API layer implementation alternative,
         the ENR will simply make the API (e.g. gethostbyname) return the synthetic IPv4 address. 
         In the case of the network-layer implementation alternative, the ENR synthesizes an A record for the
         assigned synthetic IPv4 address, and delivers it up the stack.
         If the response contains a CNAME or a DNAME record, then the CNAME or DNAME chain is 
         followed until the first terminating A or AAAA record is reached.
       </t>

       <figure title="ENR behavior illustration" anchor="Table1"><artwork><![CDATA[
  Application    | Network               | ENR behavior
    query        | response              |  
  ---------------+-----------------------+----------------------------
IPv4 address(es) | IPv4 address(es)      | return real IPv4 address(es)
IPv4 address(es) | IPv6 address(es)      | synthesize IPv4 address(es)
IPv4 address(es) | IPv4/IPv6 address(es) | return real IPv4 address(es)
     ]]></artwork></figure>

       <section title="Special exclusion sets for A and AAAA records" anchor="exclusions">
         <t>
         An ENR implementation SHOULD by default exclude certain real IPv4 and IPv6 addresses seen on received A and 
         AAAA records. The addresses to be excluded by default MAY include addresses such as those that
         should not appear in the DNS or on the wire (see <xref target="RFC6147"/> section 5.1.4 and <xref target="RFC5735"/>).
         Additional addresses MAY be excluded based on possibly configurable local policies.
         </t>
       </section>

       <section title="DNSSEC support" anchor="dnssecsupport">
         <t>
           When the ENR is implemented at the network layer, the A record synthesis can 
           cause similar issues as are described in <xref target="RFC6147"/>
           section 3. While running BIH, the main resolver of the host SHOULD NOT perform
           validation of A records as synthetic A records created by ENR would fail in validation. 
           While not running BIH, host's resolver can use DNSSEC in the same way that any other resolver can.
           The ENR MAY support DNSSEC, in which case the (stub) resolver on a host can
           be configured to trust validations done by the ENR located at the network layer.
           In some cases the host's validating stub resolver can implement the ENR by itself.
         </t>

         <t>When the ENR is implemented at the socket API level, there are no issues with 
            DNSSEC use, as the ENR itself uses socket APIs for DNS resolution. This approach 
            is RECOMMENDED.</t>
       </section>

       <section title="Reverse DNS lookup" anchor="PTRquery">
         <t>When an application requests a reverse lookup (PTR query) for an IPv4 address,
           the ENR MUST check whether the queried IPv4 address
           can be found in the Address Mapper's mapping table and is a synthetic IPv4 address. If 
           an entry is found and the queried IPv4 address is synthetic, the ENR MUST initiate 
           a corresponding reverse lookup for the real IPv6 address. In the case where the
           application requested a reverse lookup for an address not part of the synthetic IPv4 address
           pool, e.g., a global address, the request MUST be passed on unmodified.
         </t>
  
         <t>For example, when an application requests a reverse lookup for a synthetic IPv4 address, 
           the ENR needs to intercept that query. The ENR  
           asks the address mapper for the real IPv6 address that corresponds to the synthetic IPv4 address. The
           ENR shall perform a reverse lookup procedure for the destination's IPv6 address and return
           the name received as a response to the application that initiated the IPv4 query.
         </t>
       </section>   

    <section title="DNS caches and synthetic IPv4 addresses">
     <t>
       When BIH shuts down or address mapping table entries are cleared for any reason,
       DNS cache entries for synthetic IPv4 addresses MUST be flushed.
       There may be a DNS cache in the network-layer ENR itself, but also at 
       the host's stub resolver.
     </t>
    </section>

     </section>     

     <section title="Address Mapper">     

       <t>The address mapper maintains an IPv4 address pool that can be used for IPv4 
         address synthesis. The
         pool consists of <xref target="RFC1918"/> IPv4 addresses as per section 4.4. Also, the address mapper
         maintains a table consisting of pairs of synthetic IPv4 addresses and destinations' 
	 real IPv6 addresses.
       </t>

       <t>     
         When the extension name resolver, translator, or the function mapper requests 
         the address mapper to assign a synthetic IPv4 address corresponding to an IPv6 address, the 
         address mapper selects and
         returns an IPv4 address out of the local pool, and registers a new entry
         into the table. The registration occurs in the following three cases:
       </t>     
  
       <t>     
         (1) When the extension name resolver gets only IPv6 addresses for the target
         host name and there is no existing mapping entry for the IPv6 addresses.
         One or more synthetic IPv4 addresses will be returned to the application and
         mappings for synthetic IPv4 addresses to real IPv6 addresses are created.         
       </t>     

       <t>     
         (2) When the extension name resolver gets both real IPv4 and IPv6 addresses,
         but the real IPv4 addresses contain only excluded IPv4 addresses (e.g., 127.0.0.1). 
         The behavior will follow case (1).
       </t>     

       <t>     
         (3) When the function mapper is triggered by
         a received IPv6 packet and there is no existing mapping entry for the IPv6
         source address (for example, the client sent a UDP request to an anycast address
         but a response was received from a unicast address).
       </t>     

      <t>
        Other possible combinations are outside of BIH and BIH is not involved in those.
      </t>
      	
    </section>     
   </section>     
      
  <section title="Behavior and Network Examples">      

    <t>Figure 4 illustrates a very basic network scenario. An IPv4-only
    application is running on a host attached to the IPv6-only Internet and
    is talking to an IPv6-only server. Communication is made possible
    by Bump-In-the-Host.</t>

 <figure title="Network Scenario #1" anchor="fig5"><artwork><![CDATA[               
  +----+                                   +-------------+
  | H1 |----------- IPv6 Internet -------- | IPv6 server |
  +----+                                   +-------------+
  v4 only
  application
    ]]></artwork></figure>

    <t>     
    Figure 5 illustrates a possible network scenario where an IPv4-only 
    application is running on a host attached to a dual-stack network,
    but the destination server is running on a private site that is
    numbered with public IPv6 addresses and not globally reachable IPv4 addresses,
    such as <xref target="RFC1918"/> addresses, 
    without port forwarding set up on the NAT44. The only means to contact
    the server is to use IPv6.</t>

 <figure title="Network Scenario #2" anchor="fig6"><artwork><![CDATA[
  +----------------------+  +------------------------------+
  | Dual Stack Internet  |  | IPv4 Private site (Net 10)   |
  |                      |  | IPv6 routed site             |
  |                   +---------+             +----------+ |
  |                 +-|  NAT44  |-------------+          | | 
  |  +----+         | +---------+             |          | |
  |  | H1 |---------+    |  |                 |  Server  | |
  |  +----+         | +-----------+           |          | |
  | v4 only         +-|IPv6 Router|-----------+          | |
  | application       +-----------+           +----------+ |
  |                      |  |                  Dual Stack  |
  |                      |  |                    10.1.1.1  |
  |                      |  |                 2001:DB8::1  |
  +----------------------+  +------------------------------+
    ]]></artwork></figure>
    <t>
    Illustrations of host behavior in both implementation alternatives are given here.
    Figure 6 illustrates a setup where BIH (including the ENR) is implemented at
    the sockets API layer, and
    Figure 7 illustrates a setup where BIH (including the ENR) is implemented at the network layer.
    </t>    
 <?rfc needLines="8" ?>

     <figure title="Example of BIH as API addition" anchor="fig7"><artwork><![CDATA[   
"dual stack"                                                "host6"
IPv4    Socket |     [ API Translator ]    | TCP(UDP)/IP          Name
appli-  API    | ENR      Address  Function| (v6/v4)             Server
cation         |          Mapper   Mapper  |
 |        |        |        |        |         |              |       |
<<Resolve IPv4 addresses for "host6".>>        |              |       |
 |        |        |        |        |         |              |       |
 |------->|------->|  Query IPv4 addresses for host6.         |       |
 |        |        |        |        |         |              |       |
 |        |        |------------------------------------------------->|
 |        |        |  Query 'A' and 'AAAA' records for host6          |
 |        |        |        |        |         |              |       |
 |        |        |<-------------------------------------------------|
 |        |        |  Reply with the 'AAAA' record.           |       |
 |        |        |        |        |         |              |
 |        |        |<<The 'AAAA' record is resolved.>>        |
 |        |        |        |        |         |              |
 |        |        |+++++++>|  Request synthetic IPv4 address |
 |        |        |        |  corresponding to the IPv6 address.
 |        |        |        |        |         |              |
 |        |        |        |<<Assign one synthetic IPv4 address.>>  
 |        |        |        |        |         |              |
 |        |        |<+++++++|  Reply with the synthetic IPv4 address.   
 |        |        |        |        |         |              |
 |<-------|<-------| Reply with the IPv4 address              |
 |        |        |        |        |         |              |
 |        |        |        |        |         |              |
<<Call IPv4 Socket API function >>   |         |              |
 |        |        |        |        |         |              |
 |=======>|=========================>|An IPv4 Socket API action
 |        |        |        |        |         |              |
 |        |        |        |<+++++++|  Request IPv6 addresses|
 |        |        |        |        |  corresponding to the  |
 |        |        |        |        |  synthetic IPv4 addresses.       
 |        |        |        |        |         |              |
 |        |        |        |+++++++>| Reply with the IPv6 addresses.
 |        |        |        |        |         |              |
 |        |        |        |        |<<Translate IPv4 into IPv6.>>
 |        |        |        |        |         |              |
 |  An IPv6 Socket API action        |=======================>|
 |        |        |        |        |         |              |
 |        |        |        |        |<<IPv6 data received    |
 |        |        |        |        |  from network.>>       |
 |        |        |        |        |         |              |
 |  An IPv6 Socket API action        |<=======================|
 |        |        |        |        |         |              |
 |        |        |        |        |<<Translate IPv6 into IPv4.>>
 |        |        |        |        |         |              |
 |        |        |        |<+++++++|  Request synthetic IPv4 addresses
 |        |        |        |        |  corresponding to the  |
 |        |        |        |        |  IPv6 addresses.       |
 |        |        |        |        |         |              |
 |        |        |        |+++++++>| Reply with the IPv4 addresses.
 |        |        |        |        |         |              |
 |<=======|<=========================|  An IPv4 Socket API action
 |        |        |        |        |         |              |
    ]]></artwork></figure>

     <figure title="Example of BIH at the network layer" anchor="fig8"><artwork><![CDATA[   
   "dual stack"                                         "host6"
IPv4 stub  TCP/    ENR     address  translator  IPv6
app  res.  IPv4            mapper       
  |   |    |       |         |       |           |         |
<<Resolve an IPv4 address for "host6".>>         |         |
  |-->|    |       |         |       |           |         | 
  |   |----------->|  Query 'A' records for "host6".       |  Name
  |   |    |       |         |       |           |         |  Server
  |   |    |       |------------------------------------------->|
  |   |    |       |  Query 'A' and 'AAAA'  records for "host6"
  |   |    |       |         |       |           |         |    |
  |   |    |       |<-------------------------------------------|
  |   |    |       |  Reply only with 'AAAA' record.       |
  |   |    |       |         |       |           |         |
  |   |    |       |<<Only 'AAAA' record is resolved.>>    |
  |   |    |       |         |       |           |         |
  |   |    |       |-------->|  Request synthetic IPv4 address   
  |   |    |       |         |  corresponding to each IPv6 address.
  |   |    |       |         |       |           |         |
  |   |    |       |         |<<Assign synthetic IPv4 addresses.>>   
  |   |    |       |         |       |           |         |
  |   |    |       |<--------|  Reply with the synthetic IPv4 address.
  |   |    |       |         |       |           |         |
  |   |    |       |<<Create 'A' record for the IPv4 address.>>
  |   |    |       |         |       |           |         |
  |   |<-----------|  Reply with the 'A' record. |         |
  |   |    |       |         |       |           |         |
  |<--|<<Reply with the IPv4 address |           |         |
  |   |    |       |         |       |           |         |
  <<Send an IPv4 packet to "host6".>>|           |         |
  |   |    |       |         |       |           |         |
  |=======>|========================>|  An IPv4 packet.    |
  |   |    |       |         |       |           |         |
  |   |    |       |         |<++++++|  Request IPv6 addresses
  |   |    |       |         |       |  corresponding to the 
  |   |    |       |         |       |  synthetic IPv4 addresses.        
  |   |    |       |         |       |           |         |
  |   |    |       |         |++++++>|  Reply with the IPv6|
  |   |    |       |         |       |  addresses.         |
  |   |    |       |         |       |           |         |
  |   |    |       |         |       |<<Translate IPv4 into IPv6.>>
  |   |    |       |         |       |           |         |
  |   |    |       |An IPv6 packet.  |==========>|========>|
  |   |    |       |         |       |           |         |
  |   |    |       |         |   <<Reply with an IPv6 packet.>>
  |   |    |       |         |       |           |         |
  |   |    |       |An IPv6 packet.  |<==========|<========|
  |   |    |       |         |       |           |         |
  |   |    |       |         |       |<<Translate IPv6 into IPv4.>>
  |   |    |       |         |       |           |         |
  |   |    |       |         |<++++++|  Request synthetic IPv4 
  |   |    |       |         |       |  addresses corresponding
  |   |    |       |         |       |  to the IPv6 addresses.  
  |   |    |       |         |       |           |         |
  |   |    |       |         |++++++>|  Reply with the IPv4 addresses.
  |   |    |       |         |       |           |         |
  |<=======|=========================|  An IPv4 packet.    |
  |   |    |       |         |       |           |         |

    ]]></artwork></figure>

  </section>     

  <section title="Considerations">     

    <section title="Socket API Conversion">
     <t>
      IPv4 socket API functions are translated into IPv6 socket API functions that are semantically as 
      identical as possible and vice versa. See Appendix B for the API
      list intercepted by BIH. However, some
      IPv4 socket API functions are not fully compatible with IPv6 since IPv4 supports features
      that are not present in IPv6, such as SO_BROADCAST.
     </t>

    </section>

    <section title="Socket bindings"> 
     <t>
      BIH SHOULD select a source address for a socket from the recommended source address pool
      if a socket used for communications has not been explicitly bound to any IPv4 address.
     </t>
     <t>
      The binding of an explicitly bound socket MUST NOT be changed by the BIH.
     </t>
    </section>

    <section title="ICMP Message Handling">
     <t>
      ICMPv4 and ICMPv6 messages MUST be translated as defined by SIIT <xref target="RFC6145"/>.
      In the network layer implementation alternative, protocol translator MUST translate ICMPv6 packets 
      to ICMPv4 and vice versa, and in the socket API implementation alternative, the socket API MUST
      handle conversions in similar fashion.
     </t>
    </section>

    <section title="IPv4 Address Pool and Mapping Table" anchor="ipv4pool">     
     <t>     
       The address pool consists of the <xref target="RFC1918"/> private IPv4 addresses.
       This pool can be implemented at different
       granularities in the node, e.g., a single pool per node, or at some
       finer granularity such as per-user or per-process.  In the case of
       a large number of IPv4 applications communicating with a large number of IPv6
       servers, the available address space may be exhausted if the granularity is
       not fine enough. This should be 
       a rare event and chances will decrease as IPv6 support increases.
       The applications may use IPv4 addresses they learn for a much longer period than DNS
       time-to-live indicates. Therefore, the mapping table entries should be kept
       active for a long period of time. For example, a web browser may initiate one DNS query and
       then create multiple TCP sessions over time to the address it learns. 
       When address mapping table clean-up is required, the BIH may utilize techniques
       used by network address translators, such as described in <xref target="RFC2663"/>,
       <xref target="RFC5382"/>, and <xref target="RFC5508"/>.
     </t>     

     <t>
       The RFC1918 address space was chosen because generally legacy
       applications understand it as a private address space. A new dedicated
       address space would run a risk of not being understood by applications as
       private. 127/8 and 169.254/16 are rejected due to possible assumptions 
       applications may make when seeing those.
     </t>
  
     <t>
       The RFC1918 addresses used by the BIH have a risk of conflicting with addresses 
       used in the host's possible IPv4 interfaces and corresponding local networks. The 
       conflicts can be mitigated, but not fully avoided, by using less commonly
       used portions of the RFC1918 address space.  Addresses from 172.16/12 are thought 
       to be less likely to be in conflict than addresses from 10/8 or 192.168/16 spaces. 
       A source address can usually be selected in a non-conflicting manner, but 
       a small possibility exists for synthesized destination addresses
       being in conflict with real addresses used in attached IPv4 networks. 
     </t>

     <t> 
       The RECOMMENDED IPv4 addresses are following:
     </t>

     <t>Primary source addresses: 172.21.112.0/20. Source addresses have to be
       allocated because applications use getsockname() calls and in the network layer 
       mode an IP address of the IPv4 interface has to be shown (e.g., by 'ifconfig'). More than
       one address is allocated to allow implementation flexibility, e.g., for
       cases where a host has multiple IPv6 interfaces. The source addresses
       are from different subnets than destination addresses to ensure applications 
       would not make on-link assumptions and would instead enable NAT traversal functions.
     </t>

     <t>Secondary source addresses: 10.170.224.0/20. These addresses are recommended
        if a host has a conflict with primary source addresses.
     </t>

     <t>Primary destination addresses: 10.170.160.0/20. The address mapper will
      select destination addresses primarily out of this pool.
     </t>
   
     <t>Secondary destination addresses: 172.21.80.0/20. The address mapper will
      select destination addresses out of this pool if the node has 
      a dual-stack connection conflicting with primary destination addresses.
     </t>
    </section>
        
    <section title="Multi-interface">
     <t>
       In the case of dual-stack destinations BIH MUST NOT do protocol 
       translation from IPv4 to IPv6 when the host has any 
       IPv4 interfaces, native or tunneled, available for use.
     </t>
     <t>
       It is possible that an IPv4 interface is activated during BIH operation,
       for example if a node moves to a coverage area of an IPv4-enabled network. 
       In such an event, BIH MUST stop initiating protocol
       translation sessions for new connections and BIH MAY disconnect active sessions. 
       The choice of disconnection is left for implementations and it may depend
       on whether IPv4 address conflict occurs between
       addresses used by BIH and addresses used by the new IPv4 interface.
     </t>
    </section>
  
    <section title="Multicast">
     <t>
       Protocol translation for multicast is not supported. 
     </t>
    </section>

 
   </section>     

      <section title="Application-Level Gateway requirements considerations">     

       <t>	
        No Application-Level Gateway (ALG) functionality is specified herein as ALG design is generally not encouraged
        for host-based translation and as BIH is intended for applications that do not include IP 
	addresses in protocol payloads.
       </t>

      </section>     
      
      <section title="IANA Considerations">     
          <t> There are no actions for IANA.</t>
      </section>     

      <section title="Security Considerations">     
 
          <t>The security considerations of BIH follows closely, but not completely, those of NAT64 <xref target="RFC6146"/> 
             and DNS64 <xref target="RFC6147"/>. The following sections are copied from RFC6146 and RFC6147 and modified
             for BIH scenario.</t>
           
          <section title="Implications on End-to-End Security">
              <t>Any protocols that protect IP header information are essentially
                 incompatible with BIH.  This implies that end-to-end IPsec
                 verification will fail when the Authentication Header (AH) is used
                 (both transport and tunnel mode) and when ESP is used in transport
                 mode.  This is inherent in any network-layer translation mechanism.
                 End-to-end IPsec protection can be restored, using UDP encapsulation
                 as described in [RFC3948].  The actual extensions to support IPsec
                 are out of the scope of this document.
              </t>
          </section>

          <section title="Filtering">
              <t>BIH creates binding state using packets flowing from the IPv4 side
                 to the IPv6 side.  In accordance with the procedures defined in this
                 document following the guidelines defined in [RFC4787], a BIH implementation MUST
                 offer "Endpoint-Independent Mapping".</t>
           
              <t>Implementations MAY also provide support for "Address-Dependent
                 Mapping" following the guidelines defined in [RFC4787].</t>

              <t>The security properties, however, are determined by which packets the
                 BIH allows in and which it does not.  The security
                 properties are determined by the filtering behavior and by the possible filtering
                 configuration in the filtering portions of the BIH, not by the
                 address mapping behavior.</t>
          </section>

          <section title="Attacks on BIH">
              <t>The BIH implementation itself is a potential victim of different types of
                 attacks. In particular, the BIH can be a victim of DoS attacks.
                 The BIH implementation has a limited number of resources that can be
                 consumed by attackers creating a DoS attack.  The BIH has a limited
                 number of IPv4 addresses that it uses to create the bindings.  Even
                 though the BIH performs address translation, it is
                 possible for an attacker to consume the synthetic IPv4 address pool
                 by triggering a host to issue DNS queries for names that cause
                 ENR to synthesise A records. DoS attacks
                 can also affect other limited resources available in the host running BIH such
                 as memory or link capacity.  For instance, it is possible for an
                 attacker to launch a DoS attack on the memory of the BIH running device by
                 sending fragments that the BIH will store for a given period.  If
                 the number of fragments is large enough, the memory of the host could
                 be exhausted. BIH implementations MUST implement proper
                 protection against such attacks, for instance, allocating a limited
                 amount of memory for fragmented packet storage.</t>

              <t>Another consideration related to BIH resource depletion refers to
                 the preservation of binding state.  Attackers may try to keep a
                 binding state alive forever by sending periodic packets that refresh
                 the state.  In order to allow the BIH to defend against such
                 attacks, the BIH implementation MAY choose not to extend the session entry
                 lifetime for a specific entry upon the reception of packets for that
                 entry through the external interface. However, such an action would 
                 not allow one-way communication sessions to stay alive.</t>
           </section>

           <section title="DNS considerations">
             <t>BIH operates in combination with the DNS, and is therefore subject
               to whatever security considerations are appropriate to the DNS mode
               in which the BIH is operating (i.e. recursive or stub-resolver mode).
             </t>

             <t>BIH has the potential to interfere with the functioning of DNSSEC,
                because BIH modifies DNS answers, and DNSSEC is designed to detect
                such modifications and to treat modified answers as bogus.
             </t>
           </section>
      </section>     

      <section title="Changes since RFC2767 and RFC3338">     
         <t>This document combines and obsoletes both <xref target="RFC2767"/> and <xref target="RFC3338"/>.
         </t>     
   
          <t>The changes in this document mainly reflect the following:

 	 <list style="hanging">
	    <t hangText="1. RFC1918 addresses used used for synthesis">
         	<vspace blankLines="1"/>
	        The RFC3338 used unassigned IPv4 addresses (e.g., 0.0.0.1 - 0.0.0.255) 
                for synthetic IPv4 addresses. Those addresses should not have been
                used and that may cause problems with applications. It is preferable
                to use RFC1918 defined addresses instead, as described in <xref target="ipv4pool"/>.
            </t>

	    <t hangText="2. Support for reverse (PTR) DNS queries">
         	<vspace blankLines="1"/>
                Neither RFC2767 or RFC3338 included support for reverse (PTR) DNS queries. 
                This document adds the support at <xref target="PTRquery"/>.
            </t> 

            <t hangText="3. DNSSEC support">
         	<vspace blankLines="1"/>
                RFC2767 did not include DNSSEC considerations, which are now included
                in <xref target="dnssecsupport"/>
            </t>

	    <t hangText="4. Architectural recommendation">
         	<vspace blankLines="1"/>
		This document recommends socket API layer implementation option over network layer
                translation, i.e. recommends approach introduced in RFC2767 over the approach of 
                RFC3338.
            </t>

	    <t hangText="5. Standards track document">
         	<vspace blankLines="1"/>
                RFC2767 is classified as Informational RFC and RFC3338 as Experimental RFC.
                It was discussed and decided in the IETF that this technology should
                be on the standards track.
            </t>

	    <t hangText="6. Set of other extensions and improvements">
         	<vspace blankLines="1"/>
		Set of lesser extensions, improvements, and clarifications have been introduced. 
                These include but are not limited to: IPv4 and IPv6 address exclusion sets
	        at <xref target="exclusions"/>, host's DNS cache considerations, ENR behaviour 
                updates, updated security considerations, example updates, and deployment 
		scenario updates.
            </t>

          </list>
          </t>        
      </section>

      <section title="Acknowledgments">     

        <t>The authors thank the discussion from Gang Chen, Dapeng Liu, Bo Zhou, 
        Hong Liu, Tao Sun, Zhen Cao, Feng Cao et al. in the development of this document.</t>

        <t>The efforts of
	Mohamed Boucadair, 
	Dean Cheng, 
	Lorenzo Colitti, 
	Paco Cortes,
	Ralph Droms,
	Stephen Farrell,
	Fernando Gont,
	Marnix Goossens, 
	Wassim Haddad,
	Ala Hamarsheh,
 	Dave Harrington,
	Ed Jankiewizh, 
	Suresh Krishnan, 
	Julien Laganier,
	Yiu L. Lee, 
	Jan M. Melen, 
	Qibo Niu, 
	Pierrick Seite, 
	Christian Vogt, 
	Magnus Westerlund,
	Dan Wing, 
	and James Woodyatt in reviewing this document are gratefully acknowledged.</t>
        
        <t>Special acknowledgements go to Dave Thaler for his extensive review and support.</t>
  
        <t>The authors of RFC2767 acknowledged WIDE Project, Kazuhiko YAMAMOTO, 
        Jun MURAI, Munechika SUMIKAWA, Ken WATANABE, and Takahisa MIYAMOTO. The authors
        of RFC3338 acknowledged implementation contributions by
        Wanjik Lee (wjlee@arang.miryang.ac.kr) and i2soft Corporation
        (www.i2soft.net).</t>

        <t>The authors of Bump-in-the-Wire (BIW) (draft-ietf-biw-00.txt, October 2006), 
        P. Moster, L. Chin, and D. Green, are acknowledged. Some ideas and clarifications
        from BIW have been adapted to this document.</t>      
      </section>     
      
   </middle>     

   <back>     
        <references title='Normative References'>     
        	&rfc1918;
        	&rfc2119;
        	&rfc2460;
        	&rfc4213;  
                &rfc4787;
	        &rfc6145;
          &rfc6146;
          &rfc6147;
       </references>       
   
       <references title="Informative References">
	        &rfc2663; 
        	&rfc2767;        	
        	&rfc3338;
                &rfc3493;
      	 	&rfc5508;
	      	&rfc5382;
	      	&rfc6180;
                &rfc5735;
		&rfc3948;
       </references>

         
 <section anchor="app-additional" title="API list intercepted by BIH">
 
   <t>The following informational list includes some of the API functions that would be appropriate
   to intercept by BIH module when implemented at the socket API layer. Please note that this list is
   not fully exhaustive, as the function names and services that are available on different
   APIs vary significantly. 
   </t>

   <t>The functions that the application uses to pass addresses into the
   system are:

      <list style="empty">
        <t>bind()</t>
        <t>connect()</t>
        <t>sendmsg()</t>
        <t>sendto()</t>  
        <t>gethostbyaddr()</t>
        <t>getnameinfo()</t>
      </list>
   </t>

   <t>The functions that return an address from the system to an
   application are:

      <list style="empty">
      <t>accept()</t>
      <t>recvfrom()</t>
      <t>recvmsg()</t>
      <t>getpeername()</t>
      <t>getsockname()</t>
      <t>gethostbyname()</t>
      <t>getaddrinfo()</t>
     </list>
   </t>

   <t>The functions that are related to socket options are:

      <list style="empty">
      <t>getsocketopt()</t>
      <t>setsocketopt()</t>
      </list>
   </t>

   <t>As well, raw sockets for IPv4 and IPv6 may be intercepted.</t>

   <t>
   Most of the socket functions require a pointer to the socket address
   structure as an argument.  Each IPv4 argument is mapped into
   corresponding an IPv6 argument, and vice versa.</t>

   <t>According to <xref target="RFC3493"/>, the following new IPv6 basic APIs and
   structures are required.</t>

     <figure title="" anchor="figappendix1"><artwork><![CDATA[   
      IPv4                     new IPv6
      ------------------------------------------------
      AF_INET                  AF_INET6
      sockaddr_in              sockaddr_in6
      gethostbyname()          getaddrinfo()
      gethostbyaddr()          getnameinfo()
      inet_ntoa()/inet_addr()  inet_pton()/inet_ntop()
      INADDR_ANY               in6addr_any
    ]]></artwork></figure>

   <t>BIH may intercept inet_ntoa() and inet_addr() and use the address
   mapper for those.  Doing that enables BIH to support literal IP
   addresses. However, IPv4 address literals can only be used after a mapping
   entry between the IPv4 address and corresponding IPv6 address
   has been created.</t>

   <t>The gethostbyname() and getaddrinfo() calls return a list of addresses.  When the name
   resolver function invokes getaddrinfo() and  getaddrinfo() returns	
   multiple IP addresses, whether IPv4 or IPv6, they should all be
   represented in the addresses returned by gethostbyname().  Thus if
   getaddrinfo() returns multiple IPv6 addresses, this implies that
   multiple address mappings will be created; one for each IPv6 address.
   </t>

   </section>
         
   </back>     
</rfc>     

