Quick viewing(Text Mode)

(Iot) to Web of Things (Wot): Protocols, Data Formats, Etc. MINES

(Iot) to Web of Things (Wot): Protocols, Data Formats, Etc. MINES

From of Things (IoT) to Web of Things (WoT): Protocols, formats, etc.

MINES Saint-Étienne, CNRS Lab Hubert Curien UMR 5516

Amelie Gyrard & Maxime Lefrancois [email protected] [email protected] 9 November 2017 Agenda

I. Introduction: Web of Things (WoT) o Pioneer o W3C WoT Architecture

II. Protocols, Formats & Tools o Protocols: MQTT, CoAP, etc. o Format: XML, JSON, etc. o Tools: NodeRed, Postman, etc.

III. Towards the Semantic Web of Things (SWoT) o Ontology Catalogue for IoT with LOV4IoT o Deducing meaningful information from sensor data – Reasoning with SLOR o Semantic-based Smart Cities

IV. In parallel: Quizz, Demos, MindMaps

V. Conclusion: Evaluation form, Assignments, Project Suggestions 2 The rules for this class:

Rule 1: Answer the quizz!

Rule 2: Follow interactive demos on your computer!

Rule 3: Take notes you have an evaluation form at this end of the class!

Rule 4: Assignments to learn much more at home! 3 Agenda

I. Introduction: Web of Things (WoT) o Pioneer o W3C WoT Architecture

II. Protocols, Formats & Tools

III. Towards the Semantic Web of Things (SWoT)

IV. In parallel: Quizz, Demos, MindMaps

V. Conclusion: Evaluation form, Assignments, Project Suggestions

4 Before IoT and WoT

• Marc Weiser o Father of Ubiquitous Computing o 1991 o The Computer for the 21st Century [1]

• Also Pervasive Computing, Context Awereness, etc/

• Also Internet of Things (IoT) o Kevin Ashton o 1999: Beginning of RFIDs (Radio Frequency Identification) o Usage of Internet

• Without the need to use web technologies

[1] http://www.ubiq.com/hypertext/weiser/SciAmDraft3.html 5 Connecting the things to the Web

• Example: NetAtmo provides web-based applications to monitor data.

6 Assignment

• Find and classify other devices (e.g., NetAtmo) providing web-based visualizations and access to data generated. o Documentation for developers, technologies, cost, etc.

7 Do you know who is this person?

8 Tim Berners Lee

• Inventor of the World Wide Web in 1989 • Director of the World Wide Web Consortium (W3C) • He received the 2016 Turing Award "for inventing the World Wide Web, the first web browser, and the fundamental protocols and algorithms allowing the Web to scale“.

9 What is the Web of Things (WoT)? Who is the pioneer of WoT?

10 Pioneer of the Web of Things (WoT): Dominique Guinard

• PhD thesis: A Web of Things Application Architecture [Guinard 2011] • Book: Building the Web of Things [Guinard and Trifa 2016] • Book: Using the Web to build the IoT [Guinard and Trifa 2016] • Co-founder & CTO EVRYTHNG • Web of Things community in 2007

11 Recommendations: WoT Books to read

12 Towards the Web of Things (WoT)

• Internet of Things basics have been introduced in the previous classes.

• How to send data produces by sensors/devices to the web o Connecting the things/objects to the Web! => The Web of Things (WoT)!

• => We need some protocols? o The applications accessing the sensor data need to know how to communicate with the objects, e.g., which protocols to use.

13 OSI (Open Systems Interconnection) Model

• OSI model already learnt (IoT, Reseaux, Programmable Web) • In this class: mainly focused on the application and presentation layers

://www.postscapes.com/internet-of-things-protocols/ 14 Web of Things (WoT) & OSI model layer

Book: Building the Web of Things [Guinard and Trifa 2016] 15 HTTP: Hypertext Transfer Protocol

• HTTP is an protocol that allows web- based application to communicate and exchange data

• Analogy: Carrier pigeons, post mail:

16 HTTP: List of Headers

https://en.wikipedia.org/wiki/List_of_HTTP_header_fields 17 Assignment HTTP: Video to watch at home

https://www.youtube.com/watch?v=eesqK59rhGA 18 W3C Web of Things (WoT) & W3C WoT Architecture

• World Wide Web Consortium (W3C) o Standardisation for the web

• W3C Web of Things Interest Group (WoT IG) proposed the notion of “Servient” that is currently being defined to standardized software objects in WoT applications [1]

[1] https://www.w3.org/WoT/IG 19 Web Services with REST

