<?xml version="1.0"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">

<?rfc compact="yes"?>
<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc subcompact="no"?>
<?rfc symrefs="yes"?>

<rfc ipr="trust200902" docName="draft-perreault-dtnrg-http-00" category="exp">

  <front>

    <title abbrev="HTTP over BP">HTTP over Bundle Protocol for Delay-Tolerant
      Networks (DTN)</title>

    <author initials="S." surname="Perreault" fullname="Simon Perreault">
      <organization>Viagénie</organization>
      <address>
        <postal>
          <street>246 Aberdeen</street>
          <city>Québec</city>
          <region>QC</region>
          <code>G1R 2E1</code>
          <country>Canada</country>
        </postal>
        <phone>+1 418 656 9254</phone>
        <email>simon.perreault@viagenie.ca</email>
        <uri>http://viagenie.ca</uri>
      </address>
    </author>

    <author initials="J-P." surname="Dionne" fullname="Jean-Philippe Dionne">
      <organization>Viagénie</organization>
      <address>
        <postal>
          <street>246 Aberdeen</street>
          <city>Québec</city>
          <region>QC</region>
          <code>G1R 2E1</code>
          <country>Canada</country>
        </postal>
        <phone>+1 418 656 9254</phone>
        <email>simon.perreault@viagenie.ca</email>
        <uri>http://viagenie.ca</uri>
      </address>
    </author>

    <date/>

    <abstract>
      <t>This document defines how HTTP is transported over DTN using the Bundle
        Protocol.</t>
    </abstract>

  </front>

  <middle>

    <section title="Introduction">

      <t>The Hypertext Transfer Protocol (HTTP) <xref target="RFC2616"/> is the
        most popular application-layer protocol on the Internet.  Porting it to
        DTN will allow a tremendous body of knowledge and running code to be
        reused.</t>

      <t>This document describes how HTTP messages are formatted and then
        inserted into the payload of the bundles (see Bundle Protocol <xref
          target="RFC5050"/>).</t>

      <t>HTTP over BP can be used directly by BP nodes as illustrated in <xref
          target="direct"/>.</t>

      <figure anchor="direct" title="Direct Usage Scenario">
        <artwork><![CDATA[
                +-------+              +-------+
                |HTTP/BP|              |HTTP/BP|
                |client |=====<BP>=====|server |
                +-------+              +-------+
]]></artwork>
      </figure>

      <t>Regular HTTP clients and servers can also be accomodated using an
        HTTP/BP proxy as illustrated in <xref target="proxy"/>. In this case,
        the proxy speaks BP on one side and IP on the other (and presumably
        TCP, although HTTP can make use of other transport protocols over IP).
        From the point of view of the regular HTTP client and server, the two
        HTTP/BP proxies and the BP link are seen as one logical regular HTTP
        proxy.</t>

      <figure anchor="proxy" title="Proxied Usage Scenario">
        <artwork><![CDATA[

                +--------Logical HTTP proxy--------+
+------+        | +-------+              +-------+ |        +------+
| HTTP |        | |HTTP/BP|              |HTTP/BP| |        | HTTP |
|client|---<IP>---| proxy |=====<BP>=====| proxy |---<IP>---|server|
+------+        | +-------+              +-------+ |        +------+
                +----------------------------------+
]]></artwork>
      </figure>

    </section>

    <section title="Example Use Case">

      <t>DTN is often applied to space networking scenarios. <xref
          target="scenario"/> shows one such application.</t>

      <figure title="Use of HTTP over BP in a Space DTN" anchor="scenario">
        <artwork><![CDATA[
+--------+  +------------+                +-----------+  +------------+
| Sensor |--| Spacecraft |------<BP>------|  Mission  |--| Monitoring |
| (HTTP  |  +----+-------+                | operation |  |  station   |
| server)|       |HTTP/BP|                +-------+--+   |  (HTTP     |
+--------+       | proxy |                |HTTP/BP|      |  client)   |
                 +-------+                | proxy |      +------------+
                                          +-------+

|-----------IP-----------|                |------------IP-------------|



<-------------------------------------- GET /sensors/heartbeat HTTP/1.1
                                        Host: sensor.example.net

HTTP/1.1 200 OK ------------------------------------------------------>
Content-Length: ...
Content-Type: text/html

...
]]></artwork>
      </figure>

      <t>In this example, a mission operation IP network is linked to a
        spacecraft IP network using BP. Each BP endpoint is augmented with an
        HTTP/BP proxy allowing HTTP to operate end-to-end, across the DTN, from
        one IP network to another. This enables, for example, a monitoring
        station on the ground to access a sensor on the spacecraft using regular
        HTTP interfaces. BP is transparent to them and they can be programmed
        to use HTTP without having to care about the details of DTN.</t>

      <t>This is only one use case. The logical scenarios illustrated in <xref
          target="direct"/> and <xref target="scenario"/> can be applied to any
        DTN deployment.</t>

    </section>

    <section title="Design Considerations">

      <section title="Requirements">

        <t>It is intended that the format described in this document have the
          following features:
          <list style="symbols">
            <t>Support for partial HTTP messages because HTTP message length can
              be larger than bundle payload length.</t>
            <t>Support for multiple HTTP messages per bundle for efficiency
              purposes.</t>
            <t>Support for infinite-length HTTP messages because those HTTP
              messages are used, for example, in media streaming.</t>
            <t>Support for pre-fetching related HTTP resources so as to reduce
              round-trips, which is very important in DTN. In a disconnected
              network, it may be very useful to pre-fetch some data during the
              windows when communications are possible.</t>
          </list>
        </t>

      </section>

      <section title="HTTP over TLS">

        <t>HTTP over TLS is implicitly supported with the CONNECT method <xref
            target="RFC2817"/>. Note that the use of encryption will defeat
          optimizations such as pre-fetching that HTTP/BP proxies can provide
          with non-encrypted HTTP.</t>

      </section>

    </section>

    <section title="Message Format">

      <t>HTTP over BP occupies the payload block (<xref target="RFC5050"/>
        section 4.5.3). The whole block consists of a series of TLVs
        (Type-Length-Value). Each TLV has the following format:</t>

      <figure anchor="TLV" title="Generic TLV Format" align="center">
        <artwork>
