<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-wang-open-service-access-protocol-06" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" consensus="true">

<front>
<title abbrev="Open Service Access Protocol for IoT">Open Service Access Protocol for IoT Smart Devices</title><seriesInfo value="draft-wang-open-service-access-protocol-06" stream="IETF" status="standard" name="draft"></seriesInfo>
<author role="editor" initials="B." surname="Wang" fullname="Bin Wang"><organization>Hikvision</organization><address><postal><street>555 Qianmo Road, Binjiang District</street>
<city>Hangzhou</city>
<code>310051</code>
<country>CN</country>
</postal><phone>+86 571 8847 3644</phone>
<email>wbin2006@gmail.com</email>
</address></author>
<author role="editor" initials="S." surname="Zhou" fullname="Shaopeng Zhou"><organization>Hikvision</organization><address><postal><street>555 Qianmo Road, Binjiang District</street>
<city>Hangzhou</city>
<code>310051</code>
<country>CN</country>
</postal><phone>+86 571 8847 3644</phone>
<email>zhoushaopeng@hikvision.com</email>
</address></author>
<author role="editor" initials="C." surname="Li" fullname="Chao Li"><organization>Guangzhou University</organization><address><postal><street>230 Wai Huan Xi Road</street>
<city>Guangzhou</city>
<code>510006</code>
<country>CN</country>
</postal><email>lichao@gzhu.edu.cn</email>
</address></author>
<author role="editor" initials="C." surname="Wu" fullname="Chunming Wu"><organization>Zhejiang University</organization><address><postal><street>866 Yuhangtang Rd</street>
<city>Hangzhou</city>
<code>310058</code>
<country>CN</country>
</postal><email>wuchunming@zju.edu.cn</email>
</address></author>
<author role="editor" initials="Z." surname="Wang" fullname="Zizhao Wang"><organization>Zhejiang University</organization><address><postal><street>866 Yuhangtang Rd</street>
<city>Hangzhou</city>
<code>310058</code>
<country>CN</country>
</postal><email>22021272@zju.edu.cn</email>
</address></author>
<author role="editor" initials="H.N." surname="Yan" fullname="HaoNan Yan"><organization>Hikvision</organization><address><postal><street>555 Qianmo Road, Binjiang District</street>
<city>Hangzhou</city>
<code>310051</code>
<country>CN</country>
</postal><phone>+86 182 9201 6473</phone>
<email>yanhaonan@hikvision.com</email>
</address></author>
<author role="editor" initials="Y.H." surname="Xie" fullname="Yinghui Xie"><organization>Hikvision</organization><address><postal><street>555 Qianmo Road, Binjiang District</street>
<city>Hangzhou</city>
<code>310051</code>
<country>CN</country>
</postal><phone>+86 139 5327 0326</phone>
<email>xieyinghui@hikvision.com</email>
</address></author>
<date year="2024" month="October" day="14"></date>
<area>Internet</area>
<workgroup>Internet Engineering Task Force</workgroup>
<keyword>IoT</keyword>
<keyword>Access Protocol</keyword>
<keyword>Open Service</keyword>

<abstract>
<t>With the development of IoT (Internet of Things) technology, everything becomes interconnected. Mass IoT data, devices, businesses, and services adopt different data descriptions and service access methods, resulting in fragmentation issues such as data heterogeneity, device heterogeneity, and application heterogeneity. These issues hinder the development of the industry. To solve this problem, this draft proposes the requirements for IoT smart devices to transmit and control, as well as transmission and protocol interfaces. It is intended for program design, system testing and acceptance, and related research. The structured, unified, and standardized open service interconnection model reduces business replication costs and eliminates service barriers, thus promoting industrial development.</t>
</abstract>

</front>

<middle>

<section anchor="preface"><name>Preface</name>
<t>With the development of IoT technology, everything is widely interconnected and deeply invole with human-machine interaction. This includes various innovative applications such as autonomous vehicles, telemedicine, smart factories, smart cities, and more. However, as businesses grow, the adoption of different data descriptions and service access methods by mass IoT data, devices, businesses, and services leads to fragmentation issues. These fragmentation issues can be observed in the form of data heterogeneity, device heterogeneity, and application heterogeneity. Unfortunately, these issues hinder the development of the industry. The main challenges that arise from this fragmentation are:</t>