• REST: Representational State Transfer

• REST is an architectural style for developing distributed applications and is the basis upon the web is built.

• Loosely coupled services that can be easily reused

• Services implemented using URIs, HTTP, and standardized media types.

• Application programming interface (API) to interact with Things

PhD Thesis: https://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm [Fielding 2000] https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_1 20 REST

• RESTful Web services o Java implementation: JAX-RS

• HATEOAS: Hypermedia As The Engine Of Application State o A way for machines to understand and navigate them without having any information about them beforehand

• HYDRA o http://www.hydra-cg.com/

21 Web of Things

• Mainly based on Web technologies o Web services o URLs and URIs: set of readable characters and a way to locate the resource  E.g., https://www.youtube.com/ o HTML for provifing the Graphical User Interface (GUI) o JavaScript o CSS for customizing the GUI

22 Agenda

I. Introduction: Web of Things (WoT)

II. Protocols, Formats, Useful Tools o Protocols: MQTT, CoAP, etc. o Format: XML, JSON, etc. o Tools: NodeRed, Postman, etc.

III. Towards the Semantic Web of Things (SWoT)

IV. In parallel: Quizz, Demos, MindMaps

V. Conclusion: Evaluation form, Assignments, Project Suggestions

23 Interaction Protocols: Application Layer

Interaction Protocols

Request/Response Publish/Subscribe

E.g., HTTP E.g., CoAP E.g., MQTT E.g., XMPP

24 Interaction Protocols: Application Layer

Interaction Protocols

Request/Response Publish/Subscribe

E.g., HTTP E.g., CoAP E.g., MQTT E.g., XMPP

25 Request/Response

• Request/response: the first computer sends a request for some data and the second computer responds to the request. o Example: HTTP, CoAP

• Analogy: o Ring the doorbell, call somebody https://code.tutsplus.com/tutorials/http-the-protocol-every-web-developer-must-know-part- 1--net-31177 26 Interaction Protocols: Application Layer

Interaction Protocols

Request/Response Publish/Subscribe

E.g., HTTP E.g., CoAP E.g., MQTT E.g., XMPP

27 Publish/subscribe

• Publish/subscribe (Pub/sub): o Publishers are sending messages o Subscribers are receiving messages o Publishers and subscribers don’t know about the existence of one another. o Broker, which is known by both the publisher and subscriber, which filters all incoming messages and distributes them accordingly. o Example: MQTT, XMPP

• Analogy: o Follow someone/something on Facebook and receive notifications

28 Interaction Protocols: Application Layer

Interaction Protocols

Request/Response Publish/Subscribe

E.g., HTTP E.g., CoAP E.g., MQTT E.g., XMPP

29 HTTP

30 Postman: Plugin for Chrome to query APIs/web services Real-time Demo

31 Real-time Demo

• http://devices.webofthings.io

Book: Building the Web of Things [Guinard and Trifa 2016] 32 Postman Example

Book: Building the Web of Things [Guinard and Trifa 2016] 33 Postman Example: Asking for JSON

Book: Building the Web of Things [Guinard and Trifa 2016] 34 Content Negociation

• The process of asking for a specific encoding is called content negociation in the HTTP 1.1 specification.

35 Postman Example: Asking data from a specific device

Book: Building the Web of Things [Guinard and Trifa 2016] 36 Postman – HTTP Headers

37 Postman – HTTP Headers

38 Interaction Protocols: Application Layer

Interaction Protocols

Request/Response Publish/Subscribe

E.g., HTTP E.g., CoAP E.g., MQTT E.g., XMPP

39 COAP Video

https://www.youtube.com/watch?v=O4aaICV8ywA 40 CoAP: Constrained Application Protocol

• Internet Engineering Task Force Standard for Internet of Things

• Instead of having http:// o Coap://myhouse.local/lamps.7/status

• HTTP like verbs: GET, POST, PUT, DELETE, OBSERVE, DISCOVERY

41 Interaction Protocols: Application Layer

Interaction Protocols

Request/Response Publish/Subscribe

E.g., HTTP E.g., CoAP E.g., MQTT E.g., XMPP

42 MQTT video

https://www.youtube.com/watch?v=exMm-fmU5ck 43 MQTT (MQ Telemetry Transport) Protocol

• MQTT is a lightweight publish/subscribe messaging protocol

• MQTT is light weight, open, simple, and designed so as to be easy to implement.

• Eclipse Mosquitto™ is an open source message broker that implements the MQTT protocol [1]

https://mosquitto.org/ http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html 44 Assignment: MQTT Hands-on session

