この規格 プレビューページの目次
※一部、英文及び仏文を自動翻訳した日本語訳を使用しています。
1 はじめに
1.1 MQTT の構成
この仕様は 7 つの章に分かれています。
- 第1章;序章
- 第 2 章 - MQTT コントロール パケットのフォーマット
- 第 3 章 - MQTT 制御パケット
- 第 4 章 - 操作上の動作
- 第 5 章 - セキュリティ
- 第 6 章 - WebSocket をネットワーク トランスポートとして使用する
- 第 7 章 - 適合目標
1.2 用語
この仕様のキーワード「MUST」、「MUST NOT」、「REQUIRED」、「SHALL」、「SHALL NOT」、「SHOULD」、「SHOULD NOT」、「RECOMMENDED」、「MAY」、および「OPTIONAL」は、 IETF RFC 2119 [RFC2119] で説明されているように解釈されます。
ネットワーク接続:
MQTT によって使用されている、基礎となるトランスポート プロトコルによって提供される構造。
- クライアントをサーバーに接続します。
- これは、順序付けされたロスレスのバイト ストリームを双方向に送信する手段を提供します。
例については、セクション 4.2 を参照してください。
アプリケーション メッセージ:
アプリケーションのネットワークを介して MQTT プロトコルによって運ばれるデータ。申請時
メッセージは MQTT によって転送され、サービスの品質とトピック名が関連付けられています。
クライアント:
MQTT を使用するプログラムまたはデバイス。クライアントは常にネットワーク接続を確立します。
- 他のクライアントが関心を持つ可能性のあるアプリケーション メッセージを公開します。
- サブスクライブして、受信を希望するアプリケーション メッセージをリクエストします。
- アプリケーション メッセージのリクエストを削除するには、登録を解除します。
- サーバーから切断します。
サーバ:
アプリケーション メッセージを公開するクライアントと、サブスクリプションを作成したクライアントとの間の仲介者として機能するプログラムまたはデバイス。サーバー
- クライアントからのネットワーク接続を受け入れます。
- クライアントによって発行されたアプリケーション メッセージを受け入れます。
- クライアントからの購読および購読解除要求を処理します。
- クライアント サブスクリプションに一致するアプリケーション メッセージを転送します。
サブスクリプション:
サブスクリプションは、トピック フィルターと最大 QoS で構成されます。サブスクリプションは、単一のセッションに関連付けられています。セッションには、複数のサブスクリプションを含めることができます。セッション内の各サブスクリプションには、異なるトピック フィルターがあります。
トピック名:
サーバーに認識されているサブスクリプションと照合されるアプリケーション メッセージに添付されたラベル。サーバーは、一致するサブスクリプションを持つ各クライアントにアプリケーション メッセージのコピーを送信します。
トピック フィルタ:
1 つまたは複数のトピックへの関心を示す、サブスクリプションに含まれる式。トピック フィルターには、ワイルドカード文字を含めることができます。
セッション:
クライアントとサーバー間のステートフルな対話 。 一部のセッションは、ネットワーク接続の間のみ持続し、他のセッションは、クライアントとサーバー間の複数の連続したネットワーク接続にまたがることができます。
MQTT 制御パケット:
ネットワーク接続を介して送信される情報のパケット。 MQTT 仕様では、14 種類の制御パケットが定義されており、そのうちの 1 つ (PUBLISH パケット) はアプリケーション メッセージの伝達に使用されます。
1.3 規範的参照
- Bradner, S.、「要件レベルを示すために RFC で使用するためのキーワード」、BCP 14, RFC 2119, 1997 年 3 月。
http://www.ietf.org/rfc/rfc2119.txt - Yergeau, F.、「UTF-8, ISO 10646 の変換形式」、STD 63, RFC 3629, 2003 年 11 月
http://www.ietf.org/rfc/rfc3629.txt - Dierks, T. および E. Rescorla, 「トランスポート層セキュリティ (TLS) プロトコル バージョン 1.2」、RFC 5246, 2008 年 8 月。
http://www.ietf.org/rfc/rfc5246.txt - Fette, I. および A. Melnikov, 「WebSocket プロトコル」、RFC 6455, 2011 年 12 月。
http://www.ietf.org/rfc/rfc6455.txt - Unicode コンソーシアム。ユニコード標準。
http://www.unicode.org/versions/latest/
1.4 非規範的な参照
- Postel, J. Transmission Control Protoco STD 7, IETF RFC 793, 1981 年 9 月。
http://www.ietf.org/rfc/rfc793.txt - 高度暗号化標準 (AES) (FIPS PUB 197)
http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf - データ暗号化規格 (DES)
http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf - 暗号化モジュールのセキュリティ要件 (FIPS PUB 140-2)
http://csrc.nist.gov/publications/fips/fips140-2/fips1402.pdf - ローカルおよびメトロポリタン エリア ネットワークの IEEE 規格 - 安全なデバイス ID
http://standards.ieee.org/findstds/standard/802.1AR-2009.html - ISO/IEC 29192-1:2012 情報技術 — セキュリティ技術 — 軽量暗号 — 1: 一般
http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=56425 - MQTT 補足資料、MQTT および重要インフラストラクチャのサイバーセキュリティを改善するための NIST フレームワーク
http://docs.oasis-open.org/mqtt/mqtt-nist-cybersecurity/v1.0/mqtt-nist-cybersecurity-v1.0.html - MQTT V3.1 プロトコル仕様。
http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html - 重要インフラのサイバーセキュリティの改善に関する大統領令 13636
http://www.nist.gov/itl/upload/preliminary-cybersecurity-framework.pdf - NISTIR 7628 スマート グリッド サイバー セキュリティのガイドライン
http://www.nist.gov/smartgrid/upload/nistir-7628_total.pdf - NSA Suite B 暗号化
http://www.nsa.gov/ia/programs/suiteb_cryptography/ - PCI DSS クレジット カード業界のデータ セキュリティ基準
https://www.pcisecuritystandards.org/security_standards/ - Leech M, Ganis M, Lee Y, Kuris R, Koblas D, および L Jones, 「SOCKS プロトコル バージョン 5」、RFC 1928, 1996 年 3 月。
http://www.ietf.org/rfc/rfc1928.txt - Sermersheim, J., Ed.、「軽量ディレクトリ アクセス プロトコル (LDAP): プロトコル」、RFC 4511, 6 月
http://www.ietf.org/rfc/rfc4511.txt - Salowey, J.、Zhou, H.、Eronen, P.、および H. Tschofenig, 「サーバー側の状態を伴わないトランスポート層セキュリティ (TLS) セッションの再開」、RFC 5077, 2008 年 1 月。
http://www.ietf.org/rfc/rfc5077.txt - Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk, "Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile", RFC 5280, 2008 年 5 月。
http://www.ietf.org/rfc/rfc5280.txt - Eastlake 3rd, D.、「Transport Layer Security (TLS) Extensions: Extension Definitions」、RFC 6066, 2011 年 1 月。
http://www.ietf.org/rfc/rfc6066.txt - Hardt, D., Ed.、「The OAuth 2.0 Authorization Framework」、RFC 6749, 2012 年 10 月。
http://www.ietf.org/rfc/rfc6749.txt - Santesson, S.、Myers, M.、Ankney, R.、Malpani, A.、Galperin, S.、C. Adams, 「X.509 Internet Public Key Infrastructure Online Certificate Status Protocol — OCSP」、RFC 6960, 6 月2013年
http://www.ietf.org/rfc/rfc6960.txt - 2002 年の企業改革法。
http://www.gpo.gov/fdsys/pkg/PLAW-107publ204/html/PLAW-107publ204.htm - US-EU セーフハーバー
http://export.gov/safeharbor/eu/eg_main_018365.asp
1.5 データ表現
1.5.1 ビット
バイト内のビットには 7 ~ 0 のラベルが付けられます。ビット番号 7 は最上位ビットで、最下位ビットにはビット番号 0 が割り当てられます。
1.5.2 整数データ値
整数データ値はビッグエンディアン順の 16 ビットです。上位バイトが下位バイトに先行します。これは、16 ビット ワードがネットワーク上で最上位バイト (MSB) として表示され、その後に最下位バイト (LSB) が続くことを意味します。
1.5.3 UTF-8 でエンコードされた文字列
後述のコントロール パケットのテキスト フィールドは、UTF-8 文字列としてエンコードされます。 UTF-8 [RFC3629] は、テキストベースの通信をサポートするために ASCII 文字のエンコーディングを最適化する Unicode [Unicode] 文字の効率的なエンコーディングです。
これらの各文字列には、下の図 1.1 UTF-8 でエンコードされた文字列の構造に示すように、UTF-8 でエンコードされた文字列自体のバイト数を示す 2 バイトの長さフィールドがプレフィックスとして付けられます。したがって、これらの UTF-8 でエンコードされた文字列コンポーネントの 1 つで渡すことができる文字列のサイズには制限があります。 65535 バイト以上にエンコードされる文字列は使用できません。
特に明記しない限り、UTF-8 でエンコードされたすべての文字列は、0 から 65535 バイトの範囲で任意の長さにすることができます。
図 1.1 — UTF-8 でエンコードされた文字列の構造
| 少し | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| バイト 1 | 文字列長 MSB | |||||||
| バイト 2 | 文字列長 LSB | |||||||
| バイト 3 .... | 長さ > 0 の場合、UTF-8 でエンコードされた文字データ。 |
UTF-8 でエンコードされた文字列の文字データは、Unicode 仕様 [Unicode] で定義され、RFC 3629 [RFC3629] で言い換えられているように、整形式の UTF-8 でなければなりません。特に、このデータには、U+D800 と U+DFFF の間のコード ポイントのエンコーディングを含めてはなりません。サーバーまたはクライアントが不正な UTF-8 を含む制御パケットを受信した場合、ネットワーク接続を閉じる必要があります[MQTT-1.5.3-1]
UTF-8 でエンコードされた文字列には、ヌル文字 U+0000 のエンコードを含めてはなりません。受信者 (サーバーまたはクライアント) が U+0000 を含む制御パケットを受信した場合、ネットワーク接続を閉じる必要があります[MQTT-1.5.3-2]
データには、以下にリストされている Unicode [Unicode] コード ポイントのエンコーディングを含めるべきではありません。受信者 (サーバーまたはクライアント) がそれらのいずれかを含む制御パケットを受信した場合、ネットワーク接続を閉じることができます:
U+0001..U+001F 制御文字
U+007F..U+009F 制御文字
Unicode 仕様 [Unicode] で非文字として定義されているコード ポイント (たとえば、U+0FFFF)
UTF-8 でエンコードされたシーケンス 0xEF 0xBB 0xBF は、文字列のどこに出現しても常に U+FEFF ("ZERO WIDTH NO-BREAK SPACE") を意味すると解釈され、パケット受信者によってスキップされたり、取り除かれたりしてはなりません[MQTT -1.5.3-3] .
1.5.3.1 非規範的な例
たとえば、LATIN CAPITAL Letter A の後にコード ポイント U+2A6D4 (CJK IDEOGRAPH EXTENSION B 文字を表す) が続く文字列 A は、次のようにエンコードされます。
図 1.2 — UTF-8 でエンコードされた文字列の非規範的な例
| 少し | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| バイト 1 | 文字列長 MSB (0x00) | |||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| バイト 2 | 文字列長 LSB (0x05) | |||||||
| 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | |
| バイト 3 | 「あ」(0x41) | |||||||
| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | |
| バイト 4 | (0xF0) | |||||||
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | |
| バイト 5 | (0xAA) | |||||||
| 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | |
| バイト 6 | (0x9B) | |||||||
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | |
| バイト 7 | (0x94) | |||||||
| 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
1.6 編集規則
この仕様内で黄色で強調表示されているテキストは、適合ステートメントを示しています。各適合ステートメントには、 [MQTT-xxx-y]の形式で参照が割り当てられています。
1 Introduction
1.1 Organization of MQTT
This specification is split into seven chapters:
- Chapter 1 - Introduction
- Chapter 2 - MQTT Control Packet format
- Chapter 3 - MQTT Control Packets
- Chapter 4 - Operational behavior
- Chapter 5 - Security
- Chapter 6 - Using WebSocket as a network transport
- Chapter 7 - Conformance Targets
1.2 Terminology
The key words"MUST","MUST NOT","REQUIRED","SHALL","SHALL NOT","SHOULD","SHOULD NOT","RECOMMENDED","MAY", and"OPTIONAL" in this specification are to be interpreted as described in IETF RFC 2119 [RFC2119].
Network Connection:
A construct provided by the underlying transport protocol that is being used by MQTT.
- It connects the Client to the Server.
- It provides the means to send an ordered, lossless, stream of bytes in both directions.
For examples see Section 4.2.
Application Message:
The data carried by the MQTT protocol across the network for the application. When Application
Messages are transported by MQTT they have an associated Quality of Service and a Topic Name.
Client:
A program or device that uses MQTT. A Client always establishes the Network Connection to the It can
- Publish Application Messages that other Clients might be interested in.
- Subscribe to request Application Messages that it is interested in receiving.
- Unsubscribe to remove a request for Application Messages.
- Disconnect from the Server.
Server:
A program or device that acts as an intermediary between Clients which publish Application Messages and Clients which have made Subscriptions. A Server
- Accepts Network Connections from Clients.
- Accepts Application Messages published by Clients.
- Processes Subscribe and Unsubscribe requests from Clients.
- Forwards Application Messages that match Client Subscriptions.
Subscription:
A Subscription comprises a Topic Filter and a maximum QoS. A Subscription is associated with a single Session. A Session can contain more than one Subscription. Each Subscription within a session has a different Topic Filter.
Topic Name:
The label attached to an Application Message which is matched against the Subscriptions known to the Server. The Server sends a copy of the Application Message to each Client that has a matching Subscription.
Topic Filter:
An expression contained in a Subscription, to indicate an interest in one or more topics. A Topic Filter can include wildcard characters.
Session:
A stateful interaction between a Client and a Server . Some Sessions last only as long as the Network Connection, others can span multiple consecutive Network Connections between a Client and a Server.
MQTT Control Packet:
A packet of information that is sent across the Network Connection. The MQTT specification defines fourteen different types of Control Packet, one of which (the PUBLISH packet) is used to convey Application Messages.
1.3 Normative references
- Bradner, S.,"Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997.
http://www.ietf.org/rfc/rfc2119.txt - Yergeau, F.,"UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, November 2003
http://www.ietf.org/rfc/rfc3629.txt - Dierks, T. and E. Rescorla,"The Transport Layer Security (TLS) Protocol Version 1.2", RFC 5246, August 2008.
http://www.ietf.org/rfc/rfc5246.txt - Fette, I. and A. Melnikov,"The WebSocket Protocol", RFC 6455, December 2011.
http://www.ietf.org/rfc/rfc6455.txt - The Unicode Consortium. The Unicode Standard.
http://www.unicode.org/versions/latest/
1.4 Non normative references
- Postel, J. Transmission Control Protocol. STD 7, IETF RFC 793, September 1981.
http://www.ietf.org/rfc/rfc793.txt - Advanced Encryption Standard (AES) (FIPS PUB 197).
http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf - Data Encryption Standard (DES).
http://csrc.nist.gov/publications/fips/fips46-3/fips46-3.pdf - Security Requirements for Cryptographic Modules (FIPS PUB 140-2)
http://csrc.nist.gov/publications/fips/fips140-2/fips1402.pdf - IEEE Standard for Local and metropolitan area networks - Secure Device Identity
http://standards.ieee.org/findstds/standard/802.1AR-2009.html - ISO/IEC 29192-1:2012 Information technology — Security techniques — Lightweight cryptography — 1: General
http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=56425 - MQTT supplemental publication, MQTT and the NIST Framework for Improving Critical Infrastructure Cybersecurity
http://docs.oasis-open.org/mqtt/mqtt-nist-cybersecurity/v1.0/mqtt-nist-cybersecurity-v1.0.html - MQTT V3.1 Protocol Specification.
http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html - Improving Critical Infrastructure Cybersecurity Executive Order 13636
http://www.nist.gov/itl/upload/preliminary-cybersecurity-framework.pdf - NISTIR 7628 Guidelines for Smart Grid Cyber Security
http://www.nist.gov/smartgrid/upload/nistir-7628_total.pdf - NSA Suite B Cryptography
http://www.nsa.gov/ia/programs/suiteb_cryptography/ - PCI-DSS Payment Card Industry Data Security Standard
https://www.pcisecuritystandards.org/security_standards/ - Leech, M., Ganis, M., Lee, Y., Kuris, R., Koblas, D., and L. Jones,"SOCKS Protocol Version 5", RFC 1928, March 1996.
http://www.ietf.org/rfc/rfc1928.txt - Sermersheim, J., Ed.,"Lightweight Directory Access Protocol (LDAP): The Protocol", RFC 4511, June
http://www.ietf.org/rfc/rfc4511.txt - Salowey, J., Zhou, H., Eronen, P., and H. Tschofenig,"Transport Layer Security (TLS) Session Resumption without Server-Side State", RFC 5077, January 2008.
http://www.ietf.org/rfc/rfc5077.txt - Cooper, D., Santesson, S., Farrell, S., Boeyen, S., Housley, R., and W. Polk,"Internet X.509 Public Key Infrastructure Certificate and Certificate Revocation List (CRL) Profile", RFC 5280, May 2008.
http://www.ietf.org/rfc/rfc5280.txt - Eastlake 3rd, D.,"Transport Layer Security (TLS) Extensions: Extension Definitions", RFC 6066, January 2011.
http://www.ietf.org/rfc/rfc6066.txt - Hardt, D., Ed.,"The OAuth 2.0 Authorization Framework", RFC 6749, October 2012.
http://www.ietf.org/rfc/rfc6749.txt - Santesson, S., Myers, M., Ankney, R., Malpani, A., Galperin, S., and C. Adams,"X.509 Internet Public Key Infrastructure Online Certificate Status Protocol — OCSP", RFC 6960, June 2013.
http://www.ietf.org/rfc/rfc6960.txt - Sarbanes-Oxley Act of 2002.
http://www.gpo.gov/fdsys/pkg/PLAW-107publ204/html/PLAW-107publ204.htm - U.S.-EU Safe Harbor
http://export.gov/safeharbor/eu/eg_main_018365.asp
1.5 Data representations
1.5.1 Bits
Bits in a byte are labeled 7 through 0. Bit number 7 is the most significant bit, the least significant bit is assigned bit number 0.
1.5.2 Integer data values
Integer data values are 16 bits in big-endian order: the high order byte precedes the lower order byte. This means that a 16-bit word is presented on the network as Most Significant Byte (MSB), followed by Least Significant Byte (LSB).
1.5.3 UTF-8 encoded strings
Text fields in the Control Packets described later are encoded as UTF-8 strings. UTF-8 [RFC3629] is an efficient encoding of Unicode [Unicode] characters that optimizes the encoding of ASCII characters in support of text-based communications.
Each of these strings is prefixed with a two byte length field that gives the number of bytes in a UTF-8 encoded string itself, as illustrated in Figure 1.1 Structure of UTF-8 encoded strings below. Consequently there is a limit on the size of a string that can be passed in one of these UTF-8 encoded string components; you cannot use a string that would encode to more than 65535 bytes.
Unless stated otherwise all UTF-8 encoded strings can have any length in the range 0 to 65535 bytes.
Figure 1.1—Structure of UTF-8 encoded strings
| Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| byte 1 | String length MSB | |||||||
| byte 2 | String length LSB | |||||||
| byte 3 …. | UTF-8 Encoded Character Data, if length > 0. |
The character data in a UTF-8 encoded string MUST be well-formed UTF-8 as defined by the Unicode specification [Unicode] and restated in RFC 3629 [RFC3629]. In particular this data MUST NOT include encodings of code points between U+D800 and U+DFFF. If a Server or Client receives a Control Packet containing ill-formed UTF-8 it MUST close the Network Connection [MQTT-1.5.3-1].
A UTF-8 encoded string MUST NOT include an encoding of the null character U+0000. If a receiver (Server or Client) receives a Control Packet containing U+0000 it MUST close the Network Connection [MQTT-1.5.3-2].
The data SHOULD NOT include encodings of the Unicode [Unicode] code points listed below. If a receiver (Server or Client) receives a Control Packet containing any of them it MAY close the Network Connection:
U+0001..U+001F control characters
U+007F..U+009F control characters
Code points defined in the Unicode specification [Unicode] to be non-characters (for example U+0FFFF)
A UTF-8 encoded sequence 0xEF 0xBB 0xBF is always to be interpreted to mean U+FEFF ("ZERO WIDTH NO-BREAK SPACE") wherever it appears in a string and MUST NOT be skipped over or stripped off by a packet receiver [MQTT-1.5.3-3].
1.5.3.1 Non normative example
For example, the string A which is LATIN CAPITAL Letter A followed by the code point U+2A6D4 (which represents a CJK IDEOGRAPH EXTENSION B character) is encoded as follows:
Figure 1.2—UTF-8 encoded string non normative example
| Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| byte 1 | String Length MSB (0x00) | |||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
| byte 2 | String Length LSB (0x05) | |||||||
| 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | |
| byte 3 | ‘A’ (0x41) | |||||||
| 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | |
| byte 4 | (0xF0) | |||||||
| 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | |
| byte 5 | (0xAA) | |||||||
| 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | |
| byte 6 | (0x9B) | |||||||
| 1 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | |
| byte 7 | (0x94) | |||||||
| 1 | 0 | 0 | 1 | 0 | 1 | 0 | 0 |
1.6 Editing conventions
Text highlighted in Yellow within this specification identifies conformance statements. Each conformance statement has been assigned a reference in the format [MQTT-x.x.x-y].