<ol>
<li><t>Low value of data: IoT data has the characteristics of multi-source heterogeneity and huge scale, making it difficult for data analysis and sharing. At the same time, the lack of business relevance between massive amounts of data leads to inefficient use of data.</t>
</li>
<li><t>High cost of business replication: different devices use different access standards. The cost of device access is too high and the time is too long. With the growth quantity of applications and devices, new device needs to be customized and developed multiple times for different standards, resulting in increased business replication cost.</t>
</li>
<li><t>Difficulty in industrial chain cooperation: There are different access protocols and data models between different manufacturers. The internal industrial chain has its own system, which makes it difficult for industrial chain to collaborate, for devices to be linked, maintained, for service to be compatible, Which seriously affects the user experience.</t>
</li>
</ol>
<t>In order to solve the problem, this draft proposes the requirements for IoT smart devices to transmit and control, as well as transmission and protocol interfaces. It is for the program design, system testing and acceptance, and related research. Structured, unified, and standardized open service interconnection model reduces business replication cost and removes service barriers to push industrial development.</t>
</section>

<section anchor="requirements-for-consistency"><name>Requirements for Consistency</name>

<section anchor="terms-and-definitions"><name>Terms and Definitions</name>

<section anchor="area"><name>Area</name>
<t>A set of related functions, which is business independent.</t>
</section>

<section anchor="attribute"><name>Attribute</name>
<t>Used to describe the sustainable state of the devices during operation, which can be read and set.</t>
</section>

<section anchor="operation"><name>Operation</name>
<t>A method that can be called externally by a device or platform. The operation includes &quot;input parameters&quot; and &quot;output parameters&quot;. The input parameters are the instruction information that needed to perform the operation, and the output parameters are the feedback information after the instruction is executed.</t>
</section>

<section anchor="event"><name>Event</name>
<t>Information actively reported by the device. This type of information needs to be reported in real time and processed by the platform in time. If the device network is interrupted, it can be cached and reported after recovery.</t>
</section>

<section anchor="resource"><name>Resource</name>
<t>An entity that is a relatively independent component of the device and can independently handle user requirements. User applications can independently show or manage the resources of the device. For example, the video channel of NVR device.</t>
</section>

<section anchor="iot-device-management-platform"><name>IoT Device Management Platform</name>
<t>A system that connects a large number of diverse and heterogeneous sensing devices and can unify access management of devices, collect, process and store data.</t>
</section>

<section anchor="load-balancing-service"><name>Load Balancing Service</name>
<t>Responsible for equipment certification. The device actively authenticates to the load balancing service. After passing the authentication, the device will balance the load to multiple devices to access the service through redirection.</t>
</section>

<section anchor="device-access-service"><name>Device Access Service</name>
<t>Services for managing, controlling and configing device functions and support attributes, operations, and events.</t>
</section>

<section anchor="picture-service"><name>Picture Service</name>
<t>Responsible for image storage services, support upload, download images and other functions.</t>
</section>

<section anchor="video-service"><name>Video Service</name>
<t>Responsible for media data transmission, support real-time preview, video playback, voice intercom and other functions.</t>
</section>

<section anchor="event-service"><name>Event Service</name>
<t>Responsible for receiving and handling events.</t>
</section>

<section anchor="iot-smart-devices"><name>IoT Smart Devices</name>
<t>Physical entities with video, image, and information perception capabilities, including: video equipment, access control, radar, etc. It can be directly connected to the IoT device management platform, or be a gateway that connects the agent sub-device and the IoT device management platform.</t>
</section>
</section>

<section anchor="abbreviations-and-acronyms"><name>Abbreviations and Acronyms</name>
<table><name>Abbreviations and Acronyms
</name>
<thead>
<tr>
<th>Abbreviations and Acronyms</th>
<th align="right">Full Name</th>
</tr>
</thead>

<tbody>
<tr>
<td>IP</td>
<td align="right">Internet Protocol</td>
</tr>

<tr>
<td>JSON</td>
<td align="right">Java Script Object Notation</td>
</tr>

<tr>
<td>MQTT<xref target="MQTT2016"></xref></td>
<td align="right">Message Queuing Telemetry Transport</td>
</tr>