• Getting Started With MQTT and Java o http://tgrall.github.io/blog/2017/01/02/getting-started-with-mqtt/

45 MQTT @Eclipse IoT

• Eclipse: Integrated Environment Development (IDE)

• Moquitto: light and full feature broker • Paho for clients (Java, C/C++, Python, Js, Go, Lua) • Moquette: Java Broker with • Ponte: Node.js server MQTT, HTTP, CoAP • Kura: M2M application framework with MQTT as default transport

46 CloudMQTT

• Implementation of MQTT based on Mosquitto • Will be used for the hands-on session

https://www.cloudmqtt.com/docs.html 47 Interaction Protocols: Application Layer

Interaction Protocols

Request/Response Publish/Subscribe

E.g., HTTP E.g., CoAP E.g., MQTT E.g., XMPP

48 XMPP

• XMPP: Extensible Messaging and Presence Protocol o Chat Protocol based on XML o Improved for IoT

Interaction Protocols

Request/Response Publish/Subscribe

E.g., HTTP E.g., CoAP E.g., MQTT E.g., XMPP

49 can be done with:

Data Format

JSON XML

EXI CBOR

CSV EXCEL

Etc. 50 Data Format: XML

• XML: eXtensible Markup Data Format Language o Markup language that defines a set JSON XML of rules for encoding documents in a format that is both human-readable and machine-readable o Less and les less popular because of EXI CBOR JSON CSV Excel

Etc.

• XML Example:

51 Data Format: JSON Data Format

• See also Course Programmable JSON XML Web EXI CBOR • JSON is becoming more and more popular, it replaces more and more XML CSV Excel

• JSON can be easily used in web services. Etc.

• JSON Example:

52 JSON Example: Describing temperature

53 JSON

• JSON is the most successful data interchange format used on the internet.

• It has an easy-to-understand sntax and is lightweight, which makes it much more efficient to transmit compared to other formats such as XML.

• JSON is easy for humans to read and write and also for machine to parse and generate, which makes it particularly suited to be the data exchange format for the Web of Things.

54 JSON on Google Trend: 2004 -> 2016

XML on Google Trend: 2004 -> 2016

55 Data Format: CBOR

• CBOR: Concise Binary Object Data Format Representation JSON XML • Based on JSON EXI CBOR • Recommended by CoAP CSV Excel

Etc.

https://tools.ietf.org/html/rfc7049 56 Data Format: EXI

Data Format • EXI: Efficient XML Interchange JSON XML • Another data format proposed by W3C EXI CBOR • To maintain the existing interoperability between XML CSV Excel applications and XML specifications. Etc.

• Mainly designed for optimization https://www.w3.org/XML/EXI/ 57 Presentation: Formats et protocols

• Add more medatadata with: o SenML/XML, SenML/JSON, SenML/EXI o Semantic Languages: RDF, RDFS, OWL  E.g., RDF/XML  W3C Recommendations

58 SenML

• Media Types for Sensor Measurement Lists (SenML) o To represent simple sensor measurements and device parameters o Representations are in JSON, CBOR, XML, EXI o HTTP and CoAP can be used to transort such measurements

https://tools.ietf.org/html/draft-ietf-core-senml-08/ 59 SenML/JSON SENML/XML

60 SenML/JSON Example

