1、 TIA-5022.010 October 2015MQTT Protocol Binding (one M2M TS-0010-v1.0.1) NOTICE TIA Engineering Standards and Publications are designed to serve the public interest through eliminating misunderstandings between manufacturers and purchasers, facilitating interchangeability and improvement of products
2、, and assisting the purchaser in selecting and obtaining with minimum delay the proper product for their particular need. The existence of such Standards and Publications shall not in any respect preclude any member or non-member of TIA from manufacturing or selling products not conforming to such S
3、tandards and Publications. Neither shall the existence of such Standards and Publications preclude their voluntary use by Non-TIA members, either domestically or internationally. Standards and Publications are adopted by TIA in accordance with the American National Standards Institute (ANSI) patent
4、policy. By such action, TIA does not assume any liability to any patent owner, nor does it assume any obligation whatever to parties adopting the Standard or Publication. This Standard does not purport to address all safety problems associated with its use or all applicable regulatory requirements.
5、It is the responsibility of the user of this Standard to establish appropriate safety and health practices and to determine the applicability of regulatory limitations before its use. Any use of trademarks in this document are for information purposes and do not constitute an endorsement by TIA or t
6、his committee of the products or services of the company. (From Project No. TIA-PN-5022.010, formulated under the cognizance of the TIA TR-50 M2M- Smart Device Communications.) Published by TELECOMMUNICATIONS INDUSTRY ASSOCIATION Technology (b) there is no assurance that the Document will be approve
7、d by any Committee of TIA or any other body in its present or any other form; (c) the Document may be amended, modified or changed in the standards development or any editing process. The use or practice of contents of this Document may involve the use of intellectual property rights (“IPR”), includ
8、ing pending or issued patents, or copyrights, owned by one or more parties. TIA makes no search or investigation for IPR. When IPR consisting of patents and published pending patent applications are claimed and called to TIAs attention, a statement from the holder thereof is requested, all in accord
9、ance with the Manual. TIA takes no position with reference to, and disclaims any obligation to investigate or inquire into, the scope or validity of any claims of IPR. TIA will neither be a party to discussions of any licensing terms or conditions, which are instead left to the parties involved, nor
10、 will TIA opine or judge whether proposed licensing terms or conditions are reasonable or non-discriminatory. TIA does not warrant or represent that procedures or practices suggested or provided in the Manual have been complied with as respects the Document or its contents. If the Document contains
11、one or more Normative References to a document published by another organization (“other SSO”) engaged in the formulation, development or publication of standards (whether designated as a standard, specification, recommendation or otherwise), whether such reference consists of mandatory, alternate o
12、r optional elements (as defined in the TIA Procedures for American National Standards) then (i) TIA disclaims any duty or obligation to search or investigate the records of any other SSO for IPR or letters of assurance relating to any such Normative Reference; (ii) TIAs policy of encouragement of vo
13、luntary disclosure (see TIA Procedures for American National Standards Annex C.1.2.3) of Essential Patent(s) and published pending patent applications shall apply; and (iii) Information as to claims of IPR in the records or publications of the other SSO shall not constitute identification to TIA of
14、a claim of Essential Patent(s) or published pending patent applications. TIA does not enforce or monitor compliance with the contents of the Document. TIA does not certify, inspect, test or otherwise investigate products, designs or services or any claims of compliance with the contents of the Docum
15、ent. ALL WARRANTIES, EXPRESS OR IMPLIED, ARE DISCLAIMED, INCLUDING WITHOUT LIMITATION, ANY AND ALL WARRANTIES CONCERNING THE ACCURACY OF THE CONTENTS, ITS FITNESS OR APPROPRIATENESS FOR A PARTICULAR PURPOSE OR USE, ITS MERCHANTABILITY AND ITS NONINFRINGEMENT OF ANY THIRD PARTYS INTELLECTUAL PROPERTY
16、 RIGHTS. TIA EXPRESSLY DISCLAIMS ANY AND ALL RESPONSIBILITIES FOR THE ACCURACY OF THE CONTENTS AND MAKES NO REPRESENTATIONS OR WARRANTIES REGARDING THE CONTENTS COMPLIANCE WITH ANY APPLICABLE STATUTE, RULE OR REGULATION, OR THE SAFETY OR HEALTH EFFECTS OF THE CONTENTS OR ANY PRODUCT OR SERVICE REFER
17、RED TO IN THE DOCUMENT OR PRODUCED OR RENDERED TO COMPLY WITH THE CONTENTS. TIA SHALL NOT BE LIABLE FOR ANY AND ALL DAMAGES, DIRECT OR INDIRECT, ARISING FROM OR RELATING TO ANY USE OF THE CONTENTS CONTAINED HEREIN, INCLUDING WITHOUT LIMITATION ANY AND ALL INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTI
18、AL DAMAGES (INCLUDING DAMAGES FOR LOSS OF BUSINESS, LOSS OF PROFITS, LITIGATION, OR THE LIKE), WHETHER BASED UPON BREACH OF CONTRACT, BREACH OF WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY OR OTHERWISE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. THE FOREGOING NEGATION OF DAMAGES
19、 IS A FUNDAMENTAL ELEMENT OF THE USE OF THE CONTENTS HEREOF, AND THESE CONTENTS WOULD NOT BE PUBLISHED BY TIA WITHOUT SUCH LIMITATIONS. oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TTA, TTC) Page 2 of 27 This is a draft oneM2M document and should not be relied upon; the final version, if any
20、, will be made available by oneM2M Partners Type 1. About oneM2M The purpose and goal of oneM2M is to develop technical specifications which address the need for a common M2M Service Layer that can be readily embedded within various hardware and software, and relied upon to connect the myriad of dev
21、ices in the field with M2M application servers worldwide. More information about oneM2M may be found at: http/www.oneM2M.org Copyright Notification No part of this document may be reproduced, in an electronic retrieval system or otherwise, except as authorized by written permission. The copyright an
22、d the foregoing restriction extend to reproduction in all media. 2015, oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TTA, TTC). All rights reserved. Notice of Disclaimer the final version, if any, will be made available by oneM2M Partners Type 1. Contents 1 Scope 5 2 References 5 2.1 Normativ
23、e references . 5 2.2 Informative references . 5 3 Definitions and abbreviations . 6 3.1 Definitions . 6 3.2 Abbreviations . 6 4 Conventions . 6 5 Introduction 7 5.1 Use of MQTT 7 5.2 Binding overview . 7 5.2.1 Introduction 7 5.2.2 Scenarios 8 5.2.2.1 MQTT server co-located within a node . 8 5.2.2.2
24、MQTT server located independently from nodes . 9 5.2.3 Configurations 9 5.2.3.1 AE to IN . 9 5.2.3.2 AE to MN . 10 5.2.3.3 MN to IN 11 5.2.3.4 AE to MN to IN 11 5.2.3.5 AE to IN (Independent scenario) . 12 5.2.3.6 AE to MN (Independent scenario) . 12 5.2.3.7 MN to IN (Independent scenario) 12 5.2.3.
25、8 AE to MN to IN (Independent scenario) 13 6 Protocol Binding 13 6.1 Introduction . 13 6.2 Use of MQTT 14 6.3 Connecting to MQTT . 14 6.4 Sending and Receiving Messages . 15 6.4.1 Request and Response Messages 15 6.4.2 Sending a Request 16 6.4.3 Listening for and responding to a Request 16 6.4.4 Ini
26、tial Registration 17 6.4.5 Request/Response Message Flow 17 6.5 Primitive Mapping . 18 6.5.1 Request primitives 18 6.5.2 Response primitives 19 6.5.3 Content Format Negotiation 19 7 Security 19 7.1 Introduction . 19 7.2 Authorization . 20 7.3 Authentication 20 7.4 Authorization by the MQTT Server 21
27、 7.5 General Considerations 22 Annex A (informative): Overview of MQTT 23 A.1 MQTT features . 23 A.2 MQTT implementations . 24 A.3 MQTT Details 24 A.3.1 Addressing a message - Topics and Subscriptions 24 A.3.2 Reliability 25 A.3.3 Retained Messages . 26 oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI
28、, TIA, TTA, TTC) Page 4 of 27 This is a draft oneM2M document and should not be relied upon; the final version, if any, will be made available by oneM2M Partners Type 1. History 27 oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TTA, TTC) Page 5 of 27 This is a draft oneM2M document and should
29、not be relied upon; the final version, if any, will be made available by oneM2M Partners Type 1. 1 Scope The present document specifies the binding of Mca and Mcc primitives (message flows) onto the MQTT protocol. It specifies 1) How a CSE or AE connects to MQTT. 2) How an Originator (CSE or AE) for
30、mulates a Request as an MQTT message, and transmits it to its intended Receiver. 3) How a Receiver listens for incoming Requests. 4) How that Receiver can formulate and transmit a Response. 2 References 2.1 Normative references References are either specific (identified by date of publication and/or
31、 edition number or version number) or non-specific. For specific references, only the cited version applies. For non-specific references, the latest version of the reference document (including any amendments) applies. The following referenced documents are necessary for the application of the prese
32、nt document. 1 OASIS MQTT Version 3.1.1 (29 October 2014). OASIS Standard. Edited by Andrew Banks and Rahul Gupta. NOTE: Available at http:/docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html. 2 oneM2M TS-0001: “Functional Architecture“. 3 oneM2M TS-0004: “Service Layer Core Protocol Specifi
33、cation“. 4 IETF RFC 793 (September 1981): “Transmission Control Protocol - DARPA Ineternet Program - Protocol Specification“, J. Postel. NOTE: Available at http:/www.ietf.org/rfc/rfc793.txt. 5 IETF RFC 5246 (August 2008): “The Transport Layer Security (TLS) Protocol Version 1.2“, T. Dierks. NOTE: Av
34、ailable at http:/tools.ietf.org/html/rfc5246. 6 IETF RFC 6455 (December 2011): “The WebSocket Protocol“, I. Fette. NOTE: Available at http:/tools.ietf.org/html/rfc6455. 7 oneM2M TS-0003: “ Security Solutions “. 2.2 Informative references References are either specific (identified by date of publicat
35、ion and/or edition number or version number) or non-specific. For specific references, only the cited version applies. For non-specific references, the latest version of the reference document (including any amendments) applies. The following referenced documents are not necessary for the applicatio
36、n of the present document but they assist the user with regard to a particular subject area. oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TTA, TTC) Page 6 of 27 This is a draft oneM2M document and should not be relied upon; the final version, if any, will be made available by oneM2M Partners
37、 Type 1. i.1 oneM2M Drafting Rules. NOTE: Available at http:/member.onem2m.org/Static_pages/Others/Rules_Pages/oneM2M-Drafting-Rules-V1_0.doc. 3 Definitions and abbreviations 3.1 Definitions For the purposes of the present document, the following terms and definitions apply: originator 2: actor that
38、 initiates a Request NOTE: An Originator can either be an Application or a CSE. receiver 2: actor that receives the Request NOTE: A Receiver can be a CSE or an Application. resource 2: uniquely addressable entity in oneM2M System such as by the use of a Universal Resource Identifier (URI) NOTE: A re
39、source can be accessed and manipulated by using the specified procedures. 3.2 Abbreviations For the purposes of the present document, the abbreviations given in oneM2M TS-0001 2 and the following apply: ADN Application Dedicated Node ADN-AE AE which resides in the Application Dedicated Node AE Appli
40、cation Entity ASN Application Service Node ASE-AE Application Entity that is registered with the CSE in the Application Service Node ASN-CSE CSE which resides in the Application Service Node CSE Common Service Entity CSF Common Service Function EF Enabler Function IN Infrastructure Node IN-AE Applic
41、ation Entity that is registered with the CSE in the Infrastructure Node IN-CSE CSE which resides in the Infrastructure Node MN Middle Node MN-CSE CSE which resides in the Middle Node NSE Network Service Entity TLS Transport Level Security 4 Conventions The keywords “Shall“, “Shall not“, “May“, “Need
42、 not“, “Should“, “Should not“ in the present document are to be interpreted as described in the oneM2M Drafting Rules i.1. oneM2M Partners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TTA, TTC) Page 7 of 27 This is a draft oneM2M document and should not be relied upon; the final version, if any, will be mad
43、e available by oneM2M Partners Type 1. 5 Introduction 5.1 Use of MQTT This binding makes use of MQTT to provide reliable two-way communications between two parties (AEs and CSEs). It uses the following features of MQTT: Durable Sessions, providing Store and Forward in cases where network connectivit
44、y is not available. MQTTs “QoS 1“ message reliability level. This provides reliability without incurring the overhead implied by QoS 2. NAT traversal (neither of the two parties is required to have prior knowledge of the other partys IP address). Dynamic topic creation and wild-carded subscription f
45、ilters. It does not use the following features: One-to-many publish/subscribe. Retained Messages. Will Messages. QoS 0 or QoS 2 message reliability levels. 5.2 Binding overview 5.2.1 Introduction The MQTT protocol binding specifies how the Mca or Mcc request and response messages are transported acr
46、oss the MQTT protocol. Both communicating parties (AEs and CSEs) typically make use of an MQTT client library, and the communications are mediated via the MQTT server. There is no need for the client libraries or the server to be provided by the same supplier, since the protocol they use to talk to
47、each other is defined by the MQTT specification 1. Furthermore, the binding does not assume that the MQTT client libraries or server implementations are necessarily aware that they are being used to carry Mca, Mcc or any other oneM2M-defined primitives. The binding is defined in terms of the MQTT pr
48、otocol flows that take place between the client libraries and the MQTT server in order to effect the transport of an Mca or Mcc message. There are two scenarios depending on the location of MQTT server: MQTT server co-located within a node, and MQTT server located independently from nodes. oneM2M Pa
49、rtners Type 1 (ARIB, ATIS, CCSA, ETSI, TIA, TTA, TTC) Page 8 of 27 This is a draft oneM2M document and should not be relied upon; the final version, if any, will be made available by oneM2M Partners Type 1. 5.2.2 Scenarios 5.2.2.1 MQTT server co-located within a node Figure 5.2.2.1-1: MQTT server co-located scenario Figure 5.2.2.1-1 shows a protocol segment view of the MQTT server co-located scenario. In this scenario, all oneM2M nodes (ADN, ASN, MN, IN) include a MQTT client. MQTT servers are provided within MN and IN. In