CoRE | K. Li |
Internet-Draft | Huawei Technologies |
Intended status: Standards Track | X. Sun |
Expires: July 30, 2013 | China Telecom |
January 26, 2013 |
CoAP Payload-Length Option Extension
draft-li-core-coap-payload-length-option-01
This document defines an extension to the Constrained Application Protocol (CoAP) to add one new option: Payload-Length, which is used to indicate the length of the payload of the message.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet- Drafts is at http:/⁠/⁠datatracker.ietf.org/⁠drafts/⁠current/⁠.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on July 30, 2013.
Copyright (c) 2013 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http:/⁠/⁠trustee.ietf.org/⁠license-⁠info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
This specification adds one new option to the Constrained Application Protocol (CoAP): Payload-Length.
If a CoAP message is transported through UDP, the message length can be obtained from the UDP header. But not all transport mechanisms provide an unambiguous length of the CoAP message. For example, in industry field, there are some data tranport protocols, like RS232, RS422, RS485, which don't provide message length indication. For these cases, an indication of the payload length of the message is needed in CoAP message level.
TBD: how about CAN bus protocol, USB 2.0?
With this option, it will be easier for the receiver to extract the payload part from the whole message.
Another benefit to have this option is to check the integrity of the message length.
To indicate the payload length, another alternative is to use encoding method as specified in section 3.2 of [I-D.ietf-core-coap], but it is better to use an Option for this.
Reason is that, payload length is an optional feature, and in most of the cases, it is not necessary to be indicated. If we use encoding method, every implementation needs to support this encoding for the payload, not only for the options. If we use an Option for this, it is optional, and it can be optionally implemented where necessary.
The terms CoAP Server and CoAP Client are used synonymously to Server and Client as specified in the terminology section of [I-D.ietf-core-coap].
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].
+------+---+---+---+---+----------------+--------+--------+---------+ | Type | C | U | N | R | Name | Format | Length | Default | +------+---+---+---+---+----------------+--------+--------+---------+ | TBD | - | - | - | - | Payload-Length | uint | 0-2 B | (none) | +------+---+---+---+---+----------------+--------+--------+---------+
If this option is present, the value of this option is an unsigned integer giving the length of the payload of the message. Note that this integer can be zero for a zero-length payload, which can in turn be represented by a zero-length option value.
The Payload-Length option does not have a default value, so in case of its absence the receiver MUST determine the payload length through other means. This is to keep backward compatibility. If the option is absent, the payload can have any size, and the payload length needs to be determined as it is currently done for UDP.
The minimum payload length is 0, and the maximum payload length is 2^16-1= 65535.
In case that the transport layer does not provide message length indication, the Payload-Length option SHOULD be included in the CoAP message. Otherwise, it MAY be included.
This options can be used both in the request and response.
This option MUST NOT occur more than once.
In the example below, in the GET request, the payload is empty, so the Payload-Length option has a zero-length option payload. In the response, the payload is "22.3 C", and the Payload-Length is 6.
Client Server | | | | +----->| Header: GET (T=CON, Code=1, MID=0x7d38) | GET | Token: 0x53 | | Uri-Path: "temperature" | | Payload-Length: 0 | | |<- - -+ Header: (T=ACK, Code=0, MID=0x7d38) | | | | |<-----+ Header: 2.05 Content (T=CON, Code=69, MID=0xad7b) | 2.05 | Token: 0x53 | | Payload: "22.3 C" | | Payload-Length: 6 | | | | +- - ->| Header: (T=ACK, Code=0, MID=0xad7b) | |
The IANA is requested to add the following option number entries:
+--------+----------------+----------------------------+ | Number | Name | Reference | +--------+----------------+----------------------------+ | TBD | Payload-Length | Section 2 of this document | +--------+----------------+----------------------------+
The Payload-Length option defined in this document presents no security considerations beyond those in Section 10 of the base CoAP specification [I-D.ietf-core-coap].
The authors of this draft would like to thank Carsten Bormann and Klaus Hartke, for the initial texts in draft [I-D.bormann-coap-misc].
The authors of this draft would like to thank Bert Greevenbosch for the discussion and review.
[RFC2119] | Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997. |
[I-D.ietf-core-coap] | Shelby, Z, Hartke, K, Bormann, C and B Frank, "Constrained Application Protocol (CoAP)", Internet-Draft draft-ietf-core-coap-08, October 2011. |
[I-D.bormann-coap-misc] | Bormann, C and K Hartke, "Miscellaneous additions to CoAP", Internet-Draft draft-bormann-coap-misc-18, June 2012. |