Building the Web of Things with Sun Spots Vipul Gupta and David G

Building the Web of Things with Sun Spots Vipul Gupta and David G

Building the Web of Things with Sun SPOTs Vipul Gupta and David G. Simmons, Sun Labs, Oracle [email protected], [email protected] Ver: 20100921180500 JavaOne 2010, Hands-on Lab Agenda • Background: From the Internet of computers to the Internet of things. • The Web of Things: Vision, relevant technologies, challenges in constrained environments, examples. • Introduction to Sun SPOTs: motivation, features. • Lab overview and exercises: • Sample “Flashlight” application on Sun SPOTs (Ex 1) • RESTful web application on Sun SPOTs (Ex 2) • Exposing the light sensor (Ex 3) and LEDs (Ex 4) as web resources • Access control (Ex 5) 2 Background • People have been connecting “things” to the Internet even before the “Web” More Info: - Trojan room coffee pot http://www.cl.cam.ac.uk/coffee/qsf/coffee.html - Romkey & Hackett’s Internet Toaster, Interop ’90 http://www.savetz.com/yic/YIC11FI_6.html - Robin Southgate, 2001 http://news.bbc.co.uk/2/hi/science/nature/1264205.stm 3 Background • People have been connecting “things” to the Internet even before the “Web” • This trend is accelerating: phones, household appliances, sensor platforms, ambient devices, energy meters, health and fitness devices, asset tracking 4 Background • People have been connecting “things” to the Internet even before the “Web” • This trend is accelerating: phones, household appliances, sensor platforms, ambient devices, energy meters, health and fitness devices, asset tracking • Commercial entities are getting involved • Lots of standards activities: IEEE, IETF, IPSO, OGC, WWW OAuth SensorML Microformats 802.15.4 ROLL 6lowPAN CHTTP SWE EXI RHTTP Webhooks CoRE 5 Background • People have been connecting “things” to the Internet even before the “Web” • This trend is accelerating: phones, household appliances, sensor platforms, ambient devices, energy meters, health and fitness devices, asset tracking • Commercial entities are getting involved • Lots of standards activities: IEEE, IETF, “ IPSO, OGC, WWW • Recognition in mainstream media ’’ 6 Background • People have been connecting “things” to 10 fool-proof predictions for the Internet in 2020 the Internet even before the “Web” 3. The Internet will be a network of things, not computers. • This trend is accelerating: phones, As more critical infrastructure gets hooked up household appliances, sensor platforms, to the Internet, the Internet is expected to ambient devices, energy meters, health become a network of devices rather than a and fitness devices, asset tracking network of computers.Today, the Internet has around 575 million host computers, according to the CIA World Factbook 2009. But the NSF • Commercial entities are getting involved is expecting billions of sensors on buildings and bridges to be connected to the Internet for such uses as electricity and security • Lots of standards activities: IEEE, IETF, monitoring. By 2020, it's expected that the IPSO, OGC, WWW number of Internet-connected sensors will be orders of magnitude larger than the number of users. • Recognition in mainstream media 7 Motivation • Comfort and entertainment -- smart environments (buildings, homes) • Proactive health management -- both people and things (maintenance/repair) • Better efficiency -- resource management (lower cost of heating/cooling) • Timely access to information -- smart phones, environmental sensors • Improved security and peace of mind -- accurate, responsive tracking of valuable assets Connected, smarter living 8 Commercial Opportunities • “Things” or platforms for building “things”: (Arduino, BugLabs, Sun SPOT, TED, Chumby, Nabztag, Nike +iPod, Wattson, sensaware, Crossbow) • Applications (PowerMeter, RunKeeper) • Infrastructure components: gateways, relay services (therecorporation.com, iobridge.com, yaler.org) • Platforms: middle-ware or hosted service for data collection and analysis (Pachube, Sensor.Network) 9 Agenda • Background: From the Internet of computers to the Internet of things. • The Web of Things: Vision, relevant technologies, challenges in constrained environments, examples. • Introduction to Sun SPOTs: motivation, features. • Lab overview and exercises: • Sample “Flashlight” application on Sun SPOTs (Ex 1) • RESTful web application on Sun SPOTs (Ex 2) • Exposing the light sensor (Ex 3) and LEDs (Ex 4) as web resources • Access control (Ex 5) 10 Web Of Things • What? “A vision where everyday devices and objects are integrated into the Web using well-known standards and blueprints (URIs, HTTP, REST).” “Seamless integration of physical and conceptual resources” Also: “The physical web”, “the tactile web” • How? - Connect device to Internet, - Embed web server, - Model resources as URIs 11 REST (Representational State Transfer) • Architectural style of the World Wide Web • "The main idea of REST is to design applications which implement their functionality completely as a set of URI-addressable resources, with HTTP being the [uniform] access method for interacting with them. In such an application, there is no need for any special interface, the application fully blends into the Web ..." -- Erik Wilde, UC Berkeley Putting things to REST More Info: - Roy Fielding’s Ph.D. Thesis (http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm) - REST Wiki (http://rest.blueoxen.net/) 12 REST in a Nutshell • Identify application “resources” using URIs. • Each resource implements some subset of a uniform interface: POST (Create), GET (Read), PUT (Update), DELETE (Destroy). Response codes describe method success/failure. • Representations (XHTML, XML, JSON), conceptually separate from resources, transferred in requests/responses. • Representation includes metadata and links to related resources. 13 REST Examples • Create a new resource, e.g. deploy an application POST /apps HTTP/1.1 Content-Type: application/binary Client Content-Length: 8914 <application binary> Sun SPOT HTTP/1.1 201 Created Location: /apps/SensorSampler • Delete a resource, e.g. undeploy an application Client DELETE /apps/SensorSampler HTTP/1.1 Sun SPOT HTTP/1.1 200 OK 14 REST Examples (cont’d) • Read a resource, e.g. read the light sensor reading GET /light HTTP/1.1 Client Accept: */* Sun SPOT HTTP/1.1 200 OK Content-Type: text/plain Content-Length: 3 138 • Update a resource, e.g. change color of LED 4 PUT /leds/4 HTTP/1.1 Content-Type: text/plain Client Content-Length: 7 Sun SPOT 0,255,0 HTTP/1.1 200 OK 15 REST Benefits • Simplifies integration of resources into the Web, making them accessible as part of a global information system. • Ease building of apps on top of embedded devices, dynamic ad-hoc composite apps involving real-world devices (physical mashups) • “Uniform interface” enables interaction with all sorts of devices via readily available software (browsers, cURL) • “Layered system” supports intermediaries, great for addressing device/ network constraints • Get lots of features for free: caching, linking, security, bookmarking, searching, (HTTP utilized as an application protocol, not just transport). 16 Network Bandwidth Constraints • HTTP, XML are verbose. TCP connection setup/teardown adds overhead. • Use caching, compression via binary encoding, use UDP, e.g. Efficient XML Interchange (http://www.w3.org/XML/EXI/), HTTP header compression (IETF CoRE, draft-tolle- core-ebhttp-00, draft-frank-6lowpan-chopan-00) Sun SPOT Uncompressed Compressed Client GET /spot-5317/temp HTTP/1.1 Accept: */* 13 bytes Host: localhost:8080 0000 - 68 36 47 2f 74 65 6d 70-00 0e 00 00 00 h6G/temp..... Content-Length: 0 User-Agent: curl/7.19.7 ... zlib/1.2.3 HTTP/1.1 200 OK 18 bytes Content-Type: text/plain Cache-Control: max-age=60 0000 - 48 36 40 11 b0 01 0a 00-3c 0e 00 05 00 38 39 2e H6@.....<....89. Content-Length: 5 0010 - 31 35 15 89.15 17 Network Topology Constraints • Device could be behind firewall/NAT, might move • Use relay, with “long-poll” and Reverse HTTP (draft-lentczner-rhttp-00) Sun SPOT Client relay.net POST /spot-5317 HTTP/1.1 Upgrade: PTTH/1.0 Connection: Upgrade Host: relay.net HTTP/1.1 101 Switching Protocols Upgrade: PTTH/1.0 Connection: Upgrade GET /spot-5317/light HTTP/1.1 Host: relay.net GET /spot-5317/light HTTP/1.1 HTTP/1.1 200 OK HTTP/1.1 200 OK Connection: close Connection: close Content-Length: 3 Content-Length: 3 216 216 18 Energy Constraints • Devices sleep periodically to conserve battery • Use sleep-proxy to queue requests, cache responses zz z Sleep z z z proxy z Sun SPOT Client (sleep notification) GET /spots/01AB/temp HTTP/1.1 Cache-Control: max-age=60 HTTP/1.1 200 OK Age: 22 Content-Length: 5 86.45 PUT /spots/01AB/leds/5 HTTP/1.1 Content-Length: 7 0,255,0 HTTP/1.1 202 Accepted Retry-After: 45 Location: spots/01AB/requests/1cqfw 19 Discovery • Finding/understanding what a “thing” provides, relationship to other things • Bootstrapping: Well defined location for metadata (/.well-known, RFC 5785) • Typed links: Use the “rel” attribute in links to describe relationships (draft-nottingham-http-link-header-10), e.g. Link: </>; rel=“http://example.net/foo’’ • Microformats (microformats.org) <div class="vcard"> <div class="fn">Joe Doe</div> <div class="org">The Example Company</div> <div class="tel">604-555-1234</div> <a class="url" href="http://example.com/"> http://example.com/</a> </div> See also: http://hueniverse.com/2009/11/the-discovery-protocol-stack-redux 20 Notifications • Webhooks: an HTTP callback in the form of a POST Client postbin.org Sun SPOT HEAD /spots/01AB/light HTTP/1.1 HTTP/1.1 200 OK Link: </spots/01AB/light/web-hooks>, rel=”subscriptions” POST /spots/01AB/light/web-hooks HTTP/1.1 Notification-Type:

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    66 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us