<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
    <!ENTITY rfc0768 PUBLIC '' 
      'http://xml.resource.org/public/rfc/bibxml/reference.RFC.0768.xml'>
    <!ENTITY rfc0793 PUBLIC '' 
      'http://xml.resource.org/public/rfc/bibxml/reference.RFC.0793.xml'>
    <!ENTITY rfc1644 PUBLIC '' 
      'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1644.xml'>
    <!ENTITY rfc1945 PUBLIC '' 
      'http://xml.resource.org/public/rfc/bibxml/reference.RFC.1945.xml'>
    <!ENTITY rfc2827 PUBLIC '' 
      'http://xml.resource.org/public/rfc/bibxml/reference.RFC.2827.xml'>
    <!ENTITY rfc3986 PUBLIC '' 
      'http://xml.resource.org/public/rfc/bibxml/reference.RFC.3986.xml'>
]>

<rfc category="info" ipr="full3978" docName="draft-gershenfeld-thtp-00.txt">

<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>

<?rfc toc="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes"?>
<?rfc iprnotified="no" ?>
<?rfc strict="no" ?>

    <front>
        <title abbrev="THTP">Trivial Hypertext Transfer Protocol (THTP)</title>

        <author initials='N.' surname="Gershenfeld" fullname='Neil Gershenfeld'>
            <organization abbrev="CBA/MIT">
                Massachusetts Institute of Technology
            </organization>
            <address>
                <postal>
                    <street>Room E15-411</street>
                    <street>20 Ames Street</street>
                    <city>Cambridge</city> <region>MA</region>
                    <code>02139</code>
                    <country>US</country>
                </postal>
                <phone>+1 617 253 0392</phone>
                <email>gersh@cba.mit.edu</email>
            </address>
        </author>

        <author initials='D.' surname="Johnson" fullname='Douglas Johnson'>
            <organization>Sun Microsystems, Inc.</organization>
            <address>
                <postal>
                <street>Mailstop UBUR02-306</street>
                <street>One Network Drive</street>
                <city>Burlington</city> <region>MA</region>
                <code>01803</code>
                <country>US</country>
                </postal>
                <phone>+1 781 442 0716</phone>
                <email>douglas.johnson@sun.com</email>
            </address>
        </author>

        <author initials='T.' surname="Snide" fullname='Todd Snide'>
            <organization abbrev="Schneider Electric">
                Schneider Electric
            </organization>
            <address>
                <postal>
                    <street>1 High Street</street>
                    <city>North Andover</city> <region>MA</region>
                    <code>01845</code>
                    <country>US</country>
                </postal>
                <phone>+1 978 975 9472</phone>
                <email>todd.snide@us.schneider-electric.com</email>
            </address>
        </author>

        <author initials='K.' surname="Lynn" fullname='Kerry Lynn'>
            <organization abbrev="Cisco">
                Cisco
            </organization>
            <address>
                <postal>
                    <street>1414 Massachusetts Avenue</street>
                    <city>Boxborough</city> <region>MA</region>
                    <code>01719</code>
                    <country>US</country>
                </postal>
                <phone>+1 978 936 1342</phone>
                <email>kelynn@cisco.com</email>
            </address>
        </author>

       <date month="October" year="2006"/>

<abstract><t>
THTP, the Trivial Hypertext Transfer Protocol, is an implementation of
HTTP over UDP transport.  THTP is designed for environments with
limited computational power or bandwidth and single-packet exchanges.
As such, THTP is best suited for the emerging class of applications
running on embedded devices and sensor networks.  THTP decouples HTTP
from TCP and provides a subset of HTTP's functionality, in particular
leveraging HTTP's URI naming scheme.  This document describes the
THTP protocol.
</t></abstract>
    </front>

    <middle>
<section title="Introduction">
<t>
The HTTP protocol <xref target="RFC1945"/> introduced a powerful
naming construct that simultaneously identifies and locates resources.
The anticipated proliferation of smart, tiny, networked devices
require a standards-based naming scheme <xref target="ieee-i0"/>,
<xref target="i0"/>, but often cannot tolerate the overhead
necessitated by the current tight coupling between HTTP and TCP <xref
target="RFC0793"/>.  Specifically, small, inexpensive embedded devices
and sensors receiving or sending single-packet commands and responses
require neither mandated reliable network transport nor packet
sequencing at the transport layer.  
</t>

