物联网防火墙himqtt源码之MQTT协议分析
<div class='showpostmsg'><p style="text-align:justify"> </p><p align="center" style="text-align:center"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:10.5000pt"><span style="font-family:宋体"><font face="宋体">物联网防火墙</font>himqtt<font face="宋体">源码之</font><font face="Calibri">MQTT</font><font face="宋体">协议分析</font></span></span></span></span></p>
<p align="center" style="text-align:center"> </p>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">himqtt<font face="宋体">是首款完整源码的高性能</font><font face="Arial">MQTT</font><font face="宋体">物联网防火墙 </font><font face="Arial">- MQTT Application FireWall</font><font face="宋体">,</font><font face="Arial">C</font><font face="宋体">语言编写,采用</font><font face="Arial">epoll</font><font face="宋体">模式支持</font></span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:Arial"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">IoT</span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">数十万的高并发连接,并且兼容</font>ModSecurity<font face="宋体">部分规则。</font></span></span></span></span></span></span></span> <span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">代码非常优秀,非常值得收藏和学习,今天笔者就从结合</font>himqtt<font face="宋体">的源码来进行</font><font face="Arial">MQTT</font><font face="宋体">协议分析。</font></span></span></span></span></span></span></span></span></span></span></span></p>
<h1 style="margin-top:23px; margin-bottom:22px; text-align:justify"><span style="font-size:22pt"><span style="line-height:240%"><span style="font-family:Calibri"><span style="font-weight:bold"><b><span style="font-size:22.0000pt"><span style="font-family:宋体"><span style="font-weight:bold"><font face="宋体">一、</font>MQTT<font face="宋体">协议指令汇总</font></span></span></span></b></span></span></span></span></h1>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">MQTT<font face="宋体">协议一共有</font><font face="Arial">14</font><font face="宋体">个指令,如下表所示:其中有</font><font face="Arial">9</font><font face="宋体">个报文都是固定的</font><font face="Arial">2~4</font><font face="宋体">个字节,非常简单适合小型物联网设备。</font></span></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-align:left"> </p>
<table align="center" class="Table" style="border-collapse:collapse; border:1.0000pt solid #c0c0c0; font-family:"Times New Roman"; font-size:10pt">
<tbody>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:1.0000pt solid #c0c0c0" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">名字</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:1.0000pt solid #c0c0c0" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">值</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:1.0000pt solid #c0c0c0" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">固定报文</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:1.0000pt solid #c0c0c0" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">描述</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">CONNECT</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">1</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">否</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">客户端请求与服务端建立连接</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">CONNACK</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">2</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">服务端确认连接建立</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PUBLISH</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">3</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">否</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">发布消息</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PUBACK</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">4</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">收到发布消息确认</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PUBREC</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">5</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">发布消息收到</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PUBREL</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">6</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">发布消息释放</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PUBCOMP</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">7</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">发布消息完成</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">SUBSCRIBE</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">8</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">否</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">订阅请求</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">SUBACK</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">9</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">否</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">订阅确认</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">UNSUBSCRIBE</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">10</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">否</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">取消订阅</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">UNSUBACK</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">11</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">取消订阅确认</span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PING</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">12</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">客户端发送<font face="Verdana">PING(</font><font face="宋体">连接保活</font><font face="Verdana">)</font><font face="宋体">命令</font></span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PINGRSP</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">13</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PING<font face="宋体">命令回复</font></span></span></span></span></span></span></span></span></p>
</td>
</tr>
<tr>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:1.0000pt solid #c0c0c0; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">DISCONNECT</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">14</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">是</span></span></span></span></span></span></span></span></p>
</td>
<td style="border-bottom:1.0000pt solid #c0c0c0; background:#fefef2; padding:6.0000pt 10.5000pt 6.0000pt 10.5000pt ; border-left:none; border-right:1.0000pt solid #c0c0c0; border-top:none" valign="center">
<p style="text-indent:0.0000pt; text-align:left"><span style="font-size:10.5pt"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">断开连接</span></span></span></span></span></span></span></span></p>
</td>
</tr>
</tbody>
</table>
<p class="p" style="margin-top:10px; margin-bottom:10px; text-indent:0.0000pt; padding:0pt 0pt 0pt 0pt ; text-align:left"><span style="font-size:12pt"><span style="background:#fefef2"><span style="font-family:Calibri"> </span></span></span></p>
<p class="p" style="margin-top:10px; margin-bottom:10px; text-indent:0.0000pt; padding:0pt 0pt 0pt 0pt ; text-align:left"> </p>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">MQTT<font face="宋体">协议由指令号(</font><font face="Arial">1</font><font face="宋体">字节)</font><font face="Arial">+</font><font face="宋体">长度(</font><font face="Arial">1-4</font><font face="宋体">字节不定)</font><font face="Arial">+</font><font face="宋体">内容组成,比如下面第一个字节</font><font face="Arial">0x30</font><font face="宋体">表示</font><font face="Arial">publish</font><font face="宋体">发布消息指令,</font><font face="Arial">0x26</font><font face="宋体">表示后面的内容长度就是</font><font face="Arial">38</font><font face="宋体">个字节。</font></span></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">---------------</span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">MQTT PUBLISH-</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> ------40bytes-------------------------------------------</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 30 26 00 14 68 6f 6d 65 2f 67 61 72 64 65 6e 2f |0&..home/garden/|</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 66 6f 75 6e 74 61 69 6e 31 32 33 34 35 36 37 38 |fountain12345678|</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 39 30 61 62 63 64 65 66 |90abcdef</span></span></span></span></span></span></span></span></span></span></p>
<p class="p" style="margin-top:10px; margin-bottom:10px; text-indent:0.0000pt; padding:0pt 0pt 0pt 0pt ; text-align:left"> </p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">先到</font>github<font face="宋体">上下载</font><font face="Arial">himqtt</font><font face="宋体">最新源码,</font></span></span></span></span></span></span></span><a href="https://github.com/qq4108863/himqtt/"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">https://github.com/qq4108863/himqtt/</span></span></span></span></span></span></span></a><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> <font face="宋体">,打开</font>src/waf/mqtt.c<font face="宋体">文件。</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">特别注意的是:长度占用的字节数是可变的(</font>1-4<font face="宋体">字节),具体的计算方法在</font><font face="Arial">process_mqtt_msg</font><font face="宋体">这个函数里面,理论上这种算法后续消息内容是最大长度是</font><font face="Arial">268435455</font><font face="宋体">字节(约</font><font face="Arial">255M</font><font face="宋体">)。</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> static void process_mqtt_msg(mqtt_waf_msg *req)</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">{</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">......</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">/* decode mqtt variable length */</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> len = len_len = 0;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> p = req->buf + 1;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> eop = &req->buf;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> while (p < eop) {</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> lc = *((const unsigned char *) p++);</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> len += (lc & 0x7f) << 7 * len_len;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> len_len++;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> if (!(lc & 0x80)) break;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> if (len_len > 4){</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">req->msg_state = MQTT_MSG_ERROR;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">return;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> }</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> }</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">.....</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">}</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">......</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">长度和协议校验正确后,根据收到的消息类型,以此对不同的指令进行处理,代码逻辑非常清晰:</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">switch (mqtt_msg_type)</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">{</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">case MQTT_CONNECT:</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">req->msg_state = mqtt_connect(req,p,end,&mm);</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">break;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">case MQTT_CONNACK:</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">break;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">case MQTT_PUBLISH:</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">req->msg_state = mqtt_publish(req,p,end,&mm);</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">break;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">case MQTT_SUBSCRIBE:</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">req->msg_state = mqtt_subscribe(req,p,end,&mm);</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">break;</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">case MQTT_UNSUBSCRIBE:</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">req->msg_state = mqtt_unsubscribe(req,p,end,&mm);</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">......</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">下面我们主要</font></span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">CONNECT</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">、</font></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PUBLISH</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">、</font></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">SUBSCRIBE</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">、</font></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">UNSUBSCRIBE</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">这几个复杂一点的报文协议内容。</font></span></span></span></span></span></span></span></span></span></span></p>
<h1 style="margin-top:23px; margin-bottom:22px; text-align:justify"><span style="font-size:22pt"><span style="line-height:240%"><span style="font-family:Calibri"><span style="font-weight:bold"><b><span style="font-size:22.0000pt"><span style="font-family:宋体"><span style="font-weight:bold"><font face="宋体">二、</font>HiMQTT<font face="宋体">协议分析</font></span></span></span></b></span></span></span></span></h1>
<ol>
<li style="margin-top:17px; margin-bottom:17px; text-align:justify"><span style="font-size:16pt"><span style="line-height:172%"><span style="font-family:Arial"><span style="font-weight:bold"><b><span style="font-size:16.0000pt"><span style="font-family:Arial"><span style="font-weight:bold">CONNECT</span></span></span></b><b><span style="font-size:16.0000pt"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体">连接服务端</font></span></span></span></b></span></span></span></span></li>
</ol>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:Arial"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">CONNECT</span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">是客户端到服务端的网络连接建立后,客户端发送给服务端的第一个报文必须是</font>CONNECT<font face="宋体">报文,其中登录的身份认证如用户名、密码就在这个指令里面。报文协议如下:</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">--------------</span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">MQTT CONNECT</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">-----105bytes-----------------------------</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 10 67 00 04 4d 51 54 54 04 c2 00 3c 00 19 4d 51 |.g..MQTT...<..MQ|</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 54 54 5f 46 58 5f 43 6c 69 65 6e 74 5f 39 69 75 |TT_FX_Client_9iu|</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 79 38 37 36 35 35 35 00 12 69 6f 74 66 72 65 65 |y876555..iotfree|</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 74 65 73 74 2f 74 68 69 6e 67 30 00 2c 59 55 37 |test/thing0.,YU7|</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 54 6f 76 38 7a 46 57 2b 57 75 61 4c 78 39 73 39 |Tov8zFW+WuaLx9s9|</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 49 33 4d 4b 79 63 6c 69 65 39 53 47 44 75 75 4e |I3MKyclie9SGDuuN|</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 6b 6c 36 6f 39 4c 58 6f 3d |kl6o9LXo= </span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">10 //CONNECT<font face="宋体">指令号</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">67 //<font face="宋体">长度</font><font face="Arial">103</font><font face="宋体">字节</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 04 //MQTT<font face="宋体">协议长度为</font><font face="Arial">4</font><font face="宋体">字节</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">4d 51 54 54 //MQTT<font face="宋体">固定字符串</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">04 //<font face="宋体">版本</font><font face="Arial">3.1.1</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">c2 //<font face="宋体">连接标记,是否由用户名</font><font face="Arial">/</font><font face="宋体">密码等</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 3c //<font face="宋体">心跳间隔时间</font><font face="Arial">60</font><font face="宋体">秒</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 19 //<font face="宋体">用户名长度</font><font face="Arial">25</font><font face="宋体">字节,后面是用户名</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">4d 51 54 54 5f 46 58 5f 43 6c 69 65 6e 74 5f 39 69 75 79 38 37 36 35 35 35</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 12 //<font face="宋体">密码</font><font face="Arial">18</font><font face="宋体">字节</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">69 6f 74 66 72 65 65 74 65 73 74 2f 74 68 69 6e 67 30//<font face="宋体">密码</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 2c //will message<font face="宋体">长度。</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">59 55 37 ......6f 3d//will message<font face="宋体">内容</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<ol start="2">
<li style="margin-top:17px; margin-bottom:17px; text-align:justify"><span style="font-size:16pt"><span style="line-height:172%"><span style="font-family:Arial"><span style="font-weight:bold"><b><span style="font-size:16.0000pt"><span style="font-family:Arial"><span style="font-weight:bold">PUBLISH</span></span></span></b><b><span style="font-size:16.0000pt"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体">发布消息</font></span></span></span></b></span></span></span></span></li>
</ol>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:Arial"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">PUBLISH </span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">是从客户端向服务端或者服务端向客户端传输一个应用消息,这是通信的最重点,就像</font>HTTP<font face="宋体">协议的</font><font face="Arial">GET</font><font face="宋体">一样。报文协议分析如下:</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">/*</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">---------------MQTT PUBLISH-------40bytes-----------------------------</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 30 26 00 14 68 6f 6d 65 2f 67 61 72 64 65 6e 2f |0&..home/garden/|</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 66 6f 75 6e 74 61 69 6e 31 32 33 34 35 36 37 38 |fountain12345678|</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 39 30 61 62 63 64 65 66 |90abcdef</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">*/</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">30 //PUBLISH<font face="宋体">指令号</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">26 //<font face="宋体">长度</font><font face="Arial">39</font><font face="宋体">字节</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 14 //TOPIC<font face="宋体">长度</font><font face="Arial">20</font><font face="宋体">字节</font></span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:Arial"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">68 6f 6d 65 2f 67 61 72 64 65 6e 2f</span></span></span></span></span></span></span> <span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:Arial"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">66 6f 75 6e</span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //TOPIC</span></span></span></span></span></span></span></span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:Arial"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">31 32 33 34 35 36 37 38</span></span></span></span></span></span></span> <span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:Arial"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">39 30 61 62 63 64 65 6</span></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="background:#ffffff"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">6 //<font face="宋体">发布的消息</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">在实际编程中,这个地方大多是</font>json<font face="宋体">格式提交给服务器,</font><font face="Verdana">SQL</font><font face="宋体">注入</font><font face="Verdana">/XSS</font><font face="宋体">攻击很可能从这里对物联网设备发起攻击,所以一定要做攻击检查,</font><font face="Verdana">himqtt</font><font face="宋体">不知道什么原因把</font><font face="Verdana">ngx_http_dummy_json_parse</font><font face="宋体">解析</font><font face="Verdana">json</font><font face="宋体">格式的函数注释掉了。</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<ol start="3">
<li style="margin-top:17px; margin-bottom:17px; text-align:justify"><span style="font-size:16pt"><span style="line-height:172%"><span style="font-family:Arial"><span style="font-weight:bold"><b><span style="font-size:16.0000pt"><span style="font-family:Arial"><span style="font-weight:bold">SUBSCRIBE</span></span></span></b><b><span style="font-size:16.0000pt"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体">订阅消息</font></span></span></span></b></span></span></span></span></li>
</ol>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">SUBSCRIBE</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">是由客户端向服务端发送的,用于创建一个或多个订阅。每个订阅是该客户端关注的一个或多个主题。服务端依据客户端的订阅来匹配主题,然后将对应的</font>PUBLISH<font face="宋体">报文发送给客户端。报文协议分析如下:</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">---------------MQTT SUBSCRIBE------33bytes-----------------------------</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 82 1f 00 01 00 1a 68 6f 6d 65 2f 67 61 72 64 65 |......home/garde|</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 6e 2f 66 6f 75 6e 74 61 69 6e 64 65 6c 65 74 65 |n/fountaindelete|</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 00 </span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">8</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">2 //</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">SUBSCRIBE</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">指令</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">1</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">f</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //<font face="宋体">长度</font></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">31</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">字节</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 0</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">1</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //Message Identifier</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 1</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">a</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //TOPIC<font face="宋体">长度</font><font face="Verdana">2</font></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">6</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">68 6f 6d 65 2f 67 61 72 64 65</span></span></span></span></span></span> <span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">6e 2f 66 6f 75 6e 74 61 69 6e 64 65 6c 65 74 65</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //TOPIC</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 //request QOS</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<ol start="4">
<li style="margin-top:17px; margin-bottom:17px; text-align:justify"><span style="font-size:16pt"><span style="line-height:172%"><span style="font-family:Arial"><span style="font-weight:bold"><b><span style="font-size:16.0000pt"><span style="font-family:黑体"><span style="font-weight:bold">UN</span></span></span></b><b><span style="font-size:16.0000pt"><span style="font-family:Arial"><span style="font-weight:bold">SUBSCRIBE</span></span></span></b><b><span style="font-size:16.0000pt"><span style="font-family:黑体"><span style="font-weight:bold"><font face="黑体">取消订阅消息</font></span></span></span></b></span></span></span></span></li>
</ol>
<p align="justify" style="text-align:justify"> </p>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">UN</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">SUBSCRIBE</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">是客户端发送本报文给服务端,用于取消订阅主题。报文协议分析如下:</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">---------------MQTT </span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">UN</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">SUBSCRIBE-------32bytes-----------------------------</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| a2 1e 00 02 00 1a 68 6f 6d 65 2f 67 61 72 64 65 |......home/garde|</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">| 6e 2f 66 6f 75 6e 74 61 69 6e 64 65 6c 65 74 65 |n/fountaindelete|</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">a2 //</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">SUBSCRIBE</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">指令</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">1</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">e</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //<font face="宋体">长度</font></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">30</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">字节</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 0</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">2</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //Message Identifier</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">00 1</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">a</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //TOPIC<font face="宋体">长度</font><font face="Verdana">2</font></span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">6</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">68 6f 6d 65 2f 67 61 72 64 65</span></span></span></span></span></span> <span style="font-size:9.5000pt"><span style="font-family:Verdana"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal">6e 2f 66 6f 75 6e 74 61 69 6e 64 65 6c 65 74 65</span></span></span></span></span></span><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"> //TOPIC</span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<p align="justify" style="text-align:justify"> </p>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">总体来说,</font>MQTT<font face="宋体">协议比</font><font face="Verdana">HTTP</font><font face="宋体">协议简单多了,非常适合物联网设备。另外</font><font face="Verdana">himqtt</font><font face="宋体">其实也是一款功能强大的</font><font face="Verdana">WEB</font><font face="宋体">应用防火墙,其他源码我们在另外的文章中再介绍。</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="text-justify:inter-ideograph"><span style="font-family:Calibri"><span style="font-size:9.5000pt"><span style="font-family:宋体"><span style="color:#000000"><span style="letter-spacing:0.0000pt"><span style="text-transform:none"><span style="font-style:normal"><font face="宋体">也许未来几年</font>IPV6<font face="宋体">普及后,很可能几百亿带电的物体都会联网哦,期待</font><font face="Verdana">himqtt</font><font face="宋体">这类高并发的物联网防火墙能扛起信息安全的大旗,彻底阻挡黑客攻击。</font></span></span></span></span></span></span></span></span></span></span></p>
<p align="justify" style="text-align:justify"> </p>
<p align="justify" style="text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"> </span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"> </span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:24.0000pt; text-align:justify"> </p>
<p style="text-indent:24.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"> </span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"><span style="font-size:10.5pt"><span style="text-autospace:ideograph-numeric"><span style="font-family:Calibri"> </span></span></span></p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p style="text-indent:19.0000pt; text-align:justify"> </p>
<p><br />
<b><font color="#5E7384">此内容由EEWORLD论坛网友<font size="3">hihttps</font>原创,如需转载或用于商业用途需征得作者同意并注明出处</font></b></p>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <p>学习了,多谢</p>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td id="postmessage_2918517">
<p>学习了,多谢,辛苦了</p>
</td>
</tr>
</tbody>
</table>
页:
[1]