<tr>
<td>TLS<xref target="RFC8446"></xref></td>
<td align="right">Transport Layer Security</td>
</tr>

<tr>
<td>UTF-8</td>
<td align="right">8-bit Unicode Transformation Forma</td>
</tr>

<tr>
<td>URL</td>
<td align="right">Uniform Resoure Locator</td>
</tr>
</tbody>
</table></section>
</section>

<section anchor="iot-model-construction"><name>IOT model construction</name>

<section anchor="model-design-principles"><name>Model Design Principles</name>

<section anchor="simple"><name>Simple</name>
<t>The model is independent of network technology and operator protocol, and focuses on the virtualization description of the device itself, which simplifies the understanding process of the device manufacturer.</t>
</section>

<section anchor="pervasiveness"><name>Pervasiveness</name>
<t>It is compatible with the needs of more manufacturers as much as possible. The model is divided into public attributes and specific attributes. The device can have public attributes or include self-defined features of the device. and Provide industry model templates by industry.</t>
</section>

<section anchor="extensibility"><name>Extensibility</name>
<t>Support user-defined services, provide data transparent transmission mechanism, and define basic model capabilities and industry templates separately.</t>
<t>Modularity: reduce duplicate resources, extract public services for reuse, and improve utilization efficiency.</t>
</section>

<section anchor="ease-of-use"><name>Ease of use</name>
<t>Provide more easy-to-use interfaces, including DSL language model description for integration.</t>
</section>
</section>
</section>

<section anchor="framework-of-device-communication-protocol"><name>Framework of Device Communication Protocol</name>
<t>The framework of the protocol is shown below:</t>
<figure><name>Framework of Device Communication Protocol
</name>
<artwork>Bussiness Protocol-------------------------------------------+
| +------+ +-----+ +-------+        +----+     +--------+    |
| |      | |     | |       |        |Area|     |Resource|    |
| |Store/| |Media| |Upgrate|        +----+     +--------+    |
| | File | |     | |       | +---------+ +---------+ +-----+ |
| |      | |     | |       | |Attribute| |Operation| |Event| |
| +------+ +-----+ +-------+ +---------+ +---------+ +-----+ |
+------------------------------------------------------------+

Fundamental Communication Protocol---------------------------+
| +---------------------------+                              |
| | +-----------------------+ +----------------------------+ |
| | | Store | Media |Update | | Attribute|Operation| Event | |
| | |Channel|Channel|Channel| |  Channel | Channel |Channel| |
| | +-----------------------+ +----^-----+----^---------^--+ |
| +---------------------------+    |          |         |    |
|      ^         ^       ^         |          |         |    |
|      |         |   +---+---------+----------+---------+--+ |
|      |         |   |                MQTT                 | |
|      |         |   +-----------------^---------------^---+ |
|      |         |                     |               |     |
|      |         |                     |          +----+---+ |
|      |         |                     |          |   TLS  | |
|      |         |                     |          +----^---+ |
|      |         |                     |               |     |
|  +---+---+  +--+---------------------+---------------+---+ |
|  |HTTP(S)|  |                    TCP                     | |
|  +-------+  +--------------------------------------------+ |
+------------------------------------------------------------+
</artwork>
</figure>
<t>The business is separated from the protocol. In the bottom layer, it adopts MQTT to transmit data. Different transmission channels are used for authentication, media, storage and attributes, operations, and events.</t>
</section>

<section anchor="interface-protocol-structure"><name>Interface protocol structure</name>
<t>In this draft, the session channel interface adopts MQTT protocol. Structure of MQTT protocol is divided into three sections: fixed header, variable header and payload. Structure of MQTT protocol is shown below.</t>
<figure><name>MQTT protocol structure
</name>
<artwork>--------+---------------------------+-----------------------------------
        |                           |
        |         Header            |            Payload
Structre|------------+--------------+----------------+------------------
        |            |              |                |
        |Fixedheader |Variableheader|GeneralPayload  |ApplicationPayload