+----------------+---------------+
|      Type      |    Length     |
+----------------+---------------+
:                                :
:             Value              :
:                                :
        </artwork>
      </figure>

      <t>
        <list style="hanging">
          <t hangText="Type:">An SDNV identifying the TLV type.</t>
          <t hangText="Length:">An SDNV containing the length of the Value
            field, in bytes.</t>
          <t hangText="Value:">Zero or more bytes whose meaning depends on the
            Type SDNV.</t>
        </list>
      </t>

      <t>Multiple such TLVs MAY be included in a bundle's payload block. There
        is no limit on the number of TLVs besides pre-existing limits on bundle
        size.</t>

      <t>This document defines types 0, 1, and 2. Other types MAY be defined in
        the future. An implementation of HTTP over BP MUST completely ignore
        any TLV whose type is unknown.</t>

      <section title="Piece">

        <t>The Piece TLV contains a piece of HTTP message. Its type is 0. It
          has the following format:</t>

        <figure anchor="Piece" title="Piece Format" align="center">
          <artwork>
+----------------+---------------+
|     Type (0)   |    Length     |
+----------------+---------------+
|       RID      |    Offset     |
+----------------+---------------+
:                                :
:          Piece of HTTP         :
:                                :
          </artwork>
        </figure>

        <t>Note that the Length field includes the RID and Offset fields.
          <list style="hanging">
            <t hangText="RID (Request ID):">An SDNV uniquely identifying the
              request/response exchange.</t>
            <t hangText="Offset:">An SDNV indicating, in the full HTTP message,
              the number of bytes coming before the first byte in this
              piece.</t>
          </list>
        </t>

        <t>Following this is the piece of HTTP message itself. The HTTP message
          includes the headers and the body, and there is no limitation on where
          a piece begins or ends. Therefore, the HTTP headers MAY be split among
          multiple pieces, likewise for the body, and a piece MAY contain part
          of the headers and body simultaneously. A receiver MUST be prepared to
          handle all possible cases.</t>

        <t>HTTP relies on the transport-layer protocol to associate responses
          with requests. Since BP is inherently connectionless, a new mechanism
          is necessary for this purpose: the Request ID. The client sending a
          request MUST generate an ID such that the 3-tuple comprising the
          source EID, the destination EID, and the RID is unique across time.
          The server will respond with the same RID.</t>

        <t>An HTTP message MAY be split into as many pieces as the sender
          desires.  Note that some HTTP messages are effectively infinite in
          length (e.g., a response containing live streaming video).</t>

        <t>Pieces MAY not be all the same size and MAY be sent out of order.
          Note also that bundles may be reordered during transport. In
          consequence, the receiver MUST reassemble the pieces using the offset
          and length values.</t>

        <t>The sender MUST NOT send overlapping pieces. If any overlap is
          detected by the receiver, the message SHOULD be dropped.</t>

        <t>The total length of the HTTP message is not available at the bundling
          layer.  The receiver will determine the total length of the HTTP
          message in an HTTP-specific manner (e.g., for HTTP 1.1 see <xref
            target="RFC2616"/> section 4.4).</t>

      </section>

      <section title="Close">

        <t>The Close TLV is used to indicate the termination of an HTTP
          exchange. It plays a role analogous to the RST flag in TCP. Its type
          is 1. Its format is as follows:</t>

        <figure anchor="Close" title="Close Format" align="center">
          <artwork>
