+ All Categories
Home > Education > The constrained application protocol (coap) part 3

The constrained application protocol (coap) part 3

Date post: 16-Apr-2017
Category:
Upload: hamdamboy
View: 134 times
Download: 3 times
Share this document with a friend
23
The Constrained Application Protocol (CoAP)-Part 3& Conclusion Khamdamboy Urunov, a Ph.D. student., [email protected]
Transcript
Page 1: The constrained application protocol (coap)  part 3

The Constrained Application Protocol (CoAP)-Part 3&

Conclusion

Khamdamboy Urunov, a Ph.D. student.,[email protected]

Page 2: The constrained application protocol (coap)  part 3

2

CoAP Method

http://www.slideshare.net/JunHwanHuh/one-m2mprotocol-binding/15

Page 3: The constrained application protocol (coap)  part 3

3

The PUT method requests that the resource identified by the request URI be updated or created with the enclosed representation.

If a resource exists at the request URI, the enclosed representation SHOULD be considered a modified version of that resource, and a 2.04 (Changed) Response Code SHOULD be returned.

If no resource exists, then the server MAY create a new resource with that URI, resulting in a 2.01 (Created) Response Code.

If the resource could not be created or modified, then an appropriate error Response Code SHOULD be sent.

Method: PUTURI: coap://scrc.com/Value: PUT/resource/db/app1/sensor/temp/5afb?it=32.25

CoAP methods (cont…)PUT

Client Server

CON PUT/resource/db/…/?it=32.25

ACK Changed 2.04 Up

date

Page 4: The constrained application protocol (coap)  part 3

4

The DELETE method requests that the resource identified by the request URI be deleted.

A 2.02 (Deleted) Response Code SHOULD be used on success or in case the resource did not exist before the request.

DELETE is not safe but is idempotent.

Method: DELETEURI: coap://scrc.com/Value: DELETE/resource/db/app1/sensor/temp/value/

Client Server

CON DELETE/resource/db/app/sensor/temp/value/

ACK Deleted De

-regi

ster

CoAP methods (cont…)DELETE

Page 5: The constrained application protocol (coap)  part 3

Code status

5

Page 6: The constrained application protocol (coap)  part 3

CoAP messages are encoded in a simple binary format. The Message Header (4 bytes).The variable-length token value 0 and 8 bytes long.

6

Ver - Version (1) 2 bit unsigned integer . Implementations of this field to 1 (01 binary).

T – Message Type 2- bit unsigned integer. (Confirmable, Non-Confirmable, Acknowledgement, Reset).

TKL- Token Length 4-bit unsigned integer. Indicates the length of the variable-length Token field (0-8 bytes).

Code – 8-bit unsighted integer. 3 bit class(most signification bits). 5 bits detail (least significant bits).

Request Method (1-10) or Response Code (40-255)

Message ID – 16-bit identifier for matching responses

Token – Optional response matching token

Message Format

Standards Track RFC 7252 June, 2014

Page 7: The constrained application protocol (coap)  part 3

Caching

7

• CoAP includes a simple caching modelCache ability determined by response codeAn option number mask determines if it is a cache key• Freshness modelMax-Age option indicates cache lifetime• Validation modelValidity checked using the Etag Option• A proxy often supports cachingUsually on behalf of a constrained node,a sleeping node,or to reduce network load

The Max-Age Option indicates the maximum time a response may be cached before it MUST be considered not fresh.

The option value is an integer number of seconds between 0 and 2^32-1 inclusive (about 136.1 years).

A default value of 60 seconds is assumed in the absence of the option in a response. This option is "elective". It MUST NOT occur more than once.

Page 8: The constrained application protocol (coap)  part 3

Proxying and caching

8

Page 9: The constrained application protocol (coap)  part 3

Observation

9

COAP Observation

PROBLEM: REST paradigm is often “PULL” type, that is, data is obtained by issuing an explicit request

Information/data in WSN is often periodic/

triggered (e.g., get me a temperature sample every

2 seconds or get me a warning if temperature goes

below 5°C)

SOLUTION: use Observation on COAP resources

Page 10: The constrained application protocol (coap)  part 3

CoAP observation (cont… )

10http://docs.exosite.com/coap/

Page 11: The constrained application protocol (coap)  part 3

Getting Started with CoAP

11

• There are many open source implementations available

Java CoAP Library Californium

C CoAP Library Erbium

libCoAP C Library

jCoAP Java Library

OpenCoAP C Library

TinyOS and Contiki include CoAP support

• CoAP is already part of many commercial products/systems

Sensinode NanoService

RTX 4100 WiFi Module

• Firefox has a CoAP plugin called Copper

• Wireshark has CoAP dissector support

• Implement CoAP yourself, it is not that hard!

Page 12: The constrained application protocol (coap)  part 3

12

Getting Started with CoAP (cont…)

https://en.wikipedia.org/wiki/Constrained_Application_Protocol

Page 13: The constrained application protocol (coap)  part 3

LOBARO–COAP

13

Page 14: The constrained application protocol (coap)  part 3

Resource Directory

14

Page 15: The constrained application protocol (coap)  part 3

Discovery

15

• Service DiscoveryWhat services are available in the first place?

Goal of finding the IP address, port and

protocol

Usually performed by e.g. DNS-SD when DNS

is available

• Resource DiscoveryWhat are the Web resources I am interested in?Goal of finding URIsPerformed using Web Linking or some REST interface

CoRE Link Format is designed to enable resource discovery

Page 16: The constrained application protocol (coap)  part 3

Discovery (cont…)

16

The mechanism used by a node to search for resources among other nodes of the network.

A user at a node provides a search query containing a set of keywords corresponding to the resource being searched for.

A resource discovery protocol is then used to forward the search query to other nodes and search for the resource on those nodes.

When a resource is located at a node, a success message is sent to the node that originated the search query

Page 17: The constrained application protocol (coap)  part 3

Add CoAP to your application

17

Initial demonstration step of CoAP

Page 18: The constrained application protocol (coap)  part 3

18

Initial demonstration step of CoAP (cont…)• Installing Mozilla + Copper (Cu)• Java (JRE 7~8)• Eclipse (Mars 4.5) • Eclipse/ Help/ Reactive Block• Import packege CoAP and other

Page 19: The constrained application protocol (coap)  part 3

19

Initial demonstration step of CoAP (cont…)

Page 20: The constrained application protocol (coap)  part 3

20

Initial demonstration step of CoAP (cont…)

Page 21: The constrained application protocol (coap)  part 3

CoAP & MQTT

21

Page 22: The constrained application protocol (coap)  part 3

Conclusion

22

Page 23: The constrained application protocol (coap)  part 3

Thank you !

[email protected]

23


Recommended