--------+------------+--------------+-------+--------+------------------
Name    |Fixedheader |Variableheader|Length |Content |Content
--------+------------+--------------+-------+--------+------------------
Symbol  |FixedHEADER |VariableHEADER|LEN    |Gernal  |Func
--------+------------+--------------+-------+--------+------------------
Length  |2-5 Bytes   |Variable      |2 Bytes|Variable|Variable
--------+------------+--------------+-------+--------+------------------
Des-    |Depending   |Different     |The    |See     |The format
cription|on the      |control       |length |defi-   |depends on
        |length of   |message has   |of     |nition  |specific
        |the variable|different     |general|for its |transaction
        |header and  |variable      |payload|format  |
        |payload, the|headers       |       |        |
        |length of   |              |       |        |
        |the fixed   |              |       |        |
        |header      |              |       |        |
        |varies      |              |       |        |
        |between 2   |              |       |        |
        |and 5 bytes |              |       |        |
--------+------------+--------------+-------+--------+------------------
</artwork>
</figure>
<t>General protocols and business protocol bodies need AES (128) encryption during transmission, and UTF-8 encoding is used uniformly for character strings.</t>
</section>

<section anchor="device-certification"><name>Device certification</name>
<t>The overall protocol format of the authentication process is shown as follows:</t>
<figure><name>MQTT protocol format
</name>
<artwork>--------+--------------------------+------------------------------------
        |                          |
        |         Header           |            Payload
Structre|-----------+--------------+-----------------+------------------
        |           |              |                 |
        |Fixedheader|Variableheader|GeneralPayload   |ApplicationPayload
--------+-----------+--------------+---------+-------+------------------
Name    |Fixedheader|Variableheader|Version  |Con+   |
        |           |              |         |tent   |
--------+-----------+--------------+---------+-------+------------------
Symbol  |FixedHEADER|VariableHEADER|PROTOCOL-|       |PROTOCOL-
        |           |              |VERSION  |Func   |VERSION
        |           |              |         |       |
--------+-----------+--------------+---------+-------+------------------
Length  |2|5 Bytes  |Variable      |3 Bytes  |Va-    |3 Bytes
        |           |              |         |riable |
        |           |              |         |       |
--------+-----------+--------------+---------+-------+------------------
Des-    |Depending  |Different     |The      |See    |The
cription|on the     |control       |version  |tran-  |version
        |length of  |message has   |of       |saction|of
        |the        |different     |protocol |for its|protocol
        |variable   |variable      |         |format |
        |header and |headers       |         |       |
        |payload,   |              |         |       |
        |the        |              |         |       |
        |length of  |              |         |       |
        |the fixed  |              |         |       |
        |header     |              |         |       |
        |varies     |              |         |       |
        |between 2  |              |         |       |
        |and 5 bytes|              |         |       |
--------+-----------+--------------+---------+-------+------------------

</artwork>
</figure>
<t>The protocol version definition is shown as follows:</t>
<table><name>Protocol version definition
</name>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th align="right">Description</th>
</tr>
</thead>

<tbody>
<tr>
<td>FORM_VERSION</td>
<td>char</td>
<td align="right">version number of protocol  form</td>
</tr>

<tr>
<td>HIGH<em>TYPE</em>VERSION</td>
<td>char</td>
<td align="right">version number of protocol  type(high)</td>
</tr>

<tr>
<td>LOW<em>TYPE</em>VERSION</td>
<td>char</td>
<td align="right">version number of protocol  type(low)</td>
</tr>
</tbody>
</table><t>Device access adopts bidirectional negotiation protocol process. Devices sends the supported type of protocol group to the balance load service, and the server will determine which way to communicate depending on its own situation. After the device being authenticated, it can establish an MQTT connection with the device access service (Das) through the sessionkey to communicate with the bussiness protocol. The specific bidirectional negotiation diagram is as follows:</t>
<figure><name>bidirectional negotiation diagram - consistence
</name>
<artwork>                                    +------+                   +------+
                                    |Device|                   |Server|
                                    +---+--+                   +------+
                                        |                          |
                                        |                          |
                                        |                          |
                                        |                          |
+----------------------+----------+     |                          |
| Negotiation Request  |          |     |                          |
+----------------------+          |     +--Negotiation Request---&gt; +--+
|      Control Message Type:0x1   |     |                          |  |
|                                 |     |                          |  |
|      Control Flag:0x1           |     |                          |  |
|                                 |     |                          |  |
|      Protocol Type:1            |     |                          |  |
|                                 |     |                          |  |
|      Protocol Group:(1,2,4,8)   |     |                          |  |
|                                 |     | &lt;--Negotiation Response--+  |
|      Transaction Content:xxxxxx |     |                          |  |
+---------------------------------+     |                          +--+
                                        |                          |
                                        |                          |