<t>
For example, the application of a networked light switch sending an
"on" instruction to a networked light bulb in the same physical room
does not need the overhead of a TCP full three-way handshake.  In
addition, implementing TCP or even T/TCP <xref target="RFC1644"/> is
prohibitively expensive in terms of the communication and state
machine complexity on such a resource constrained computing platform.
</t>

<t>
This document details Trivial Hypertext Transfer Protocol or THTP, an
application-layer protocol.  THTP is a scaled-down adaptation of HTTP
designed to run over the UDP <xref target="RFC0768"/> transport layer.
It is not intended as a replacement of HTTP over TCP, but rather a
complementary scheme to widen the range of possible environments where
HTTP-like semantics are used.  For example, a similar but more complex
scheme is used by UPnP <xref target="upnp"/>; THTP codifies a simple,
portable, standards-based means of extending HTTP to UDP.  
</t>
</section>

<section title="THTP Design">

<t>
THTP is designed to be lightweight and easy for applications and
application designers to implement.  THTP uses HTTP's URI naming
scheme.  THTP differs from HTTP in several important ways.  These
differences are conscious design decisions based on THTP's intended
environment of limited computational power or bandwidth and
single-packet exchanges.  This section details critical aspects
of the THTP design.
</t>

<section title="Protocol Relationships">
<t>
THTP uses UDP <xref target="RFC0768"/> as its transport layer.  <xref
target="protocol"/> shows the relationship between THTP and various
Internet protocols.
</t>
<figure anchor="protocol">
    <preamble>Protocol Relationships</preamble>
    <artwork>
                 +-----+ +------+  +------+ +------+     +-----+
                 | FTP | | HTTP |  | TFTP | | THTP | ... | ... |
                 +-----+ +------+  +------+ +------+     +-----+
                     |     |            |     |             |
                    +-------+         +---------+        +-----+
                    |  TCP  |         |   UDP   | ...... | ... |
                    +-------+         +---------+        +-----+
                        |                  |                |
                    +------------------------------------------+
                    |          IP (Internet Protocol)          |
                    +------------------------------------------+
                             |                         |
               +------------------------+  +------------------------+
               | Local Network Protocol |  | Local Network Protocol |
               +------------------------+  +------------------------+
    </artwork>
</figure>
</section>

<section title="URI Format">
<t>
THTP defines a naming scheme analogous to HTTP's Uniform Resource
Locator (URL) which has been subsumed into the more abstract notion of
a Uniform Resource Identifier (URI) <xref target="RFC3986"/>.  THTP
leverages the URI naming and large base of existing implementations to
provide an efficient means of addressing and communicating with
devices in a range of environments. 
</t>

<t>
A THTP URI is semantically identically to those in HTTP, but with UDP
as transport.  The THTP URI format is defined as follows:
</t>

<figure>
<artwork>
  THTP_URI = "thtp:" "//" host [ ":" port ] [ abs_path [ "?" query]]
</artwork>
</figure>

<t>
THTP URIs are processed identically to HTTP URIs.  THTP uses
UDP port 80 by default, but may use other UDP ports via the
optional port specification in the URI.
</t>
</section>

<section title="Request Model">
<t>
In contrast to the request/response paradigm of HTTP, responses in
THTP are not required.  Responses may be either unnecessary or
implicit via an out-of-band channel.  Note that THTP does not preclude
request responses, however it explicitly separates the two functions.
A user may query the state of the light bulb remotely, receive a
notification that the filament is burned out, or require a device to
periodically report its status via THTP.  The separation of request
and response in THTP has several design implications, most notably on
reliability and message size.
</t>

<t>
A THTP message must fit entirely in a single UDP packet.  THTP cannot
transfer data larger than a single packet in a single request.
Applications that require ordered delivery, large messages, flow
control or congestion control should use HTTP (over TCP).  Multiple
messages cannot be placed within a single THTP packet.  As such,
"chunked" transfer-coding is not allowed.
</t>
</section>

<section title="Reliability">
<t>
THTP uses UDP as its transport layer.  Since UDP is an unreliable
transport protocol and THTP does not include reliability, THTP makes
no guarantees of packet delivery.  For example, light switches
and home appliances, the user receives immediate feedback: the room
illuminates, therefore the request over the network was successful. If
the packet is lost and the light bulb does not light, the user can
actuate the light switch again.  
</t>