[ { "n":"urn:dev:ow:10e2073a01080063“ ,"u":"Cel","t":1.276020076e+09, "v":23.5}, { "n":"urn:dev:ow:10e2073a01080063", "u":"Cel","t":1.276020091e+09, "v":23.6} ]

 To avoid to repeat n each time, replace by bn

[ { "bn":"urn:dev:ow:10e2073a01080063", "u":"Cel", "t":1.276020076e+09, "v":23.5}, { "u":"Cel", "t":1.276020091e+09, "v":23.6} ]

61 SenML/XML Example

62 SenML Annotator Playground

http://sensormeasurement.appspot.com/?p=senml_converter 63 NodeRed

• Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways. • It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click.

https://nodered.org/ 64 NodeRed

65 Assignment: NodeRed Tutorial

https://www.youtube.com/watch?v=vYreeoCoQPI&feature=youtu.be 66 Assignment: NodeRed in 5 minutes Tutorial

https://www.youtube.com/watch?v=f5o4tIz2Zzc 67 NodeRed Set up – Step 1

• Open a console o Ex. Search for cmd.exe with Windows

68 NodeRed Set up – Step 2 • STEP 2: Write within the console: sudo npm install -g --unsafe-perm node-red • Remove sudo on Windows

https://nodered.org/docs/getting-started/installation 69 NodeRed Set up – Step 3

• STEP 3: Within the console write the following command: node-red

https://nodered.org/docs/getting-started/running 70 NodeRed Set up – Step 4

• STEP 4: Open a browser o Access the Node-RED editor at http://localhost:1880

https://nodered.org/docs/getting-started/running 71 Do you remember the class from Orange – Pierre Rust?

What are the IoT applicatives?

72 Cours Pierre Rust

• Applicative Domains: o Wearables, IoT, smart homes, Energy, Smart Agriculture, Transportation, Smart cities

• => We have done a huge classification of projects integrating semantic web technologies in those domains o Semantic Web dedicated course o What you need here  We need model to structure data  In semantic web we call them ontologies  Something similar to UML

73 Any ideas of smart cities?

74 Assignment

• Find and classify sensors relevant to build smart cities?

75 Agenda

I. Introduction: Web of Things (WoT)

II. Sensor Discovery: Protocols & Formats

III. Towards the Semantic Web of Things (SWoT) o Ontology Catalogue for IoT with LOV4IoT o Deducing meaningful information from sensor data – Reasoning with SLOR o Semantic-based Smart Cities

IV. In parallel: Quizz, Demos, MindMaps

V. Conclusion: Evaluation form, Assignments, Project Suggestions

76 Google Knowledge Graph

https://www.youtube.com/watch?v=mmQl6VGvX-c 77 How to Deduce Meaningful from Sensor Data?

Sensor data

Thermometer Interpretation How machines can by humans interpret data?

Applications to visualize data Machine learning? Reusing domain knowledge?

14/08/2017 78 Taking inspiration from Automatically built semantic web technologies by machines

79 Why Do We Use Semantic Web Technologies Within Internet of Things?

• Machine-understandable data • Describe data with common vocabularies Global interoperability • Reuse domain knowledge • Link to other data • Ease the reasoning  How to provide a common description of sensor data to later reason on it? Common description

Device Abstraction

Common App. Protocol Common Nwk. Protocol

“Semantic Web of Things: an analysis of the application semantics for the IoT moving towards the IoT convergence” [Jara et al. 2014] 80 What do you know about UML?

81 UML (Unified Modeling Language)

• Example:

• => Could be implemented as an ontology/vocabulary (See Semantic Web Course) 82 Do you know what is an ontology catalogue? Which ones?

83 How to reuse knowledge already designed?

Let’s talk about: Linked Open Vocabularies for Internet of Things (LOV4IoT)

84 LOV4IoT Demo Embedded

LOV4IoT Video on Youtube: https://youtu.be/a1zsdkzE_oY 85 LOV4IoT Demo: HTML User interface A second life for ontologies!

=> Classification by domain

http://www.sensormeasurement.appspot.com/?p=ontologies 86 LOV4IoT Demo: HTML User interface A second life for ontologies!

=> Classification according to semantic web best practices

87 How to exploit the domain knowledge already available on the Web and make it interoperable?

• Domain knowledge already structured and designed

• Ontologies used to share and reuse the domain knowledge

Collect Classify Interoperability 88 LOV4IoT: An ontology catalogue

• LOV4IoT: Linked Open Vocabularies for Internet of Things (LOV4IoT) o An extension of the Linked Open Vocabularies (LOV) catalogue o Numerous ontologies relevant for IoT were not referenced yet due to a lack of unknown semantic web best practices

• LOV4IoT: A dataset referencing more than 350 ontology- based projects relevant for various (IoT) domains o Ontologies, Datasets, Rules, Technologies, Sensors and Domains o LOV4IoT RDF dataset to make statistics o Long-term goal: Reusing and Extracting domain knowledge to build (IoT) applications

89 LOV4IoT Demo: Web services and RDF dataset E.g.: Automatically compute the number of projects per Web service called: domain http://sensormeasurement.appspot.com/lov4iot/nbOntoD omain/?domain=BuildingAutomation

Display the result returned by the web service:

90 Multiple Ontology for standardizations

• W3C Semantic Sensor Networks (SSN) [1] o V1 released in 2011 o V2, Oct. 2017 -> W3C recommendation

• OneM2M ontology [2] o Does not reuse SSN

• W3C Web of Things (WoT) ontology [3]

• iot.schema.org (ongoing)

[1] https://www.w3.org/TR/vocab-ssn/ [2] http://www.onem2m.org/technical/developers-corner/tools/onem2m-ontologies [3] http://iot.linkeddata.es/def/wot/index-en.html 91 Learning existing ontology catalogues tools with MindMap • Interact with the online interactive MindMap

http://lov4iot.appspot.com/?p=ontology_catalogue_sota 92 Do you know what is a mindmap?

93 MindMap: Introduction

• Tony Buzan: creator of Mindmaps • Used to strcture thoughts • Also used for teaching, management, etc.

• Numerous tools: o Coogle: Collaborative tool online (free)  https://coggle.it/

94 Smart Cities: MindMap

Interactive Mindmap: http://semantic-web-of-things.appspot.com/?p=smartCity

95 Assignment

• Paper to read: o Internet of Things for Smart Cities [Zanella et al. 2014]  http://ieeexplore.ieee.org/document/6740844/

96 Project Suggestion: Programming with JavaScript

• D3.js is a javaScript library to visualize any datasets in a user friendly interface [1]. A large set of visualizations is provided. • Suggestion: Parse a dataset file [2] and use JavaScript for a better visualization

[1] http://d3js.org/ [2] http://sensormeasurement.appspot.com/dataset/lov4iot-dataset 97 Project Suggestion: Bubble view to classify datasets according to the resource type

• Project Suggestion: Take inspiration from LOV [1] user interface and adapt it to IoT domain o Bubble view to classify datasets according to the resource type o Technology: Use D3.js JavaScript library for visualizations.

[1] http://lov.okfn.org/dataset/lov/ 98 Project Suggestion: Bubble view to classify datasets according to the IoT applicative domain

• Project Suggestion: Take inspiration from LOV [1] user interface and adapt it to IoT domain o Bubble view to classify datasets according to the resource type o Technology: Use D3.js JavaScript library for visualizations.

[1] http://lov.okfn.org/dataset/lov/ 99 List of sensor datasets

• E-learning web page sensor datasets o http://semantic-web-of-things.appspot.com/?p=sensorDataset

• Catalogue of datasets o E.g., CKAN: https://ckan.org/

• Datasets could be used to visualize IoT datasets or to do analytics on them.

100 How to interpret IoT data?

Let’s talk about: Logic-based reasoning with Sensor- based Linked Open Rules (S-LOR)

101 Towards the Next Linked Open *

?

Linked Open Data (LOD) Linked Open Vocabularies (LOV)

Let’s build the Linked Open Rules: Sharing and reusing logical rules

102 Sensor-based Linked Open Rules (S-LOR)

1) Dataset of logic- 2) Selection of based rules to Rules specific interpret IoT data to sensors, applicative domains, etc.

