Subject: [core] Clarification reg YANG Hash

From: Sathish Kumar Selvaraj <[email-masked]>
Date: Mon, 27 Apr 2015 19:08:49 +0530

Hi All,

I'm Sathish currently working in CoAP CoMI protocol for 6LoWPAN devices.
I'm facing problem in understanding the YANG Hash model.

In the COMI IETF draft there is YANG hash reference
https://datatracker.ietf.org/doc/draft-vanderstok-core-comi/?include_text=1

The YANG hash value for 'current-datetime' is calculated by
   constructing the schema node identifier for the object:

   /sys:system-state/sys:clock/sys:current-datetime

   The 30 bit murmur3 hash value is calculated on this string
   (0x15370408 and VNwQI).  The request using this hash value is shown
   below:

   REQ: GET example.com/mg/VNwQI

   RES: 2.05 Content (Content-Format: application/cbor)
   {
       0x15370408 : "2014-10-26T12:16:31Z"
   }

In the above reference, i could n't understand the following things clearly,

   1. How to calculate 30 bit murmur3 hash? Is there any java or any
programming example you could guide upon?
   2. How the values 0x15370408 and VNwQI were derived?

Could anyone please guide me in the right way to clearly understand
the CoMI Interface.

I'm eagerly waiting for your answers.

TIA,

Sathish

---

From: Michel Veillette <[email-masked]>
Date: Mon, 27 Apr 2015 15:01:49 +0000

Hi Sathish

I currently use python to compute the YANG hash.
You need to download ande install Python version 3.4 ot 2.7 (I currently use 2.7) and the mmh3 package version 2.3.
https://www.python.org/downloads/
https://pypi.python.org/pypi/mmh3/2.3

Once done, start the python command line and enter the following functions:

import mmh3

def toChar(v) :
  if v < 26 :
    return  chr(v + 65)
  elif v < 52 :
    return  chr(v + 71)
  elif v < 62 :
    return  chr(v - 4)
  elif v == 62 :
    return  '-'
  else:
    return  '_';

def toBase64(h) :
    return  toChar((h & 0x3f000000) >> 24) + toChar((h & 0xfc0000) >> 18) + toChar((h & 0x03f000) >> 12) + toChar((h & 0x000fc0) >> 6) + toChar(h & 0x00003f);

Then enter these commands:
>>> h = mmh3.hash('/sys:system-state/sys:clock/sys:current-datetime', 42)
>>> print '%d or "%s" in base64' % (h & 0x3fffffff, toBase64(h))

The output should be:
355927048 or "VNwQI" in base64

Michel Veillette
System Architecture Director
Trilliant Inc.
Tel: 450-375-0556 ext. 237
[email-masked]<mailto:[email-masked]>
www.trilliantinc.com<http://www.trilliantinc.com/>

From: core [mailto:[email-masked]] On Behalf Of Sathish Kumar Selvaraj
Sent: 27 avril 2015 09:39
To: [email-masked]
Subject: [core] Clarification reg YANG Hash

Hi All,

I'm Sathish currently working in CoAP CoMI protocol for 6LoWPAN devices. I'm facing problem in understanding the YANG Hash model.

In the COMI IETF draft there is YANG hash reference https://datatracker.ietf.org/doc/draft-vanderstok-core-comi/?include_text=1

   below:

   REQ: GET example.com/mg/VNwQI<http://example.com/mg/VNwQI>

   {

   }

1.  How to calculate 30 bit murmur3 hash? Is there any java or any programming example you could guide upon?

Could anyone please guide me in the right way to clearly understand the CoMI Interface.

TIA,

Sathish

---

From: Sathish Kumar Selvaraj <[email-masked]>
Date: Mon, 27 Apr 2015 22:08:28 +0530

Hi Michel & IETF Core Team,

Thanks.

This works perfectly fine. Now I'm able to see the results =).

Thanks,
Sathish

On Mon, Apr 27, 2015 at 8:31 PM, Michel Veillette <
[email-masked]> wrote:

> You need to download ande install Python version 3.4 ot 2.7 (I currently
> use 2.7) and the mmh3 package version 2.3.
>
>     return  toChar((h & 0x3f000000) >> 24) + toChar((h & 0xfc0000) >> 18)
> + toChar((h & 0x03f000) >> 12) + toChar((h & 0x000fc0) >> 6) + toChar(h &
> 0x00003f);
>
>
>
> [email-masked]
>
> www.trilliantinc.com
>
>
>
>
>
> *From:* core [mailto:[email-masked]] *On Behalf Of *Sathish Kumar
> Selvaraj
> *Sent:* 27 avril 2015 09:39
> *To:* [email-masked]
> *Subject:* [core] Clarification reg YANG Hash
>
>
>
> Hi All,
>
>
>