<t>
However, THTP does not preclude reliability at other layers where
necessary to support specific applications.  Consider for example an
application that requires lightweight, reliable single-message passing
but not ordered delivery.  Such an application could use THTP in
conjunction with reliability at the physical or application layer.  In
addition, automated systems without an out-of-band feedback mechanism
require additional verification, either by actively querying the state
of the remote device or by adding application layer reliability.  
</t>
</section>

<section title="Multicast">
  <t>
  Because THTP uses UDP, it is possible to send a THTP message to 
  a multicast group address.  Assuming the underlying data-link layer
  network supports broadcast or multicast transmission, a single
  THTP message could be sent to, and received by, multiple nodes.
  An immediately practical application is to assign locally scoped
  multicast group addresses to a set of nodes.  For example, a 
  single light switch might send a THTP "on" instruction to multicast
  group M.  All light bulbs assigned to group M would receive the
  message and switch on.  While Internet multicast deployment is
  limited, THTP multicast messages are useful in many local
  area networks.
  </t>
</section>
</section>


<section title="HTTP Features">
<t>
THTP must implement a minimum subset of HTTP's features,
but is not required to implement all of HTTP.   The 
subset of features THTP must support are a natural 
consequence of using UDP and maintaining simplicity.
Additional HTTP mechanisms may be implemented on an
application specific basis by prearrangement.  However,
a THTP server may always legally respond with the status code 
501 (not implemented) as needed.  Status codes are
documented in <xref target="status_codes"/>.
</t>

<t>
At a minimum, THTP clients and servers must support the
HTTP GET and POST methods.  A server must always respond
to a GET request or provide the appropriate status code
error.  A server may respond to a POST request or 
provide the appropriate status code error.  A server must
respond with an error on an error event regardless of
the method type.
</t>

<section title="GET Method">
<t>
THTP and HTTP's use of the GET method are identical.  THTP must
support the GET method.  A THTP GET request from a client expects a
response and the server must send the requested object identified by
the Request-URI or an error.  If the Request-URI refers to a
data-producing process, the data from that process is returned.
</t>

<t>
To send information from the client to the server process, a client
may imbed that information in the HTTP URI and use the GET method.
The user agent appends a '?' to the action URI along with the data set
in `application/x-www-form-urlencoded' format.  
</t>

<t>
THTP may support "conditional GET" in instances where cached 
entities can be used without consuming unneeded network bandwidth
</t>
</section>

<section title="POST Method">
<t>
THTP must also accept the POST method, but uses POST in a slightly
different manner than HTTP.  A THTP server may respond to a
successful POST, but is not required to do so.  The optional response
covers cases where the client is not expecting a response and where
communication resources are scarce, for instance sensor nodes.  In
the case of a lightbulb and lightswitch, a POST request may be used
to change the state of the light and does not require a response.
However, a THTP server must always respond with an error status
code on an error condition.
</t>

<t>
The POST method requests that the destination server process the data
within the request as a subordinate of the the Request-URI resource.
To perform an action with a POST, the user agent uses the action URI
and adds a message body of type `application/x-www-form-urlencoded'.  
</t>

</section>

<section title="Status Code Definitions" anchor="status_codes">
<t>
THTP uses the same status codes as defined by HTTP.  THTP 
servers must implement the following status codes at a
minimum:
</t>

 <section title="Successful 2xx">
 <t>
   200 OK

   The 200 successful status code differs slightly from that 
   in HTTP due to it being optional for POST requests.   Code
   200 indicates that the request has succeeded.  A successful 
   GET request must 
   result in response containing the 200 status code along the
   information queried.  A
   POST request may return a 200 status code.
 </t>
 </section>
 <section title="Client Error 4xx">
 <t>
   400 Bad Request

   The request is malformed and rejected by the server.

   404 Not Found

   The request cannot be honored by the server because the
   requested resource is not available.
 </t>
 </section>
 <section title="Server Error 5xx">
 <t>
 501 Not Implemented

   The request cannot be honored by the server because the
   server does not support the requested functionality.  Such
   an error may occur for unsupported methods.
 </t>
 </section>
</section>

<section title="Proxies">
  <t>
  THTP messages may be proxied.  Proxies are a natural consequence
  of interconnecting a local area network, e.g. for home automation,
  with the larger Internet.  
  </t>
</section>

