idnits 2.17.1 draft-ietf-core-senml-04.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (October 31, 2016) is 2728 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) -- Possible downref: Non-RFC (?) normative reference: ref. 'BIPM' -- Possible downref: Non-RFC (?) normative reference: ref. 'IEEE.754.1985' -- Possible downref: Non-RFC (?) normative reference: ref. 'NIST811' ** Obsolete normative reference: RFC 5226 (Obsoleted by RFC 8126) ** Obsolete normative reference: RFC 7049 (Obsoleted by RFC 8949) ** Obsolete normative reference: RFC 7159 (Obsoleted by RFC 8259) == Outdated reference: A later version (-05) exists of draft-arkko-core-dev-urn-03 == Outdated reference: A later version (-11) exists of draft-greevenbosch-appsawg-cbor-cddl-09 == Outdated reference: A later version (-10) exists of draft-ietf-core-links-json-06 -- Obsolete informational reference (is this intentional?): RFC 2141 (Obsoleted by RFC 8141) Summary: 3 errors (**), 0 flaws (~~), 4 warnings (==), 5 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group C. Jennings 3 Internet-Draft Cisco 4 Intended status: Standards Track Z. Shelby 5 Expires: May 4, 2017 ARM 6 J. Arkko 7 A. Keranen 8 Ericsson 9 C. Bormann 10 Universitaet Bremen TZI 11 October 31, 2016 13 Media Types for Sensor Measurement Lists (SenML) 14 draft-ietf-core-senml-04 16 Abstract 18 This specification defines media types for representing simple sensor 19 measurements and device parameters in the Sensor Measurement Lists 20 (SenML). Representations are defined in JavaScript Object Notation 21 (JSON), Concise Binary Object Representation (CBOR), eXtensible 22 Markup Language (XML), and Efficient XML Interchange (EXI), which 23 share the common SenML data model. A simple sensor, such as a 24 temperature sensor, could use this media type in protocols such as 25 HTTP or CoAP to transport the measurements of the sensor or to be 26 configured. 28 Status of This Memo 30 This Internet-Draft is submitted in full conformance with the 31 provisions of BCP 78 and BCP 79. 33 Internet-Drafts are working documents of the Internet Engineering 34 Task Force (IETF). Note that other groups may also distribute 35 working documents as Internet-Drafts. The list of current Internet- 36 Drafts is at http://datatracker.ietf.org/drafts/current/. 38 Internet-Drafts are draft documents valid for a maximum of six months 39 and may be updated, replaced, or obsoleted by other documents at any 40 time. It is inappropriate to use Internet-Drafts as reference 41 material or to cite them other than as "work in progress." 43 This Internet-Draft will expire on May 4, 2017. 45 Copyright Notice 47 Copyright (c) 2016 IETF Trust and the persons identified as the 48 document authors. All rights reserved. 50 This document is subject to BCP 78 and the IETF Trust's Legal 51 Provisions Relating to IETF Documents 52 (http://trustee.ietf.org/license-info) in effect on the date of 53 publication of this document. Please review these documents 54 carefully, as they describe your rights and restrictions with respect 55 to this document. Code Components extracted from this document must 56 include Simplified BSD License text as described in Section 4.e of 57 the Trust Legal Provisions and are provided without warranty as 58 described in the Simplified BSD License. 60 Table of Contents 62 1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . 3 63 2. Requirements and Design Goals . . . . . . . . . . . . . . . . 4 64 3. Terminology . . . . . . . . . . . . . . . . . . . . . . . . . 5 65 4. SenML Structure and Semantics . . . . . . . . . . . . . . . . 5 66 4.1. Base attributes . . . . . . . . . . . . . . . . . . . . . 6 67 4.2. Regular attributes . . . . . . . . . . . . . . . . . . . 6 68 4.3. Considerations . . . . . . . . . . . . . . . . . . . . . 7 69 4.4. Resolved Records . . . . . . . . . . . . . . . . . . . . 8 70 4.5. Associating Meta-data . . . . . . . . . . . . . . . . . . 8 71 5. JSON Representation (application/senml+json) . . . . . . . . 9 72 5.1. Examples . . . . . . . . . . . . . . . . . . . . . . . . 10 73 5.1.1. Single Datapoint . . . . . . . . . . . . . . . . . . 10 74 5.1.2. Multiple Datapoints . . . . . . . . . . . . . . . . . 10 75 5.1.3. Multiple Measurements . . . . . . . . . . . . . . . . 11 76 5.1.4. Resolved Data . . . . . . . . . . . . . . . . . . . . 12 77 5.1.5. Multiple Data Types . . . . . . . . . . . . . . . . . 13 78 5.1.6. Collection of Resources . . . . . . . . . . . . . . . 13 79 5.1.7. Setting an Actuator . . . . . . . . . . . . . . . . . 14 80 6. CBOR Representation (application/senml+cbor) . . . . . . . . 15 81 7. XML Representation (application/senml+xml) . . . . . . . . . 17 82 8. EXI Representation (application/senml+exi) . . . . . . . . . 19 83 9. Usage Considerations . . . . . . . . . . . . . . . . . . . . 22 84 10. CDDL . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 85 11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 24 86 11.1. Units Registry . . . . . . . . . . . . . . . . . . . . . 25 87 11.2. SenML Label Registry . . . . . . . . . . . . . . . . . . 28 88 11.3. Media Type Registration . . . . . . . . . . . . . . . . 29 89 11.3.1. senml+json Media Type Registration . . . . . . . . . 29 90 11.3.2. senml+cbor Media Type Registration . . . . . . . . . 31 91 11.3.3. senml+xml Media Type Registration . . . . . . . . . 32 92 11.3.4. senml+exi Media Type Registration . . . . . . . . . 33 94 11.4. XML Namespace Registration . . . . . . . . . . . . . . . 34 95 11.5. CoAP Content-Format Registration . . . . . . . . . . . . 34 96 12. Security Considerations . . . . . . . . . . . . . . . . . . . 35 97 13. Privacy Considerations . . . . . . . . . . . . . . . . . . . 35 98 14. Acknowledgement . . . . . . . . . . . . . . . . . . . . . . . 35 99 15. References . . . . . . . . . . . . . . . . . . . . . . . . . 35 100 15.1. Normative References . . . . . . . . . . . . . . . . . . 35 101 15.2. Informative References . . . . . . . . . . . . . . . . . 37 102 Appendix A. Links Extension . . . . . . . . . . . . . . . . . . 38 103 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 38 105 1. Overview 107 Connecting sensors to the Internet is not new, and there have been 108 many protocols designed to facilitate it. This specification defines 109 new media types for carrying simple sensor information in a protocol 110 such as HTTP or CoAP. This format was designed so that processors 111 with very limited capabilities could easily encode a sensor 112 measurement into the media type, while at the same time a server 113 parsing the data could relatively efficiently collect a large number 114 of sensor measurements. The markup language can be used for a 115 variety of data flow models, most notably data feeds pushed from a 116 sensor to a collector, and the web resource model where the sensor is 117 requested as a resource representation (e.g., "GET /sensor/ 118 temperature"). 120 There are many types of more complex measurements and measurements 121 that this media type would not be suitable for. SenML strikes a 122 balance between having some information about the sensor carried with 123 the sensor data so that the data is self describing but it also tries 124 to make that a fairly minimal set of auxiliary information for 125 efficiency reason. Other information about the sensor can be 126 discovered by other methods such as using the CoRE Link Format 127 [RFC6690]. 129 SenML is defined by a data model for measurements and simple meta- 130 data about measurements and devices. The data is structured as a 131 single array that contains a series of SenML Records which can each 132 contain attributes such as an unique identifier for the sensor, the 133 time the measurement was made, the unit the measurement is in, and 134 the current value of the sensor. Serializations for this data model 135 are defined for JSON [RFC7159], CBOR [RFC7049], XML, and Efficient 136 XML Interchange (EXI) [W3C.REC-exi-20140211]. 138 For example, the following shows a measurement from a temperature 139 gauge encoded in the JSON syntax. 141 [ 142 {"n":"urn:dev:ow:10e2073a01080063","u":"Cel","v":23.1} 143 ] 145 In the example above, the array has a single SenML Record with a 146 measurement for a sensor named "urn:dev:ow:10e2073a01080063" with a 147 current value of 23.1 degrees Celsius. 149 2. Requirements and Design Goals 151 The design goal is to be able to send simple sensor measurements in 152 small packets on mesh networks from large numbers of constrained 153 devices. Keeping the total size of payload under 80 bytes makes this 154 easy to use on a wireless mesh network. It is always difficult to 155 define what small code is, but there is a desire to be able to 156 implement this in roughly 1 KB of flash on a 8 bit microprocessor. 157 Experience with Google power meter and large scale deployments has 158 indicated that the solution needs to support allowing multiple 159 measurements to be batched into a single HTTP or CoAP request. This 160 "batch" upload capability allows the server side to efficiently 161 support a large number of devices. It also conveniently supports 162 batch transfers from proxies and storage devices, even in situations 163 where the sensor itself sends just a single data item at a time. The 164 multiple measurements could be from multiple related sensors or from 165 the same sensor but at different times. 167 The basic design is an array with a series of measurements. The 168 following example shows two measurements made at different times. 169 The value of a measurement is in the "v" tag, the time of a 170 measurement is in the "t" tag, the "n" tag has a unique sensor name, 171 and the unit of the measurement is carried in the "u" tag. 173 [ 174 {"n":"urn:dev:ow:10e2073a01080063","u":"Cel","t":1.276020076e+09, 175 "v":23.5}, 176 {"n":"urn:dev:ow:10e2073a01080063","u":"Cel","t":1.276020091e+09, 177 "v":23.6} 178 ] 180 To keep the messages small, it does not make sense to repeat the "n" 181 tag in each SenML Record so there is a concept of a Base Name which 182 is simply a string that is prepended to the Name field of all 183 elements in that record and any records that follow it. So a more 184 compact form of the example above is the following. 186 [ 187 {"bn":"urn:dev:ow:10e2073a01080063","u":"Cel","t":1.276020076e+09, 188 "v":23.5}, 189 {"u":"Cel","t":1.276020091e+09, 190 "v":23.6} 191 ] 193 In the above example the Base Name is in the "bn" tag and the "n" 194 tags in each Record are the empty string so they are omitted. 196 Some devices have accurate time while others do not so SenML supports 197 absolute and relative times. Time is represented in floating point 198 as seconds and values greater than zero represent an absolute time 199 relative to the Unix epoch while values of 0 or less represent a 200 relative time in the past from the current time. A simple sensor 201 with no absolute wall clock time might take a measurement every 202 second and batch up 60 of them then send it to a server. It would 203 include the relative time the measurement was made to the time the 204 batch was send in the SenML Pack. The server might have accurate NTP 205 time and use the time it received the data, and the relative offset, 206 to replace the times in the SenML with absolute times before saving 207 the SenML Pack in a document database. 209 3. Terminology 211 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 212 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 213 "OPTIONAL" in this document are to be interpreted as described in 214 [RFC2119]. 216 This document also uses the following terms: 218 SenML Record: One measurement or configuration instance in time 219 presented using the SenML data model. 221 SenML Pack: One or more SenML Records in an array structure. 223 4. SenML Structure and Semantics 225 Each SenML Pack carries a single array that represents a set of 226 measurements and/or parameters. This array contains a series of 227 SenML Records with several attributes described below. There are two 228 kind of attributes: base and regular. The base attributes can only 229 be included in the first SenML Record and they apply to the entries 230 in all Records. All base attributes are optional. Regular 231 attributes can be included in any SenML Record and apply only to that 232 Record. 234 4.1. Base attributes 236 Base Name: This is a string that is prepended to the names found in 237 the entries. 239 Base Time: A base time that is added to the time found in an entry. 241 Base Unit: A base unit that is assumed for all entries, unless 242 otherwise indicated. If a record does not contain a Unit value, 243 then the Base Unit is used. Otherwise the value found in the Unit 244 (if any) is used. 246 Base Value: A base value is added to the value found in an entry, 247 similar to Base Time. 249 Base Sum: A base sum is added to the sum found in an entry, similar 250 to Base Time. 252 Version: Version number of media type format. This attribute is an 253 optional positive integer and defaults to 5 if not present. [RFC 254 Editor: change the default value to 10 when this specification is 255 published as an RFC and remove this note] 257 4.2. Regular attributes 259 Name: Name of the sensor or parameter. When appended to the Base 260 Name attribute, this must result in a globally unique identifier 261 for the resource. The name is optional, if the Base Name is 262 present. If the name is missing, Base Name must uniquely identify 263 the resource. This can be used to represent a large array of 264 measurements from the same sensor without having to repeat its 265 identifier on every measurement. 267 Unit: Units for a measurement value. Optional. If the Record has 268 no Unit, the Base Unit is used as the Unit. Having no Unit and no 269 Base Unit is allowed. 271 Value Value of the entry. Optional if a Sum value is present, 272 otherwise required. Values are represented using basic data 273 types. This specification defines floating point numbers ("v" 274 field for "Value"), booleans ("vb" for "Boolean Value"), strings 275 ("vs" for "String Value") and binary data ("vd" for "Data Value"). 276 Exactly one value field MUST appear unless there is Sum field in 277 which case it is allowed to have no Value field. 279 Sum: Integrated sum of the values over time. Optional. This 280 attribute is in the units specified in the Unit value multiplied 281 by seconds. 283 Time: Time when value was recorded. Optional. 285 Update Time: An optional time in seconds that represents the maximum 286 time before this sensor will provide an updated reading for a 287 measurement. This can be used to detect the failure of sensors or 288 communications path from the sensor. 290 4.3. Considerations 292 The SenML format can be extended with further custom attributes. 293 Both new base and regular attributes are allowed. See Section 11.2 294 for details. Implementations MUST ignore attributes they don't 295 recognize. 297 Systems reading one of the objects MUST check for the Version 298 attribute. If this value is a version number larger than the version 299 which the system understands, the system SHOULD NOT use this object. 300 This allows the version number to indicate that the object contains 301 mandatory to understand attributes. New version numbers can only be 302 defined in an RFC that updates this specification or it successors. 304 The Name value is concatenated to the Base Name value to get the name 305 of the sensor. The resulting name needs to uniquely identify and 306 differentiate the sensor from all others. If the object is a 307 representation resulting from the request of a URI [RFC3986], then in 308 the absence of the Base Name attribute, this URI is used as the 309 default value of Base Name. Thus in this case the Name field needs 310 to be unique for that URI, for example an index or subresource name 311 of sensors handled by the URI. 313 Alternatively, for objects not related to a URI, a unique name is 314 required. In any case, it is RECOMMENDED that the full names are 315 represented as URIs or URNs [RFC2141]. One way to create a unique 316 name is to include some bit string that has guaranteed uniqueness 317 (such as a 1-wire address) that is assigned to the device. Some of 318 the examples in this draft use the device URN type as specified in 319 [I-D.arkko-core-dev-urn]. UUIDs [RFC4122] are another way to 320 generate a unique name. Note that long-term stable unique 321 identifiers are problematic for privacy reasons [RFC7721] and should 322 be used with care or avoided. 324 The resulting concatenated name MUST consist only of characters out 325 of the set "A" to "Z", "a" to "z", "0" to "9", "-", ":", ".", or "_" 326 and it MUST start with a character out of the set "A" to "Z", "a" to 327 "z", or "0" to "9". This restricted character set was chosen so that 328 these names can be directly used as in other types of URI including 329 segments of an HTTP path with no special encoding and can be directly 330 used in many databases and analytic systems. [RFC5952] contains 331 advice on encoding an IPv6 address in a name. 333 If either the Base Time or Time value is missing, the missing 334 attribute is considered to have a value of zero. The Base Time and 335 Time values are added together to get the time of measurement. A 336 time of zero indicates that the sensor does not know the absolute 337 time and the measurement was made roughly "now". A negative value is 338 used to indicate seconds in the past from roughly "now". A positive 339 value is used to indicate the number of seconds, excluding leap 340 seconds, since the start of the year 1970 in UTC. 342 If only one of the Base Sum or Sum value is present, the missing 343 attribute is considered to have a value of zero. The Base Sum and 344 Sum values are added together to get the sum of measurement. If 345 neither the Base Sum or Sum are present, then the measurement does 346 not have a sum value. 348 Representing the statistical characteristics of measurements, such as 349 accuracy, can be very complex. Future specification may add new 350 attributes to provide better information about the statistical 351 properties of the measurement. 353 4.4. Resolved Records 355 Sometimes it is useful to be able to refer to a defined normalized 356 format for SenML records. This normalized format tends to get used 357 for big data applications and intermediate forms when converting to 358 other formats. 360 A SenML Record is referred to as "resolved" if it does not contain 361 any base values and has no relative times, but the base values of the 362 SenML Pack (if any) are applied to the Record. That is, name and 363 base name are concatenated, base time is added to the time of the 364 Record, if the Record did not contain Unit the Base Unit is applied 365 to the record, etc. In addition the records need to be in 366 chronological order. An example of this is show in Section 5.1.4. 368 Future specification that defines new base attributes need to specify 369 how the attribute is resolved. 371 4.5. Associating Meta-data 373 SenML is designed to carry the minimum dynamic information about 374 measurements, and for efficiency reasons does not carry significant 375 static meta-data about the device, object or sensors. Instead, it is 376 assumed that this meta-data is carried out of band. For web 377 resources using SenML Packs, this meta-data can be made available 378 using the CoRE Link Format [RFC6690]. The most obvious use of this 379 link format is to describe that a resource is available in a SenML 380 format in the first place. The relevant media type indicator is 381 included in the Content-Type (ct=) attribute. 383 5. JSON Representation (application/senml+json) 385 The SenML labels (JSON object member names) shown in Table 1 are used 386 in JSON SenML Record attributes. 388 +---------------+-------+---------+ 389 | Name | label | Type | 390 +---------------+-------+---------+ 391 | Base Name | bn | String | 392 | Base Time | bt | Number | 393 | Base Unit | bu | String | 394 | Base Value | bv | Number | 395 | Base Sum | bs | Number | 396 | Version | bver | Number | 397 | Name | n | String | 398 | Unit | u | String | 399 | Value | v | Number | 400 | String Value | vs | String | 401 | Boolean Value | vb | Boolean | 402 | Data Value | vd | String | 403 | Value Sum | s | Number | 404 | Time | t | Number | 405 | Update Time | ut | Number | 406 | Link | l | String | 407 +---------------+-------+---------+ 409 Table 1: JSON SenML Labels 411 The root content consists of an array with one JSON object for each 412 SenML Record. All the fields in the above table MAY occur in the 413 records with the type specified in the table. 415 Only the UTF-8 form of JSON is allowed. Characters in the String 416 Value are encoded using the escape sequences defined in [RFC7159]. 417 Octets in the Data Value are base64 encoded with URL safe alphabet as 418 defined in Section 5 of [RFC4648]. 420 Systems receiving measurements MUST be able to process the range of 421 floating point numbers that are representable as an IEEE double 422 precision floating point numbers [IEEE.754.1985]. The number of 423 significant digits in any measurement is not relevant, so a reading 424 of 1.1 has exactly the same semantic meaning as 1.10. If the value 425 has an exponent, the "e" MUST be in lower case. The mantissa SHOULD 426 be less than 19 characters long and the exponent SHOULD be less than 427 5 characters long. This allows time values to have better than micro 428 second precision over the next 100 years. 430 5.1. Examples 432 5.1.1. Single Datapoint 434 The following shows a temperature reading taken approximately "now" 435 by a 1-wire sensor device that was assigned the unique 1-wire address 436 of 10e2073a01080063: 438 [ 439 {"n":"urn:dev:ow:10e2073a01080063","u":"Cel","v":23.1} 440 ] 442 5.1.2. Multiple Datapoints 444 The following example shows voltage and current now, i.e., at an 445 unspecified time. 447 [ 448 {"bn":"urn:dev:ow:10e2073a01080063;","n":"voltage","u":"V","v":120.1}, 449 {"n":"current","u":"A","v":1.2} 450 ] 452 The next example is similar to the above one, but shows current at 453 Tue Jun 8 18:01:16.001 UTC 2010 and at each second for the previous 5 454 seconds. 456 [ 457 {"bn":"urn:dev:ow:10e2073a0108006;","bt":1.276020076001e+09, 458 "bu":"A","bver":5, 459 "n":"voltage","u":"V","v":120.1}, 460 {"n":"current","t":-5,"v":1.2}, 461 {"n":"current","t":-4,"v":1.3}, 462 {"n":"current","t":-3,"v":1.4}, 463 {"n":"current","t":-2,"v":1.5}, 464 {"n":"current","t":-1,"v":1.6}, 465 {"n":"current","v":1.7} 466 ] 468 Note that in some usage scenarios of SenML the implementations MAY 469 store or transmit SenML in a stream-like fashion, where data is 470 collected over time and continuously added to the object. This mode 471 of operation is optional, but systems or protocols using SenML in 472 this fashion MUST specify that they are doing this. SenML defines a 473 separate media type to indicate Sensor Streaming Measurement Lists 474 (SensML) for this usage (see Section 11.3.1). In this situation the 475 SensML stream can be sent and received in a partial fashion, i.e., a 476 measurement entry can be read as soon as the SenML Record is received 477 and not have to wait for the full SensML Stream to be complete. 479 For instance, the following stream of measurements may be sent via a 480 long lived HTTP POST from the producer of a SensML to the consumer of 481 that, and each measurement object may be reported at the time it was 482 measured: 484 [ 485 {"bn":"urn:dev:ow:10e2073a01080063","bt":1.320067464e+09, 486 "bu":"%RH","v":21.2}, 487 {"t":10,"v":21.3}, 488 {"t":20,"v":21.4}, 489 {"t":30,"v":21.4}, 490 {"t":40,"v":21.5}, 491 {"t":50,"v":21.5}, 492 {"t":60,"v":21.5}, 493 {"t":70,"v":21.6}, 494 {"t":80,"v":21.7}, 495 ... 497 5.1.3. Multiple Measurements 499 The following example shows humidity measurements from a mobile 500 device with a 1-wire address 10e2073a01080063, starting at Mon Oct 31 501 13:24:24 UTC 2011. The device also provides position data, which is 502 provided in the same measurement or parameter array as separate 503 entries. Note time is used to for correlating data that belongs 504 together, e.g., a measurement and a parameter associated with it. 505 Finally, the device also reports extra data about its battery status 506 at a separate time. 508 [ 509 {"bn":"urn:dev:ow:10e2073a01080063","bt":1.320067464e+09, 510 "bu":"%RH","v":20}, 511 {"u":"lon","v":24.30621}, 512 {"u":"lat","v":60.07965}, 513 {"t":60,"v":20.3}, 514 {"u":"lon","t":60,"v":24.30622}, 515 {"u":"lat","t":60,"v":60.07965}, 516 {"t":120,"v":20.7}, 517 {"u":"lon","t":120,"v":24.30623}, 518 {"u":"lat","t":120,"v":60.07966}, 519 {"u":"%EL","t":150,"v":98}, 520 {"t":180,"v":21.2}, 521 {"u":"lon","t":180,"v":24.30628}, 522 {"u":"lat","t":180,"v":60.07967} 523 ] 525 The size of this example represented in various forms, as well as 526 that form compressed with gzip is given in the following table. 528 +----------+------+-----------------+ 529 | Encoding | Size | Compressed Size | 530 +----------+------+-----------------+ 531 | JSON | 573 | 206 | 532 | XML | 649 | 235 | 533 | CBOR | 254 | 196 | 534 | EXI | 174 | 197 | 535 +----------+------+-----------------+ 537 Table 2: Size Comparisons 539 Note the EXI sizes are not using the schema guidance so the EXI 540 representation could be a bit smaller. 542 5.1.4. Resolved Data 544 The following shows the example from the previous section show in 545 resolved format. 547 [ 548 {"n":"urn:dev:ow:10e2073a01080063","u":"%RH","t":1.320067464e+09, 549 "v":20}, 550 {"n":"urn:dev:ow:10e2073a01080063","u":"lon","t":1.320067464e+09, 551 "v":24.30621}, 552 {"n":"urn:dev:ow:10e2073a01080063","u":"lat","t":1.320067464e+09, 553 "v":60.07965}, 554 {"n":"urn:dev:ow:10e2073a01080063","u":"%RH","t":1.320067524e+09, 555 "v":20.3}, 556 {"n":"urn:dev:ow:10e2073a01080063","u":"lon","t":1.320067524e+09, 557 "v":24.30622}, 558 {"n":"urn:dev:ow:10e2073a01080063","u":"lat","t":1.320067524e+09, 559 "v":60.07965}, 560 {"n":"urn:dev:ow:10e2073a01080063","u":"%RH","t":1.320067584e+09, 561 "v":20.7}, 562 {"n":"urn:dev:ow:10e2073a01080063","u":"lon","t":1.320067584e+09, 563 "v":24.30623}, 564 {"n":"urn:dev:ow:10e2073a01080063","u":"lat","t":1.320067584e+09, 565 "v":60.07966}, 566 {"n":"urn:dev:ow:10e2073a01080063","u":"%EL","t":1.320067614e+09, 567 "v":98}, 568 {"n":"urn:dev:ow:10e2073a01080063","u":"%RH","t":1.320067644e+09, 569 "v":21.2}, 570 {"n":"urn:dev:ow:10e2073a01080063","u":"lon","t":1.320067644e+09, 571 "v":24.30628}, 572 {"n":"urn:dev:ow:10e2073a01080063","u":"lat","t":1.320067644e+09, 573 "v":60.07967} 574 ] 576 5.1.5. Multiple Data Types 578 The following example shows a sensor that returns different data 579 types. 581 [ 582 {"bn":"urn:dev:ow:10e2073a01080063;","n":"temp","u":"Cel","v":23.1}, 583 {"n":"label","vs":"Machine Room"}, 584 {"n":"open","vb":false}, 585 {"n":"nfv-reader","vd":"aGkgCg=="} 586 ] 588 5.1.6. Collection of Resources 590 The following example shows how to query one device that can provide 591 multiple measurements. The example assumes that a client has fetched 592 information from a device at 2001:db8::2 by performing a GET 593 operation on http://[2001:db8::2] at Mon Oct 31 16:27:09 UTC 2011, 594 and has gotten two separate values as a result, a temperature and 595 humidity measurement. 597 [ 598 {"bn":"http://[2001:db8::2]/","bt":1.320078429e+09, 599 "n":"temperature","u":"Cel","v":27.2}, 600 {"n":"humidity","u":"%RH","v":80} 601 ] 603 5.1.7. Setting an Actuator 605 The following example show the SenML that could be used to set the 606 current set point of a typical residential thermostat which has a 607 temperature set point, a switch to turn on and off the heat, and a 608 switch to turn on the fan override. 610 [ 611 {"bn":"urn:dev:ow:10e2073a01080063;"}, 612 {"n":"temp","u":"Cel","v":23.1}, 613 {"n":"heat","u":"/","v":1}, 614 {"n":"fan","u":"/","v":0} 615 ] 617 In the following example two different lights are turned on. It is 618 assumed that the lights are on a 802.1BA network that can guarantee 619 delivery of the messages to the two lights within 15 ms and uses 620 802.1AS for time synchronization. The controller has set the time of 621 the lights coming on to 20 ms in the future from the current time. 622 This allows both lights to receive the message, wait till that time, 623 then apply the switch command so that both lights come on at the same 624 time. 626 [ 627 {"bt":1.320078429e+09,"bu":"/","n":"http://[2001:db8::3]/","v":1}, 628 {"n":"http://[2001:db8::4]/","v":1} 629 ] 631 The following shows two lights being turned off using a non 632 deterministic network that has a high odds of delivering a message in 633 less than 100 ms and uses NTP for time synchronization. The current 634 time is 1320078429. The user has just turned off a light switch 635 which is turning off two lights. Both lights are dimmed to 50% 636 brightness immediately to give the user instant feedback that 637 something is changing. However given the network, the lights will 638 probably dim at somewhat different times. Then 100 ms in the future, 639 both lights will go off at the same time. The instant but not 640 synchronized dimming gives the user the sensation of quick responses 641 and the timed off 100 ms in the future gives the perception of both 642 lights going off at the same time. 644 [ 645 {"bt":1.320078429e+09,"bu":"/","n":"http://[2001:db8::3]/","v":0.5}, 646 {"n":"http://[2001:db8::4]/","v":0.5}, 647 {"n":"http://[2001:db8::3]/","t":0.1,"v":0}, 648 {"n":"http://[2001:db8::4]/","t":0.1,"v":0} 649 ] 651 6. CBOR Representation (application/senml+cbor) 653 The CBOR [RFC7049] representation is equivalent to the JSON 654 representation, with the following changes: 656 o For JSON Numbers, the CBOR representation can use integers, 657 floating point numbers, or decimal fractions (CBOR Tag 4); however 658 a representation SHOULD be chosen such that when the CBOR value is 659 converted back to an IEEE double precision floating point value, 660 it has exactly the same value as the original Number. For the 661 version number, only an unsigned integer is allowed. 663 o Characters in the String Value are encoded using a definite length 664 text string (type 3). Octets in the Data Value are encoded using 665 a definite length byte string (type 2) . 667 o For compactness, the CBOR representation uses integers for the map 668 keys defined in Table 3. This table is conclusive, i.e., there is 669 no intention to define any additional integer map keys; any 670 extensions will use string map keys. This allows translators 671 converting between CBOR and JSON representations to convert also 672 all future labels without needing to update implementations. 674 +---------------+-------+------------+ 675 | Name | Label | CBOR Label | 676 +---------------+-------+------------+ 677 | Version | bver | -1 | 678 | Base Name | bn | -2 | 679 | Base Time | bt | -3 | 680 | Base Units | bu | -4 | 681 | Base Value | bv | -5 | 682 | Base Sum | bs | -6 | 683 | Name | n | 0 | 684 | Units | u | 1 | 685 | Value | v | 2 | 686 | String Value | vs | 3 | 687 | Boolean Value | vb | 4 | 688 | Value Sum | s | 5 | 689 | Time | t | 6 | 690 | Update Time | ut | 7 | 691 | Data Value | vd | 8 | 692 | Link | l | 9 | 693 +---------------+-------+------------+ 695 Table 3: CBOR representation: integers for map keys 697 o For streaming SensML in CBOR representation, the array containing 698 the records SHOULD be an CBOR indefinite length array while for 699 non streaming SenML, a definite length array MUST be used. 701 The following example shows a dump of the CBOR example for the same 702 sensor measurement as in Section 5.1.2. 704 0000 87 a7 21 78 1b 75 72 6e 3a 64 65 76 3a 6f 77 3a |..!x.urn:dev:ow:| 705 0010 31 30 65 32 30 37 33 61 30 31 30 38 30 30 36 3b |10e2073a0108006;| 706 0020 22 fb 41 d3 03 a1 5b 00 10 62 23 61 41 20 05 00 |".A...[..b#aA ..| 707 0030 67 76 6f 6c 74 61 67 65 01 61 56 02 fb 40 5e 06 |gvoltage.aV..@^.| 708 0040 66 66 66 66 66 a3 00 67 63 75 72 72 65 6e 74 06 |fffff..gcurrent.| 709 0050 24 02 fb 3f f3 33 33 33 33 33 33 a3 00 67 63 75 |$..?.333333..gcu| 710 0060 72 72 65 6e 74 06 23 02 fb 3f f4 cc cc cc cc cc |rrent.#..?......| 711 0070 cd a3 00 67 63 75 72 72 65 6e 74 06 22 02 fb 3f |...gcurrent."..?| 712 0080 f6 66 66 66 66 66 66 a3 00 67 63 75 72 72 65 6e |.ffffff..gcurren| 713 0090 74 06 21 02 f9 3e 00 a3 00 67 63 75 72 72 65 6e |t.!..>...gcurren| 714 00a0 74 06 20 02 fb 3f f9 99 99 99 99 99 9a a3 00 67 |t. ..?.........g| 715 00b0 63 75 72 72 65 6e 74 06 00 02 fb 3f fb 33 33 33 |current....?.333| 716 00c0 33 33 33 |333| 717 00c3 719 7. XML Representation (application/senml+xml) 721 A SenML Pack or Stream can also be represented in XML format as 722 defined in this section. 724 Only the UTF-8 form of XML is allowed. Characters in the String 725 Value are encoded using the escape sequences defined in [RFC7159]. 726 Octets in the Data Value are base64 encoded with URL safe alphabet as 727 defined in Section 5 of [RFC4648]. 729 The following example shows an XML example for the same sensor 730 measurement as in Section 5.1.2. 732 733 735 736 737 738 739 740 741 743 The SenML Stream is represented as a sensml tag that contains a 744 series of senml tags for each SenML Record. The SenML Fields are 745 represents as XML attributes. The following table shows the mapping 746 of the SenML labels, which are used for the attribute name, to the 747 attribute types used in the XML senml tags. 749 +---------------+-------+---------+ 750 | Name | Label | Type | 751 +---------------+-------+---------+ 752 | Base Name | bn | string | 753 | Base Time | bt | double | 754 | Base Unit | bu | string | 755 | Base Value | bv | double | 756 | Base Sum | bs | double | 757 | Base Version | bver | int | 758 | Name | n | string | 759 | Unit | u | string | 760 | Value | v | double | 761 | String Value | vs | string | 762 | Data Value | vd | string | 763 | Boolean Value | vb | boolean | 764 | Value Sum | s | double | 765 | Time | t | double | 766 | Update Time | ut | double | 767 | Link | l | string | 768 +---------------+-------+---------+ 770 Table 4: XML SenML Labels 772 The RelaxNG schema for the XML is: 774 default namespace = "urn:ietf:params:xml:ns:senml" 775 namespace rng = "http://relaxng.org/ns/structure/1.0" 777 senml = element senml { 778 attribute bn { xsd:string }?, 779 attribute bt { xsd:double }?, 780 attribute bv { xsd:double }?, 781 attribute bs { xsd:double }?, 782 attribute bu { xsd:string }?, 783 attribute bver { xsd:int }?, 785 attribute l { xsd:string }?, 787 attribute n { xsd:string }?, 788 attribute s { xsd:double }?, 789 attribute t { xsd:double }?, 790 attribute u { xsd:string }?, 791 attribute ut { xsd:double }?, 793 attribute v { xsd:double }?, 794 attribute vb { xsd:boolean }?, 795 attribute vs { xsd:string }?, 796 attribute vd { xsd:string }? 797 } 799 sensml = 800 element sensml { 801 senml+ 802 } 804 start = sensml 806 8. EXI Representation (application/senml+exi) 808 For efficient transmission of SenML over e.g. a constrained network, 809 Efficient XML Interchange (EXI) can be used. This encodes the XML 810 Schema structure of SenML into binary tags and values rather than 811 ASCII text. An EXI representation of SenML SHOULD be made using the 812 strict schema-mode of EXI. This mode however does not allow tag 813 extensions to the schema, and therefore any extensions will be lost 814 in the encoding. For uses where extensions need to be preserved in 815 EXI, the non-strict schema mode of EXI MAY be used. 817 The EXI header option MUST be included. An EXI schemaID options MUST 818 be set to the value of "a" indicating the scheme provided in this 819 specification. Future revisions to the schema can change this 820 schemaID to allow for backwards compatibility. When the data will be 821 transported over CoAP or HTTP, an EXI Cookie SHOULD NOT be used as it 822 simply makes things larger and is redundant to information provided 823 in the Content-Type header. 825 The following is the XSD Schema to be used for strict schema guided 826 EXI processing. It is generated from the RelaxNG. 828 829 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 862 The following shows a hexdump of the EXI produced from encoding the 863 following XML example. Note this example is the same information as 864 the first example in Section 5.1.2 in JSON format. 866 867 869 870 872 Which compresses with EXI to the following displayed in hexdump: 874 0000 a0 30 3d cd 95 b9 b5 b0 b9 9d 95 b8 b9 e1 cd 90 |.0=.............| 875 0010 80 79 d5 c9 b8 e9 91 95 d8 e9 bd dc e8 c4 c1 94 |.y..............| 876 0020 c8 c0 dc cd 84 c0 c4 c0 e0 c0 c0 d8 cc ed 82 5d |...............]| 877 0030 9b db 1d 18 59 d9 48 0d 58 ac 42 60 18 e1 2c 6e |....Y.H.X.B`..,n| 878 0040 ae 4e 4c ad ce 84 06 82 41 90 0e |.NL.....A..| 879 004b 881 The above example used the bit packed form of EXI but it is also 882 possible to use a byte packed form of EXI which can makes it easier 883 for a simple sensor to produce valid EXI without really implementing 884 EXI. Consider the example of a temperature sensor that produces a 885 value in tenths of degrees Celsius over a range of 0.0 to 55.0. It 886 would produce an XML SenML file such as: 888 889 890 892 The compressed form, using the byte alignment option of EXI, for the 893 above XML is the following: 895 0000 a0 00 48 81 ee 6c ad cd ad 85 cc ec ad c5 cf 0e |..H..l..........| 896 0010 6c 80 01 07 1d 75 72 6e 3a 64 65 76 3a 6f 77 3a |l....urn:dev:ow:| 897 0020 31 30 65 32 30 37 33 61 30 31 30 38 30 30 36 33 |10e2073a01080063| 898 0030 02 05 43 65 6c 01 00 e7 01 01 00 03 01 |..Cel........| 899 003d 901 A small temperature sensor devices that only generates this one EXI 902 file does not really need an full EXI implementation. It can simply 903 hard code the output replacing the 1-wire device ID starting at byte 904 0x20 and going to byte 0x2F with it's device ID, and replacing the 905 value "0xe7 0x01" at location 0x37 and 0x38 with the current 906 temperature. The EXI Specification [W3C.REC-exi-20140211] contains 907 the full information 'on how floating point numbers are represented, 908 but for the purpose of this sensor, the temperature can be converted 909 to an integer in tenths of degrees (231 in this example). EXI stores 910 7 bits of the integer in each byte with the top bit set to one if 911 there are further bytes. So the first bytes at is set to low 7 bits 912 of the integer temperature in tenths of degrees plus 0x80. In this 913 example 231 & 0x7F + 0x80 = 0xE7. The second byte is set to the 914 integer temperature in tenths of degrees right shifted 7 bits. In 915 this example 231 >> 7 = 0x01. 917 9. Usage Considerations 919 The measurements support sending both the current value of a sensor 920 as well as the an integrated sum. For many types of measurements, 921 the sum is more useful than the current value. For example, an 922 electrical meter that measures the energy a given computer uses will 923 typically want to measure the cumulative amount of energy used. This 924 is less prone to error than reporting the power each second and 925 trying to have something on the server side sum together all the 926 power measurements. If the network between the sensor and the meter 927 goes down over some period of time, when it comes back up, the 928 cumulative sum helps reflect what happened while the network was 929 down. A meter like this would typically report a measurement with 930 the units set to watts, but it would put the sum of energy used in 931 the "s" attribute of the measurement. It might optionally include 932 the current power in the "v" attribute. 934 While the benefit of using the integrated sum is fairly clear for 935 measurements like power and energy, it is less obvious for something 936 like temperature. Reporting the sum of the temperature makes it easy 937 to compute averages even when the individual temperature values are 938 not reported frequently enough to compute accurate averages. 939 Implementors are encouraged to report the cumulative sum as well as 940 the raw value of a given sensor. 942 Applications that use the cumulative sum values need to understand 943 they are very loosely defined by this specification, and depending on 944 the particular sensor implementation may behave in unexpected ways. 945 Applications should be able to deal with the following issues: 947 1. Many sensors will allow the cumulative sums to "wrap" back to 948 zero after the value gets sufficiently large. 950 2. Some sensors will reset the cumulative sum back to zero when the 951 device is reset, loses power, or is replaced with a different 952 sensor. 954 3. Applications cannot make assumptions about when the device 955 started accumulating values into the sum. 957 Typically applications can make some assumptions about specific 958 sensors that will allow them to deal with these problems. A common 959 assumption is that for sensors whose measurement values are always 960 positive, the sum should never get smaller; so if the sum does get 961 smaller, the application will know that one of the situations listed 962 above has happened. 964 10. CDDL 966 For reference, the JSON and CBOR representations can be described 967 with the common CDDL [I-D.greevenbosch-appsawg-cbor-cddl] 968 specification in Figure 1. 970 SenML-Pack = [initial-record, * follow-on-record] 972 initial-record = initial-defined .and initial-generic 973 follow-on-record = follow-on-defined .and follow-on-generic 975 ; first do a specification of the labels as defined: 977 initial-defined = { 978 ? bn => tstr, ; Base Name 979 ? bt => numeric, ; Base Time 980 ? bu => tstr, ; Base Units 981 ? bv => numeric, ; Base value 982 ? bver => uint, ; Base Version 983 follow-on-defined-group, 984 + base-key-value-pair 985 } 987 follow-on-defined-group = ( 988 ? n => tstr, ; Name 989 ? u => tstr, ; Units 990 ? s => numeric, ; Value Sum 991 ? t => numeric, ; Time 992 ? ut => numeric, ; Update Time 993 * key-value-pair, 994 ? ( v => numeric // ; Numeric Value 995 vs => tstr // ; String Value 996 vb => bool // ; Boolean Value 997 vd => binary-value ) ; Data Value 998 ) 999 follow-on-defined = { follow-on-defined-group } 1001 ; now define the generic versions 1003 initial-generic = { 1004 follow-on-generic-group, 1005 * base-key-value-pair, 1006 } 1008 follow-on-generic-group = ( 1009 + key-value-pair, 1010 ) 1011 follow-on-generic = { follow-on-generic-group } 1013 key-value-pair = ( non-b-label => value ) 1015 base-key-value-pair = ( b-label => value ) 1017 non-b-label = tstr .regexp "[A-Zac-z0-9][-_:.A-Za-z0-9]*" / uint 1018 b-label = tstr .regexp "b[-_:.A-Za-z0-9]+" / nint 1020 value = tstr / binary-value / numeric / bool 1021 numeric = number / decfrac 1023 Figure 1: Common CDDL specification for CBOR and JSON SenML 1025 For JSON, we use text labels and base64url-encoded binary data 1026 (Figure 2). 1028 bver = "bver" n = "n" s = "s" 1029 bn = "bn" u = "u" t = "t" 1030 bt = "bt" v = "v" ut = "ut" 1031 bu = "bu" vs = "vs" vd = "vd" 1032 bv = "bv" vb = "vb" l = "l" 1034 binary-value = tstr ; base64url encoded 1036 Figure 2: JSON-specific CDDL specification for SenML 1038 For CBOR, we use integer labels and native binary data (Figure 3). 1040 bver = -1 n = 0 s = 5 1041 bn = -2 u = 1 t = 6 1042 bt = -3 v = 2 ut = 7 1043 bu = -4 vs = 3 vd = 8 1044 bv = -5 vb = 4 l = 9 1046 binary-value = bstr 1048 Figure 3: CBOR-specific CDDL specification for SenML 1050 11. IANA Considerations 1052 Note to RFC Editor: Please replace all occurrences of "RFC-AAAA" with 1053 the RFC number of this specification. 1055 11.1. Units Registry 1057 IANA will create a registry of SenML unit symbols. The primary 1058 purpose of this registry is to make sure that symbols uniquely map to 1059 give type of measurement. Definitions for many of these units can be 1060 found in location such as [NIST811] and [BIPM]. Units marked with an 1061 asterisk are NOT RECOMMENDED to be produced by new implementations, 1062 but are in active use and SHOULD be implemented by consumers that can 1063 use the related base units. 1065 +----------+------------------------------------+-------+-----------+ 1066 | Symbol | Description | Type | Reference | 1067 +----------+------------------------------------+-------+-----------+ 1068 | m | meter | float | RFC-AAAA | 1069 | kg | kilogram | float | RFC-AAAA | 1070 | g | gram* | float | RFC-AAAA | 1071 | s | second | float | RFC-AAAA | 1072 | A | ampere | float | RFC-AAAA | 1073 | K | kelvin | float | RFC-AAAA | 1074 | cd | candela | float | RFC-AAAA | 1075 | mol | mole | float | RFC-AAAA | 1076 | Hz | hertz | float | RFC-AAAA | 1077 | rad | radian | float | RFC-AAAA | 1078 | sr | steradian | float | RFC-AAAA | 1079 | N | newton | float | RFC-AAAA | 1080 | Pa | pascal | float | RFC-AAAA | 1081 | J | joule | float | RFC-AAAA | 1082 | W | watt | float | RFC-AAAA | 1083 | C | coulomb | float | RFC-AAAA | 1084 | V | volt | float | RFC-AAAA | 1085 | F | farad | float | RFC-AAAA | 1086 | Ohm | ohm | float | RFC-AAAA | 1087 | S | siemens | float | RFC-AAAA | 1088 | Wb | weber | float | RFC-AAAA | 1089 | T | tesla | float | RFC-AAAA | 1090 | H | henry | float | RFC-AAAA | 1091 | Cel | degrees Celsius | float | RFC-AAAA | 1092 | lm | lumen | float | RFC-AAAA | 1093 | lx | lux | float | RFC-AAAA | 1094 | Bq | becquerel | float | RFC-AAAA | 1095 | Gy | gray | float | RFC-AAAA | 1096 | Sv | sievert | float | RFC-AAAA | 1097 | kat | katal | float | RFC-AAAA | 1098 | m2 | square meter (area) | float | RFC-AAAA | 1099 | m3 | cubic meter (volume) | float | RFC-AAAA | 1100 | l | liter (volume)* | float | RFC-AAAA | 1101 | m/s | meter per second (velocity) | float | RFC-AAAA | 1102 | m/s2 | meter per square second | float | RFC-AAAA | 1103 | | (acceleration) | | | 1104 | m3/s | cubic meter per second (flow rate) | float | RFC-AAAA | 1105 | l/s | liter per second (flow rate)* | float | RFC-AAAA | 1106 | W/m2 | watt per square meter (irradiance) | float | RFC-AAAA | 1107 | cd/m2 | candela per square meter | float | RFC-AAAA | 1108 | | (luminance) | | | 1109 | bit | bit (information content) | float | RFC-AAAA | 1110 | bit/s | bit per second (data rate) | float | RFC-AAAA | 1111 | lat | degrees latitude (note 2) | float | RFC-AAAA | 1112 | lon | degrees longitude (note 2) | float | RFC-AAAA | 1113 | pH | pH value (acidity; logarithmic | float | RFC-AAAA | 1114 | | quantity) | | | 1115 | dB | decibel (logarithmic quantity) | float | RFC-AAAA | 1116 | Bspl | bel (sound pressure level; | float | RFC-AAAA | 1117 | | logarithmic quantity)* | | | 1118 | count | 1 (counter value) | float | RFC-AAAA | 1119 | / | 1 (Ratio e.g., value of a switch, | float | RFC-AAAA | 1120 | | note 1) | | | 1121 | % | 1 (Ratio e.g., value of a switch, | float | RFC-AAAA | 1122 | | note 1)* | | | 1123 | %RH | Percentage (Relative Humidity) | float | RFC-AAAA | 1124 | %EL | Percentage (remaining battery | float | RFC-AAAA | 1125 | | energy level) | | | 1126 | EL | seconds (remaining battery energy | float | RFC-AAAA | 1127 | | level) | | | 1128 | 1/s | 1 per second (event rate) | float | RFC-AAAA | 1129 | 1/min | 1 per minute (event rate, "rpm")* | float | RFC-AAAA | 1130 | beat/min | 1 per minute (Heart rate in beats | float | RFC-AAAA | 1131 | | per minute)* | | | 1132 | beats | 1 (Cumulative number of heart | float | RFC-AAAA | 1133 | | beats)* | | | 1134 +----------+------------------------------------+-------+-----------+ 1136 Table 5 1138 o Note 1: A value of 0.0 indicates the switch is off while 1.0 1139 indicates on and 0.5 would be half on. The preferred name of this 1140 unit is "/". For historical reasons, the name "%" is also 1141 provided for the same unit - but note that while that name 1142 strongly suggests a percentage (0..100) -- it is however NOT a 1143 percentage, but the absolute ratio! 1145 o Note 2: Assumed to be in WGS84 unless another reference frame is 1146 known for the sensor. 1148 New entries can be added to the registration by either Expert Review 1149 or IESG Approval as defined in [RFC5226]. Experts should exercise 1150 their own good judgment but need to consider the following 1151 guidelines: 1153 1. There needs to be a real and compelling use for any new unit to 1154 be added. 1156 2. Units should define the semantic information and be chosen 1157 carefully. Implementors need to remember that the same word may 1158 be used in different real-life contexts. For example, degrees 1159 when measuring latitude have no semantic relation to degrees 1160 when measuring temperature; thus two different units are needed. 1162 3. These measurements are produced by computers for consumption by 1163 computers. The principle is that conversion has to be easily be 1164 done when both reading and writing the media type. The value of 1165 a single canonical representation outweighs the convenience of 1166 easy human representations or loss of precision in a conversion. 1168 4. Use of SI prefixes such as "k" before the unit is not 1169 recommended. Instead one can represent the value using 1170 scientific notation such a 1.2e3. The "kg" unit is exception to 1171 this rule since it is an SI base unit; the "g" unit is provided 1172 for legacy compatibility. 1174 5. For a given type of measurement, there will only be one unit 1175 type defined. So for length, meters are defined and other 1176 lengths such as mile, foot, light year are not allowed. For 1177 most cases, the SI unit is preferred. 1179 6. Symbol names that could be easily confused with existing common 1180 units or units combined with prefixes should be avoided. For 1181 example, selecting a unit name of "mph" to indicate something 1182 that had nothing to do with velocity would be a bad choice, as 1183 "mph" is commonly used to mean miles per hour. 1185 7. The following should not be used because the are common SI 1186 prefixes: Y, Z, E, P, T, G, M, k, h, da, d, c, n, u, p, f, a, z, 1187 y, Ki, Mi, Gi, Ti, Pi, Ei, Zi, Yi. 1189 8. The following units should not be used as they are commonly used 1190 to represent other measurements Ky, Gal, dyn, etg, P, St, Mx, G, 1191 Oe, Gb, sb, Lmb, mph, Ci, R, RAD, REM, gal, bbl, qt, degF, Cal, 1192 BTU, HP, pH, B/s, psi, Torr, atm, at, bar, kWh. 1194 9. The unit names are case sensitive and the correct case needs to 1195 be used, but symbols that differ only in case should not be 1196 allocated. 1198 10. A number after a unit typically indicates the previous unit 1199 raised to that power, and the / indicates that the units that 1200 follow are the reciprocal. A unit should have only one / in the 1201 name. 1203 11. A good list of common units can be found in the Unified Code for 1204 Units of Measure [UCUM]. 1206 11.2. SenML Label Registry 1208 IANA will create a new registry for SenML labels. The initial 1209 content of the registry is: 1211 +---------------+-------+------+----------+----+---------+ 1212 | Name | Label | CBOR | XML Type | ID | Note | 1213 +---------------+-------+------+----------+----+---------+ 1214 | Base Name | bn | -2 | string | a | RFCXXXX | 1215 | Base Sum | bs | -6 | double | a | RFCXXXX | 1216 | Base Time | bt | -3 | double | a | RFCXXXX | 1217 | Base Unit | bu | -4 | string | a | RFCXXXX | 1218 | Base Value | bv | -5 | double | a | RFCXXXX | 1219 | Base Version | bver | -1 | int | a | RFCXXXX | 1220 | Boolean Value | vb | 4 | boolean | a | RFCXXXX | 1221 | Data Value | vd | 8 | string | a | RFCXXXX | 1222 | Name | n | 0 | string | a | RFCXXXX | 1223 | String Value | vs | 3 | string | a | RFCXXXX | 1224 | Time | t | 6 | double | a | RFCXXXX | 1225 | Unit | u | 1 | string | a | RFCXXXX | 1226 | Update Time | ut | 7 | double | a | RFCXXXX | 1227 | Value | v | 2 | double | a | RFCXXXX | 1228 | Value Sum | s | 5 | double | a | RFCXXXX | 1229 | Link | l | 9 | string | a | RFCXXXX | 1230 +---------------+-------+------+----------+----+---------+ 1232 Table 6: SenML Labels 1234 Note to RFC Editor. Please replace RFCXXXX with the number for this 1235 RFC. 1237 All new entries must define the Label Name, Label, and XML Type but 1238 the CBOR labels SHOULD be left empty as CBOR will use the string 1239 encoding for any new labels. The ID fields contains the EXI schemaID 1240 of the first Schema which includes this label or is empty if this 1241 label was not intended for use with EXI. The Note field SHOULD 1242 contain information about where to find out more information about 1243 this label. 1245 The JSON, CBOR, and EXI types are derived from the XML type. All XML 1246 numeric types such as double, float, integer and int become a JSON 1247 Number. XML boolean and string become a JSON Boolean and String 1248 respectively. CBOR represents numeric values with a CBOR type that 1249 does not loose any information from the JSON value. EXI uses the XML 1250 types. 1252 New entries can be added to the registration by either Expert Review 1253 or IESG Approval as defined in [RFC5226]. Experts should exercise 1254 their own good judgment but need to consider that shorter labels 1255 should have more strict review. 1257 All new SenML labels that have "base" semantics (see Section 4.1) 1258 MUST start with character 'b'. Regular labels MUST NOT start with 1259 that character. 1261 Extensions that add a label that is intended for use with XML need to 1262 create a new RelaxNG scheme that includes all the labels in the IANA 1263 registry. 1265 Extensions that add a label that is intended for use with EXI need to 1266 create a new XSD Schema that includes all the labels in the IANA 1267 registry then allocate a new EXI schemaID. Moving to the next letter 1268 in the alphabet is the suggested way to create the new EXI schemaID. 1269 Any labels with previously blank ID values SHOULD be updated in the 1270 IANA table to have their ID set to this new schemaID value. 1272 11.3. Media Type Registration 1274 The following registrations are done following the procedure 1275 specified in [RFC6838] and [RFC7303]. 1277 Note to RFC Editor - please remove this paragraph. Note that a 1278 request for media type review for senml+json was sent to the media- 1279 types@iana.org on Sept 21, 2010. A second request for all the types 1280 was sent on October 7, 2016. 1282 11.3.1. senml+json Media Type Registration 1284 Type name: application 1286 Subtype name: senml+json and sensml+json 1288 Required parameters: none 1290 Optional parameters: none 1291 Encoding considerations: Must be encoded as using a subset of the 1292 encoding allowed in [RFC7159]. See RFC-AAAA for details. This 1293 simplifies implementation of very simple system and does not impose 1294 any significant limitations as all this data is meant for machine to 1295 machine communications and is not meant to be human readable. 1297 Security considerations: Sensor data can contain a wide range of 1298 information ranging from information that is very public, such the 1299 outside temperature in a given city, to very private information that 1300 requires integrity and confidentiality protection, such as patient 1301 health information. This format does not provide any security and 1302 instead relies on the transport protocol that carries it to provide 1303 security. Given applications need to look at the overall context of 1304 how this media type will be used to decide if the security is 1305 adequate. 1307 Interoperability considerations: Applications should ignore any JSON 1308 key value pairs that they do not understand. This allows backwards 1309 compatibility extensions to this specification. The "bver" field can 1310 be used to ensure the receiver supports a minimal level of 1311 functionality needed by the creator of the JSON object. 1313 Published specification: RFC-AAAA 1315 Applications that use this media type: The type is used by systems 1316 that report e.g., electrical power usage and environmental 1317 information such as temperature and humidity. It can be used for a 1318 wide range of sensor reporting systems. 1320 Additional information: 1322 Magic number(s): none 1324 File extension(s): senml and sensml 1326 Macintosh file type code(s): none 1328 Person & email address to contact for further information: Cullen 1329 Jennings 1331 Intended usage: COMMON 1333 Restrictions on usage: None 1335 Author: Cullen Jennings 1337 Change controller: IESG 1339 11.3.2. senml+cbor Media Type Registration 1341 Type name: application 1343 Subtype name: senml+cbor and sensml+cbor 1345 Required parameters: none 1347 Optional parameters: none 1349 Encoding considerations: Must be encoded as using [RFC7049]. See 1350 RFC-AAAA for details. 1352 Security considerations: Sensor data can contain a wide range of 1353 information ranging from information that is very public, such the 1354 outside temperature in a given city, to very private information that 1355 requires integrity and confidentiality protection, such as patient 1356 health information. This format does not provide any security and 1357 instead relies on the transport protocol that carries it to provide 1358 security. Given applications need to look at the overall context of 1359 how this media type will be used to decide if the security is 1360 adequate. 1362 Interoperability considerations: Applications should ignore any key 1363 value pairs that they do not understand. This allows backwards 1364 compatibility extensions to this specification. The "bver" field can 1365 be used to ensure the receiver supports a minimal level of 1366 functionality needed by the creator of the CBOR object. 1368 Published specification: RFC-AAAA 1370 Applications that use this media type: The type is used by systems 1371 that report e.g., electrical power usage and environmental 1372 information such as temperature and humidity. It can be used for a 1373 wide range of sensor reporting systems. 1375 Additional information: 1377 Magic number(s): none 1379 File extension(s): senmlc and sensmlc 1381 Macintosh file type code(s): none 1383 Person & email address to contact for further information: Cullen 1384 Jennings 1386 Intended usage: COMMON 1387 Restrictions on usage: None 1389 Author: Cullen Jennings 1391 Change controller: IESG 1393 11.3.3. senml+xml Media Type Registration 1395 Type name: application 1397 Subtype name: senml+xml and sensml+xml 1399 Required parameters: none 1401 Optional parameters: none 1403 Encoding considerations: Must be encoded as using 1404 [W3C.REC-xml-20081126]. See RFC-AAAA for details. 1406 Security considerations: Sensor data can contain a wide range of 1407 information ranging from information that is very public, such the 1408 outside temperature in a given city, to very private information that 1409 requires integrity and confidentiality protection, such as patient 1410 health information. This format does not provide any security and 1411 instead relies on the transport protocol that carries it to provide 1412 security. Given applications need to look at the overall context of 1413 how this media type will be used to decide if the security is 1414 adequate. 1416 Interoperability considerations: Applications should ignore any tags 1417 or attributes that they do not understand. This allows backwards 1418 compatibility extensions to this specification. The "bver" attribute 1419 in the senml tag can be used to ensure the receiver supports a 1420 minimal level of functionality needed by the creator of the XML. 1422 Published specification: RFC-AAAA 1424 Applications that use this media type: The type is used by systems 1425 that report e.g., electrical power usage and environmental 1426 information such as temperature and humidity. It can be used for a 1427 wide range of sensor reporting systems. 1429 Additional information: 1431 Magic number(s): none 1433 File extension(s): senmlx and sensmlx 1434 Macintosh file type code(s): none 1436 Person & email address to contact for further information: Cullen 1437 Jennings 1439 Intended usage: COMMON 1441 Restrictions on usage: None 1443 Author: Cullen Jennings 1445 Change controller: IESG 1447 11.3.4. senml+exi Media Type Registration 1449 Type name: application 1451 Subtype name: senml+exi and sensml+exi 1453 Required parameters: none 1455 Optional parameters: none 1457 Encoding considerations: Must be encoded as using 1458 [W3C.REC-exi-20140211]. See RFC-AAAA for details. 1460 Security considerations: Sensor data can contain a wide range of 1461 information ranging from information that is very public, such the 1462 outside temperature in a given city, to very private information that 1463 requires integrity and confidentiality protection, such as patient 1464 health information. This format does not provide any security and 1465 instead relies on the transport protocol that carries it to provide 1466 security. Given applications need to look at the overall context of 1467 how this media type will be used to decide if the security is 1468 adequate. 1470 Interoperability considerations: Applications should ignore any tags 1471 or attributes that they do not understand. This allows backwards 1472 compatibility extensions to this specification. The "bver" attribute 1473 in the senml tag can be used to ensure the receiver supports a 1474 minimal level of functionality needed by the creator of the XML. 1475 Further information on using schemas to guide the EXI can be found in 1476 RFC-AAAA. 1478 Published specification: RFC-AAAA 1480 Applications that use this media type: The type is used by systems 1481 that report e.g., electrical power usage and environmental 1482 information such as temperature and humidity. It can be used for a 1483 wide range of sensor reporting systems. 1485 Additional information: 1487 Magic number(s): none 1489 File extension(s): senmle and sensmle 1491 Macintosh file type code(s): none 1493 Person & email address to contact for further information: Cullen 1494 Jennings 1496 Intended usage: COMMON 1498 Restrictions on usage: None 1500 Author: Cullen Jennings 1502 Change controller: IESG 1504 11.4. XML Namespace Registration 1506 This document registers the following XML namespaces in the IETF XML 1507 registry defined in [RFC3688]. 1509 URI: urn:ietf:params:xml:ns:senml 1511 Registrant Contact: The IESG. 1513 XML: N/A, the requested URIs are XML namespaces 1515 11.5. CoAP Content-Format Registration 1517 IANA is requested to assign CoAP Content-Format IDs for the SenML 1518 media types in the "CoAP Content-Formats" sub-registry, within the 1519 "CoRE Parameters" registry [RFC7252]. All IDs are assigned from the 1520 "Expert Review" (0-255) range. The assigned IDs are show in Table 7. 1522 +-------------------------+-----+ 1523 | Media type | ID | 1524 +-------------------------+-----+ 1525 | application/senml+json | TBD | 1526 | application/sensml+json | TBD | 1527 | application/senml+cbor | TBD | 1528 | application/sensml+cbor | TBD | 1529 | application/senml+xml | TBD | 1530 | application/sensml+xml | TBD | 1531 | application/senml+exi | TBD | 1532 | application/sensml+exi | TBD | 1533 +-------------------------+-----+ 1535 Table 7: CoAP Content-Format IDs 1537 12. Security Considerations 1539 See Section 13. Further discussion of security properties can be 1540 found in Section 11.3. 1542 13. Privacy Considerations 1544 Sensor data can range from information with almost no security 1545 considerations, such as the current temperature in a given city, to 1546 highly sensitive medical or location data. This specification 1547 provides no security protection for the data but is meant to be used 1548 inside another container or transport protocol such as S/MIME or HTTP 1549 with TLS that can provide integrity, confidentiality, and 1550 authentication information about the source of the data. 1552 14. Acknowledgement 1554 We would like to thank Alexander Pelov, Andrew McClure, Andrew 1555 Mcgregor, Bjoern Hoehrmann, Christian Amsuess, Christian Groves, 1556 Daniel Peintner, Jan-Piet Mens, Joe Hildebrand, John Klensin, Karl 1557 Palsson, Lennart Duhrsen, Lisa Dusseault, Lyndsay Campbell, Martin 1558 Thomson, Michael Koster, and Stephen Farrell, for their review 1559 comments. 1561 15. References 1563 15.1. Normative References 1565 [BIPM] Bureau International des Poids et Mesures, "The 1566 International System of Units (SI)", 8th edition, 2006. 1568 [IEEE.754.1985] 1569 Institute of Electrical and Electronics Engineers, 1570 "Standard for Binary Floating-Point Arithmetic", 1571 IEEE Standard 754, August 1985. 1573 [NIST811] Thompson, A. and B. Taylor, "Guide for the Use of the 1574 International System of Units (SI)", NIST Special 1575 Publication 811, 2008. 1577 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 1578 Requirement Levels", BCP 14, RFC 2119, 1579 DOI 10.17487/RFC2119, March 1997, 1580 . 1582 [RFC3688] Mealling, M., "The IETF XML Registry", BCP 81, RFC 3688, 1583 DOI 10.17487/RFC3688, January 2004, 1584 . 1586 [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data 1587 Encodings", RFC 4648, DOI 10.17487/RFC4648, October 2006, 1588 . 1590 [RFC5226] Narten, T. and H. Alvestrand, "Guidelines for Writing an 1591 IANA Considerations Section in RFCs", BCP 26, RFC 5226, 1592 DOI 10.17487/RFC5226, May 2008, 1593 . 1595 [RFC6838] Freed, N., Klensin, J., and T. Hansen, "Media Type 1596 Specifications and Registration Procedures", BCP 13, 1597 RFC 6838, DOI 10.17487/RFC6838, January 2013, 1598 . 1600 [RFC7049] Bormann, C. and P. Hoffman, "Concise Binary Object 1601 Representation (CBOR)", RFC 7049, DOI 10.17487/RFC7049, 1602 October 2013, . 1604 [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data 1605 Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March 1606 2014, . 1608 [RFC7252] Shelby, Z., Hartke, K., and C. Bormann, "The Constrained 1609 Application Protocol (CoAP)", RFC 7252, 1610 DOI 10.17487/RFC7252, June 2014, 1611 . 1613 [RFC7303] Thompson, H. and C. Lilley, "XML Media Types", RFC 7303, 1614 DOI 10.17487/RFC7303, July 2014, 1615 . 1617 [W3C.REC-exi-20140211] 1618 Schneider, J., Kamiya, T., Peintner, D., and R. Kyusakov, 1619 "Efficient XML Interchange (EXI) Format 1.0 (Second 1620 Edition)", World Wide Web Consortium Recommendation REC- 1621 exi-20140211, February 2014, 1622 . 1624 [W3C.REC-xml-20081126] 1625 Bray, T., Paoli, J., Sperberg-McQueen, M., Maler, E., and 1626 F. Yergeau, "Extensible Markup Language (XML) 1.0 (Fifth 1627 Edition)", World Wide Web Consortium Recommendation REC- 1628 xml-20081126, November 2008, 1629 . 1631 15.2. Informative References 1633 [I-D.arkko-core-dev-urn] 1634 Arkko, J., Jennings, C., and Z. Shelby, "Uniform Resource 1635 Names for Device Identifiers", draft-arkko-core-dev-urn-03 1636 (work in progress), July 2012. 1638 [I-D.greevenbosch-appsawg-cbor-cddl] 1639 Vigano, C. and H. Birkholz, "CBOR data definition language 1640 (CDDL): a notational convention to express CBOR data 1641 structures", draft-greevenbosch-appsawg-cbor-cddl-09 (work 1642 in progress), September 2016. 1644 [I-D.ietf-core-links-json] 1645 Li, K., Rahman, A., and C. Bormann, "Representing CoRE 1646 Formats in JSON and CBOR", draft-ietf-core-links-json-06 1647 (work in progress), July 2016. 1649 [RFC2141] Moats, R., "URN Syntax", RFC 2141, DOI 10.17487/RFC2141, 1650 May 1997, . 1652 [RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform 1653 Resource Identifier (URI): Generic Syntax", STD 66, 1654 RFC 3986, DOI 10.17487/RFC3986, January 2005, 1655 . 1657 [RFC4122] Leach, P., Mealling, M., and R. Salz, "A Universally 1658 Unique IDentifier (UUID) URN Namespace", RFC 4122, 1659 DOI 10.17487/RFC4122, July 2005, 1660 . 1662 [RFC5952] Kawamura, S. and M. Kawashima, "A Recommendation for IPv6 1663 Address Text Representation", RFC 5952, 1664 DOI 10.17487/RFC5952, August 2010, 1665 . 1667 [RFC6690] Shelby, Z., "Constrained RESTful Environments (CoRE) Link 1668 Format", RFC 6690, DOI 10.17487/RFC6690, August 2012, 1669 . 1671 [RFC7721] Cooper, A., Gont, F., and D. Thaler, "Security and Privacy 1672 Considerations for IPv6 Address Generation Mechanisms", 1673 RFC 7721, DOI 10.17487/RFC7721, March 2016, 1674 . 1676 [UCUM] Schadow, G. and C. McDonald, "The Unified Code for Units 1677 of Measure (UCUM)", Regenstrief Institute and Indiana 1678 University School of Informatics, 2013, 1679 . 1681 Appendix A. Links Extension 1683 An attribute to support a link extension for SenML is defined as a 1684 string attribute by this specification. The link extension can be 1685 used for additional information about a SenML Record. The definition 1686 and usage of the contents of this value are specified in 1687 [I-D.ietf-core-links-json]. 1689 For JSON and XML the attribute has a label of "l" and a value that is 1690 a string. 1692 The following shows an example of the links extension. 1694 [ 1695 {"bn":"urn:dev:ow:10e2073a01080063;","bt":1.320078429e+09, 1696 "l":"[{\"href\":\"humidity\",\"foo\":\"bar1\"}", 1697 "n":"temperature","u":"Cel","v":27.2}, 1698 {"n":"humidity","u":"%RH","v":80} 1699 ] 1701 Authors' Addresses 1703 Cullen Jennings 1704 Cisco 1705 400 3rd Avenue SW 1706 Calgary, AB T2P 4H2 1707 Canada 1709 Email: fluffy@iii.ca 1710 Zach Shelby 1711 ARM 1712 150 Rose Orchard 1713 San Jose 95134 1714 USA 1716 Phone: +1-408-203-9434 1717 Email: zach.shelby@arm.com 1719 Jari Arkko 1720 Ericsson 1721 Jorvas 02420 1722 Finland 1724 Email: jari.arkko@piuha.net 1726 Ari Keranen 1727 Ericsson 1728 Jorvas 02420 1729 Finland 1731 Email: ari.keranen@ericsson.com 1733 Carsten Bormann 1734 Universitaet Bremen TZI 1735 Postfach 330440 1736 Bremen D-28359 1737 Germany 1739 Phone: +49-421-218-63921 1740 Email: cabo@tzi.org