+----------------+---------------+
|     Type (1)   |    Length     |
+----------------+---------------+
|       RID      |    Offset     |
+----------------+---------------+
          </artwork>
        </figure>

        <t>The RID SDNV indicates the request/response exhange that is being
          terminated.</t>

        <t>The Offset SDNV indicates the number of bytes that are to be received
          before the HTTP exchange is closed. An Offset of zero means that the
          Close takes effect immediately, no matter how many bytes have been
          received.</t>

        <t>An HTTP/BP proxy SHOULD send a Close TLV when the corresponding
          connection on the IP side (TCP, SCTP, or other) is terminated before
          the HTTP request/response exchange has completed, unless it has
          already sent or received a Close TLV for this RID.</t>

      </section>

      <section title="Prefetch">

        <t>It is often important on the DTN to eliminate as many round-trips as
          possible. With HTTP, many heuristics can be used to this end. For
          example, one technique consists in transferring multiple related HTTP
          resources across the DTN in anticipation of future requests for them.
          For a local cache to be able to correctly compute the cacheability
          properties of a resource, it must have access to the request and
          response headers.</t>

        <t>The Prefetch TLV contains an HTTP request concatenated with the
          corresponding HTTP response. Its format is as follows:</t>
         
        <figure anchor="Prefetch" title="Prefetch Format" align="center">
          <artwork>
