Internet
Engineering Task Force (IETF) Z. Shelby
Request for Comments: 7252 ARM
Category: Standards Track K. Hartke
ISSN: 2070-1721 C. Bormann
Universitaet Bremen TZI
June
2014
The
Constrained Application Protocol (CoAP)
制約付きアプリケーションプロトコル(CoAP)
Abstract
The Constrained
Application Protocol (CoAP) is a specialized web
transfer protocol for use with constrained nodes and constrained
(e.g., low-power, lossy) networks. The nodes often have 8-bit
microcontrollers with small amounts of ROM and RAM, while constrained
networks such as IPv6 over Low-Power Wireless Personal Area Networks
(6LoWPANs) often have high packet error rates and a typical
throughput of 10s of kbit/s. The protocol is designed for machine-
to-machine (M2M) applications such as smart energy and building
automation.
CoAPは制約の有るノードや制約のあるネットワーク(例:低消費電力、損失の多い)で使用するためのWeb転送プロトコルである。ノードは低容量のRAM
and ROMで8bitのマイコンであることが多く、IPv6 over Low-Power Wireless Personal Area Networks
(6LoWPANs)
では高いパケットエラー率でありスループットは10kbit/sである。このプロトコルはスマートエネルギーやビルオートメーションとしてM2Mアプリケーションのために設計された。
CoAP provides a
request/response interaction model between
application endpoints, supports built-in discovery of services and
resources, and includes key concepts of the Web such as URIs and
Internet media types. CoAP is designed to easily interface with HTTP
for integration with the Web while meeting specialized requirements
such as multicast support, very low overhead, and simplicity for
constrained environments.
CoAPはアプリケーションエンドポイント間のrequest/responseモデルを提供し、URIとInternet media
typeのようなWebの主要な要素を含むサービス、リソースへのアクセスを提供する。CoAPは制限のある環境のためにシンプル、低オーバーヘッド、マルチキャストのような特殊な要求を満たしながら、HTTPとの相互運用性を容易に満たすインターフェースとして設計されている。
Status of This Memo
This is an Internet Standards Track document.
This document is
a product of the Internet Engineering Task Force
(IETF). It represents the consensus of the IETF community. It has
received public review and has been approved for publication by the
Internet Engineering Steering Group (IESG). Further information on
Internet Standards is available in Section 2 of RFC 5741.
Information
about the current status of this document, any errata,
and how to provide feedback on it may be obtained at
http://www.rfc-editor.org/info/rfc7252.
Shelby, et al. Standards Track [Page 1]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
Copyright Notice
Copyright (c)
2014 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is
subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(http://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction
. . . . . . . . . . . . . . . . . . . . . . . . 5
1.1. Features . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2. Terminology . . . . . . . . . . . . . . . . . . . . . . . 6
専門用語
2. Constrained Application Protocol . . . . . . . . . . . . . . 10
2.1. Messaging Model . . . . . . . . . . . . . . . . . . . . . 11
2.2. Request/Response Model . . . . . . . . . . . . . . . . . 12
2.3. Intermediaries and Caching . . . . . . . . . . . . . . . 15
仲介、媒介とキャッシュ
2.4. Resource Discovery . . . . . . . . . . . . . . . . . . . 15
3. Message Format . . . . . . . . . . . . . . . . . . . . . . . 15
3.1. Option Format . . . . . . . . . . . . . . . . . . . . . . 17
3.2. Option Value Formats . . . . . . . . . . . . . . . . . . 19
4. Message Transmission . . . . . . . . . . . . . . . . . . . . 20
4.1. Messages and Endpoints . . . . . . . . . . . . . . . . . 20
4.2. Messages Transmitted Reliably . . . . . . . . . . . . . . 21
信頼性のあるメッセージ送信
4.3. Messages Transmitted without Reliability . . . . . . . . 23
信頼性のないメッセージ送信
4.4. Message Correlation . . . . . . . . . . . . . . . . . . . 24
メッセージの関連性
4.5. Message Deduplication . . . . . . . . . . . . . . . . . . 24
メッセージの重複排除
4.6. Message Size . . . . . . . . . . . . . . . . . . . . . . 25
4.7. Congestion Control . . . . . . . . . . . . . . . . . . . 26
輻輳制御
4.8. Transmission Parameters . . . . . . . . . . . . . . . . . 27
4.8.1. Changing the Parameters . . . . . . . . . . . . . . . 27
4.8.2. Time Values Derived from Transmission Parameters . . 28
5. Request/Response Semantics . . . . . . . . . . . . . . . . . 31
5.1. Requests . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2. Responses . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2.1. Piggybacked . . . . . . . . . . . . . . . . . . . . . 33
5.2.2. Separate . . . . . . . . . . . . . . . . . . . . . . 33
5.2.3. Non-confirmable . . . . . . . . . . . . . . . . . . . 34
5.3. Request/Response Matching . . . . . . . . . . . . . . . . 34
5.3.1. Token . . . . . . . . . . . . . . . . . . . . . . . . 34
5.3.2. Request/Response Matching Rules . . . . . . . . . . .
35
Shelby, et al. Standards Track [Page 2]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
5.4. Options . .
. . . . . . . . . . . . . . . . . . . . . . . 36
5.4.1. Critical/Elective . . . . . . . . . . . . . . . . . . 37
5.4.2. Proxy Unsafe or Safe-to-Forward and NoCacheKey . . . 38
5.4.3. Length . . . . . . . . . . . . . . . . . . . . . . . 38
5.4.4. Default Values . . . . . . . . . . . . . . . . . . . 38
5.4.5. Repeatable Options . . . . . . . . . . . . . . . . . 39
5.4.6. Option Numbers . . . . . . . . . . . . . . . . . . . 39
5.5. Payloads and Representations . . . . . . . . . . . . . . 40
5.5.1. Representation . . . . . . . . . . . . . . . . . . . 40
5.5.2. Diagnostic Payload . . . . . . . . . . . . . . . . . 41
5.5.3. Selected Representation . . . . . . . . . . . . . . . 41
5.5.4. Content Negotiation . . . . . . . . . . . . . . . . . 41
5.6. Caching . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.6.1. Freshness Model . . . . . . . . . . . . . . . . . . . 43
5.6.2. Validation Model . . . . . . . . . . . . . . . . . . 43
5.7. Proxying . . . . . . . . . . . . . . . . . . . . . . . . 44
5.7.1. Proxy Operation . . . . . . . . . . . . . . . . . . . 44
5.7.2. Forward-Proxies . . . . . . . . . . . . . . . . . . . 46
5.7.3. Reverse-Proxies . . . . . . . . . . . . . . . . . . . 46
5.8. Method Definitions . . . . . . . . . . . . . . . . . . . 47
5.8.1. GET . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.8.2. POST . . . . . . . . . . . . . . . . . . . . . . . . 47
5.8.3. PUT . . . . . . . . . . . . . . . . . . . . . . . . . 48
5.8.4. DELETE . . . . . . . . . . . . . . . . . . . . . . . 48
5.9. Response Code Definitions . . . . . . . . . . . . . . . . 48
5.9.1. Success 2.xx . . . . . . . . . . . . . . . . . . . . 48
5.9.2. Client Error 4.xx . . . . . . . . . . . . . . . . . . 50
5.9.3. Server Error 5.xx . . . . . . . . . . . . . . . . . . 51
5.10. Option Definitions . . . . . . . . . . . . . . . . . . . 52
5.10.1. Uri-Host, Uri-Port, Uri-Path, and Uri-Query . . . . 53
5.10.2. Proxy-Uri and Proxy-Scheme . . . . . . . . . . . . . 54
5.10.3. Content-Format . . . . . . . . . . . . . . . . . . . 55
5.10.4. Accept . . . . . . . . . . . . . . . . . . . . . . . 55
5.10.5. Max-Age . . . . . . . . . . . . . . . . . . . . . . 55
5.10.6. ETag . . . . . . . . . . . . . . . . . . . . . . . . 56
5.10.7. Location-Path and Location-Query . . . . . . . . . . 57
5.10.8. Conditional Request Options . . . . . . . . . . . . 57
5.10.9. Size1 Option . . . . . . . . . . . . . . . . . . . . 59
6. CoAP URIs . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6.1. coap URI Scheme . . . . . . . . . . . . . . . . . . . . . 59
6.2. coaps URI Scheme . . . . . . . . . . . . . . . . . . . . 60
6.3. Normalization and Comparison Rules . . . . . . . . . . . 61
6.4. Decomposing URIs into Options . . . . . . . . . . . . . . 61
6.5. Composing URIs from Options . . . . . . . . . . . . . . . 62
7. Discovery . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.1. Service Discovery . . . . . . . . . . . . . . . . . . . . 64
7.2. Resource Discovery . . . . . . . . . . . . . . . . . . . 64
7.2.1. 'ct' Attribute . . . . . . . . . . . . . . . . . . .
64
Shelby, et al.
Standards Track [Page 3]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
8. Multicast CoAP
. . . . . . . . . . . . . . . . . . . . . . . 65
8.1. Messaging Layer . . . . . . . . . . . . . . . . . . . . . 65
8.2. Request/Response Layer . . . . . . . . . . . . . . . . . 66
8.2.1. Caching . . . . . . . . . . . . . . . . . . . . . . . 67
8.2.2. Proxying . . . . . . . . . . . . . . . . . . . . . . 67
9. Securing CoAP . . . . . . . . . . . . . . . . . . . . . . . . 68
9.1. DTLS-Secured CoAP . . . . . . . . . . . . . . . . . . . . 69
9.1.1. Messaging Layer . . . . . . . . . . . . . . . . . . . 70
9.1.2. Request/Response Layer . . . . . . . . . . . . . . . 71
9.1.3. Endpoint Identity . . . . . . . . . . . . . . . . . . 71
10. Cross-Protocol Proxying between CoAP and HTTP . . . . . . . . 74
10.1. CoAP-HTTP Proxying . . . . . . . . . . . . . . . . . . . 75
10.1.1. GET . . . . . . . . . . . . . . . . . . . . . . . . 76
10.1.2. PUT . . . . . . . . . . . . . . . . . . . . . . . . 77
10.1.3. DELETE . . . . . . . . . . . . . . . . . . . . . . . 77
10.1.4. POST . . . . . . . . . . . . . . . . . . . . . . . . 77
10.2. HTTP-CoAP Proxying . . . . . . . . . . . . . . . . . . . 77
10.2.1. OPTIONS and TRACE . . . . . . . . . . . . . . . . . 78
10.2.2. GET . . . . . . . . . . . . . . . . . . . . . . . . 78
10.2.3. HEAD . . . . . . . . . . . . . . . . . . . . . . . . 79
10.2.4. POST . . . . . . . . . . . . . . . . . . . . . . . . 79
10.2.5. PUT . . . . . . . . . . . . . . . . . . . . . . . . 79
10.2.6. DELETE . . . . . . . . . . . . . . . . . . . . . . . 80
10.2.7. CONNECT . . . . . . . . . . . . . . . . . . . . . . 80
11. Security Considerations . . . . . . . . . . . . . . . . . . . 80
11.1. Parsing the Protocol and Processing URIs . . . . . . . . 80
11.2. Proxying and Caching . . . . . . . . . . . . . . . . . . 81
11.3. Risk of Amplification . . . . . . . . . . . . . . . . . 81
11.4. IP Address Spoofing Attacks . . . . . . . . . . . . . . 83
11.5. Cross-Protocol Attacks . . . . . . . . . . . . . . . . . 84
11.6. Constrained-Node Considerations . . . . . . . . . . . . 86
12. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 86
12.1. CoAP Code Registries . . . . . . . . . . . . . . . . . . 86
12.1.1. Method Codes . . . . . . . . . . . . . . . . . . . . 87
12.1.2. Response Codes . . . . . . . . . . . . . . . . . . . 88
12.2. CoAP Option Numbers Registry . . . . . . . . . . . . . . 89
12.3. CoAP Content-Formats Registry . . . . . . . . . . . . . 91
12.4. URI Scheme Registration . . . . . . . . . . . . . . . . 93
12.5. Secure URI Scheme Registration . . . . . . . . . . . . . 94
12.6. Service Name and Port Number Registration . . . . . . . 95
12.7. Secure Service Name and Port Number Registration . . . . 96
12.8. Multicast Address Registration . . . . . . . . . . . . . 97
13. Acknowledgements . . . . . . . . . . . . . . . . . . . . . . 97
14. References . . . . . . . . . . . . . . . . . . . . . . . . . 98
14.1. Normative References . . . . . . . . . . . . . . . . . . 98
14.2. Informative References . . . . . . . . . . . . . . . . . 100
Appendix A. Examples . . . . . . . . . . . . . . . . . . . . . . 104
Appendix B. URI Examples . . . . . . . . . . . . . . . . . . . .
110
Shelby, et al. Standards Track [Page 4]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
1. Introduction
The use of web
services (web APIs) on the Internet has become
ubiquitous in most applications and depends on the fundamental
Representational State Transfer [REST] architecture of the Web.
Internetのweb serviceの利用(web
API)はWebのRESTアーキテクチャに依存した多くのアプリケーションで普及している。
The work on
Constrained RESTful Environments (CoRE) aims at realizing
the REST architecture in a suitable form for the most constrained
nodes (e.g., 8-bit microcontrollers with limited RAM and ROM) and
networks (e.g., 6LoWPAN, [RFC4944]). Constrained networks such as
6LoWPAN support the fragmentation of IPv6 packets into small link-
layer frames; however, this causes significant reduction in packet
delivery probability. One design goal of CoAP has been to keep
message overhead small, thus limiting the need for fragmentation.
制約付きRESTful Environment(CoRE)は制約されたノード(8bitマイコン、RAM and
ROM制限あり)とnetwork(6LoWPAN)に適したRESTアーキテクチャの実現を目指している。6LoWPANのような制約付きネットワークでは小さなLink-layerフレームへのIPv6パケットのフラグメンテーションをサポートする。しかし、これはパケット転送率の低下を引き起こす。CoAPの設計の一つの目標はフラグメンテーションを抑え、メッセージのオーバーヘッドを減らすことである。
One of the main
goals of CoAP is to design a generic web protocol for
the special requirements of this constrained environment, especially
considering energy, building automation, and other machine-to-machine
(M2M) applications. The goal of CoAP is not to blindly compress HTTP
[RFC2616], but rather to realize a subset of REST common with HTTP
but optimized for M2M applications. Although CoAP could be used for
refashioning simple HTTP interfaces into a more compact protocol,
more importantly it also offers features for M2M such as built-in
discovery, multicast support, and asynchronous message exchanges.
CoAPの目的のひとつは、エネルギー制限、ビルオートメーション、その他のM2Mアプリケーションのような制約された環境への特別な要求への一般的なWebプロトコルを設計することである。CoAPの目的は単にHTTPを圧縮することではなく、HTTPと共通のRESTを実現しながら、M2Mアプリケーション向けに最適化することである。CoAPはHTTPを単純化するために使用でき、M2Mのためのbuilt-in
discovery(SSDP?)、マルチキャスト、非同期メッセージ交換をサポートする。
This document
specifies the Constrained Application Protocol (CoAP),
which easily translates to HTTP for integration with the existing Web
while meeting specialized requirements such as multicast support,
very low overhead, and simplicity for constrained environments and
M2M applications.
本ドキュメントでは制約のある環境、M2Mアプリケーション、マルチキャスト、低オーバーヘッドのような要求を満たし、簡単にHTTPと変換して既存のWebとの互換性を実現できるCoAPを規定する。
1.1. Features
CoAP has the
following main features:
CoAPには主要な下記の機能がある。
o Web protocol
fulfilling M2M requirements in constrained
environments
Webプロトコル:制約のある環境におけるM2M要求を満たす。
o UDP [RFC0768]
binding with optional reliability supporting unicast
and multicast requests.
UDP:信頼性のあるユニキャストとマルチキャストをサポートする。
o Asynchronous message exchanges.
非同期メッセージの交換。
o Low header
overhead and parsing complexity.
ヘッダー:オーバーヘッドとパーサーの複雑さが低い。
o URI and
Content-type support.
URIとContent-typeのサポート。
o Simple proxy
and caching capabilities.
Simple proxyとキャッシュ機能のサポート。
Shelby, et al. Standards Track [Page 5]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
o A stateless HTTP
mapping, allowing proxies to be built providing
access to CoAP resources via HTTP in a uniform way or for HTTP
simple interfaces to be realized alternatively over CoAP.
HTTP経由でのCoAPリソースへのアクセスおよびCoAPでのHTTP
interfaceの大体が可能なstatelessなHTTPとの対応付けが可能。
o Security
binding to Datagram Transport Layer Security (DTLS)
[RFC6347].
セキュリティ:DTLSによる。
1.2. Terminology
The key words
"MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in
[RFC2119] when they appear in ALL CAPS. These words may also appear
in this document in lowercase, absent their normative meanings.
This
specification requires readers to be familiar with all the terms
and concepts that are discussed in [RFC2616], including "resource",
"representation", "cache", and "fresh". (Having been completed
before the updated set of HTTP RFCs, RFC 7230 to RFC 7235, became
available, this specification specifically references the predecessor
version -- RFC 2616.) In addition, this specification defines the
following terminology:
Endpoint
An entity participating in the CoAP protocol. Colloquially, an
endpoint lives on a "Node", although "Host" would be more
consistent with Internet standards usage, and is further
identified by transport-layer multiplexing information that can
include a UDP port number and a security association
(Section 4.1).
CoAPプロトコルを利用するエンティティ。Node内に位置し、Hostとも呼ばれる。Transport-layerのUDP
port番号とsecurity association(Section 4.1)により識別できる。
Sender
The originating endpoint of a message. When the aspect of
identification of the specific sender is in focus, also "source
endpoint".
メッセージを発信するendpoint。特定の送信者に注目する場合、source endpointともいう。
Recipient
The destination endpoint of a message. When the aspect of
identification of the specific recipient is in focus, also
"destination endpoint".
メッセージを受信するendpoint。特定の受信者に注目する場合、destination
endpointともいう。
Client
The originating endpoint of a request; the destination endpoint of
a response.
requestを発信するendpoint。responseの宛先のendpoint。
Server
The destination endpoint of a request; the originating endpoint of
a response.
requestの宛先のendpoint。responseを発信するendpoint。
Shelby, et al. Standards Track [Page 6]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
Origin
Server
The server on which a given resource resides or is to be created.
リソースが存在するか生成されるサーバー。
Intermediary
A CoAP endpoint that acts both as a server and as a client towards
an origin server (possibly via further intermediaries). A common
form of an intermediary is a proxy; several classes of such
proxies are discussed in this specification.
serverとしてと、origin serverに対するclientとして(他のintermediary経由でもよい)動作するCoAP
endpoint。一般的にはproxyである。本仕様で議論する。
Proxy
An intermediary that mainly is concerned with forwarding requests
and relaying back responses, possibly performing caching,
namespace translation, or protocol translation in the process. As
opposed to intermediaries in the general sense, proxies generally
do not implement specific application semantics. Based on the
position in the overall structure of the request forwarding, there
are two common forms of proxy: forward-proxy and reverse-proxy.
In some cases, a single endpoint might act as an origin server,
forward-proxy, or reverse-proxy, switching behavior based on the
nature of each request.
主にrequestの転送とresponseの中継、キャッシュ、名前空間の変換、プロトコル変換などをするintermediary。汎用的な意味を持つintermediaryに対して、proxyは通常、特別なアプリケーションセマンティクスを実装しない。request転送の方法により、forward-proxyとreverse-proxyに分類される。あるケースでは各リクエストに従い一つのendpointがorigin
server、forward-proxy、revere-proxyの役目を切り替える。
Forward-Proxy
An endpoint selected by a client, usually via local configuration
rules, to perform requests on behalf of the client, doing any
necessary translations. Some translations are minimal, such as
for proxy requests for "coap" URIs, whereas other requests might
require translation to and from entirely different application-
layer protocols.
設定によりclientが選択したendpointで、clientに代わって必要に応じて変換をしてrequestを実行する。全く異なるrequestをするとapplication-layerプロトコルでも変換が必要になるため、変換は最小限である。
Reverse-Proxy
An endpoint that stands in for one or more other server(s) and
satisfies requests on behalf of these, doing any necessary
translations. Unlike a forward-proxy, the client may not be aware
that it is communicating with a reverse-proxy; a reverse-proxy
receives requests as if it were the origin server for the target
resource.
複数のserverの代わりに必要に応じて変換してリクエストを処理するendpoint。reverse-proxyはtarget
resourceのorigin
serverであるかのようにrequestを受信するため、forward-proxyと異なり、clientはreverse-proxyを意識しないかもしれない。
CoAP-to-CoAP
Proxy
A proxy that maps from a CoAP request to a CoAP request, i.e.,
uses the CoAP protocol both on the server and the client side.
Contrast to cross-proxy.
CoAP requestとCoAP
requestをmapするproxy。server、clientとしてCoAPプロトコルを使用する。cross-proxyとは対照的。
Cross-Proxy
A cross-protocol proxy, or "cross-proxy" for short, is a proxy
that translates between different protocols, such as a CoAP-to-
HTTP proxy or an HTTP-to-CoAP proxy. While this specification
makes very specific demands of CoAP-to-CoAP proxies, there is more
variation possible in cross-proxies.
cross-protocol
proxy、cross-proxyはCoAP-to-HTTPやHTTP-to-CoAPのように異なるプロトコルを変換する。この仕様ではCoAP-to-CoAP
proxyについて様々な規定をしているが、cross-proxyにも様々なバリエーションがある。
Shelby, et al. Standards Track [Page 7]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
Confirmable
Message
Some messages require an acknowledgement. These messages are
called "Confirmable". When no packets are lost, each Confirmable
message elicits exactly one return message of type Acknowledgement
or type Reset.
一部のmessageはacknowledgementが必要である。そのようなメッセージはConfirmableと呼ばれる。パケットがロスしない場合、各Confrmable
messageはAcknowledgementかResetのメッセージを応答する。
Non-confirmable
Message
Some other messages do not require an acknowledgement. This is
particularly true for messages that are repeated regularly for
application requirements, such as repeated readings from a sensor.
Acknowledgementが必要でないメッセージ。センサーから定期的にデータを読み込むような、定期的なメッセージのアプリケーション要件のために使用される。
Acknowledgement
Message
An Acknowledgement message acknowledges that a specific
Confirmable message arrived. By itself, an Acknowledgement
message does not indicate success or failure of any request
encapsulated in the Confirmable message, but the Acknowledgement
message may also carry a Piggybacked Response (see below).
Acknowledgement messageは特定のConfirmable
messageの到達を伝える。このmessage自体がConfirmable
messageのfailure/successを示すわけではないが、Piggybacked Responseで送信することはできる。
Reset
Message
A Reset message indicates that a specific message (Confirmable or
Non-confirmable) was received, but some context is missing to
properly process it. This condition is usually caused when the
receiving node has rebooted and has forgotten some state that
would be required to interpret the message. Provoking a Reset
message (e.g., by sending an Empty Confirmable message) is also
useful as an inexpensive check of the liveness of an endpoint
("CoAP ping").
Reset messageは特定のメッセージ(Confrmable or
Non-confirmable)を受信したが、そのmessageを処理するためのcontextが失われていることを示す。受信nodeがrebootや状態を忘れてしまった場合にこの状態が発生する。Reset
messageはエンドポイントの死活確認にも有効である(例:Empty Confirmable messageの送信)。
Piggybacked
Response
A piggybacked Response is included right in a CoAP Acknowledgement
(ACK) message that is sent to acknowledge receipt of the Request
for this Response (Section 5.2.1).
piggybacked ResponseはCoAP Acknowledgement(ACK)
messageに含まれる、Requestの受信のacknowledgeのための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
exchange (Section 5.2.2).
Requestを送信するConfirmable messageのacknowledgeがEmpty
messageの場合(例えば、serverがすぐに応答できなかった場合)、Separate message exchangeのSeparate
Responseが送信される(Section 5.2.2)。
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.
Codeが0.00のmessage。requestでもresponseでもない。Empty
messageは4byteのheaderのみで構成される。
Shelby, et al. Standards Track [Page 8]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
Critical
Option
An option that would need to be understood by the endpoint
ultimately receiving the message in order to properly process the
message (Section 5.4.1). Note that the implementation of critical
options is, as the name "Option" implies, generally optional:
unsupported critical options lead to an error response or summary
rejection of the message.
endpointが受信したメッセージを正しく処理するために必要なオプション。"Option"は一般的にはoptionalという意味があるため、critical
optionの実装には注意すること。critical optionがサポートされていない場合、error responseかmessageのsummary
rejection★(summary rejectionって何?)をする。
Elective Option
An option that is intended to be ignored by an endpoint that does
not understand it. Processing the message even without
understanding the option is acceptable (Section 5.4.1).
optionをサポートしていないendpointでは無視されるoption。optionを無視してメッセージを処理することは許容される。(Section
5.4.1)
Unsafe
Option
An option that would need to be understood by a proxy receiving
the message in order to safely forward the message
(Section 5.4.2). Not every critical option is an unsafe option.
messageを安全に転送するため()Section 5.4.2 ★(safely
forwardって何)、このmessageを受信したproxyによって使用される。全てのcritical optionがunsafe
optionというわけではない。
Safe-to-Forward
Option
An option that is intended to be safe for forwarding by a proxy
that does not understand it. Forwarding the message even without
understanding the option is acceptable (Section 5.4.2).
対応していないproxyが転送をsafeにすることを意図する。optionを理解できない場合の転送も許容される(Section
5.4.2★safe転送が不明)。
Resource
Discovery
The process where a CoAP client queries a server for its list of
hosted resources (i.e., links as defined in Section 7).
CoAP clientがserverのもつresourceのlistを取得するためのプロセス。(Section
7のlink)
Content-Format
The combination of an Internet media type, potentially with
specific parameters given, and a content-coding (which is often
the identity content-coding), identified by a numeric identifier
defined by the "CoAP Content-Formats" registry. When the focus is
less on the numeric identifier than on the combination of these
characteristics of a resource representation, this is also called
"representation format".
Internet media typeとcontent-coding(content-codingの識別子)の組み合わせで、"CoAP
Content-Formats"のレジストリで定義された数値で識別される。
Additional
terminology for constrained nodes and constrained-node
networks can be found in [RFC7228].
制約のあるノードと制約のあるノードのネットワークに関する用語はRFC7228にある。
In this
specification, the term "byte" is used in its now customary
sense as a synonym for "octet".
本仕様における"byte"という用語は、"octet"と同義で仕様される。
All multi-byte
integers in this protocol are interpreted in network
byte order.
このプロトコルのマルチバイトの整数は、ネットワークバイトオーダー(ビッグエンディアン)で解釈される。
Where arithmetic
is used, this specification uses the notation
familiar from the programming language C, except that the operator
"**" stands for exponentiation.
算術演算では、**のべき乗以外は、C言語と同じ表記を使用する。
Shelby, et al. Standards Track [Page 9]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
2. Constrained
Application Protocol
制約のあるアプリケーションプロトコル
The interaction
model of CoAP is similar to the client/server model
of HTTP. However, machine-to-machine interactions typically result
in a CoAP implementation acting in both client and server roles. A
CoAP request is equivalent to that of HTTP and is sent by a client to
request an action (using a Method Code) on a resource (identified by
a URI) on a server. The server then sends a response with a Response
Code; this response may include a resource representation.
CoAPのモデルはHTTPのclient/server
modelに似ている。M2MではCoAPはclient/serverの両方で動作する。CoAP
requestはHTTPと同様に、serverのresource(URIで識別される)に対するaction(Methed
Codeを使用)を要求としてclientから送信する。serverはResponse Codeおよび場合によってはresouceを応答として送信する。
Unlike HTTP, CoAP deals with these interchanges asynchronously over a
datagram-oriented transport such as UDP. This is done logically
using a layer of messages that supports optional reliability (with
exponential back-off). CoAP defines four types of messages:
Confirmable, Non-confirmable, Acknowledgement, Reset. Method Codes
and Response Codes included in some of these messages make them carry
requests or responses. The basic exchanges of the four types of
messages are somewhat orthogonal to the request/response
interactions; requests can be carried in Confirmable and Non-
confirmable messages, and responses can be carried in these as well
as piggybacked in Acknowledgement messages.
HTTPと異なり、CoAPではUDPのようなdatagram-oriented転送の非同期の交換を使用する。信頼性がオプションとして提供される。CoAPでは4つのメッセージ(Confrmable、Non-confirmable、Acknowledgement、Reset)が定義される。これらのメッセージがrequestやresponseで送信されるとき、Method
CodeやResponse
Codeが含まれる。4つのメッセージはRequest/Responseに関係している。RequestはConfirmableとNon-confirmable
message、ResponseはAcknowledgementにpiggybackしてメッセージを含めることができる。
One could think
of CoAP logically as using a two-layer approach, a
CoAP messaging layer used to deal with UDP and the asynchronous
nature of the interactions, and the request/response interactions
using Method and Response Codes (see Figure 1). CoAP is however a
single protocol, with messaging and request/response as just features
of the CoAP header.
CoAPは2つのレイヤとして考えるとこができる。CoAP Message
layerはUDPとの間の処理、request/responseはMethod/Response Codeによる処理を実施する(Figure
1参照)。しかし、CoAPは1つのプロトコルであり、messaging、request/responseはCoAP headerで実現される。
+----------------------+
| Application |
+----------------------+
+----------------------+ \
| Requests/Responses | |
|----------------------| | CoAP
| Messages | |
+----------------------+ /
+----------------------+
| UDP |
+----------------------+
Figure 1: Abstract Layering of CoAP
Shelby, et al.
Standards Track [Page 10]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
2.1. Messaging
Model
The CoAP
messaging model is based on the exchange of messages over
UDP between endpoints.
CoAP messaging modelはendpoint間のUDPメッセージ交換に基いている。
CoAP uses a
short fixed-length binary header (4 bytes) that may be
followed by compact binary options and a payload. This message
format is shared by requests and responses. The CoAP message format
is specified in Section 3. Each message contains a Message ID used
to detect duplicates and for optional reliability. (The Message ID
is compact; its 16-bit size enables up to about 250 messages per
second from one endpoint to another with default protocol
parameters.)
CoAPは後にバイナリのオプションとpayloadが続く、固定長のbinary header(4
bytes)を使用する。このメッセージフォーマットはrequest/responseで共通である。CoAPのメッセージフォーマットはSection
3で規定される。各メッセージには重複検出とoptionの信頼性のためのMessage IDが含まれる。Message
IDはコンパクトで、16bitであり、あるendpointから別のendpointに対して250メッセージ/sを可能とする(Memo:16bit=65535★250メッセージ/sの理由)。
Reliability is
provided by marking a message as Confirmable (CON). A
Confirmable message is retransmitted using a default timeout and
exponential back-off between retransmissions, until the recipient
sends an Acknowledgement message (ACK) with the same Message ID (in
this example, 0x7d34) from the corresponding endpoint; see Figure 2.
When a recipient is not at all able to process a Confirmable message
(i.e., not even able to provide a suitable error response), it
replies with a Reset message (RST) instead of an Acknowledgement
(ACK).
信頼性はConfirmable(CON)のmessageとして提供される。Confirmable
messageは再送期間中、受信者が対応するendpointからの同じMessage IDをもつAcknowledgement
message(ACK)を送信するまで、timeoutとexponential back-offを使用して再送される(Figure
2参照)。受信者がConfirmable messageを処理できない場合(エレー responseもできない場合)、ACKの代わりにReset
message(RST)で応答する。
Client Server
| |
| CON [0x7d34] |
+----------------->|
| |
| ACK [0x7d34] |
|<-----------------+
| |
Figure 2: Reliable Message Transmission
A message that
does not require reliable transmission (for example,
each single measurement out of a stream of sensor data) can be sent
as a Non-confirmable message (NON). These are not acknowledged, but
still have a Message ID for duplicate detection (in this example,
0x01a0); see Figure 3. When a recipient is not able to process a
Non-confirmable message, it may reply with a Reset message (RST).
信頼性が要求されないmessage(例えば1単位時間のセンサ情報)はNon-confirmable
message(NON)で送信してよい。それらはACKを必要としないが、重複検出用のMessage IDは持っている(Figure
3参照)。受信者がNon-confirmable messageを処理できない場合、Reset
message(RST)を応答してもよい。
Shelby, et al. Standards Track [Page 11]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
Client Server
| |
| NON [0x01a0] |
+----------------->|
| |
Figure 3: Unreliable Message Transmission
See Section 4
for details of CoAP messages.
詳細なCoAP messageはSection 4参照。
As CoAP runs
over UDP, it also supports the use of multicast IP
destination addresses, enabling multicast CoAP requests. Section 8
discusses the proper use of CoAP messages with multicast addresses
and precautions for avoiding response congestion.
CoAPはUDP上で動作するため、multicast IP宛の送信をサポートし、CoAP
requestのmulticast送信をサポートする。Section 8ではmulticast addressのCoAP
messageの使用方法とresponseの輻輳回避について説明する。
Several security
modes are defined for CoAP in Section 9 ranging from
no security to certificate-based security. This document specifies a
binding to DTLS for securing the protocol; the use of IPsec with CoAP
is discussed in [IPsec-CoAP].
証明書ベースのセキュリティについてはSection
9で定義される。このドキュメントではDTLSへのbindについて規定する。CoAPとIPsecの使用については
[IPsec-CoAP]参照。
2.2. Request/Response Model
CoAP request and
response semantics are carried in CoAP messages,
which include either a Method Code or Response Code, respectively.
Optional (or default) request and response information, such as the
URI and payload media type are carried as CoAP options. A Token is
used to match responses to requests independently from the underlying
messages (Section 5.3). (Note that the Token is a concept separate
from the Message ID.)
CoAP request/responseのsemanticsはそれぞれCoAP messageのMethod Code/Response
Codeにより提供される。URIやpayload media
typeのようなOptionalまたはdefaultのrequest/responseの情報は、CoAP
optionとして提供される。Tokenはunderlying message(Section 5.3★underlying
message不明)から独立してresponse/requestを関連付けるために使用される(TokenはMessage
IDとは異なる概念である。)。
A request is
carried in a Confirmable (CON) or Non-confirmable (NON)
message, and, if immediately available, the response to a request
carried in a Confirmable message is carried in the resulting
Acknowledgement (ACK) message. This is called a piggybacked
response, detailed in Section 5.2.1. (There is no need for
separately acknowledging a piggybacked response, as the client will
retransmit the request if the Acknowledgement message carrying the
piggybacked response is lost.) Two examples for a basic GET request
with piggybacked response are shown in Figure 4, one successful, one
resulting in a 4.04 (Not Found) response.
requestがConfirmable(CON)またはNon-confirmable(NON)で送信され、可能な場合、CONに対するResponseがACK
messageで送信される。これはpiggybacked responseと呼ばれ、詳細はSection 5.2.1で述べられる。piggybacked
responseのGET requestの例をFigure 4に示す。ひとつは成功で、もう一つは4.04(Not Fount)
Responseである。
Shelby, et al. Standards Track [Page 12]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
Client
Server Client Server
| | | |
| CON [0xbc90] | | CON [0xbc91] |
| GET /temperature | | GET /temperature |
| (Token 0x71) | | (Token 0x72) |
+----------------->| +----------------->|
| | | |
| ACK [0xbc90] | | ACK [0xbc91] |
| 2.05 Content | | 4.04 Not Found |
| (Token 0x71) | | (Token 0x72) |
| "22.5 C" | | "Not found" |
|<-----------------+ |<-----------------+
| | | |
Figure 4: Two GET Requests with Piggybacked Responses
If the server is
not able to respond immediately to a request carried
in a Confirmable message, it simply responds with an Empty
Acknowledgement message so that the client can stop retransmitting
the request. When the response is ready, the server sends it in a
new Confirmable message (which then in turn needs to be acknowledged
by the client). This is called a "separate response", as illustrated
in Figure 5 and described in more detail in Section 5.2.2.
serverがConfirmable
messageのrequestに即座に応答できない場合、clientのrequest再送を停止させるため、Empty Acknowledgement
messageを応答する。responseの準備ができた場合、serverは新しいConfirmable
message(その後ClinetにACKが返される必要がある)を送信する。これは"Separate Response"と呼ばれ、Figure
5に示され、Section 5.2.2で説明する。
Client Server
| |
| CON [0x7a10] |
| GET /temperature |
| (Token 0x73) |
+----------------->|
| |
| ACK [0x7a10] |
|<-----------------+
| |
... Time Passes ...
| |
| CON [0x23bb] |
| 2.05 Content |
| (Token 0x73) |
| "22.5 C" |
|<-----------------+
| |
| ACK [0x23bb] |
+----------------->|
| |
Figure 5: A GET Request with a Separate Response
Shelby, et al.
Standards Track [Page 13]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
If a request is
sent in a Non-confirmable message, then the response
is sent using a new Non-confirmable message, although the server may
instead send a Confirmable message. This type of exchange is
illustrated in Figure 6.
requestがNONで送信された場合、severはCONで応答してもよく、新たなNONで応答してもよい。Figure
6に示す。
Client Server
| |
| NON [0x7a11] |
| GET /temperature |
| (Token 0x74) |
+----------------->|
| |
| NON [0x23bc] |
| 2.05 Content |
| (Token 0x74) |
| "22.5 C" |
|<-----------------+
| |
Figure 6: A
Request and a Response Carried in Non-confirmable
Messages
CoAP makes use
of GET, PUT, POST, and DELETE methods in a similar
manner to HTTP, with the semantics specified in Section 5.8. (Note
that the detailed semantics of CoAP methods are "almost, but not
entirely unlike" [HHGTTG] those of HTTP methods: intuition taken from
HTTP experience generally does apply well, but there are enough
differences that make it worthwhile to actually read the present
specification.)
CoAPはHTTPと同様にGET, PUT, POST, DELETE methodが使用される。それらのsemanticsはSection
5.8で規定される。CoAP methodのsemanticsはHTTPとは異なる。
Methods beyond
the basic four can be added to CoAP in separate
specifications. New methods do not necessarily have to use requests
and responses in pairs. Even for existing methods, a single request
may yield multiple responses, e.g., for a multicast request
(Section 8) or with the Observe option [OBSERVE].
4つのmethod以外もCoAPに追加することができる。新しいmethodは必ずしもrequest/responseである必要はない。既存のmethodでは1つのrequestに対して複数のresponseがある(multicast
request。Section 8参照)場合がある。
URI support in a
server is simplified as the client already parses
the URI and splits it into host, port, path, and query components,
making use of default values for efficiency. Response Codes relate
to a small subset of HTTP status codes with a few CoAP-specific codes
added, as defined in Section 5.9.
serverでサポートされるURIはclientがパースした後、簡略化される(★よくわからない)。Section 5.9
で定義されるResponse CodeはCoAP固有のcodeとHTTPのstatus codeのサブセットである。
Shelby, et al. Standards Track [Page 14]
RFC 7252 The Constrained Application Protocol (CoAP) June 2014
2.3. Intermediaries
and Caching
仲介、媒介とキャッシュ
The protocol
supports the caching of responses in order to
efficiently fulfill requests. Simple caching is enabled using
freshness and validity information carried with CoAP responses. A
cache could be located in an endpoint or an intermediary. Caching
functionality is specified in Section 5.6.
プロトコルは効率的にrequestに対応するためresponseのキャッシュをサポートする。単純なキャッシュはCoAP
responseにfreshnessとvalidityの情報を付与することで可能となる。キャッシュはendpointまたはintermediaryに配置することができる。キャッシュについてはSection
5.6で述べる。
Proxying is
useful in constrained networks for several reasons,
including to limit network traffic, to improve performance, to access
resources of sleeping devices, and for security reasons. The
proxying of requests on behalf of another CoAP endpoint is supported
in the protocol. When using a proxy, the URI of the resource to
request is included in the request, while the destination IP address
is set to the address of the proxy. See Section 5.7 for more
information on proxy functionality.
Proxyはネットワークトラフィックの制限、パフォーマンスの向上、sleeping
deviceのリソースへのアクセス、セキュリティーなどの理由で制約のあるネットワークには有効である。CoAP
endpointの代わりにrequestするproxyはCoAPでサポートされる。proxyを使用する場合、宛先IPアドレスにproxyのアドレスが設定され、requestには要求するリソースのURIが含まれている。proxyについてはSection
5.7参照。
As CoAP was
designed according to the REST architecture [REST], and
thus exhibits functionality similar to that of the HTTP protocol, it
is quite straightforward to map from CoAP to HTTP and from HTTP to
CoAP. Such a mapping may be used to realize an HTTP REST interface
using CoAP or to convert between HTTP and CoAP. This conversion can
be carried out by a cross-protocol proxy ("cross-proxy"), which
converts the Method or Response Code, media type, and options to the
corresponding HTTP feature. Section 10 provides more detail about
HTTP mapping.
CoAPはRESTアーキテクチャに従って設計されており、HTTPと機能的にも類似しているため、CoAPからHTTP、HTTPからCoAPにmapすることは容易である。mappingはCoAPを使用してHTTP
REST interfaceを実現するため、またはHTTP-CoAP間の変換をするために使用できる。この変換は、cross-protocol
proxy("cross-proxy")により実現でき、Method/Response Code/media
type/optionを対応するHTTP機能に変換する。Section 10ではHTTPとのmappingについて述べる。
2.4. Resource Discovery
Resource
discovery is important for machine-to-machine interactions
and is supported using the CoRE Link Format [RFC6690] as discussed in
Section 7.
Resource discoveryはM2Mに必要であり、Section 7のCoRE Link Format
[RFC6690]を使用して提供される。
3. Message Format
CoAP is based on
the exchange of compact messages that, by default,
are transported over UDP (i.e., each CoAP message occupies the data
section of one UDP datagram). CoAP may also be used over Datagram
Transport Layer Security (DTLS) (see Section 9.1). It could also be
used over other transports such as SMS, TCP, or SCTP, the
specification of which is out of this document's scope. (UDP-lite
[RFC3828] and UDP zero checksum [RFC6936] are not supported by CoAP.)
CoAPはUDPで送信され、デフォルトでcompact message交換に基いている。CoAPはDTLSを使用してよい(Section
9.1参照)。その他の転送方法(SMS, TCP, SCTP)は本ドキュメントのスコープ外である。UDP-lite[RFC3828] UDP zero
checksum [RFC6936] はCoAPでは未サポートである(ヘッダ、pktフォーマット等の問題?)。
CoAP messages
are encoded in a simple binary format. The message
format starts with a fixed-size 4-byte header. This is followed by a
variable-length Token value, which can be between 0 and 8 bytes long.
CoAPはbinary形式でエンコードされる。message
formatは固定長の4byteのヘッダーで始まる。これに可変長(0~8byte)のToken値が続く。
Shelby, et al.
Standards Track [Page 15]
RFC 7252 The Constrained Application Protocol (CoAP) June
2014
Following the Token
value comes a sequence of zero or more CoAP
Options in Type-Length-Value (TLV) format, optionally followed by a
payload that takes up the rest of the datagram.
Token valueの後に0以上のType-Length-Value(TLV)のCoAP Optionが続き、
オプションでdatagramの残りの部分にpayloadが設定される。
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Ver| T | TKL | Code | Message ID |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Token (if any, TKL bytes) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options (if any) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1 1 1 1 1 1 1 1| Payload (if any) ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Figure 7: Message Format
The fields in
the header are defined as follows:
headerのfieldは下記のように定義される。
Version (Ver):
2-bit unsigned integer. Indicates the CoAP version
number. Implementations of this specification MUST set this field
to 1 (01 binary). Other values are reserved for future versions.
Messages with unknown version numbers MUST be silently ignored.
2bit 符号なし整数。CoAP version numberを示す。この仕様では1(01
binary)を設定すること。他の値は後のバージョンのためのreserve。未知のversion numberをmessageはsilnetly
ignoreすること。
Type (T): 2-bit
unsigned integer. Indicates if this message is of
type Confirmable (0), Non-confirmable (1), Acknowledgement (2), or
Reset (3). The semantics of these message types are defined in
Section 4.
2bit 符号なし整数。message type Confirmable(0), Non-confrmable(1),
Acknowledgement(2), Reset(3)を示す。message typeのsemanticsはSection 4で定義される。
Token Length (TKL): 4-bit unsigned integer. Indicates the length of
the variable-length Token field (0-8 bytes). Lengths 9-15 are
reserved, MUST NOT be sent, and MUST be processed as a message
format error.
4bit 符号なし整数。可変長のToken field(0~8
byte)の長さを示す。長さ9~15はreserveで、送信しないこととし、message format errorとして処理すること。
Code: 8-bit
unsigned integer, split into a 3-bit class (most
significant bits) and a 5-bit detail (least significant bits),
documented as "c.dd" where "c" is a digit from 0 to 7 for the
3-bit subfield and "dd" are two digits from 00 to 31 for the 5-bit
subfield. The class can indicate a request (0), a success
response (2), a client error response (4), or a server error
response (5). (All other class values are reserved.) As a
special case, Code 0.00 indicates an Empty message. In case of a
request, the Code field indicates the Request Method; in case of a
response, a Response Code. Possible values are maintained in the
CoAP Code Registries (Section 12.1). The semantics of requests
and responses are defined in Section 5.
8bit符号なし整数。上位3bit classと下位5bit
detailに分けられ、このドキュメントでは"c.dd"と表現する。"c"は0~7までの3bitの値で、"dd"は2桁で00~31の5bitの値である。classはrequest(0),
success response(2), client error response(4), server error
response(5)を示し、他の値はreserveである。Code 0.00はEmpty messageを示す。requestの場合、Code
fieldはRequest Methodを示し、responseの場合はResponse Codeを示す。CoAP Code
RegistriesはSection 12.1参照。request/responseのsemanticsはSection 5参照。
Shelby, et al.
Standards Track [Page 16]
RFC 7252 The Constrained Application Protocol (CoAP) June
2014
Message ID: 16-bit
unsigned integer in network byte order. Used to
detect message duplication and to match messages of type
Acknowledgement/Reset to messages of type Confirmable/Non-
confirmable. The rules for generating a Message ID and matching
messages are defined in Section 4.
ネットワークバイトオーダー(ビッグエンディアン)の16bit符号なし整数。メッセージの重複検出とAcknowledgement/ResetとConfirmable/Non-confirmableのmessageを照合するために使用する。Message
IDの生成方法と照合の方法はSection 4で定義される。
The header is
followed by the Token value, which may be 0 to 8 bytes,
as given by the Token Length field. The Token value is used to
correlate requests and responses. The rules for generating a Token
and correlating requests and responses are defined in Section 5.3.1.
headerはその後、Token Length fieldによって示される0~8byteのToken valueが続く。Token
valueはrequest/responseを関連付けるために使用される。Tokenの生成方法と、request/responseの関連付け方はSection
5.3.1参照。
Header and Token
are followed by zero or more Options (Section 3.1).
An Option can be followed by the end of the message, by another
Option, or by the Payload Marker and the payload.
Header、Tokenの後には0以上のOptionが続く(Section
3.1参照)。Optionはmessageの最後になるか、もしくは他のOptionかPayload Markerとpayloadが後に続く。(Payload
Maker⇒0xFFのpayloadの開始marker)
Following the
header, token, and options, if any, comes the optional
payload. If present and of non-zero length, it is prefixed by a
fixed, one-byte Payload Marker (0xFF), which indicates the end of
options and the start of the payload. The payload data extends from
after the marker to the end of the UDP datagram, i.e., the Payload
Length is calculated from the datagram size. The absence of the
Payload Marker denotes a zero-length payload. The presence of a
marker followed by a zero-length payload MUST be processed as a
message format error.
Header, token,
optionに続いてオプションでpayloadが付与される。payloadが存在し、非0のlengthの場合、optionの終わりとpayloadの始まりを示す固定長の1byteのPayload
Marker(0xFF)が付与される(Optionに0xFFがきた場合は?⇒optionが始まるところに0xFFがあるかどうかで判別可能。)。payload
dataはmarkerの後からUDP dataの終わり、つまりPayload Lengthはdatagram sizeから計算される。Payload
Markerが無い場合は、zero-length payloadであることを示している。markerの後がzero-length
payloadの場合はmessage format errorとして処理すること。
Implementation
Note: The byte value 0xFF may also occur within an
option length or value, so simple byte-wise scanning for 0xFF is
not a viable technique for finding the payload marker. The byte
0xFF has the meaning of a payload marker only where the beginning
of another option could occur.
0xFFでもoption
lengthやoptionに含まれる場合があるため、単純に0xFFをバイト単位でスキャンするのは、payload
markerを探す方法には使えない。0xFFがpayload
markerとして意味を持つのは、別のoptionが始まる可能性のある場所にある場合のみである(Optionの開始位置に0xFFは使用できない)。
3.1. Option Format
CoAP defines a
number of options that can be included in a message.
Each option instance in a message specifies the Option Number of the
defined CoAP option, the length of the Option Value, and the Option
Value itself.
CoAPはmessageに含まれるoptionの数を定義する。message内のoptionのインスタンスは、CoAP optionのOption
Number、Option Valueの長さ、Option Valueを規定する。
Instead of
specifying the Option Number directly, the instances MUST
appear in order of their Option Numbers and a delta encoding is used
between them: the Option Number for each instance is calculated as
the sum of its delta and the Option Number of the preceding instance
in the message. For the first instance in a message, a preceding
option instance with Option Number zero is assumed. Multiple
instances of the same option can be included by using a delta of
zero.
Option Numberを直接規定する代わりに、インスタンスはOption Numberの順に設定され、delta
encodingがそれらの間で使われる。各インスタンスのOption Numberはdeltaとmessage内の先行のOption
Numberの合計として計算される。
Shelby, et al.
Standards Track [Page 17]
RFC 7252 The Constrained Application Protocol (CoAP) June
2014
Option Numbers are
maintained in the "CoAP Option Numbers" registry
(Section 12.2). See Section 5.4 for the semantics of the options
defined in this document.
Option NumberはSection 12.2の"CoAP Option
Numbers"registryで規定される。本ドキュメントで定義されたoptionのsemanticsはSection 5.4参照。
0 1 2 3
4 5 6 7
+---------------+---------------+
| | |
| Option Delta | Option Length | 1 byte
| | |
+---------------+---------------+
\ \
/ Option Delta / 0-2 bytes
\ (extended) \
+-------------------------------+
\ \
/ Option Length / 0-2 bytes
\ (extended) \
+-------------------------------+
\ \
/ /
\ \
/ Option Value / 0 or more bytes
\ \
/ /
\ \
+-------------------------------+
Figure 8: Option Format
The fields in an
option are defined as follows:
option fieldは次のように定義される。
Option Delta:
4-bit unsigned integer. A value between 0 and 12
indicates the Option Delta. Three values are reserved for special
constructs:
4bit 符号なし整数。Option Deltaを示す0~12の値。13~15はreserve。
13: An 8-bit
unsigned integer follows the initial byte and
indicates the Option Delta minus 13.
8bit 符号なし整数が続き、Option Delta -13を示す。(★イマイチ意味わからない)
14: A 16-bit
unsigned integer in network byte order follows the
initial byte and indicates the Option Delta minus 269.
ネットワークバイトオーダー(ビッグエンディアン)の16bit 符号なし整数が続き、Option Delta
-269を示す。(★イマイチ意味わからない)
15: Reserved
for the Payload Marker. If the field is set to this
value but the entire byte is not the payload marker, this MUST
be processed as a message format error.
Payload Markerのためのreserve。fieldがこの値に設定され、payload
markerでない場合はmessage format errorとして処理すること。
Shelby, et al.
Standards Track [Page 18]
RFC 7252 The Constrained Application Protocol (CoAP) June
2014
The resulting
Option Delta is used as the difference between the
Option Number of this option and that of the previous option (or
zero for the first option). In other words, the Option Number is
calculated by simply summing the Option Delta values of this and
all previous options before it.
結果、Option DeltaはそのoptionのOption
Numberと前のoption(最初のoptionの場合は0)との差として使用される。言い換えると、Option
NumberはそのOptionの前のすべてのOption Deltaを加算することで計算できる。
Option Length:
4-bit unsigned integer. A value between 0 and 12
indicates the length of the Option Value, in bytes. Three values
are reserved for special constructs:
4bit 符号なし整数。Option Valueの長さを示す0~12の値。13~15はreserve。
13: An 8-bit
unsigned integer precedes the Option Value and
indicates the Option Length minus 13.
8bit 符号なし整数がOption Valueの前にあり、Option Length -13を示す。
14: A 16-bit
unsigned integer in network byte order precedes the
Option Value and indicates the Option Length minus 269.
ネットワークバイトオーダー(ビッグエンディアン)の16bit 符号なし整数がOption Valueの前にあり、Option
Length -269を示す。
15: Reserved
for future use. If the field is set to this value,
it MUST be processed as a message format error.
後のためのreserve。このfieldに15が設定された場合、message format
errorとして処理する。
Value: A
sequence of exactly Option Length bytes. The length and
format of the Option Value depend on the respective option, which
MAY define variable-length values. See Section 3.2 for the
formats used in this document; options defined in other documents
MAY make use of other option value formats.
Option Lengthのbyte sequence。Option
Valueのlengthとformatは各オプションに依存する。本ドキュメントで使用するformatはSection
3.2参照。他のドキュメントで定義されたoptionは他のoption value formatを持つ。
3.2. Option Value Formats
The options
defined in this document make use of the following option
value formats.
本ドキュメントで定義されたoptionは下記のoption value formatを使用する。
empty: A
zero-length sequence of bytes.
zero-lengthのbyte列。
opaque: An
opaque sequence of bytes.
曖昧な長さのbyte列。
uint: A
non-negative integer that is represented in network byte
order using the number of bytes given by the Option Length
field.
Option Lengthのbyte数長のネットワークバイトオーダーの非負の整数。
An option definition may specify a range of permissible
numbers of bytes; if it has a choice, a sender SHOULD
represent the integer with as few bytes as possible, i.e.,
without leading zero bytes. For example, the number 0 is
represented with an empty option value (a zero-length
sequence of bytes) and the number 1 by a single byte with
the numerical value of 1 (bit combination 00000001 in most
significant bit first notation). A recipient MUST be
prepared to process values with leading zero bytes.
Optionの定義はbyte数の範囲を規定する。選択可能な場合、senderは0byteを除く、できるだけ少ないbyteで表現する。例えば、0はempty
option value(0byte)で、1は1byte(0000 0001)で表現される。recipientは0
byteを考慮して処理すること。(★いまいちわからない)
Shelby, et al.
Standards Track [Page 19]
RFC 7252 The Constrained Application Protocol (CoAP) June
2014
Implementation Note: The exceptional behavior permitted
for the sender is intended for highly constrained,
templated implementations (e.g., hardware
implementations) that use fixed-size options in the
templates.
senderの動作は、hardwareのような制約がある場合を意図している。
string: A
Unicode string that is encoded using UTF-8 [RFC3629] in
Net-Unicode form [RFC5198].
Net-Unicode[RFC5198]でUTF-8[RFC3629]を使用してエンコードしたUnicode文字。
Note
that here, and in all other places where UTF-8★★
encoding is used in the CoAP protocol, the intention is
that the encoded strings can be directly used and compared
as opaque byte strings by CoAP protocol implementations.
There is no expectation and no need to perform
normalization within a CoAP implementation (except where
Unicode strings that are not known to be normalized are
imported from sources outside the CoAP protocol). Note
also that ASCII strings (that do not make use of special
control characters) are always valid UTF-8 Net-Unicode
strings.
4. Message Transmission
CoAP messages
are exchanged asynchronously between CoAP endpoints.
They are used to transport CoAP requests and responses, the semantics
of which are defined in Section 5.
CoAP messageはCoAP endpoint間で非同期に交換される。Section 5で定義されたsemanticsを持つCoAP
request/responseが送信される。
As CoAP is bound
to unreliable transports such as UDP, CoAP messages
may arrive out of order, appear duplicated, or go missing without
notice. For this reason, CoAP implements a lightweight reliability
mechanism, without trying to re-create the full feature set of a
transport like TCP. It has the following features:
CoAPはUDPのような信頼性の無いTransportにバインドされるため、CoAP
messageは順不同だったり、重複したり、消失する場合がある。CoAPはTCPのようなTrasnportによる完全な再送メカニズム無しに、軽量の信頼性メカニズムを実装している。それには下記の機能がある。
o Simple
stop-and-wait retransmission reliability with exponential
back-off for Confirmable messages.
Confirmable messageのためのexponential
back-offを使用した単純なstop-and-wait再送。
o Duplicate detection for both Confirmable and Non-confirmable
messages.
Confirmable/Non-confirmable message両方での重複メッセージ検出。
4.1. Messages and Endpoints
A CoAP endpoint
is the source or destination of a CoAP message. The
specific definition of an endpoint depends on the transport being
used for CoAP. For the transports defined in this specification, the
endpoint is identified depending on the security mode used (see
Section 9): With no security, the endpoint is solely identified by an
IP address and a UDP port number. With other security modes, the
endpoint is identified as defined by the security mode.
CoAP endpointはCoAP
messageのsourceかdestinationである。endpointの定義はCoAPに仕様される転送方法に依存する。Security無しの場合、endpointはIP
addressとUDP port番号で識別される。Security有りの場合、endpointはSecurity
modeの定義に従って識別される。
Shelby, et al.
Standards Track [Page 20]
RFC 7252 The Constrained Application Protocol (CoAP) June
2014
There are
different types of messages. The type of a message is
specified by the Type field of the CoAP Header.
異なるタイプのmessageがある。message typeはCoAP HeaderのType fieldで規定される。
Separate from
the message type, a message may carry a request, a
response, or be Empty. This is signaled by the Request/Response Code
field in the CoAP Header and is relevant to the request/response
model. Possible values for the field are maintained in the CoAP Code
Registries (Section 12.1).
message typeとは別に、messageはrequest/response/Emptyを送ってよい。CoAP
HeaderのRequest/Response Codeはrequest/response modelに関連する。filedの値はCoAP Code
Registries(Section 12.1)で管理されている。
An Empty message
has the Code field set to 0.00. The Token Length
field MUST be set to 0 and bytes of data MUST NOT be present after
the Message ID field. If there are any bytes, they MUST be processed
as a message format error.
Empty messageはCode filedが0.00に設定される。Token Length fieldは0であり、dataはMessage
ID fieldの後には存在しないこと。