+----------------------+----------+     |                          |
| Negotiation Response |          |     |                          |
+----------------------+          |     |                          |
|      Control Message Type:0x2   |     |                          |
|                                 |     |                          |
|      Control Flag:0x1           |     |                          |
|                                 |     |                          |
|      Protocol Type:1            |     |                          |
|                                 |     |                          |
|      Transaction Content:xxxxxx |     |                          |
+---------------------------------+     |                          |
</artwork>
</figure>
<figure><name>bidirectional negotiation diagram - inconsistence
</name>
<artwork>                    +------+          +------+
                    |Device|          |Server|
                    +---+--+          +------+
+----------------+-+    |                 |    +----------------+-+
| Negotiation    | |    |                 |    | Negotiation    | |
|  Request2      | |    |                 |    |  Response2     | |
+----------------+ |    |  Negotiation    |    +----------------+ |
|Control           |    +--  Request1 --&gt; |    |Control           |
|Message Type:0x1  |    |                 |    |Message Type:0x2  |
|                  |    |                 |    |                  |
|Control Flag:0x1  |    |                 |    |Control Flag:0x1  |
|                  |    |                 |    |                  |
|Protocol Type:2   |    |                 |    |Protocol Type:2   |
|                  |    |                 |    |                  |
|Protocol          |    |    Negotiation  |    |Protocol          |
|Group:(1,2,4,8)   |    | &lt;--  Response1--+    |Group:(2,4,8)     |
|                  |    |                 |    |                  |
|Transaction       |    |                 |    |Transaction       |
|Content:xxxx      |    |                 |    |Content:xxxx      |
+------------------+    |                 |    +------------------+
                        |                 |
+------------------------------------------------------------------+
                        |  Negotiation    |
 Disconnect             +--  Request2 --&gt; |
                        |                 |
+----------------+-+    |                 |    +----------------+-+
| Negotiation    | |    |                 |    | Negotiation    | |
|  Request2      | |    |                 |    |  Response2     | |
+----------------+ |    |                 |    +----------------+ |
|Control           |    |                 |    |Control           |
|Message Type:0x1  |    |    Negotiation  |    |Message Type:0x2  |
|                  |    | &lt;--  Response2--+    |                  |
|Control Flag:0x1  |    |                 |    |Control Flag:0x1  |
|                  |    |                 |    |                  |
|Protocol Type:2   |    |                 |    |Protocol Type:2   |
|                  |    |                 |    |                  |
|Protocol          |    |                 |    |Transaction       |
|Group:(1,2,4,8)   |    |                 |    |Content:xxxx      |
|                  |    |                 |    |                  |
|Transaction       |    |                 |    |                  |
|Content:xxxx      |    |                 |    |                  |
+------------------+    |                 |    +------------------+
                        |                 |
                        |                 |
                        +                 +
</artwork>
</figure>
<t>bidirectional negotiation can be divided into two conditions:</t>
<t>(1) If the service supports this type of protocol, select the most secure protocol in the device's protocol group to complete the negotiation and communicate with the device;</t>
<t>(2) If the service does not support the type of protocol, return the message to the device, which contains the type of protocol and protocol group supported by the service. And then, interupt TCP connection. If the device supports it, use again the type of protocol and protocol group supported by the service to go through the authentication process. Otherwise, the device should give up authentication with the service.</t>
<t>In order to ensure forward compatibility with the ECDH key interaction mode, Bit1 of the control flag bit is enabled. When Bit1 is 0, the control message type remains in the original mode, and when Bit1 is 1, it means that the ECDH key mode is used for interaction. The key algorithm of secret key in the authentication process:</t>
<t>sharekey:pdkdf2<em>SHA256(md5(md5(MD5(verification code + device serial number)+www.88075998.com)))
Device masterkey: ecdh</em>NID<em>secp384r1 (lbs</em>publickey, device<em>privatekey)
Server masterkey: ecdh</em>NID<em>secp384r1 (device</em>publickey, lbs_privatekey)</t>
<t>a) First Authentication</t>
<t>When the device requires for working online the first time, useexchange algorithm of ECDH secret key to initialize DEVID and MasterKey. The process is shown as follows:</t>
<figure><name>First Authentication
</name>
<artwork>  +------+                                     +-----------+
  |Device|                                     |Lbs Service|
  +------+                                     +------+----+
     |                                                |