3) Domain knowledge 4) Reducing extracted from development time of IoT applications and increase interoperability 103 S-LOR Demo Embedded

SLOR Video on Youtube: https://youtu.be/_l81H4pxqfA 104 S-LOR Demo: Rule Discovery Web Service

Sensor name compliant with the M3 ontology (= classification of sensors)

URL of the rule to get the implementation

http://sensormeasurement.appspot.com/slor/rule/LightSensor105 SLOR Demo: Rule Discovery GUI - Demo V1

Classification of sensors (M3 ontology)

URL of the rule to get the implementation

Demo online: http://sensormeasurement.appspot.com/?p=slor 106 SLOR Demo: Rule Example • Rules compliant with the Jena framework • Rules compliant with a taxonomy of sensors, applicative domains, etc. (M3 ontology)

107 SLOR Demo: Rule Engine Executed on RDF datasets

• E.g., IoT application using precipitation sensor and precipitation rules

=> Executing the Jena reasoning engine with a subset of SLOR-dataset => Reasoning Result is parsed and displayed in this dataset => Adding new triples with the RDF dataset 108 SLOR Demo: Rule Discovery GUI - Demo V2

1. Select a domain to get all sensor specific to the domain 2. Select a sensor to get all rules specific to this sensor 3. Select a sensor to get the provenance of the rules

1 3 2

Demo online: http://sensormeasurement.appspot.com/?p=slorv2 109 S-LOR embedded in Constrained Devices • SLOR can be executed on Android-embedded devices thank to AndroJena.

110 Towards the Linked Open Reasoning

http://linkedopenreasoning.appspot.com/ 111 Fill in the evaluation form: 10 mins!

• To evaluate what you understood

• Evaluation form to fill in: https://goo.gl/forms/u6oSiSBBsRdWe1nt1

112 From Internet of Things (IoT) to Web of Things (WoT): Protocols, data formats, etc.

MINES Saint-Étienne, CNRS Lab Hubert Curien UMR 5516

Amelie Gyrard [email protected]