<?xml version="1.0" encoding="UTF-8"?>
  <?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
  <!-- generated by https://github.com/cabo/kramdown-rfc2629 version 1.0.40 -->

<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
]>

<?rfc toc="yes"?>
<?rfc sortrefs="yes"?>
<?rfc symrefs="yes"?>

<rfc ipr="trust200902" docName="draft-groves-core-senml-bto-01" category="std">

  <front>
    <title abbrev="SenML BTO">SenML Base Time Offset Attribute</title>

    <author initials="C." surname="Groves" fullname="Christian Groves">
      <organization></organization>
      <address>
        <postal>
          <street></street>
          <city></city>
          <code></code>
          <country>Australia</country>
        </postal>
        <email>cngroves.std@gmail.com</email>
      </address>
    </author>
    <author initials="W." surname="Yang" fullname="Weiwei Yang">
      <organization>Huawei</organization>
      <address>
        <postal>
          <street></street>
          <city></city>
          <code></code>
          <country>P.R.China</country>
        </postal>
        <email>tommy@huawei.com</email>
      </address>
    </author>

    <date year="2017" month="April" day="19"/>

    <area>art</area>
    <workgroup>CoRE Working Group</workgroup>
    <keyword>Internet-Draft</keyword>

    <abstract>


<t>SenML <xref target="I-D.ietf-core-senml"/> defines a base time attribute and time value 
which is used to determine the time when a value is recorded. In 
some applications a SenML pack will contain a series of records 
related to a constant sample time interval, e.g. once every 60 seconds. 
This means that the time attribute will be required for each record. 
This document defines a new “time offset” base attribute that allows a 
sender to include the time for the sample interval between records. If the “time offset” base attribute is used the sender will not send the time attribute for each record, minimising message and storage size.</t>



    </abstract>


  </front>

  <middle>


<section anchor="introduction" title="Introduction">

<t>SenML currently defines the base time “bt” and time “t” attributes to indicate the time that each value in a SenML record is recorded. This means that for each record (value “v”) that a “t” attribute is required. The example from section 5.1.2/<xref target="I-D.ietf-core-senml"/> is copied below to illustrate a SenML pack with multiple records.</t>

