Re: [core] Designs to resolve streaming issues in SenML

Michael Koster <michaeljohnkoster@gmail.com> Fri, 15 January 2016 02:43 UTC

Return-Path: <michaeljohnkoster@gmail.com>
X-Original-To: core@ietfa.amsl.com
Delivered-To: core@ietfa.amsl.com
Received: from localhost (ietfa.amsl.com [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id 926971A87D7 for <core@ietfa.amsl.com>; Thu, 14 Jan 2016 18:43:45 -0800 (PST)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -0.598
X-Spam-Level:
X-Spam-Status: No, score=-0.598 tagged_above=-999 required=5 tests=[BAYES_05=-0.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, SPF_PASS=-0.001, WEIRD_PORT=0.001] autolearn=ham
Received: from mail.ietf.org ([4.31.198.44]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id u_mvHscfiZt5 for <core@ietfa.amsl.com>; Thu, 14 Jan 2016 18:43:42 -0800 (PST)
Received: from mail-pf0-x233.google.com (mail-pf0-x233.google.com [IPv6:2607:f8b0:400e:c00::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id 1EF401A87D4 for <core@ietf.org>; Thu, 14 Jan 2016 18:43:42 -0800 (PST)
Received: by mail-pf0-x233.google.com with SMTP id n128so109813609pfn.3 for <core@ietf.org>; Thu, 14 Jan 2016 18:43:42 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=7hTDdntUdOMB+ygBcxZxVuW2LVwi/3Kk3xu+f9ucAQI=; b=ihMrlTXwqp0ZBwy0cYzSWu18wqcGI1S/8EIxY2TmtEdIhvU8RLPSFnpOxEYs6DKqlu wgBYZz2w+WIlRJUVAKhaOUcnHuraniNp52A5+cumqvgsCpYV/94sTlwGpF/YBeLj0/qP xWl6aS5g4EY1N0DdM+6jklwLwKJ4L1UoGcqXk3fprRtD0wjorCXTrBNMPnqkBC/W3Kxg 89DBNhilyZjpBfWI6PAK3F+Ucgt/OsJmoInzqtMQTAPMUvLp7osUxGVrPqMmyb0Li5CG juhpo7thEOOih8ys3evmvGN6+wuKuBMiM4bQuISHDL+yzdtnJP78/fKTYtvGkUrJrgNc nu4w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:message-id:references:to; bh=7hTDdntUdOMB+ygBcxZxVuW2LVwi/3Kk3xu+f9ucAQI=; b=D4hCOs+4pqfxLgZ7TdIqCOHVmNLja7CJi8O0c5Suat4qoF0f13z7QvFsj0U8f6PPgV ksDUzsVL6DNzwBH1e4PcEx/ISQOH9tXyZZ1LdfD9w20e1zrZAwYrGBiAC83gh3OlhX0P Yyf0cZ7NmGTem6Ib5luZC7XoBVRhYNByaaTBCIcybQRyMzMo/Tknk6M/5gnajm22Jyrj 1Geztt0b4m+naDM8G56AS/yskE+Ri0ig2zm/9ahQOtFaAiF9nUUlB8A6oGPegG7JS8J1 GLAZzbVsSVyAKEqpolPMXP4qQxGfzvGnL0jMgZKERABn84AUXBgzapa4xVPHmxR5XTBk e9qA==
X-Gm-Message-State: ALoCoQntzEjrLcj5SDkOkk1YQF5Lp5HV/uVBnZBtEYbgSVTUXRBoSYTjN1UEz0VY/z/QkyhbNUW7il1Louo4iKFObZiifafnJg==
X-Received: by 10.98.93.195 with SMTP id n64mr11552221pfj.67.1452825821711; Thu, 14 Jan 2016 18:43:41 -0800 (PST)
Received: from [10.0.0.21] (108-201-184-41.lightspeed.sntcca.sbcglobal.net. [108.201.184.41]) by smtp.gmail.com with ESMTPSA id 72sm12125692pfk.28.2016.01.14.18.43.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 14 Jan 2016 18:43:40 -0800 (PST)
Content-Type: multipart/alternative; boundary="Apple-Mail=_5F96250A-4C95-4D78-8C35-44E48418CC83"
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
From: Michael Koster <michaeljohnkoster@gmail.com>
In-Reply-To: <175A1806-ACB0-4FC7-A318-2A58FF66CDD2@cisco.com>
Date: Thu, 14 Jan 2016 18:43:38 -0800
Message-Id: <85DB69FC-A20E-4314-AAB0-5E8AA8B5E5E6@gmail.com>
References: <175A1806-ACB0-4FC7-A318-2A58FF66CDD2@cisco.com>
To: "Cullen Jennings (fluffy)" <fluffy@cisco.com>
X-Mailer: Apple Mail (2.2104)
Archived-At: <http://mailarchive.ietf.org/arch/msg/core/MyzaGkayeuXlnAeFBt6BUo9LtyE>
Cc: core <core@ietf.org>
Subject: Re: [core] Designs to resolve streaming issues in SenML
X-BeenThere: core@ietf.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: "Constrained RESTful Environments \(CoRE\) Working Group list" <core.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/options/core>, <mailto:core-request@ietf.org?subject=unsubscribe>
List-Archive: <https://mailarchive.ietf.org/arch/browse/core/>
List-Post: <mailto:core@ietf.org>
List-Help: <mailto:core-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/core>, <mailto:core-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 15 Jan 2016 02:43:45 -0000

Hi,

I have been working with JSON serializations of senml and link data lately and I have some comments on the new SenML draft. I haven’t kept up with the format changes because I have something already working that I like that is based on the senml core wg draft-01. 

There are two problems with the new formats (-02 and -04) for my use case. The first is that I have added more element types to extend senml to represent collections that may have links, forms, and data items. The second is the issue of mapping vs. streaming as discussed previously.  First, I’ll try to explain the issue as I see it with mapping vs. streaming.

This is how the “collection” example appears in section 6.1.4 of draft-04:

   [{"bn": "http://[2001:db8::2]/",
     "bt": 1320078429,
     "ver": 3},
      { "n": "temperature", "v": 27.2, "u": "Cel" },
      { "n": "humidity", "v": 80, "u": "%RH" }
   ]

The block formatting of the first map and addition of whitespace to the second 2 maps gives the visual impression that there is some hierarchy. The reformatted example below using standard json pretty print makes it easier to see how this parses into a data structure using standard json tools. I’d recommend following this format to make the examples consistent and easy to read. I will do the same in my drafts.

[
  {
    "bn": "http://[2001:db8::2]/",
    "bt": 1320078429,
    "ver": 3
  },
  {
    "n": "temperature",
    "u": "Cel",
    "v": 27.2
  },
  {
    "n": "humidity",
    "u": "%RH",
    "v": 80
  }
]
As pointed out, the streaming format can only be processed in streaming form. Storing this in memory using a JSON parser does not result in a structure that can be easily sorted or indexed by base element. If I were to design a parser for this, it would have a state machine that would consume the top level array elements in sequence and create an in-memory structure that looks like the structures described in draft-02:

[
  {
    "bn": "http://[2001:db8::2]/",
    "bt": 1320078429,
    "ver": 1
  },
  [
    {
      "n": "temperature",
      "u": "Cel",
      "v": 27.2
    },
    {
      "n": "humidity",
      "u": "%RH",
      "v": 80
    }
  ]
]
Or draft-01:

{
  "bn": "http://[2001:db8::2]/",
  "bt": 1320078429,
  "ver": 1
  "e": [
    {
      "n": "temperature",
      "u": "Cel",
      "v": 27.2
    },
    {
      "n": "humidity",
      "u": "%RH",
      "v": 80
    }
  ],
}
With these earlier structures I could use standard JSON parse tools and then selection algorithms that match the “bn” value and select the contents within that item’s scope (for patching, etc.). With the streaming formats I need to add another level of serialize/deserialize between the content format and the actual program data model and process elements in order.

IOW, I already have a JSON parser and a JSON data structure filter that work together. Now with this format change, I need to add another layer of deserializing to create an index or remap the base elements.

The other issue is that in draft-01 the element tag “e” maps to the XML serialization <e/> tags nicely. I have tools that process both XML and JSON that understand this. Also, this is easily extensible to add more element classes to the senml data model, which I have done of links and forms.

{
  "bn": "/",
  "e": [
    {
      "n": "test",
      "sv": "testValue"
    }
  ],
  "l": [
    {
      "href": "",
      "rel": [
        "self"
      ]
    },
    {
      "href": "test",
      "rel": "sub"
    }
  ]
}

I have indicated this with a content format “collection+senml+json”, to indicate the senml data model with a collection extension or subtype.

Since the recent changes in senml, I have considered forking -01 and creating a new set of media types called hyper-senml, or “hsml”, so “application/hsml+json”, “application/hsml+xml”, “application/collection+hsml+json”, etc.

I guess my preferred outcome would be a senml optimized for mapping that looks like -01 and can be extended to add element classes, and a separate, streaming optimized format.

Best regards,

Michael


> On Jan 13, 2016, at 5:57 AM, Cullen Jennings (fluffy) <fluffy@cisco.com> wrote:
> 
> The changes we made to SenML to support streaming in the -02 version raised many issues for lots of people. In the end, one of the biggest problems is it forces all things receiving SenML to support streaming. 
> 
> I have an alternative design for streaming that I think addresses the issues raised and I would like the WG to think about two alternative designs for SenML and give me some direction on which one to use. 
> 
> The first design is the current -02 design with simple fixes and is in draft draft-jennings-core-senml-03
> 
> The second design is the new design I am proposing and is in draft-jennings-core-senml-04. It many way it moves back to be much closer to what was in -01 than what is in -02. 
> 
> The drafts can be found at 
> 
> https://datatracker.ietf.org/doc/draft-jennings-core-senml/03/
> 
> and 
> 
> https://datatracker.ietf.org/doc/draft-jennings-core-senml/04/
> 
> 
> Practically speaking the differences are not that much between the two but they do resolve a bunch of the issue. Let me discuss this in terms of the JSON representation and the rest of the representations mirror that.  In the new design measurements are put in JSON object as always. The object are put in array to represent a series of measurements. The objects can also have the base values right in the object and the base values apply to all the things in the object and any future objects in the array. 
> 
> Here is an example of something that is not a stream in both old and new design.
> 
> OLD 
> 
> [{"bn": "urn:dev:mac:0024befffe804ff1/"},
> [ { "n": "voltage", "t": 0, "u": "V", "v": 120.1 },
>   { "n": "current", "t": 0, "u": "A", "v": 1.2 } ]
> ]
> 
> NEW
> 
> [{"bn": "urn:dev:mac:0024befffe804ff1/"},
> { "n": "voltage", "t": 0, "u": "V", "v": 120.1 },
> { "n": "current", "t": 0, "u": "A", "v": 1.2 } 
> ]
> 
> Note the old design has an array with a base object, followed by a second array of measurements. The new design just has an single array and the first object happens to only have base values that apply to future object in the array. 
> 
> This could also be sent as
> 
> [
>    {
> 	"t": 0, 
>      	"n": "voltage", 
> 	"u": "V", 
>     	"bn": "urn:dev:mac:0024befffe804ff1/",
> 	"v": 120.1
>   },
>   { 
> 	"n": "current", 
> 	"t": 0, 
> 	"u": "A", 
> 	"v": 1.2 
>   } 
> ]
> 
> Here is an example of streaming with old and new design 
> 
> OLD 
> 
> [{"bn": "http://[2001:db8::1]",
>  "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 },
> ...
> 
> NEW 
> 
> [ {"bn": "http://[2001:db8::1]",
>  "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 },
> ...
> 
> 
> The draft does not have it yet but an applications that supports receiving streaming is written is a substantially different way that one that does not. I think the best way to deal with this is simply use a different mine type for streaming ( calls it senml_stream for now but send me suggestions on name for it). That way it can be clearly indicated and negotiated in existing transport protocols. 
> 
> Appreciate any thoughts people have on pro / cons of the -03 design vs -04 design.
> 
> 
> 
> 
> _______________________________________________
> core mailing list
> core@ietf.org
> https://www.ietf.org/mailman/listinfo/core