Movatterモバイル変換


[0]ホーム

URL:


RFC 8790FETCH and PATCH with SenMLJune 2020
Keränen & MohajerStandards Track[Page]
Stream:
Internet Engineering Task Force (IETF)
RFC:
8790
Category:
Standards Track
Published:
ISSN:
2070-1721
Authors:
A. Keränen
Ericsson
M. Mohajer

RFC 8790

FETCH and PATCH with Sensor Measurement Lists (SenML)

Abstract

The Sensor Measurement Lists (SenML) media type and data model can be used to send collections of resources, such as batches of sensor data or configuration parameters. The Constrained Application Protocol (CoAP) FETCH, PATCH, and iPATCH methods enable accessing and updating parts of a resource or multiple resources with one request. This document defines new media types for the CoAP FETCH, PATCH, and iPATCH methods for resources represented using the SenML data model.

Status of This Memo

This is an Internet Standards Track document.

This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). Further information on Internet Standards is available in Section 2 of RFC 7841.

Information about the current status of this document, any errata, and how to provide feedback on it may be obtained athttps://www.rfc-editor.org/info/rfc8790.

Copyright Notice

Copyright (c) 2020 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 (https://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.

Table of Contents

1.Introduction

The Sensor Measurement Lists (SenML) media type[RFC8428] and datamodel can be used to transmit collections of resources, such asbatches of sensor data or configuration parameters.

An example of a SenML collection is shown below:

[ {"bn":"2001:db8::2/3311/0/", "n":"5850", "vb":true}, {"n":"5851", "v":42}, {"n":"5750", "vs":"Ceiling light"}]

Here, three resources, "3311/0/5850", "3311/0/5851", and "3311/0/5750",of a dimmable light smart object[IPSO] are represented usinga single SenML Pack with three SenML Records. All resources share thesame base name "2001:db8::2/3311/0/"; hence, full names for the resourcesare "2001:db8::2/3311/0/5850", etc.

The CoAP[RFC7252] FETCH, PATCH, and iPATCH methods[RFC8132]enable accessing and updating parts of a resource or multiple resourceswith one request.

This document defines two new media types, one using the JavaScriptObject Notation (JSON)[RFC8259] and one using the Concise BinaryObject Representation (CBOR)[RFC7049], which can be used with theCoAP FETCH, PATCH, and iPATCH methods for resources represented using theSenML data model (i.e., for both SenML and Sensor Streaming MeasurementLists (SenSML) data). The rest of the document uses the term "(i)PATCH" whenreferring to both methods as the semantics of the new media types are thesame for the CoAP PATCH and iPATCH methods.

2.Terminology

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 BCP 14[RFC2119][RFC8174] when, and only when, they appear in all capitals, as shown here.

Readers should also be familiar with the terms and concepts discussedin[RFC8132] and[RFC8428]. The following additional terms are used inthis document:

Fetch Record:
One set of parameters that is used to match SenML Record(s).
Fetch Pack:
One or more Fetch Records in an array structure.
Patch Record:
One set of parameters similar to Fetch Record but also containinginstructions on how to change existing SenML Pack(s).
Patch Pack:
One or more Patch Records in an array structure.
Target Record:
A Record in a SenML Pack that matches the selection criteria ofa Fetch or Patch Record and hence is a target for a Fetch or Patchoperation.
Target Pack:
A SenML Pack that is a target for a Fetch or Patch operation.
(i)PATCH:
A term that refers to both CoAP "PATCH" and "iPATCH" methods whenthere is no difference in this specification as to which one is used.

3.Using FETCH and (i)PATCH with SenML

The FETCH/(i)PATCH media types for SenML are modeled as extensions to theSenML media type to enable reuse of existing SenML parsers andgenerators, in particular on constrained devices. Unless mentionedotherwise, FETCH and PATCH Packs are constructed with the same rules andconstraints as SenML Packs.

The key differences from the SenML media type are allowing the use of a"null" value for removing Records with the (i)PATCH method and the lack ofvalue fields in Fetch Records. Also, the Fetch and Patch Records do nothave a default time or base version when the fields are omitted.

3.1.SenML FETCH

The FETCH method can be used to select and return a subset of Records, insequence, of one or more SenML Packs. The SenML Records are selected bygiving a set of names that, when resolved, match resolved names in aTarget SenML Pack. The names for a Fetch Pack are given using the SenML"name" and/or "base name" fields. The names are resolved by concatenatingthe base name with the name field as defined in[RFC8428].

A Fetch PackMUST contain at least one Fetch Record. A Fetch RecordMUSTcontain a name and/or base name field.

For example, to select the resources "5850" and "5851" from theexample inSection 1, the following Fetch Pack can be used:

[ {"bn":"2001:db8::2/3311/0/", "n":"5850"}, {"n":"5851"}]

The result of a FETCH request with the example above would be:

[ {"bn":"2001:db8::2/3311/0/", "n":"5850", "vb":true}, {"n":"5851", "v":42},]

The SenML time and unit fields can be used in a Fetch Record to furthernarrow the selection of matched SenML Records. When no time or unit isgiven in a Fetch Record, all SenML Records with the given name arematched (i.e., unlike with SenML Records, the lack of time field in a FetchRecord does not imply a time value of zero). When time is given in the FetchRecord, a Target Record is matched only when its resolved time value and nameare equal to those of the Fetch Record. Similarly, when unit is given, aTarget Record is matched only when its resolved unit and name are equal tothose of the Fetch Record. If both the time and unit are given in the FetchRecord, a Target Record is matched only when both are equal to those of theFetch Record. Each Target RecordMUST be included in the response atmost once, even if multiple Fetch Records match with the same TargetRecord.

For example, if the resource "5850" had multiple sensor readings (SenML Records) with different time values, the following FetchPack can be used to retrieve the Record with time "1.276020091e+09":

[ {"bn":"2001:db8::2/3311/0/", "n":"5850", "t":1.276020091e+09}]

The resolved form of Records (Section 4.6 of [RFC8428]) is used whencomparing the names, times, and units of the Target and Fetch Records toaccommodate differences in the use of the base values. In the resolved form,the SenML name in the example above becomes "2001:db8::2/3311/0/5850".Since there is no base time in the Pack, the time in resolved form isequal to the time in the example.

If no SenML Records match, an empty SenML Pack (i.e., array with noelements) is returned as a response.

Fetch RecordsMUST NOT contain other fields than name, base name, time,base time, unit, and base unit. ImplementationsMUST reject and generatean error for a Fetch Pack with other fields.[RFC8132],Section 2.2 provides guidance for FETCH request error handling, e.g., using the 4.22(Unprocessable Entity) CoAP error response code.

3.2.SenML (i)PATCH

The (i)PATCH method can be used to change the fields of SenML Records, toadd new Records, and to remove existing Records. The names, times, andunits of the Patch Records are given and matched in the same way as for theFetch Records, except each Patch RecordMUST match at most one TargetRecord. A Patch Record matching more than one Target Record is consideredinvalid (patching multiple Target Records with one Patch Record wouldresult in multiple copies of the same Record). Patch Packs can alsoinclude new values and other SenML fields for the Records. Application ofPatch Packs is idempotent; hence, the PATCH and iPATCH methods for SenML Packsare equivalent.

When the name in a Patch Record matches with the name in an existingRecord, the resolved time values and units (if any) are compared. If thetime values and units either do not exist in both Records or are equal,the Target Record is replaced with the contents of the Patch Record. AllPatch RecordsMUST contain at least a SenML Value or Sum field.

If a Patch Record contains a name, or the combination of a time value, unit,and name, that does not exist in any existing Record in the Pack, thegiven Record, with all the fields it contains, is added to the Pack.

If a Patch Record has a value ("v") field with a null value, itMUST NOT beadded, but the matched Record (if any) is removed from the Target Pack.

The Patch RecordsMUST be applied in the same sequence as they are in thePatch Pack. If multiple Patch Packs are being processed at the same time,the resultMUST be equivalent to applying them in one sequence.

ImplementationsMUST reject and generate an error for Patch Packs withinvalid Records. If a Patch Pack is rejected, the state of the TargetPack is not changed, i.e., either all or none of the Patch Records areapplied.[RFC8132],Section 3.4 provides guidance for error handlingwith PATCH and iPATCH requests, e.g., using the 4.22 (UnprocessableEntity) and 4.09 (Conflict) CoAP error response codes.

For example, the following document could be given as an (i)PATCH payloadto change/set the values of two SenML Records for the example inSection 1:

[ {"bn":"2001:db8::2/3311/0/", "n":"5850", "vb":false}, {"n":"5851", "v":10}]

If the request is successful, the resulting representation of theexample SenML Pack would be as follows:

[ {"bn":"2001:db8::2/3311/0/", "n":"5850", "vb":false}, {"n":"5851", "v":10}, {"n":"5750", "vs":"Ceiling light"}]

As another example, the following document could be given as an (i)PATCHpayload to remove the two SenML Records:

[ {"bn":"2001:db8::2/3311/0/", "n":"5850", "v":null}, {"n":"5851", "v":null}]

4.Fragment Identification

Fragment identification for Records of Fetch and Patch Packs uses thesame mechanism as SenML JSON/CBOR fragment identification (seeSection 9 of [RFC8428]), i.e., the "rec" scheme followed by a comma-separated list ofRecord positions or range(s) of Records. For example, to select the 3rdand 5th Record of a Fetch or Patch Pack, a fragment identifier "rec=3,5"can be used in the URI of the Fetch or Patch Pack resource.

5.Extensibility

The SenML mandatory-to-understand field extensibility mechanism (seeSection 4.4 of [RFC8428]) does not apply to Patch Packs, i.e., unknownfieldsMUST NOT generate an error, but such fields are treated like anyother field (e.g., added to Patch target Records where applicable).

This specification allows only a small subset of SenML fields in FetchRecords, but future specifications may enable new fields for Fetch Recordsand possibly also new fields for selecting targets for Patch Records.

6.Security Considerations

The security and privacy considerations of SenML also apply to theFETCH and (i)PATCH methods. CoAP's security mechanisms are used toprovide security for the FETCH and (i)PATCH methods.

In FETCH and (i)PATCH requests, the client can pass arbitrary names tothe target resource for manipulation. The resource implementer must takecare to only allow access to names that are actually part of (oraccessible through) the target resource. In particular, the receiver needsto ensure that any input does not lead to uncontrolled specialinterpretation by the system.

If the client is not allowed to do a GET or PUT on the full targetresource (and thus all the names accessible through it), accesscontrol rules must be evaluated for each Record in the Pack.

7.IANA Considerations

This document registers two new media types and CoAP Content-Format IDsfor both media types.

7.1.CoAP Content-Format Registration

IANA has assigned CoAP Content-Format IDs for the SenML PATCHand FETCH media types in the "CoAP Content-Formats" subregistry, withinthe "Constrained RESTful Environments (CoRE) Parameters" registry[RFC7252]. The assigned IDs are shown inTable 1.

Table 1:CoAP Content-Format IDs
Media TypeEncodingID
application/senml-etch+json-320
application/senml-etch+cbor-322

7.2.senml-etch+json Media Type

Type name:
application
Subtype name:
senml-etch+json
Required parameters:
N/A
Optional parameters:
N/A
Encoding considerations:
binary
Security considerations:
SeeSection 6 of RFC 8790.
Interoperability considerations:
N/A
Published specification:
RFC 8790
Applications that use this media type:
Applications that use theSenML media type for resource representation.
Fragment identifier considerations:
Fragment identification forapplication/senml-etch+json is supported by using fragment identifiers asspecified bySection 4 of RFC 8790.
Additional information:


Deprecated alias names for this type:
N/A
Magic number(s):
N/A
File extension(s):
senml-etchj
Windows Clipboard Name:
"SenML FETCH/PATCH format"
Macintosh file type code(s):
N/A
Macintosh Universal Type Identifier code:


org.ietf.senml-etch-json conforms to public.text

Person & email address to contact for furtherinformation:


Ari Keränen <ari.keranen@ericsson.com>

Intended usage:
COMMON
Restrictions on usage:
N/A
Author:

Ari Keränen <ari.keranen@ericsson.com>

Change controller:
IESG

7.3.senml-etch+cbor Media Type

Type name:
application
Subtype name:
senml-etch+cbor
Required parameters:
N/A
Optional parameters:
N/A
Encoding considerations:
binary
Security considerations:
SeeSection 6 of RFC 8790.
Interoperability considerations:
N/A
Published specification:
RFC 8790
Applications that use this media type:
Applications that use theSenML media type for resource representation.
Fragment identifier considerations:
Fragment identification forapplication/senml-etch+cbor is supported by using fragment identifiers asspecified bySection 4 of RFC 8790.
Additional information:


Deprecated alias names for this type:
N/A
Magic number(s):
N/A
File extension(s):
senml-etchc
Macintosh file type code(s):
N/A
Macintosh Universal Type Identifier code:


org.ietf.senml-etch-cbor conforms to public.data

Person & email address to contact for further information:


Ari Keränen <ari.keranen@ericsson.com>

Intended usage:
COMMON
Restrictions on usage:
N/A
Author:

Ari Keränen <ari.keranen@ericsson.com>

Change controller:
IESG

8.References

8.1.Normative References

[RFC2119]
Bradner, S.,"Key words for use in RFCs to Indicate Requirement Levels",BCP 14,RFC 2119,DOI 10.17487/RFC2119,,<https://www.rfc-editor.org/info/rfc2119>.
[RFC7049]
Bormann, C. and P. Hoffman,"Concise Binary Object Representation (CBOR)",RFC 7049,DOI 10.17487/RFC7049,,<https://www.rfc-editor.org/info/rfc7049>.
[RFC7252]
Shelby, Z., Hartke, K., and C. Bormann,"The Constrained Application Protocol (CoAP)",RFC 7252,DOI 10.17487/RFC7252,,<https://www.rfc-editor.org/info/rfc7252>.
[RFC8132]
van der Stok, P., Bormann, C., and A. Sehgal,"PATCH and FETCH Methods for the Constrained Application Protocol (CoAP)",RFC 8132,DOI 10.17487/RFC8132,,<https://www.rfc-editor.org/info/rfc8132>.
[RFC8174]
Leiba, B.,"Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words",BCP 14,RFC 8174,DOI 10.17487/RFC8174,,<https://www.rfc-editor.org/info/rfc8174>.
[RFC8259]
Bray, T., Ed.,"The JavaScript Object Notation (JSON) Data Interchange Format",STD 90,RFC 8259,DOI 10.17487/RFC8259,,<https://www.rfc-editor.org/info/rfc8259>.
[RFC8428]
Jennings, C., Shelby, Z., Arkko, J., Keranen, A., and C. Bormann,"Sensor Measurement Lists (SenML)",RFC 8428,DOI 10.17487/RFC8428,,<https://www.rfc-editor.org/info/rfc8428>.

8.2.Informative References

[IPSO]
IPSO,"IPSO Light Control Smart Object",,<http://www.openmobilealliance.org/tech/profiles/lwm2m/3311.xml>.

Acknowledgements

The use of the FETCH and (i)PATCH methods with SenML was first introduced by the OMA SpecWorks Lightweight Machine to Machine (LwM2M) v1.1 specification. This document generalizes the use to any SenML representation. The authors would like to thankCarsten Bormann,Christian Amsüss,Jaime Jiménez,Klaus Hartke,Michael Richardson, and other participants from the IETF CoRE and OMA SpecWorks DMSE working groups who have contributed ideas and reviews.

Authors' Addresses

Ari Keränen
Ericsson
FI-02420Jorvas
Finland
Email:ari.keranen@ericsson.com
Mojan Mohajer
Email:mojanm@hotmail.com

[8]ページ先頭

©2009-2025 Movatter.jp