<figure title="SenML pack with multiple records" anchor="figmul"><artwork><![CDATA[
[ {"bn": "urn:dev:ow:10e2073a01080063",
      "bt": 1320067464,
      "bu": "%RH",
      "v": 21.2, "t": 0 },
      { "v": 21.3, "t": 10 },
      { "v": 21.4, "t": 20 },
      { "v": 21.4, "t": 30 },
      { "v": 21.5, "t": 40 },
      { "v": 21.5, "t": 50 },
      { "v": 21.5, "t": 60 },
      { "v": 21.6, "t": 70 },
      { "v": 21.7, "t": 80 },
      { "v": 21.5, "t": 90 },
   ... 

]]></artwork></figure>

<t>As can be seen in the example above there is a fixed offset between the data points of 10 seconds.</t>

<t>This document proposes a base time offset “bto” attribute that is used to indicate the offset between datapoints when a fixed offset is used. This negates the need to include the “t” attribute for each data point. The example below takes the above example and applies the base time offset to it.</t>

<figure title="SenML pack with multiple records using base time offset" anchor="figmulbto"><artwork><![CDATA[
[ {"bn": "urn:dev:ow:10e2073a01080063",
      "bt": 1320067464,
      “bto”: 10,
      "bu": "%RH",
      "v": 21.2},
      { "v": 21.3},
      { "v": 21.4},
      { "v": 21.4},
      { "v": 21.5},
      { "v": 21.5},
      { "v": 21.5},
      { "v": 21.6},
      { "v": 21.7},
      { "v": 21.5},
   ... 
]]></artwork></figure>

<t>It can be seen that it results in a record and overall pack size reduction. The receiver of the record would use the base time “bt” for the initial data point, e.g. “v”: 21.2 would have a timestamp  of 1320067464. Each subsequent record would have a time stamp equal to the previous record plus the base time offset “bto”, e.g. “v”: 21.3 would have a timestamp of 1320067474, “v”: 21.4 would have a timestamp of 1320067484, and so on.</t>

</section>
<section anchor="terminology" title="Terminology">
<t>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 <xref target="RFC2119"></xref>.</t>

<t>See <xref target="I-D.ietf-core-senml"/> for further definitions.</t>

</section>
<section anchor="structure" title="SenML Structure and Semantics">

<section anchor="base-attributes" title="Base Attributes">
<t>This document adds an additional “base time offset” attribute.</t>

<t>Base Time Offset: The base time offset represents a fixed time offset between each record in a SenML pack. The first record represents time zero (or the base time if provided) and the offset is then applied to each subsequent record. Either a positive or negative base time offset is allowed.</t>

</section>
<section anchor="regular-attributes" title="Regular Attributes">
<t>This document modifies the behaviour of the time attribute.</t>

<t>Time: If the base time offset attribute is used in a SenML pack then the time attribute shall not be used in the individual records.</t>

<t><spanx style="emph">Editor’s note: One theoretical use case may be to include the time attribute if the entry’s time deviates from the regular offset. It is not seen that such a corner case warrants the extra complexity.</spanx></t>

</section>
<section anchor="considerations" title="Considerations">
<t>To simplify implementation, the use of base time offset is limited to:</t>

<t><list style="symbols">
  <t>Fixed time increasing or decreasing records from the time stamp associated with the first record in the SenML pack. This means that usages such as described by the 2nd example in 5.1.2/<xref target="I-D.ietf-core-senml"/> where negative time offset from time zero being provided by the last record in a SenML pack are not possible.</t>
</list></t>

<t><spanx style="emph">Editor’s note: It could be possible to facilitate this use case by allowing a t=0 to be set on the last record with the use of a negative base time offset value. However again it’s not seen that such a corner case warrants the extra complexity in having to store values and calculate offsets at the end of transmission/reception.</spanx></t>

<t><list style="symbols">
  <t>It is not possible to for two records in the SenML pack to have the same time. For example the inclusion of a record for a voltage measurement followed by a current measurement would result in the records having times with a difference of the time offset.</t>
</list></t>

</section>
</section>
<section anchor="senmljson" title="JSON Representation (application/senml+json)">
<t>This document defines an additional SenML label (JSON object member name) as shown in <xref target="jsonlabels"/> below.</t>

<texttable title="JSON SenML Labels" anchor="jsonlabels">
      <ttcol align='left'>Name</ttcol>
      <ttcol align='left'>label</ttcol>
      <ttcol align='left'>Type</ttcol>
      <c>Base Time Offset</c>
      <c>bto</c>
      <c>Numer</c>
</texttable>

</section>
<section anchor="senmlcbor" title="CBOR Representation (application/senml+cbor)">
<t>As per section 6/<xref target="I-D.ietf-core-senml"/>, for CBOR the string map key “bto” shall be used to indicate the use of the base time offset.</t>

</section>
<section anchor="senmlxml" title="XML representation (application/senml+xml)">
<t>This document defines an addition XML attribute as shown in <xref target="xmllabels"/> below.</t>

<texttable title="XML SenML Labels" anchor="xmllabels">
      <ttcol align='left'>Name</ttcol>
      <ttcol align='left'>XML</ttcol>
      <ttcol align='left'>Type</ttcol>
      <c>Base Time Offset</c>
      <c>bto</c>
      <c>double</c>
</texttable>

<t>The RelaxNG schema for the XML is:</t>

<figure><artwork><![CDATA[
  senml = element senml {
     attribute bn { xsd:string }?,
     attribute bt { xsd:double }?,
     attribute bv { xsd:double }?,
     attribute bs { xsd:double }?,
     attribute bu { xsd:string }?,
     attribute bver { xsd:int }?,
     attribute bto { xsd:double }?,

     attribute l { xsd:string }?,

     attribute n { xsd:string }?,
     attribute s { xsd:double }?,
     attribute t { xsd:double }?,
     attribute u { xsd:string }?,
     attribute ut { xsd:double }?,

     attribute v { xsd:double }?,
     attribute vb { xsd:boolean }?,
     attribute vs { xsd:string }?,
     attribute vd { xsd:string }?
   }

   sensml =
     element sensml {
       senml+
   }

   start = sensml
]]></artwork></figure>

</section>
<section anchor="senmlexi" title="EXI Representation (application/senml-exi)">
<t>As per clause 8/<xref target="I-D.ietf-core-senml"/> extensions are indicated through the use of an EXI schemaID options. The EXI schemaID options MUST be set to the value of “b” indicating the scheme provided in this specification.</t>

<t>The following is the XSD Schema to be used for strict schema guided EXI processing.</t>

<figure><artwork><![CDATA[
<?xml version="1.0" encoding="utf-8"?>
   <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
   elementFormDefault="qualified"
   targetNamespace="urn:ietf:params:xml:ns:senml"
   xmlns:ns1="urn:ietf:params:xml:ns:senml">
     <xs:element name="senml">
       <xs:complexType>
         <xs:attribute name="bn" type="xs:string" />
         <xs:attribute name="bt" type="xs:double" />
         <xs:attribute name="bv" type="xs:double" />
         <xs:attribute name="bu" type="xs:string" />
         <xs:attribute name="bver" type="xs:int" />
         <xs:attribute name="bto" type="xs:double" />
         <xs:attribute name="l" type="xs:string" />
         <xs:attribute name="n" type="xs:string" />
         <xs:attribute name="s" type="xs:double" />
         <xs:attribute name="t" type="xs:double" />
         <xs:attribute name="u" type="xs:string" />
         <xs:attribute name="ut" type="xs:double" />
         <xs:attribute name="v" type="xs:double" />
         <xs:attribute name="vb" type="xs:boolean" />
         <xs:attribute name="vs" type="xs:string" />
         <xs:attribute name="vd" type="xs:string" />
       </xs:complexType>
     </xs:element>
     <xs:element name="sensml">
       <xs:complexType>
         <xs:sequence>
           <xs:element maxOccurs="unbounded" ref="ns1:senml" />
         </xs:sequence>
       </xs:complexType>
     </xs:element>
   </xs:schema>
]]></artwork></figure>

</section>
<section anchor="security-considerations" title="Security Considerations">
<t>No extra security issues are seen beyond those described in <xref target="I-D.ietf-core-senml"/>.</t>

</section>
<section anchor="iana-considerations" title="IANA Considerations">
<t>This document proposes one new entry in the IANA SenML label reegistry.</t>

<t>Label Name: Base Time Offset</t>

<t>Label: bto</t>

<t>CBOR: -</t>

<t>XML Type: Double</t>

<t>ID: b</t>

<t>Reference: This specification.</t>

</section>
<section anchor="acknowledgements" title="Acknowledgements">
<t>TBD</t>

</section>
<section anchor="changelog" title="Changelog">

<t>draft-groves-core-senml-bto-01</t>

<t><list style="symbols">
  <t>General: Changed “SenML Package” to “SenML Pack”</t>
</list></t>

</section>


  </middle>

  <back>

    <references title='Normative References'>





<reference  anchor='RFC2119' target='http://www.rfc-editor.org/info/rfc2119'>
<front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials='S.' surname='Bradner' fullname='S. Bradner'><organization /></author>
<date year='1997' month='March' />
<abstract><t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t></abstract>
</front>
<seriesInfo name='BCP' value='14'/>
<seriesInfo name='RFC' value='2119'/>
<seriesInfo name='DOI' value='10.17487/RFC2119'/>
</reference>



<reference anchor='I-D.ietf-core-senml'>
<front>
<title>Media Types for Sensor Measurement Lists (SenML)</title>

<author initials='C' surname='Jennings' fullname='Cullen Jennings'>
    <organization />
</author>

<author initials='Z' surname='Shelby' fullname='Zach Shelby'>
    <organization />
</author>

<author initials='J' surname='Arkko' fullname='Jari Arkko'>
    <organization />
</author>

<author initials='A' surname='Keranen' fullname='Ari Keranen'>
    <organization />
</author>

<author initials='C' surname='Bormann' fullname='Carsten Bormann'>
    <organization />
</author>

<date month='March' day='13' year='2017' />

<abstract><t>This specification defines media types for representing simple sensor measurements and device parameters in the Sensor Measurement Lists (SenML).  Representations are defined in JavaScript Object Notation (JSON), Concise Binary Object Representation (CBOR), eXtensible Markup Language (XML), and Efficient XML Interchange (EXI), which share the common SenML data model.  A simple sensor, such as a temperature sensor, could use this media type in protocols such as HTTP or CoAP to transport the measurements of the sensor or to be configured.</t></abstract>

</front>

<seriesInfo name='Internet-Draft' value='draft-ietf-core-senml-05' />
<format type='TXT'
        target='http://www.ietf.org/internet-drafts/draft-ietf-core-senml-05.txt' />
</reference>




    </references>




  </back>

<!-- ##markdown-source:
H4sIAAgT91gAA61a/W4bNxL/34Dfgdji0KS11pKdOMmibs+13caHxO7ZKdqi
KA7cXUpis7vUkVzJquNDX+OAu5frk9zMkPslrW3FPfkP7ZIzw+HwN1+UB4PB
9paVNhMRuxLF2zfsa24EeydzwS7GYyMsO7JWy7i0YnuLx7EW85ry3cX2VqqS
gufAnWo+toOJVnNhBonSYmBEkWeD2KpBxq0wFojhO2J7w9GLwfDZYPRqeyuB
kYnSy4gZm25vbW/JmY6Y1aWxe8Phq+EeLKoFjxjXwL9Q+j2sUM4idqwuT9kP
8C6LCfsWx7a33oslUKQROyus0IWwgxNUCsUay4v0HzxTBSiwFGZ7ayYj9rNV
yQ4zSlstxgaeljk+/IIcvLRTpaPtrQGThYEFQ1xmjqyMuS0fT7U0VvKiNaP0
hBfyN26lKiKGIwaECxuxTz+l10TaJb7Qs0pF81wWFg1xBHvXPJMcR0XOZRax
pHCGDcFKf53gWJiovNbth5D9xItJo9kPQi6ErAe7Sr0uOUw+RrXvwsvweCqL
tmpW5fnyr1OS6ZTa3iqUzmGxuYiQ8PKb473R6BU9nw1OQinsuIUQGoeDL8Yd
LpQDGx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