<?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 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-01.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 Systems
            </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="December" year="2007"/>

<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
URI naming.  This document describes
the THTP protocol.
</t></abstract>
    </front>

    <middle>

<section title="Introduction">
<t>
This memo 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 expand HTTP-like semantics to a wider 
range of possible environments.
</t>
</section>


<section title="Motivation">
<t>
HTTP <xref target="RFC1945"/> provides a powerful naming construct
that simultaneously identifies and locates resources.  However,
the tight coupling between HTTP and TCP necessitates TCP's 
protocol overhead and state machine complexity.  
Decoupling HTTP from TCP enables a well-standardized protocol 
to operate in a wider range of environments and devices.
</t>

<t>
For example, 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
large amounts of overhead.  In addition the communication requirements
and patterns of small, inexpensive devices and sensors may differ from
traditional network participants.  Specifically, 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>
Consider the application of a light switch using IP to communicate
with a light bulb over a network.   The light switch sending an "on"
instruction to the 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>
Rather than requiring constrained devices or
environments to implement a new lightweight protocol, 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, however 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 MUST BE processed identically to HTTP URIs.  THTP SHOULD
use 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>
THTP explicitly separates requests and responses.  While HTTP uses a
request/response paradigm, responses in THTP are not required.
Responses may be either unnecessary or implicit via an out-of-band
channel.  For instance, a THTP request to turn a light bulb "on" does
not require a response.  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, notably on reliability and message size.  
</t>

<t>
A THTP request MAY generate a THTP response.  Because THTP uses
UDP, requests and responses do not have congestion control.
Therefore, THTP responses MUST NOT be sent without a THTP request.
</t>

<t>
A THTP message MUST fit entirely in a single UDP packet (one PDU).
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. 
"Chunked" transfer-coding MUST NOT be used.  
</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.  In many instances where THTP will
be used, reliability is not required.  For example, a user turning a
light switch receives immediate feedback: the room illuminates,
therefore the request over the network was successful. If the packet
is corrupted or 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.  An
application MAY implement THTP on top of THTP.  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, THTP MAY use multicast group addresses.
  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 process 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 implements a minimum subset of HTTP's features, but is not
required to implement all of HTTP.   The subset of features THTP
supports are a natural consequence of using UDP and maintaining
simplicity.  
</t>

<t>
THTP clients and servers MUST support the HTTP GET and POST methods
and MAY support other 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.  A THTP server MUST always legally
respond with the status code 501 (not implemented) for requests it
cannot process as needed.  Status codes are documented in <xref
target="status_codes"/>.  
</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 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 for POST.
</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.  Because THTP's request
  model anticipates all requests to be carried through to the final
  recipient, THTP SHOULD NOT be cached.
  </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 MAY rely on ingress filtering <xref
target="RFC2827"/> of source addresses.  Enterprises MAY use transport
layer packet filtering to keep all THTP internal to their private
intranet.  For example, a packet filter rule on the enterprise gateway
would block UDP port 80 traffic from entering or exiting the intranet.
</t>

<t>
Applications that require strong encryption and/or authentication
MAY employ appropriate lightweight encryption <xref target="sea"/>.
</t>

</section>

    </middle>

    <back>
        <references>
        &rfc0768;
        &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>
