1、 ETSI TS 118 120 V2.0.0 (2016-09) oneM2M; WebSocket Protocol Binding (oneM2M TS-0020 version 2.0.0 Release 2) TECHNICAL SPECIFICATION ETSI ETSI TS 118 120 V2.0.0 (2016-09)2(oneM2M TS-0020 version 2.0.0 Release 2) Reference DTS/oneM2M-000020 Keywords IoT, M2M, protocol ETSI 650 Route des Lucioles F-0
2、6921 Sophia Antipolis Cedex - FRANCE Tel.: +33 4 92 94 42 00 Fax: +33 4 93 65 47 16 Siret N 348 623 562 00017 - NAF 742 C Association but non lucratif enregistre la Sous-Prfecture de Grasse (06) N 7803/88 Important notice The present document can be downloaded from: http:/www.etsi.org/standards-sear
3、ch The present document may be made available in electronic versions and/or in print. The content of any electronic and/or print versions of the present document shall not be modified without the prior written authorization of ETSI. In case of any existing or perceived difference in contents between
4、 such versions and/or in print, the only prevailing document is the print of the Portable Document Format (PDF) version kept on a specific network drive within ETSI Secretariat. Users of the present document should be aware that the document may be subject to revision or change of status. Informatio
5、n on the current status of this and other ETSI documents is available at https:/portal.etsi.org/TB/ETSIDeliverableStatus.aspx If you find errors in the present document, please send your comment to one of the following services: https:/portal.etsi.org/People/CommiteeSupportStaff.aspx Copyright Notif
6、ication No part may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm except as authorized by written permission of ETSI. The content of the PDF version shall not be modified without the written authorization of ETSI. The copyright
7、and the foregoing restriction extend to reproduction in all media. European Telecommunications Standards Institute 2016. All rights reserved. DECTTM, PLUGTESTSTM, UMTSTMand the ETSI logo are Trade Marks of ETSI registered for the benefit of its Members. 3GPPTM and LTE are Trade Marks of ETSI registe
8、red for the benefit of its Members and of the 3GPP Organizational Partners. GSM and the GSM logo are Trade Marks registered and owned by the GSM Association. ETSI ETSI TS 118 120 V2.0.0 (2016-09)3(oneM2M TS-0020 version 2.0.0 Release 2) Contents Intellectual Property Rights 4g3Foreword . 4g31 Scope
9、5g32 References 5g32.1 Normative references . 5g32.2 Informative references 5g33 Definitions and abbreviations . 6g33.1 Definitions 6g33.2 Abbreviations . 6g34 Conventions 6g35 Overview on WebSocket Binding 6g35.1 Use of WebSocket 6g35.2 Binding Overview 7g36 Protocol Binding 10g36.1 Introduction 10
10、g36.2 WebSocket connection establishment 10g36.2.1 General 10g36.2.2 Client handshake . 11g36.2.2.1 Format of request-line . 11g36.2.2.2 Host header . 11g36.2.2.3 Upgrade header . 11g36.2.2.4 Connection header . 11g36.2.2.5 Sec-WebSocket-Key header 11g36.2.2.6 Sec-WebSocket-Version header 11g36.2.2.
11、7 Sec-WebSocket-Protocol header . 12g36.2.2.8 Sec-WebSocket-Extensions header . 12g36.2.2.9 Subprotocol names and serialization formats 12g36.2.3 Server handshake format 13g36.2.3.1 Format of status-line . 13g36.2.3.2 Upgrade header . 13g36.2.3.3 Connection header . 13g36.2.3.4 Sec-WebSocket-Accept
12、header . 13g36.2.3.5 Sec-WebSocket-Protocol header . 13g36.2.3.6 Sec-WebSocket-Extensions header . 13g36.3 Closing WebSocket connection 13g36.4 Registration procedure . 14g36.5 Handling of Non-Registration Request 14g36.6 Use of proxy servers . 14g37 Security Aspects . 14g3Annex A (informative): Exa
13、mple Procedures .15g3A.1 AE Registration and creation of a Container child resource 15g3History 18g3ETSI ETSI TS 118 120 V2.0.0 (2016-09)4(oneM2M TS-0020 version 2.0.0 Release 2) Intellectual Property Rights IPRs essential or potentially essential to the present document may have been declared to ET
14、SI. The information pertaining to these essential IPRs, if any, is publicly available for ETSI members and non-members, and can be found in ETSI SR 000 314: “Intellectual Property Rights (IPRs); Essential, or potentially Essential, IPRs notified to ETSI in respect of ETSI standards“, which is availa
15、ble from the ETSI Secretariat. Latest updates are available on the ETSI Web server (https:/ipr.etsi.org/). Pursuant to the ETSI IPR Policy, no investigation, including IPR searches, has been carried out by ETSI. No guarantee can be given as to the existence of other IPRs not referenced in ETSI SR 00
16、0 314 (or the updates on the ETSI Web server) which are, or may be, or may become, essential to the present document. Foreword This Technical Specification (TS) has been produced by ETSI Partnership Project oneM2M (oneM2M). ETSI ETSI TS 118 120 V2.0.0 (2016-09)5(oneM2M TS-0020 version 2.0.0 Release
17、2) 1 Scope The present document specifies the binding of Mca and Mcc primitives onto the WebSocket binding. It specifies: Procedures and message formats for operating and closing of WebSocket connections. How request and response primitives are mapped into the payload of the WebSocket protocol. 2 Re
18、ferences 2.1 Normative references References are either specific (identified by date of publication 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 referenced document (including
19、 any amendments) applies. Referenced documents which are not found to be publicly available in the expected location might be found at https:/docbox.etsi.org/Reference/. NOTE: While any hyperlinks included in this clause were valid at the time of publication, ETSI cannot guarantee their long term va
20、lidity. The following referenced documents are necessary for the application of the present document. 1 IETF RFC 6455: “The Web Socket Protocol“, December 2011. 2 ETSI TS 118 101: “oneM2M; Functional Architecture (oneM2M TS-0001). 3 IETF RFC 7230: “Hypertext Transport Protocol (HTTP/1.1): Message Sy
21、ntax and Routing“, June 2014. 4 ETSI TS 118 103: “oneM2M; Security Solutions (oneM2M TS-0003)“. 5 ETSI TS 118 104: “oneM2M; Service Layer Core Protocol Specification (oneM2M TS-0004)“. 6 IETF RFC 7692: “Compression Extension for WebSocket“, December 2015. 2.2 Informative references References are ei
22、ther specific (identified by date of publication 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 referenced document (including any amendments) applies. NOTE: While any hyperlink
23、s included in this clause were valid at the time of publication, ETSI cannot guarantee their long term validity. The following referenced documents are not necessary for the application of the present document but they assist the user with regard to a particular subject area. i.1 oneM2M Drafting Rul
24、es. NOTE: Available at http:/www.onem2m.org/images/files/oneM2M-Drafting-Rules.pdf. ETSI ETSI TS 118 120 V2.0.0 (2016-09)6(oneM2M TS-0020 version 2.0.0 Release 2) 3 Definitions and abbreviations 3.1 Definitions For the purposes of the present document, the following terms and definitions apply: oneM
25、2M WebSocket Client (WS Client): WebSocket Client associated with an AE or a CSE capable of establishing the WebSocket connections oneM2M WebSocket Server (WS Server): WebSocket Server associated with a CSE which accepts requests to establish WebSocket connections 3.2 Abbreviations For the purposes
26、of the present document, the following abbreviations apply: ADN Application Dedicated Node AE Application Entity ASN Application Service Node CBOR Concise Binary Object Representation CSE Common Services Entity FQDN Fully Qualified Domain Name GUID Globally Unique Identifier HTTP Hypertext Transport
27、 Protocol IANA Internet Assigned Numbers Authority IETF Internet Engineering Task Force IN-CSE Infrastructure Node Common Services Entity IP Internet Protocol JSON JavaScript Object Notation MN Middle Node MN-CSE Middle Node Common Services Entity NAT Network Address Translator SAEF Security Associa
28、tion Establishment Framework TCP Transmission Control Protocol TLS Transport Layer Security URI Uniform Resource Identifier WS WebSocket XML eXtensible Markup Language 4 Conventions The key words “Shall“, “Shall not“, “May“, “Need not“, “Should“, “Should not“ in the present document are to be interp
29、reted as described in the oneM2M Drafting Rules i.1. 5 Overview on WebSocket Binding 5.1 Use of WebSocket This binding makes use of the WebSocket protocol IETF RFC 6455 1 to transport serialized representations of oneM2M request and response primitives over the Mca or Mcc reference points. ETSI ETSI
30、 TS 118 120 V2.0.0 (2016-09)7(oneM2M TS-0020 version 2.0.0 Release 2) Establishment of a WebSocket connection shall be initiated by a WebSocket client by sending a handshake to a WebSocket server as specified in section 4 of IETF RFC 6455 1. Once the WebSocket connection is established, both oneM2M
31、request and response primitives can be exchanged bi-directionally between the two endpoints of the connection. Serialized representations of the request and response primitives shall be mapped in the Payload Data field of the WebSocket base framing protocol, as defined in section 5.2 of IETF RFC 645
32、5 1. A WebSocket connection employs either a TCP/IP or a TLS over TCP/IP connection. The underlying TCP and TLS connections are established as the first step of the WebSocket handshake. 5.2 Binding Overview WebSocket binding may be employed for communication between any two endpoints which can be co
33、nnected over the Mca, Mcc or Mcc interface reference points supported by the oneM2M Architecture as shown in figure 6.1-1 of ETSI TS 118 101 2. When using the WebSocket protocol, one communication endpoint shall act as the WebSocket server. The WebSocket server listens for inbound handshake messages
34、 arriving from any WebSocket client to which a WebSocket connection is not yet established. Whether a communication endpoint takes the role of the client or the server shall depend on the registration relationship between the communicating entities as follows: the registree shall always use a WebSoc
35、ket client, while the associated registrar shall always use a WebSocket server on the respective reference point. This implies that ADN and ASN always take the role of a WebSocket client when WebSocket binding is employed. An MN-CSE uses a WebSocket server to communicate with its registrees and a We
36、bSocket client to communicate with its own registrar (which can be another MN-CSE or an IN-CSE). The IN-CSE provides a WebSocket server functionality to communicate with all its registrees, i.e. within a service providers domain. On the Mcc reference points, i.e. for communication between IN-CSEs of
37、 different Service Provider domains, the IN-CSE shall provide both WebSocket client and server functionality. This enables any IN-CSE to open a WebSocket connection to any IN-CSE of another Service Providers domain. Figure 5.2.-1 shows some applicable example system configuration. ETSI ETSI TS 118 1
38、20 V2.0.0 (2016-09)8(oneM2M TS-0020 version 2.0.0 Release 2) Figure 5.2-1: Example scenarios of WebSocket client and server configurations There exists a maximum of one WebSocket connection between two nodes. A WebSocket connection is established for the first time when the initial registration proc
39、edure of an entity to its registrar is performed. On an established WebSocket connection, request and response primitives can be exchanged in both directions. Any connection may be closed by either the WebSocket client or the server, depending on the communication schedule of either entity. However,
40、 the connection can be reopened from the client side only. If the connection is closed temporarily, it shall be reopened when the next request primitive is sent from the client to the server side, or when the time to become reachable configured at resource. If the WebSocket connection with the next-
41、hop entity is not opened, and the WebSocket connection cannot be established due to lack of pointOfAccess address for the entity, a sending CSE may enable buffering of primitives which should be sent to the entity until the connection is reopened or their expiration time is reached. See Annex H of E
42、TSI TS 118 104 5 about buffering of primitives by CMDH functionality. Figure 5.2-2 shows an example message flow for a scenario where an ADN-AE registers to its registrar MN-CSE using an unsecured TCP connection without proxy and then continues exchanging non-registration request and response primit
43、ives. AE WSClientCSE WSServerWSClientAE CSE WSClientAE AE WSClientCSE WSClientAE CSE WSServerWSClientAE CSE WS Server WS Client ADN ASN ADN MN MN ASN IN Mcc Mcc Mca Mcc Mca Mcc ETSI ETSI TS 118 120 V2.0.0 (2016-09)9(oneM2M TS-0020 version 2.0.0 Release 2) 1) The ADN-AE wants to register to its regis
44、trar MN-CSE. If a WebSocket connection does not exist, it is established by the following steps 2) and 3). It is assumed that the ADN-AE knows the point of access (i.e. WebSocket URI specified in IETF RFC 6455 1) under which the registrar CSE can be reached with WebSocket binding. 2) The WebSocket c
45、lient opens handshake to the server with subprotocol name oneM2M-pro-v1.0 following IETF RFC 6455 1. If the server can be reached under the WebSocket URI ws:/:9000/, the client handshake may look as follows: GET / HTTP/1.1 Host: :9000 Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Key: ud63env
46、87LQLd4uIV20/oQ= Sec-WebSocket-Protocol: oneM2M-pro-v1.0 Sec-WebSocket-Version: 13 3) The WebSocket server replies with a handshake to the client. In the successful case, the status-line of this HTTP response may look as follow: Request-Version: HTTP/1.1 Status-Code: 101 Response-Phrase: Switching P
47、rotocols Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Protocol: oneM2M-pro-v1.0 Sec-WebSocket-Accept: FuSSKANnI7C/6/FrPMt70mfBY8E= AE WS client CSE WS server ADN MN 1) AE wants to start registration procedure and triggers WebSocket connection establishment 2) Client handshake 3) Server hands
48、hake 4)Request primitive 5) WebSocket Binding 6) WebSocket message 7) Unpacking request primitive 8)Request primitive 9) Receiver side processing of AE registration procedure 10) Response primitive 11) WebSocket Binding 12) WebSocket message 13) Unpacking response primitive 14) Response primitive 15
49、) non-registration CRUDN operations Figure 5.2-2: Example message flow with Websocket binding ETSI ETSI TS 118 120 V2.0.0 (2016-09)10(oneM2M TS-0020 version 2.0.0 Release 2) 4) The ADN-AE issue a registration request primitive. The request primitive may e.g. look as follows as JSON-serialized representation: “m2m:rqp“:“op“:1,“to“:“/ “apn“:“app1234“,“ty“: 2 NOTE: The WebSocket client associated with an ADN-AE does not need to be reachable