Chapter 6.
COAP
(Constrained Application Protocol – RFC7252)
6.1 INTRODUCTION
Chapter 6 - 92
Chapter 6. COAP
(Constrained Application Protocol)
6.1 INTRODUCTION
Chapter 6 - 93
Chapter 6. COAP
(Constrained Application Protocol)
6.1 INTRODUCTION
Chapter 6 - 94
Chapter 6. COAP
(Constrained Application Protocol)
6.1 INTRODUCTION
Terminology
Endpoint: An entity participating in the CoAP protocol. Colloquially, an
endpoint lives on a "Node“.
Sender: The originating endpoint of a message.
Recipient: The destination endpoint of a message. When the aspect of
identification of the specific recipient is in focus, also "destination endpoint".
Client: The originating endpoint of a request; the destination endpoint of a
response.
Server: The destination endpoint of a request; the originating endpoint of a
response.
Chapter 6 - 95
Chapter 6. COAP
(Constrained Application Protocol)
6.1 INTRODUCTION
Terminology
Piggybacked Response: a response content is included right in a CoAP
acknowledgement (ACK) message that is sent to acknowledge receipt of the
Request for this Response.
Separate Response: When a Confirmable message carrying a request is
acknowledged with an Empty message (e.g., because the server doesn't
have the answer right away), a Separate Response is sent in a separate
message.
Empty Message: A message with a Code of 0.00; neither a request nor a
response. An Empty message only contains the 4-byte header.
Chapter 6 - 96
Chapter 6. COAP
(Constrained Application Protocol)
6.2 MESSAGING MODEL
Chapter 6 - 97
Chapter 6. COAP
(Constrained Application Protocol)
6.2 MESSAGING MODEL
Chapter 6 - 98
Chapter 6. COAP
(Constrained Application Protocol)
6.2 MESSAGING MODEL A message that does not
Reliability is provided by marking a require reliable
message as Confirmable (CON). transmission is sent as a
Confirmable message is retransmitted Non-confirmable message
using a default timeout and exponential (NON).
back-off between retransmissions, until
the recipient sends an ACK message
with the same Message ID (in this
example, 0x7d34).
Reset Message: A Reset
message indicates that a
specific message was
received, but some context
is missing.
Chapter 6 - 99
Chapter 6. COAP
(Constrained Application Protocol)
6.2 MESSAGING MODEL
Request code (get, put, post, delete)
Chapter 6 - 100
Chapter 6. COAP
(Constrained Application Protocol)
6.2 MESSAGING MODEL
Response Codes
Chapter 6 - 101
Chapter 6. COAP
(Constrained Application Protocol)
6.2 MESSAGING MODEL
• Message ID: used to detect message
duplication, and match messages of
type Ack/Reset to messages of type
Confirmable/Non-confirmable.
• Token: a Token is used to match responses to requests independently from
the underlying messages.
• case 1: A request is carried in a Confirmable (CON) message and the
response is immediately available.
• case 2: A request is carried in a Confirmable (CON) message but the
response is not immediately available.
• case 3: A request is sent in a Non-confirmable message
Chapter 6 - 102
Chapter 6. COAP
(Constrained Application Protocol)
6.3 REQUEST / RESPONSE MODEL
Case 1: A request is carried in a Confirmable (CON) message and the response
is immediately available.
Chapter 6 - 103
Chapter 6. COAP
(Constrained Application Protocol)
6.3 REQUEST / RESPONSE MODEL
Case 2: A request is
carried in a Confirmable
(CON) message but the
response is not
immediately available.
Chapter 6 - 104
Chapter 6. COAP
(Constrained Application Protocol)
6.3 REQUEST / RESPONSE MODEL
Case 3: A request is sent in a Non-
confirmable message.
Chapter 6 - 105
Chapter 6. COAP
(Constrained Application Protocol)
BÀI TẬP NHÓM
1. Cho các piggybacked response như hình, xác định giá trị binary các trường
của header bản tin trao đổi giữa client và server trong từng trường hợp:
a)
Chapter 6 - 106
Chapter 6. COAP
a piggybacked response
(Constrained Application Protocol)
BÀI TẬP NHÓM
b)
Chapter 6 - 107
Chapter 6. COAP
(Constrained Application Protocol)
BÀI TẬP NHÓM
2. Cho luồng trao
đổi bản tin như
hình, hãy điền
giá trị các trường
để trống của
header bản tin.
a)
Chapter 6 - 108
Chapter 6. COAP
(Constrained Application Protocol)
BÀI TẬP NHÓM
b)
Chapter 6 - 109
Chapter 6. COAP
(Constrained Application Protocol)
BÀI TẬP NHÓM
3. Cho piggybacked response như hình, chọn các giá trị phù hợp còn trống và
vẽ bản tin với giá trị binary (trừ payload).
Chapter 6 - 110