| With the development of the economy and the advancement of science and technology,the Internet of Things has been widely used in smart homes,smart medical and other fields,providing great convenience for people's lives.In the Internet of Things era,various devices can be connected to the network for information exchange.The MQTT protocol is a lightweight application layer protocol based on subscription/publishing mechanism.It is designed to provide reliable messaging services for resource-constrained devices in low-bandwidth,unreliable networks.Its lightweight,simple,and reliable features are well suited.The Internet of Things environment has a wide range of applications in the Internet of Things.However,with the development of the Internet of Things,in the face of some new scenarios,the MQTT protocol has some shortcomings that need to be improved.For example,the MQTT protocol cannot implement the publisher's control over the flow of messages,which may cause privacy security problems.The lack of mechanisms for querying key information of the server part,such as the topic structure,may cause inconvenience in the use process;The fields used by the frequency are not optimized,and the message length may be too long.In addition,for the MQTT system,the server and the client only support the TCP-based MQTT protocol,but the subscription/release mechanism used by the MQTT protocol is independent of the specific protocol.If multiple protocols are supported based on the mechanism,the system will be more convenient.This article will focus on the research of MQTT,optimize and expand the MQTT protocol message and MQTT system,so that it can better undertake the corresponding work.In view of the above problems,this paper has carried out two aspects of research.Firstly,this paper studies the extension and optimization of the MQTT protocol,and designs and implements the directed publishing mechanism,the field reuse mechanism and the topic information query mechanism.The directed publishing mechanism enables the publisher to control the flow of messages and avoid the leakage of private data.The field multiplexing mechanism effectively shortens the average length of messages and saves limited bandwidth resources in the Internet of Things environment.The topic query mechanism allows the client to query the current theme structure facilitates the client to obtain the subject information.Secondly,this paper studies the extension and optimization of the MQTT system.The system provides support for the extended and optimized MQTT protocol.Based on the subscription/publishing mechanism,the system designs and implements support for publishing and subscribing using multiple protocols.system.The optimized and expanded system supports the MQTT,MQTT OVER UDP,HTTP,and MQTT OVER BLE protocols.The system will be applied to a private IoT platform.In the environment of Windows node.js server,STM32F103 client,Windows node.js client,HTTP client and Raspberry pie BLE slave,the above schemes are implemented,applied and tested.The test results show that the new mechanism enriches and perfects the function of MQTT.The average length of extended and optimized messages is significantly shortened,and clients using different protocols can communicate with each other.The research results in this paper can provide valuable reference for the MQTT protocol and subscription/publishing mechanism. |