+----------------+---------------+
|     Type (2)   |    Length     |
+----------------+---------------+
|                                |
/           HTTP request         /
/                                /
|                                |
+--------------------------------+
|                                |
/           HTTP response        /
/                                /
|                                |
+--------------------------------+
          </artwork>
        </figure>

        <t>The Type SDNV has value 2.</t>

        <t>The request and response contained in the Prefetch TLV MUST NOT be
          infinite in length.</t>

        <t>The mechanisms that trigger Prefetch TLVs on the sender side, as well
          as the way they are interpreted on the receiver side are out of scope
          for this document.</t>

      </section>

      <section title="Reliability">

        <t>HTTP depends on the transport protocol (traditionally TCP) to provide
          reliability. Over BP, custody transfer SHOULD be used.</t>

        <t>Implementations of HTTP over BP SHOULD provide user-configurable
          timeouts for each HTTP transaction state item that is created. An HTTP
          transaction SHOULD be aborted after a user-specified period of
          inactivity. The timeouts MAY be much longer than what is commonly used
          with TCP.</t>

        <t>Implementations MAY set bundle lifetimes based on the value of the
          Expires HTTP header and/or the Cache-Control "max-age" parameter, when
          they are present.</t>

      </section>

    </section>

  </middle>

  <back>

    <references>

      <reference anchor='RFC2616'>
        <front>
          <title abbrev='HTTP/1.1'>Hypertext Transfer Protocol -- HTTP/1.1</title>
          <author initials='R.' surname='Fielding' fullname='Roy T. Fielding'>
            <organization abbrev='UC Irvine'>Department of Information and Computer Science</organization>
            <address>
              <postal>
                <street>University of California, Irvine</street>
                <city>Irvine</city>
                <region>CA</region>
                <code>92697-3425</code></postal>
              <facsimile>+1(949)824-1715</facsimile>
              <email>fielding@ics.uci.edu</email></address></author>
          <author initials='J.' surname='Gettys' fullname='James Gettys'>
            <organization abbrev='Compaq/W3C'>World Wide Web Consortium</organization>
            <address>
              <postal>
                <street>MIT Laboratory for Computer Science, NE43-356</street>
                <street>545 Technology Square</street>
                <city>Cambridge</city>
                <region>MA</region>
                <code>02139</code></postal>
              <facsimile>+1(617)258-8682</facsimile>
              <email>jg@w3.org</email></address></author>
          <author initials='J.' surname='Mogul' fullname='Jeffrey C. Mogul'>
            <organization abbrev='Compaq'>Compaq Computer Corporation</organization>
            <address>
              <postal>
                <street>Western Research Laboratory</street>
                <street>250 University Avenue</street>
                <city>Palo Alto</city>
                <region>CA</region>
                <code>94305</code></postal>
              <email>mogul@wrl.dec.com</email></address></author>
          <author initials='H.' surname='Frystyk' fullname='Henrik Frystyk Nielsen'>
            <organization abbrev='W3C/MIT'>World Wide Web Consortium</organization>
            <address>
              <postal>
                <street>MIT Laboratory for Computer Science, NE43-356</street>
                <street>545 Technology Square</street>
                <city>Cambridge</city>
                <region>MA</region>
                <code>02139</code></postal>
              <facsimile>+1(617)258-8682</facsimile>
              <email>frystyk@w3.org</email></address></author>
          <author initials='L.' surname='Masinter' fullname='Larry Masinter'>
            <organization abbrev='Xerox'>Xerox Corporation</organization>
            <address>
              <postal>
                <street>MIT Laboratory for Computer Science, NE43-356</street>
                <street>3333 Coyote Hill Road</street>
                <city>Palo Alto</city>
                <region>CA</region>
                <code>94034</code></postal>
              <email>masinter@parc.xerox.com</email></address></author>
          <author initials='P.' surname='Leach' fullname='Paul J. Leach'>
            <organization abbrev='Microsoft'>Microsoft Corporation</organization>
            <address>
              <postal>
                <street>1 Microsoft Way</street>
                <city>Redmond</city>
                <region>WA</region>
                <code>98052</code></postal>
              <email>paulle@microsoft.com</email></address></author>
          <author initials='T.' surname='Berners-Lee' fullname='Tim Berners-Lee'>
            <organization abbrev='W3C/MIT'>World Wide Web Consortium</organization>
            <address>
              <postal>
                <street>MIT Laboratory for Computer Science, NE43-356</street>
                <street>545 Technology Square</street>
                <city>Cambridge</city>
                <region>MA</region>
                <code>02139</code></postal>
              <facsimile>+1(617)258-8682</facsimile>
              <email>timbl@w3.org</email></address></author>
          <date year='1999' month='June' />
          <abstract>
            <t>
              The Hypertext Transfer Protocol (HTTP) is an application-level
              protocol for distributed, collaborative, hypermedia information
              systems. It is a generic, stateless, protocol which can be used for
              many tasks beyond its use for hypertext, such as name servers and
              distributed object management systems, through extension of its
              request methods, error codes and headers . A feature of HTTP is
              the typing and negotiation of data representation, allowing systems
              to be built independently of the data being transferred.
            </t>
            <t>
              HTTP has been in use by the World-Wide Web global information
              initiative since 1990. This specification defines the protocol
              referred to as "HTTP/1.1", and is an update to RFC 2068 .
        </t></abstract></front>
        <seriesInfo name='RFC' value='2616' />
        <format type='TXT' octets='422317' target='http://www.rfc-editor.org/rfc/rfc2616.txt' />
        <format type='PS' octets='5529857' target='http://www.rfc-editor.org/rfc/rfc2616.ps' />
        <format type='PDF' octets='550558' target='http://www.rfc-editor.org/rfc/rfc2616.pdf' />
        <format type='HTML' octets='636125' target='http://xml.resource.org/public/rfc/html/rfc2616.html' />
        <format type='XML' octets='493420' target='http://xml.resource.org/public/rfc/xml/rfc2616.xml' />
      </reference>

      <reference anchor='RFC2817'>
        <front>
          <title>Upgrading to TLS Within HTTP/1.1</title>
          <author initials='R.' surname='Khare' fullname='R. Khare'>
            <organization /></author>
          <author initials='S.' surname='Lawrence' fullname='S. Lawrence'>
            <organization /></author>
          <date year='2000' month='May' />
          <abstract>
            <t>This memo explains how to use the Upgrade mechanism in HTTP/1.1 to initiate Transport Layer Security (TLS) over an existing TCP connection. [STANDARDS-TRACK]</t></abstract></front>
        <seriesInfo name='RFC' value='2817' />
        <format type='TXT' octets='27598' target='http://www.rfc-editor.org/rfc/rfc2817.txt' />
      </reference>

      <reference anchor='RFC5050'>
        <front>
          <title>Bundle Protocol Specification</title>
          <author initials='K.' surname='Scott' fullname='K. Scott'>
            <organization /></author>
          <author initials='S.' surname='Burleigh' fullname='S. Burleigh'>
            <organization /></author>
          <date year='2007' month='November' />
          <abstract>
            <t>This document describes the end-to-end protocol, block formats, and abstract service description for the exchange of messages (bundles) in Delay Tolerant Networking (DTN).&lt;/t>&lt;t> This document was produced within the IRTF's Delay Tolerant Networking Research Group (DTNRG) and represents the consensus of all of the active contributors to this group. See http://www.dtnrg.org for more information. This memo defines an Experimental Protocol for the Internet community.</t></abstract></front>
        <seriesInfo name='RFC' value='5050' />
        <format type='TXT' octets='120435' target='http://www.rfc-editor.org/rfc/rfc5050.txt' />
      </reference>

    </references>

  </back>

</rfc>