+-----------------Private key Exchange------------------------+
     +-----+                                           |
     |     |Generate Private Key and Publickey         |
     &lt;-----+                                           |
     +-----+                                           |
     |     |Generate Share Key                         |
     &lt;-----+                                           |
     |-------Request for Private Key Interaction-------&gt;
     &lt;-------Reponse for Private Key Interaction-------+
     +-----+                                           |
     |     |Decrypt lbs_publickey from Response        |
     &lt;-----+                                           |
     +-----+                                           |
     |     |Generate Mater Key                         |
     &lt;-----+                                           |
 +-------------------- Apply DevID----------------------------+
     |-------| Request for Applying DevID |------------&gt;
     &lt;---------Reponse for Applying DevID--------------+
     +-----+                                           |
     |     |Decrypt DevID and Session Key from Response|
     &lt;-----+                                           |
     |---|Request for Getting Das Service Address------&gt;
     &lt;----Reponse for Getting Das Service Address------+
     |                                                 |
     +                                                 +
</artwork>
</figure>
<t>b) Re-authentication</t>
<t>When the device is disconnected and ask for re-authenticated, it needs to request re-authentication from the platform and update the session key. The specific process is shown as follows:</t>
<figure><name>Re-authenticate
</name>
<artwork> +------+                                       +-----------+
 |Device|                                       |Lbs Service|
 +------+                                       +-----+-----+
    |                                                 |
+-------------------------------------------------------------+
    +------+ Update Request for Sessionkey +-----------&gt;
    |                                                  |
    &lt;------+ Update Respond for Sessionkey +-----------+
    |                                                  |
    +-----+                                            |
    |     Decrypt Session Key                          |
    |     | From Response                              |
    &lt;-----+                                            |
+-------------------------------------------------------------+
    |                                                  |
    +---------+ Get Service Address Request +----------&gt;
    |                                                  |
    &lt;---------+ Get Service Address Response +---------+
    |                                                  |
</artwork>
</figure>
<t>c) Define the ECDH control message type as follows:</t>
<table><name>Protocol version definition
</name>
<thead>
<tr>
<th>message direction</th>
<th>control message</th>
<th>name</th>
<th align="right">description</th>
</tr>
</thead>

<tbody>
<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x1</td>
<td>Authentication<em>ECDH</em>Req</td>
<td align="right">request for ECDH exchange</td>
</tr>

<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x2</td>
<td>Authentication<em>ECDH</em>Rsp</td>
<td align="right">response for ECDH exchange</td>
</tr>

<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x3</td>
<td>Rsrv</td>
<td align="right">reserve</td>
</tr>

<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x4</td>
<td>Refresh<em>SessionKey</em>Req</td>
<td align="right">refresh SessionKey request</td>
</tr>

<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x5</td>
<td>Rsrv</td>
<td align="right">reserve</td>
</tr>

<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x6</td>
<td>Refresh<em>SessionKey</em>Rsp</td>
<td align="right">refresh SessionKey response</td>
</tr>

<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x7</td>
<td>Authentication<em>apply</em>devid_Req</td>
<td align="right">request device ID</td>
</tr>

<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x8</td>
<td>Authentication<em>apply</em>devid_Rsq</td>
<td align="right">response device ID</td>
</tr>

<tr>
<td>Dev&lt;---&gt;Lbs</td>
<td>0x9</td>
<td>Authentication<em>apply</em>devid_Cfm</td>
<td align="right">confirm device ID</td>
</tr>
</tbody>
</table></section>

<section anchor="get-access-service"><name>Get access service</name>
<t>As the number of device accesses increases, there will be bottlenecks in the performance of single-node accesses, so the platform needs to support the mode of multiple device accesses. To support this mode, the devices are redirected to multiple access services by a load balancing server. After the device obtains the session key through two-way authentication, it initiates a request for access service within the same TCP connection, and the message in the request is encrypted with the session key.</t>
<figure><name>Get access service
</name>
<artwork>                               +------------+  +-------------+
+------+                       |Balance Load|  |Device Access|
|Device|                       |  Service   |  |  Service    |
+------+                       +------+-----+  +------+------+
   |                                  |               |