<section title="Caching">
  <t>
  HTTP explicitly allows and makes provisions for content caching.  A request
  may be honored by an intermediary other than the final recipient.
  When cached, the response comes from this intermediary.  Clearly, in
  THTP's intended environments such as control and automation networks,
  caching is not expected.  Caching is not explicitly forbidden, but
  THTP's request model anticipates all requests to be carried through to
  the final recipient,
  </t>
</section>

</section>


<section title="Security Considerations">
<t>
Since THTP is implemented on top of UDP, many of the security
issues inherent in UDP are inherited by THTP.  By eliminating the
minimal source validation afforded by the three-way handshake of
TCP, THTP is vulnerable to source IP address spoofing.  Without a
stronger means of authentication, THTP must rely on provider
ingress filtering <xref target="RFC2827"/>.  Instead, THTP may
use appropriate lightweight encryption <xref target="sea"/>
and/or authentication.
</t>

</section>

    </middle>

    <back>
        <references>
        &rfc0768;
        &rfc0793;
        &rfc1644;
        &rfc1945;
        &rfc2827;
        &rfc3986;

       <reference anchor="upnp">
           <front>
               <title>Universal Plug N' Play Forum</title>
               <author initials="Y." surname="Goland"
                       fullname="Yaron Goland">
                   <organization abbrev="CrossGain">
                   CrossGain
                   </organization>
               </author>
               <author initials="J." surname="Schlimmer"
                       fullname="Jeffrey Schlimmer">
                   <organization abbrev="Microsoft">
                   Microsoft
                   </organization>
               </author>
           </front>
               <seriesInfo name="http://www.upnp.org/" value="" />
           <format type='HTML' target='http://www.upnp.org/' />
       </reference>

       <reference anchor="i0">
           <front>
               <title>The Internet of Things</title>
               <author initials="N." surname="Gershenfeld"
                       fullname="Neil Gershenfeld">
                   <organization abbrev="MIT">
                   MIT/Center for Bits and Atoms
                   </organization>
               </author>
               <author initials="R." surname="Krikorian"
                       fullname="Raffi Krikorian">
                   <organization abbrev="MIT">
                   MIT/Center for Bits and Atoms
                   </organization>
               </author>
               <author initials="D." surname="Cohen"
                       fullname="Danny Cohen">
                   <organization abbrev="Sun">
                   Sun Microsystems
                   </organization>
               </author>
               <date month="October" year="2004" />
           </front>
           <seriesInfo name="Scientific American" value="" />
           <format type='HTML'
                target='http://www.sciam.com/article.cfm?chanID=sa006&colID=1&articleID=00023B66-5F28-1150-902F83414B7F4945' />
       </reference>

       <reference anchor="ieee-i0">
           <front>
               <title>Internet 0: Interdevice Internetworking</title>
               <author initials="N." surname="Gershenfeld"
                       fullname="Neil Gershenfeld">
                   <organization abbrev="MIT">
                   MIT/Center for Bits and Atoms
                   </organization>
               </author>
               <author initials="D." surname="Cohen"
                       fullname="Danny Cohen">
                   <organization abbrev="Sun">
                   Sun Microsystems
                   </organization>
               </author>

               <date month="October" year="2006" />
           </front>
           <seriesInfo name="IEEE Circuits and Systems" value="" />
       </reference>

       <reference anchor="sea">
           <front>
               <title>SEA: a Scalable Encryption Algorithm for Small Embedded Applications</title>
               <author initials="F." surname="Standaert"
                       fullname="François-Xavier Standaert">
               </author>

               <author initials="G." surname="Piret"
                       fullname="Gilles Piret">
               </author>

               <author initials="N." surname="Gershenfeld"
                       fullname="Neil Gershenfeld">
                   <organization abbrev="MIT">
                   MIT/Center for Bits and Atoms
                   </organization>
               </author>

               <author initials="J." surname="Quisquater"
                       fullname="Jean-Jacques Quisquater">
               </author>
               <date month="April" year="2006" />
           </front>
           <seriesInfo name="CARDIS" value="" />
           <format type='HTML'
             target='http://www.di.ens.fr/~piret/publ/cardis2006.pdf#search=%22SEA%3A%20a%20Scalable%20Encryption%20Algorithm%20for%20Small%22' />
       </reference>
        </references>

<section title="Acknowledgments">
<t>The authors gratefully acknowledge the contributions of 
(alphabetically):
Robert Beverly,
Danny Cohen,
David Dalrymple,
and
Karen Sollins.
</t>
</section>

    </back>
</rfc>
