CoRE Working Group | Z. Shelby |
Internet-Draft | ARM |
Intended status: Informational | M. Koster |
Expires: April 25, 2019 | SmartThings |
C. Groves | |
J. Zhu | |
Huawei | |
B. Silverajan, Ed. | |
Tampere University of Technology | |
October 22, 2018 |
Dynamic Resource Linking for Constrained RESTful Environments
draft-ietf-core-dynlink-07
For CoAP (RFC7252), Dynamic linking of state updates between resources, either on an endpoint or between endpoints, is defined with the concept of Link Bindings. This specification defines conditional observation attributes that work with Link Bindings or with CoAP Observe (RFC7641).
The git repository for the draft is found at https://github.com/core-wg/dynlink
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 https://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 April 25, 2019.
Copyright (c) 2018 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.
IETF Standards for machine to machine communication in constrained environments describe a REST protocol [RFC7252] and a set of related information standards that may be used to represent machine data and machine metadata in REST interfaces. CoRE Link-format [RFC6690] is a standard for doing Web Linking [RFC8288] in constrained environments.
This specification introduces the concept of a Link Binding, which defines a new link relation type to create a dynamic link between resources over which state updates are conveyed. Specifically, a Link Binding is a unidirectional link for binding the states of source and destination resources together such that updates to one are sent over the link to the other. CoRE Link Format representations are used to configure, inspect, and maintain Link Bindings. This specification additionally defines a set of conditional Observe Attributes for use with Link Bindings and with the standalone CoRE Observe [RFC7641] method.
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.
This specification requires readers to be familiar with all the terms and concepts that are discussed in [RFC8288] and [RFC6690]. This specification makes use of the following additional terminology:
In a M2M RESTful environment, endpoints may directly exchange the content of their resources to operate the distributed system. For example, a light switch may supply on-off control information that may be sent directly to a light resource for on-off control. Beforehand, a configuration phase is necessary to determine how the resources of the different endpoints are related to each other. This can be done either automatically using discovery mechanisms or by means of human intervention and a so-called commissioning tool. In this specification such an abstract relationship between two resources is defined, called a link Binding. The configuration phase necessitates the exchange of binding information so a format recognized by all CoRE endpoints is essential. This specification defines a format based on the CoRE Link-Format to represent binding information along with the rules to define a binding method which is a specialized relationship between two resources. The purpose of such a binding is to synchronize the content between a source resource and a destination resource. The destination resource MAY be a group resource if the authority component of the destination URI contains a group address (either a multicast address or a name that resolves to a multicast address). Since a binding is unidirectional, the binding entry defining a relationship is present only on one endpoint. The binding entry may be located either on the source or the destination endpoint depending on the binding method.
A binding method defines the rules to generate the web-transfer exchanges that synchronize state between source and destination resources. By using REST methods content is sent from the source resource to the destination resource.
In order to use binding methods, this specification defines a special CoRE link attribute "bind". This is the identifier of a binding method which defines the rules to synchronize the destination resource. This attribute is mandatory.
Attribute | Parameter | Value |
---|---|---|
Binding method | bind | xsd:string |
The following table gives a summary of the binding methods defined in this specification.
Name | Identifier | Location | Method |
---|---|---|---|
Polling | poll | Destination | GET |
Observe | obs | Destination | GET + Observe |
Push | push | Source | PUT |
The description of a binding method must define the following aspects:
The binding methods are described in more detail below.
The Polling method consists of sending periodic GET requests from the destination endpoint to the source resource and copying the content to the destination resource. The binding entry for this method MUST be stored on the destination endpoint. The destination endpoint MUST ensure that the polling frequency does not exceed the limits defined by the pmin and pmax attributes of the binding entry. The copying process MAY filter out content from the GET requests using value-based conditions (e.g based on the Change Step, Less Than, Greater Than attributes).
The Observe method creates an observation relationship between the destination endpoint and the source resource. On each notification the content from the source resource is copied to the destination resource. The creation of the observation relationship requires the CoAP Observation mechanism [RFC7641] hence this method is only permitted when the resources are made available over CoAP. The binding entry for this method MUST be stored on the destination endpoint. The binding conditions are mapped as query string parameters (see Section 4).
When the Push method is assigned to a binding, the source endpoint sends PUT requests to the destination resource when the binding condition attributes are satisfied for the source resource. The source endpoint MUST only send a notification request if the binding conditions are met. The binding entry for this method MUST be stored on the source endpoint.
Since Binding involves the creation of a link between two resources, Web Linking and the CoRE Link-Format are a natural way to represent binding information. This involves the creation of a new relation type, named “boundto”. In a Web link with this relation type, the target URI contains the location of the source resource and the context URI points to the destination resource.
In addition to "bind", this specification further defines Web link attributes allowing a fine-grained control of the type of state synchronization along with the conditions that trigger an update.
When resource interfaces following this specification are made available over CoAP, the CoAP Observation mechanism [RFC7641] MAY also be used to observe any changes in a resource, and receive asynchronous notifications as a result. A resource using an interface description defined in this specification and marked as Observable in its link description SHOULD support these observation parameters.
In addition, the set of parameters are defined here allow a client to control how often a client is interested in receiving notifications and how much a resource value should change for the new representation to be interesting, as query parameters.
These query parameters MUST be treated as resources that are read using GET and updated using PUT, and MUST NOT be included in the Observe request. Multiple parameters MAY be updated at the same time by including the values in the query string of a PUT. Before being updated, these parameters have no default value.
These attributes are defined below:
Attribute | Parameter | Value |
---|---|---|
Minimum Period (s) | pmin | xsd:integer (>0) |
Maximum Period (s) | pmax | xsd:integer (>0) |
Change Step | st | xsd:decimal (>0) |
Greater Than | gt | xsd:decimal |
Less Than | lt | xsd:decimal |
Notification Band | band | xsd:boolean |
When present, the minimum period indicates the minimum time to wait (in seconds) before triggering a new state synchronization (even if it has changed). In the absence of this parameter, the minimum period is up to the synchronization initiator. The minimum period MUST be greater than zero otherwise the receiver MUST return a CoAP error code 4.00 “Bad Request” (or equivalent).
When present, the maximum period indicates the maximum time in seconds between two consecutive state synchronizations (regardless if it has changed). In the absence of this parameter, the maximum period is up to the synchronization initiator. The maximum period MUST be greater than zero and MUST be greater than the minimum period parameter (if present) otherwise the receiver MUST return a CoAP error code 4.00 “Bad Request” (or equivalent).
When present, the change step indicates how much the value of a resource SHOULD change before triggering a new state synchronization (compared to the value of the previous synchronization). Upon reception of a query including the st attribute the current value (CurrVal) of the resource is set as the initial value (STinit). Once the resource value differs from the STinit value (i.e. CurrVal >= STinit + ST or CurrVal <= STint - ST) then a new state synchronization occurs. STinit is then set to the state synchronization value and new state synchronizations are based on a change step against this value. The change step MUST be greater than zero otherwise the receiver MUST return a CoAP error code 4.00 “Bad Request” (or equivalent).
The Change Step parameter can only be supported on resources with an atomic numeric value.
Note: Due to the state synchronization based update of STint it may result in that resource value received in two sequential state synchronizations differs by more than st.
When present, Greater Than indicates the upper limit value the resource value SHOULD cross before triggering a new state synchronization. State synchronization only occurs when the resource value exceeds the specified upper limit value. The actual resource value is used for the synchronization rather than the gt value. If the value continues to rise, no new state synchronizations are generated as a result of gt. If the value drops below the upper limit value and then exceeds the upper limit then a new state synchronization is generated.
When present, Less Than indicates the lower limit value the resource value SHOULD cross before triggering a new state synchronization. State synchronization only occurs when the resource value is less than the specified lower limit value. The actual resource value is used for the synchronization rather than the lt value. If the value continues to fall no new state synchronizations are generated as a result of lt. If the value rises above the lower limit value and then drops below the lower limit then a new state synchronization is generated.
The notification band attribute allows a bounded or unbounded (based on a minimum or maximum) value range that may trigger multiple state synchronizations. This enables use cases where different ranges results in differing behaviour. For example: monitoring the temperature of machinery. Whilst the temperature is in the normal operating range only periodic observations are needed. However as the temperature moves to more abnormal ranges more frequent synchronization/reporting may be needed.
Without a notification band, a transition across a less than (lt), or greater than (gt) limit only generates one notification. This means that it is not possible to describe a case where multiple notifications are sent so long as the limit is exceeded.
The band attribute works as a modifier to the behaviour of gt and lt. Therefore, if band is present in a query, gt, lt or both, MUST be included.
When band is present with the lt attribute, it defines the lower bound for the notification band (notification band minimum). State synchronization occurs when the resource value is equal to or above the notification band minimum. If lt is not present there is no minimum value for the band.
When band is present with the gt attribute, it defines the upper bound for the notification band (notification band maximum). State synchronization occurs when the resource value is equal to or below the notification band maximum. If gt is not present there is no maximum value for the band.
If band is present with both the gt and lt attributes, two kinds of signaling bands are specified.
If a band is specified in which the value of gt is less than that of lt, in-band signaling occurs. State synchronization occurs whenever the resource value is between the notification band minimum and maximum or is equal to the notification band minimum or maximum.
On the other hand if the band is specified in which the value of gt is greater than that of lt, out-of-band signaling occurs. State synchronization occurs whenever the resource value is outside the notification band minimum and maximum or is equal to the notification band minimum or maximum.
Pmin, pmax, st, gt and lt may be present in the same query. Parameters are not defined at multiple prioritization levels. Instead, the server state machine generates a notification whenever any of the parameter conditions are met, after which it performs a reset on all the requested conditions. State synchronization also occurs only once even if there are multiple conditions being met at the same time. The reference code below illustrates how notifications are generated.
bool notifiable( Resource * r ) { #define BAND r->band #define SCALAR_TYPE ( num_type == r->type ) #define STRING_TYPE ( str_type == r->type ) #define BOOLEAN_TYPE ( bool_type == r->type ) #define PMIN_EX ( r->last_sample_time - r->last_rep_time >= r->pmin ) #define PMAX_EX ( r->last_sample_time - r->last_rep_time > r->pmax ) #define LT_EX ( r->v < r->lt ^ r->last_rep_v < r->lt ) #define GT_EX ( r->v > r->gt ^ r->last_rep_v > r->gt ) #define ST_EX ( abs( r->v - r->last_rep_v ) >= r->st ) #define IN_BAND ( ( r->gt <= r->v && r->v <= r->lt ) || ( r->lt <= r->gt && r->gt <= r->v ) || ( r->v <= r->lt && r->lt <= r->gt ) ) #define VB_CHANGE ( r->vb != r->last_rep_vb ) #define VS_CHANGE ( r->vs != r->last_rep_vs ) return ( PMIN_EX && ( SCALAR_TYPE ? ( ( !BAND && ( GT_EX || LT_EX || ST_EX || PMAX_EX ) ) || ( BAND && IN_BAND && ( ST_EX || PMAX_EX) ) ) : STRING_TYPE ? ( VS_CHANGE || PMAX_EX ) : BOOLEAN_TYPE ? ( VB_CHANGE || PMAX_EX ) : false ) ); }
Figure 1: Code logic for attribute interactions for observe notification
The Binding table is a special resource that gives access to the bindings on a endpoint. This section defines a REST interface for Binding table resources. The Binding table resource MUST support the Binding interface defined below. The interface supports the link-format type.
The if= column defines the Interface Description (if=) attribute value to be used in the CoRE Link Format for a resource conforming to that interface. When this value appears in the if= attribute of a link, the resource MUST support the corresponding REST interface described in this section. The resource MAY support additional functionality, which is out of scope for this specification. Although this interface description is intended to be used with the CoRE Link Format, it is applicable for use in any REST interface definition.
The Methods column defines the REST methods supported by the interface, which are described in more detail below.
Interface | if= | Methods | Content-Formats |
---|---|---|---|
Binding | core.bnd | GET, POST, DELETE | link-format |
The Binding interface is used to manipulate a binding table. A request with a POST method and a content format of application/link-format simply appends new bindings to the table. All links in the payload MUST have a relation type "boundto". A GET request simply returns the current state of a binding table whereas a DELETE request empties the table. Individual entries may be deleted from the table by specifying the resource path in a DELETE request.
The following example shows requests for adding, retrieving and deleting bindings in a binding table.
Req: POST /bnd/ (Content-Format: application/link-format) <coap://sensor.example.com/s/light>; rel="boundto";anchor="/a/light";bind="obs";pmin="10";pmax="60" Res: 2.04 Changed Req: GET /bnd/ Res: 2.05 Content (application/link-format) <coap://sensor.example.com/s/light>; rel="boundto";anchor="/a/light";bind="obs";pmin="10";pmax="60" Req: DELETE /bnd/a/light Res: 2.04 Changed Req: DELETE /bnd/ Res: 2.04 Changed
Figure 2: Binding Interface Example
When using multiple resource bindings (e.g. multiple Observations of resource) with different bands, consideration should be given to the resolution of the resource value when setting sequential bands. For example: Given BandA (Abmn=10, Bbmx=20) and BandB (Bbmn=21, Bbmx=30). If the resource value returns an integer then notifications for values between and inclusive of 10 and 30 will be triggered. Whereas if the resolution is to one decimal point (0.1) then notifications for values 20.1 to 20.9 will not be triggered.
The use of the notification band minimum and maximum allow for a synchronization whenever a change in the resource value occurs. Theoretically this could occur in-line with the server internal sample period for the determining the resource value. Implementors SHOULD consider the resolution needed before updating the resource, e.g. updating the resource when a temperature sensor value changes by 0.001 degree versus 1 degree.
The initiation of a link binding can be delegated from a client to a link state machine implementation, which can be an embedded client or a configuration tool. Implementation considerations have to be given to how to monitor transactions made by the configuration tool with regards to link bindings, as well as any errors that may arise with establishing link bindings as well as with established link bindings.
Consideration has to be given to what kinds of security credentials the state machine of a configuration tool or an embedded client needs to be configured with, and what kinds of access control lists client implementations should possess, so that transactions on creating link bindings and handling error conditions can be processed by the state machine.
The specification registers the “binding” CoRE interface description link target attribute value as per [RFC6690].
Description: The binding interface is used to manipulate a binding table which describes the link bindings between source and destination resources for the purposes of synchronizing their content.
Reference: This specification. Note to RFC editor: please insert the RFC of this specification.
Notes: None
This specification registers the new “boundto” link relation type as per [RFC8288].
Acknowledgement is given to colleagues from the SENSEI project who were critical in the initial development of the well-known REST interface concept, to members of the IPSO Alliance where further requirements for interface types have been discussed, and to Szymon Sasin, Cedric Chauvenet, Daniel Gavelle and Carsten Bormann who have provided useful discussion and input to the concepts in this specification. Christian Amsuss supplied a comprehensive review of draft -06.
Matthieu Vial Schneider-Electric Grenoble France Phone: +33 (0)47657 6522 EMail: matthieu.vial@schneider-electric.com
draft-ietf-core-dynlink-07
draft-ietf-core-dynlink-06
draft-ietf-core-dynlink-05
draft-ietf-core-dynlink-03
draft-ietf-core-dynlink-02
draft-ietf-core-dynlink-01
draft-ietf-core-dynlink Initial Version 00:
draft-groves-core-dynlink Draft Initial Version 00:
[RFC2119] | Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997. |
[RFC6690] | Shelby, Z., "Constrained RESTful Environments (CoRE) Link Format", RFC 6690, DOI 10.17487/RFC6690, August 2012. |
[RFC8174] | Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017. |
[RFC8288] | Nottingham, M., "Web Linking", RFC 8288, DOI 10.17487/RFC8288, October 2017. |
[RFC7252] | Shelby, Z., Hartke, K. and C. Bormann, "The Constrained Application Protocol (CoAP)", RFC 7252, DOI 10.17487/RFC7252, June 2014. |
[RFC7641] | Hartke, K., "Observing Resources in the Constrained Application Protocol (CoAP)", RFC 7641, DOI 10.17487/RFC7641, September 2015. |
This appendix provides some examples of the use of binding attribute / observe attributes.
Note: For brevity the only the method or response code is shown in the header field.
Observed CLIENT SERVER Actual t State | | State ____________ | | ____________ 1 | | 2 unknown | | 18.5 Cel 3 +----->| Header: GET 4 | GET | Token: 0x4a 5 | | Uri-Path: temperature 6 | | Uri-Query: gt="25" 7 | | Observe: 0 (register) 8 | | 9 ____________ |<-----+ Header: 2.05 10 | 2.05 | Token: 0x4a 11 18.5 Cel | | Observe: 9 12 | | Payload: "18.5 Cel" 13 | | 14 | | 15 | | ____________ 16 ____________ |<-----+ Header: 2.05 17 | 2.05 | 26 Cel Token: 0x4a 18 26 Cel | | Observe: 16 29 | | Payload: "26 Cel" 20 | | 21 | |
Figure 3: Client Registers and Receives one Notification of the Current State and One of a New State when it passes through the greather than threshold of 25.
Observed CLIENT SERVER Actual t State | | State ____________ | | ____________ 1 | | 2 unknown | | 18.5 Cel 3 +----->| Header: GET 4 | GET | Token: 0x4a 5 | | Uri-Path: temperature 6 | | Uri-Query: pmax="20";gt="25" 7 | | Observe: 0 (register) 8 | | 9 ____________ |<-----+ Header: 2.05 10 | 2.05 | Token: 0x4a 11 18.5 Cel | | Observe: 9 12 | | Payload: "18.5 Cel" 13 | | 14 | | 15 | | 16 | | 17 | | 18 | | 19 | | 20 | | 21 | | 22 | | 23 | | 24 | | 25 | | 26 | | 27 | | 28 | | 29 | | ____________ 30 ____________ |<-----+ Header: 2.05 31 | 2.05 | 23 Cel Token: 0x4a 32 23 Cel | | Observe: 30 33 | | Payload: "23 Cel" 34 | | 35 | | 36 | | ____________ 37 ____________ |<-----+ Header: 2.05 38 | 2.05 | 26 Cel Token: 0x4a 39 26 Cel | | Observe: 37 40 | | Payload: "26 Cel" 41 | | 42 | |
Figure 4: Client Registers and Receives one Notification of the Current State, one when pmax time expires and one of a new State when it passes through the greather than threshold of 25.