Redirect---------------------------------+            |
|  +--- F1:Request for getting a -----&gt;  |            |
|  |  device access service address   |  |            |
|  |                                  |  |            |
|  &lt;--- F2:Return a device access ----+  |            |
|  |       service information        |  |            |
+----------------------------------------+            |
   |                                  |               |
Bussiness-------------------------------------------------------+
|  |                                  |               |         |
|  &lt;------- Business message:AES128(message)----------&gt;         |
|  |        AES128 private key:session key            |         |
|  |                                  |               |         |
+---------------------------------------------------------------+
</artwork>
</figure>
</section>

<section anchor="registration-and-deregistration"><name>Registration and Deregistration</name>
<t>After the device completes two-way authentication to obtain a specific access service address, the device initiates a request to register online through the MQTT protocol, and the application message body in the request is encrypted using the sessionKey obtained by two-way authentication.</t>
<figure><name>Registration and Deregistration
</name>
<artwork>+-------------+                                           +------------+
|   Device    |                                           |  Platform  |
|(MQTT Client)|                                           |(MQTT Sever)|
+-----+-------+                                           +------+-----+
      |                                                          |
      +------- F1:Device register and login(MQTT CONNECT) -------&gt;
      |                                                          |
      &lt;-------- F2:Register and respond(MQTT CONNACK) -----------+
      |                                                          |
      &lt;---------------- Business interaction --------------------&gt;
      |                                                          |
      +---- F3:Send request for disconnect(MQTT DISCONNECT) -----&gt;
      |                                                          |
      +                                                          +
</artwork>
</figure>
<t>a) F1: After the device and platform network connection is established, the device sends a online request to the platform via MQTTCONNECT, of which payload contains one or more encoded fields, including: unique identifier of the client, Will subject, Will message, username and password.</t>
<t>b) F2: The platform returns the response message to the device via MQTTCONNACK to inform it whether it succeeded or not;</t>
<t>c) F3: Before disconnecting, the device sends a DISSCONNECT message to the platform, indicating that it wants to disconnect normally, and the platform will close the TCP/IP connection after receiving the request.</t>
</section>

<section anchor="heartbeat"><name>Heartbeat</name>
<t>After the device has registered with the platform, it needs to send heartbeat requests periodically according to the heartbeat interval indicated in the registration request. The interval is usually 30s. Used for:</t>
<t>a) Inform the platform that the device is alive when no other control messages are sent from the device to the platform.</t>
<t>b) Request the platform to send a response confirming that it is alive.</t>
<t>c) Use the network to confirm that the network connection is not disconnected.</t>
<figure><name>Heartbeat
</name>
<artwork>+------+                                                    +--------+
|Device|                                                    |Platform|
+------+                                                    +----+---+
   |                                                             |
   +------ F1: Send a heartbeat request(MQTT PINGREQ) -----------&gt;
   |                                                             |
   &lt;--- F2: Respond to the heartbeat request MQTT PINGRESP) -----+
   |                                                             |
</artwork>
</figure>
</section>

<section anchor="security-considerations"><name>Security Considerations</name>
<t>This entire memo deals with security issues.</t>
</section>

<section anchor="iana-considerations"><name>IANA Considerations</name>
<t>This documents has no IANA actions.</t>
</section>

</middle>

<back>
<references><name>Informative References</name>
<reference anchor="MQTT2016" target="https://www.iso.org/obp/ui/#iso:std:iso-iec:20922:ed-1:v1:en">
  <front>
    <title>Information technology - Message Queuing Telemetry Transport</title>
    <author>
      <organization>ISOIEC</organization>
    </author>
    <date></date>
  </front>
</reference>
<reference anchor="RFC8446" target="https://www.rfc-editor.org/info/rfc8446">
  <front>
    <title>The Transport Layer Security (TLS) Protocol Version 1.3</title>
    <author fullname="E. Rescorla" initials="E." surname="Rescorla">
      <organization></organization>
    </author>
    <date year="2018" month="August"></date>
  </front>
  <seriesInfo name="DOI" value="10.17487/RFC8446"></seriesInfo>
</reference>
</references>

</back>

</rfc>
