Web-Integrated Smart City InfrastructureA caching proxy for hybrid CoAP-HTTP networks.
Supervisor: Candidate:Prof. Dr. Giovanni Malnati Francesco Corazza
Co-supervisors: Prof. Dr. Stefano Ceri (Politecnico di Milano) Prof. Dr. Friedemann Mattern (ETH Zurich)
Tutor: Dipl.-Ing. Matthias Kovatch (ETH Zurich)
26 November 2012
Web-Integrated Smart City Infrastructure
2
Smart Cities?
Francesco Corazza
Ningbo City, China Taipei , Taiwan
Web-Integrated Smart City Infrastructure
5
• • • • • 1. Smart Cities and Internet:
interconnected worlds
• Wireless Sensor Network (WSN)• Spatially distributed autonomous sensors
• Low bandwidth, lossy, unstable medium
• Low energy, power, processing, faults
• IEEEE 802.15.4 – Low Rate WPAN
• Internet of Things• Proprietary solutions
• IPv6 over Low-power WPAN (6LoWPAN)
• IP as common language• “Things” can access standard web services
• “Things“ can be addressed from Internet
• Application-layer interconnection (Web)
The Internet of Things vision
• • •
Internet of Things
(Trillions of nodes)
Fringe Internet(Billions of
nodes)
Core Internet(Millions of nodes)
Francesco Corazza
Web-Integrated Smart City Infrastructure
7
• • • • • 1. Smart Cities and Internet:
RESTfy real world
• Web of Things• Web tools in real world (browser, search)
• Physical/virtual mashups
• REST• Everything is a resource
• Architectural constraints
• Scalability, usability, and accessibility
• HTTP
• Constrained Application Protocol • Designed from a subset of HTTP
• Low overhead (UDP fragmentation)
• Machine to Machine (M2M) applications
Francesco Corazza
Intersection originating the WoT
• • •
Web-Integrated Smart City Infrastructure
9
• • • • •
1. Smart Cities and Internet:CoAP (Constrained Application Protocol)
• Features• Async communication (request/response)
• Stateless reliability (confirmable/ack)
• Security (CoAPS)
• Observation (native publish/subscribe)
• Blockwise transfers (stateless large transfers)
• Options• Minimum parsing complexity
• Finite number of identifiers
• Caching• Freshness model
• Validation model
• Proxying
Francesco Corazza
1 802.15.4.5 PHYEthernet PHY
2 802.15.4.5 MAC
Ethernet MAC
3 IP
4 UDPTCP
7 CoAPHTTP
IPv6
6LoWPAN
HTTP vs. CoAP protocol stack
• • •
Web-Integrated Smart City Infrastructure
11
• • • • • 2. Web-Integration:
proxy deployment
• Positioning• Server-side
• Client-side
• External
• Server-side proxy✓ Effective TCP/UDP mapping
✓ Caching
✓ Multicast
✓ Traffic queuing and limiting
✗ Scalability
✗ Availability
• Uri-mapping• Homogeneous (intercepting proxy)
• Embedded (reverse proxy)
Francesco Corazza
Forward proxy
Reverse proxy
Intercepting proxy
• • •
Web-Integrated Smart City Infrastructure
13
Francesco Corazza
• Reverse proxy
• Embedded uri-mapping
HTTP RequestGET http://proxy.mywsn.com/coap/cnb.mywsn.com/b/tempAccept: application/json
2. Web-Integration:cross-protocol mappings (HTTP to CoAP)
• • •
Web-Integrated Smart City Infrastructure
14
Francesco Corazza
• HTTP-CoAP mapping• Split HTTP request uri
• Map Accept header
CoAP RequestType: CONFIRMABLE - Uri-host: cnb.myswn.comCode: GET - Uri-port: 5683Options: - Uri-path: b- Accept: 50 - Uri-path: temp
2. Web-Integration:cross-protocol mappings (HTTP to CoAP)
• • •
Web-Integrated Smart City Infrastructure
15
Francesco Corazza
• Piggybacked response
• Mag-Age
CoAP ResponseType: ACKNOWLEDGE Options:Code: 2.05 - Content-Type: 50Payload: {temp: 21.5} - Mag-Age: 60
2. Web-Integration:cross-protocol mappings (HTTP to CoAP)
• • • • • •
Web-Integrated Smart City Infrastructure
16
Francesco Corazza
• CoAP-HTTP mapping• Cache-Control
• Content-Type
Http ResponseStatus-Code: 200 OKCache-Control: max-age=60Content-Type: application/json; charset=utf-8Body: {temp: 21.5}
2. Web-Integration:cross-protocol mappings (HTTP to CoAP)
• • •
Web-Integrated Smart City Infrastructure
19
• • • • • 2. Web-Integration:
caching
• Response code (≠ HTTP)• 2.05, cache
• 2.03, update
• 2.0x, invalidate
• Update max-age• Time passed in cache
• max_age = original_max_age - cache_age
Francesco Corazza
• • •
Web-Integrated Smart City Infrastructure
22
• • • • • 3. Design the proxy:
components
• Californium• Rapid prototyping in backend
• Layered architecture
• Apache HttpCore• Minimal memory footprint
• Non-blocking I/O
• Apache HttpClient• Uses HttpCore internally
• 1xx & 3xx codes managed
• Built-in security
• Google Guava Cache• Used in production by Google
• 286.000 tests
Francesco Corazza
• • •
Web-Integrated Smart City Infrastructure
23
• • • • • 3. Design the proxy:
integration (Californium architecture)
• Layered architecture• Chain of Responsibility
• Single thread model
• Limited to clients and servers
• Pitfalls• Synchronized responses
• Blocking UDP thread
• Missing client abstraction
• Missing server abstraction
Francesco Corazza
Resources
Abstractions
Layers
Communicator
Endpoint
Resource
UDPLayer
TransferLayer
Variable Layers
⟳
• • •
Web-Integrated Smart City Infrastructure
25
• • • • • 3. Design the proxy:
integration (proxying)
• Encapsulations• Forwarding resources (client)
• Stacks (servers)
• Multi-thread model• Concurrent responses
• Resource thread-safeness
• Non-blocking UDP thread
• Communicator• Two message flows
• Thread-safeness
• Endpoint• Avoid HTTP in CoAP servers
• Encapsulate cache
Francesco Corazza
Servers
Resources
Abstractions
Resource
HTTP Resource
CoAP StackHTTP Stack
CoAP Resource
Proxy Endpoint
Proxy Communicator
⟳⟳⟳⟳
⟳⟳⟳
• • •
Web-Integrated Smart City Infrastructure
26
Resources
Abstractions
Servers HTTP StackCoAP Stack
Proxy Communicator
Proxy Endpoint
HTTP Client
CoAP ClientResource
3. Design the proxy:final architecture
Francesco Corazza
HTTP Translator
HTTP Translator
Cache
• • •
Web-Integrated Smart City Infrastructure
• • • • • 4. Evaluation:
performance assessment
• Emulation• Proxy JVM limitation
• CoAP Server Virtualization
• Test client• Pre-compiled requests
• Random distribution of requests
• Normal distribution of resources
• Average of several “runs”
• Produced data• Raw RTT distributions
• RTT/throughput trends
• CDF for RTT
Francesco Corazza
27
0 100 200 300 400 500 600 700 800 900 10000
50
100
150
200
250
300
350
400100 requests/s
200 requests/s
400 requests/s
600 requests/s
• • •
Request number
Avera
ge R
ound T
rip T
ime (
ms)
Web-Integrated Smart City Infrastructure
4. Evaluation:performance assessment (CoAP-to-HTTP proxying)
Francesco Corazza
28
0 100 200 300 400 500 6000
0.2
0.4
0.6
0.8
1
100 Kbit/s w/ cache 400 Kbit/s w/ cache
100 Kbit/s w/o cache 400 Kbit/s w/o cache
0 50 100 150 200 250 300 350 400 4500
50100150200250300350
Tests w/o cachingTests w/ caching
• • •
Produced throughput (Kbit/s)
Average Round Trip Time (ms)
Avera
ge R
TT (
ms)
Cum
ula
tive D
ensi
ty F
.
Web-Integrated Smart City Infrastructure
33
• • • • • 4. Evaluation:
hybrid mashup
Francesco Corazza
• • •
HTTP to CoAPParaimpu control Panel
Twits containing temperatures
Web-Integrated Smart City Infrastructure
35
• • • • • Conclusions
• Smart city• Mashup as leading paradigm in the WoT
• Scalability through physical locality
• Chains of proxies
• Lesson learnt• Design for extensibility
• Interoperability through standards
• Cheat sheet for overlapping specifications
• Future work• Standardization process
• Intercepting proxy
• Secure proxy (HTTPS-CoAPS mapping)
Francesco Corazza
0
1000
2000
3000
4000
5000
6000
7000K Lines added
K Unchanged Lines
CoAP draft evolution
Web-Integrated Smart City Infrastructure
36
Thank you for the attention
Francesco Corazza
Top Related