Back-end Integration Issues for CoAP Matthias Kovatsch Tuesday, 27 Nov 2012

advertisement
Back-end Integration Issues for CoAP
Matthias Kovatsch
kovatsch@inf.ethz.ch
Tuesday, 27 Nov 2012
OUTLINE
Experiences from Implementing Californium
Client/Server Architectures
Web Browser Integration
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
Experiences with Implementing Everything
C AP back-end
CoAP
b k d fframeworkk
Clients, servers, and proxies
p
Blockwise transfers,
Observing resources
resources,
caching cross-proxy
DTLS 1.2 support
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
3
Internal Structure
ƒ Separation of concerns is good
ƒ Separation
p
of state is not
ƒ Retransmissions vs Observe
ƒ MID vs Token
ƒ Deduplication
D d li ti vs separate
t responses
ƒ Californium “2.0”
ƒ
ƒ
ƒ
ƒ
Connectors for different transport
Req/res matching directly after parsing
Separate
p
p
processing
g layers
y
All exchange state in one object
ƒ (Do not port the current code)
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
CoAP Endpoint
Token Layer
y
Transfer Layer
Matching Layer
Rate Control Layer
y
Message Layer
Adverse Layer
UDP
DTLS
…
4
CLIENT VS SERVER
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
5
Resource-Oriented Architecture
‘active’
Mappings
can become
very complex
/conf/map/on
/conf/map/off
/switch
observe
‘true’
/conf/observe
/power
What about
additional
rules?
Matthias Kovatsch – ETH Zürich
URI
Everything
must be
prepared
Back-end Integration Issues for CoAP
6
Mixing Client and Server Role
ƒ Suitable for many M2M applications
ƒ Good compromise
p
for convergence
g
however
ƒ
ƒ
ƒ
ƒ
ƒ
Conflicts with REST constraints
State space is distributed over all nodes
Application state can become complex at clients
Usually no caches inside LLNs
REST keeps servers simple
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
7
Thin Server Architecture
/sen/humidity
/raw/ADC2
/config/program
/config/temperature
/sensors/temp
/status/power/consumption
/set/valve
/status/timeleft
/ /
/set/target
/action/run
/relay
Application-agnostic
hardware wrappers
Matthias Kovatsch – ETH Zürich
/meter/power
/switch
Back-end Integration Issues for CoAP
8
Web Scripting for Class 1 Devices
http://weather com
http://weather.com
Heating Script
if ( occupied ) {
heatRoom( COMFORT_TEMP );
}
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
9
Actinium (Ac) RESTful Runtime Container
Script
POST
/install
2.01 Created
POST
Config
/installed/my-app
2.01 Created
DELETE
PUT
2.04
2.02Changed
Deleted
Matthias Kovatsch – ETH Zürich
Server-side
JavaScript
/instance/my-instance
/running/my-instance
Back-end Integration Issues for CoAP
Sandbox REST API
10
Actinium (Ac) Apps Are REST Resources
// handler for GET requests to "/"
// handler for GET requests to /
app.root.onget = function(request) {
// returns CoAP's "2.05 Content" with payload
request.respond(2.05, "Hello world");
};
// sub‐resource "/config"
var sub = new AppResource(
AppResource("config");
config );
sub.onput = function(request) {
variable = request.payloadText;
request.respond(2.04); // "2.04 Changed"
};
app.root.add(sub);
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
11
Mashups
Ac App
Ac App
Ac App
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
12
Mashups with Devices and Other Apps
var req = new CoapRequest();
// Request the temperature sensor reading via CoAP
req open("GET"
req.open(
GET , "coap://mote1
coap://mote1.example.com/sensors/temp
example com/sensors/temp",
false /*synchronous*/);
// Set Accept header to application/json
req.setRequestHeader("Accept", "application/json");
req.send(); // blocking
// Use IoT data just like Web data
var roomTemperature = JSON.parse(req.responseText);
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
13
CoapRequest with CoAP-specific Features
req.open("GET", "coap://app‐server.example.com/
running/occ‐room1/occupancy”, true /
running/occ‐room1/occupancy
/*asynchronous*/);
asynchronous /);
// Register for CoAP Observe push notifications
req.setRequestHeader("Observe", "0");
// define the callback for push notifications
req.onprogess = function() {
switchLights(this responseText=="true");
switchLights(this.responseText==
true );
};
// define the callback for normal/final response
req.onload = function() {
handleNotObservable(this);
};
req.send(); // non‐blocking
req.send(); // non
blocking
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
14
Web Integration with Copper (Cu)
Browse embedded resources just like the Web
CoAP protocol handler
and GUI for Firefox
Discovery and interaction
Resource visualization
Mozilla open for integration
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
15
Web Browser Integration
We need integration
g
into Web applications
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
16
ToDos
ƒ Develop application scenarios
ƒ Define reasonable securityy model
ƒ Convince the browser vendors
ƒ Provide patches
ƒ Overcome the chicken-egg problem
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
17
THANK YOU
Questions?
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
18
Publicly Available Resources
ƒ Open Source Software under 3-Clause BSD on GitHub:
ƒ https://github.com/mkovatsc
ƒ Maven repository:
ƒ http://maven.thingml.org/
ƒ Copper (Cu) Firefox add-on:
ƒ https://addons.mozilla.org/en-US/firefox/addon/copper-270430/
ƒ CoAP
C AP test
t t server:
ƒ coap://vs0.inf.ethz.ch:5683/
ƒ Papers:
ƒ http://people.inf.ethz.ch/mkovatsc/#publ
http://people inf ethz ch/mkovatsc/#publ
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
19
Ac Round-Trip Time Overhead
A
App server
Border
router
R
Router
SLIP
Subnet A
Subnet B
M
Mote
1 10
1..10
802.15.4
CH 21
LLN
Minimum
Maximum
Average
Ping
32ms
77ms
46ms
CoAP (Cf)
34ms
78ms
48ms
+2ms
Actinium
33ms
97ms
49ms
+1ms
1000 Requests
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
Overhead
20
Mixing Client and Server Role Is Not RESTful
ƒ But
ƒ Peer-to-peer architecture is perfect for many M2M applications
ƒ CoAP enables convergence
ƒ CoAP servers are a good way to configure clients
ƒ However, REST means HATEOAS
ƒ Application logic must be disseminated to all nodes
ƒ Application state can become complex at client
ƒ REST relies on caches which are hard within LLNs
ƒ REST becomes central for Web integration
g
of devices
Matthias Kovatsch – ETH Zürich
Back-end Integration Issues for CoAP
21
Download