# Web of Things and Rust
---
## Intro
- Luca Barbato
- Edoardo Morandi
---
## Intro - Internet Of Things
- Connected Stuff
- Connected what?
- Risks and operational problems
- Oven-roast-3am
- ...
---
## Internet Of Things - Problems
- Many many walled gardends
- Who owns what?
- Who controls what?
---
## Intro - SIFIS Home
- We try to prove those problems have a solution
---
## SIFIS Home
- SIFIS Pillars
- Safe by default (and Smarter)
- Fault tolerant
- Interoperable
---
## SIFIS Home - Safe by default
- SIFIS uses some (ML and not) techniques similar to those deployed on network IDS to prevent incidents by doing some sort of behavioural analysis
- e.g. if it is uncommon that you roast a turkey at 3:00 AM the system will prevent the action and ask you if you are __really__ sure.
---
## SIFIS Home - Fault tolerant
- The SIFIS system is redundant by default and leverages libp2p primitives to distribute information and manage consensus
---
## SIFIS Home - Interoperable
- We chose to rely on and implement the W3C Web Of Things
- The W3C Thing Description paradigm fits perfect our needs
- We need a mean to add additional semantic meaning to what every connected component can do so the system can reason about it and the user can be made aware of the risks.
---
## Web Of Things
- Key concepts
- Thing Description
- Servient
- Discovery
---
## Web Of Things - Thing Description
- Every device, physical or logical is a Thing
- A Thing is able to self-describe
- The Thing Description provides all the information you need to control a device.
---
## Web Of Things - Thing Description
- The description groups the way to interact with a device in 3:
- **Properties**: a direct read or write access to the device state, e.g. `On/Off` state.
- **Actions**: a command that will be execute by the device over time.
- **Events**: information that the device may emit.
- They are called interaction affordance.
---
## Web Of Things - Servient
- A connected Thing acts both as Client and Server, thus the portmanteau Servient.
- TBD
---
## Web Of Things - Discovery & Directory
- Web Of Things defines how thing can advertise their existence over the network (discovery)
- It also defines how this information should be provided, leveraging the Servient and Thing Description systems.
---
## Web Of Things - Thing Description in SIFIS
- The Thing Description is based on JSON-LD
- It lets you add additional Contexts (ontologies) to extend the Description
- We wrote an ontology to express which are the risks for each affordance with adequate granularity: e.g. the `brightness` of an halogen lamp can get risky if it is above `80%`.
---
## Rust + Web Of Things = wot-rust
- Most of the SIFIS code is written in Rust
- We started contributing with the Webthings.io implementations of WOT.
- We ended up implementing from ground up WOT writing smaller reusable crates.
---
## wot-rust
It is composed of 3 crates
- `wot-td` to serialize and deserialize the Thing Descriptions
- `wot-serve` to build servients as you build their matching Thing Description
- `wot-discovery` to discover servients advertising over mDNS and keep a directory of them
---
## wot-td
---
## wot-td
- The Thing Description is based on JSON-LD and it is overly extensible.
- We ideally want to be able to provide a **type safe** way to deal with that.
---
## wot-td - Architecture
{"metaMigratedAt":"2023-06-17T05:43:00.612Z","metaMigratedFrom":"YAML","title":"Web of Things and Rust","breaks":true,"contributors":"[{\"id\":\"eb4a4496-41ef-46e3-8970-f8220f409921\",\"add\":3757,\"del\":219}]"}