An Internet of Things gateway communication method, system, device and storage medium
The decentralized IoT gateway system is built through the DDS protocol, which solves the problems of high protocol adaptation costs and low efficiency in the IoT communication system, realizes automatic device identification and efficient data transmission, and is suitable for real-time communication scenarios of massive data.
Patent Information
- Application Number
- CN202310559151.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-17
- Publication Date
- 2025-07-18
- Estimated Expiration
- 2043-05-17
AI Technical Summary
When facing a large number of heterogeneous devices, the existing IoT communication systems have high protocol adaptation costs, poor system stability, and low communication efficiency, making it difficult to meet the needs of efficient real-time data transmission.
The DDS protocol is used to build a decentralized IoT gateway system, and data conversion and transmission are converted and transmitted by scanning the device port IP information, and retry queues and data compression technologies are introduced to realize automatic identification and efficient communication of devices.
It reduces labor costs, improves equipment access efficiency and data transmission reliability, supports the transmission of tens of thousands of pieces of data per second, is suitable for real-time communication scenarios of massive data, and is used in fields such as medicine, industry, national defense and artificial intelligence.
Smart Images

Figure CN116567102B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of the Internet of Things, and more specifically, it relates to an Internet of Things gateway communication method, system, device, and storage medium. Background Art
[0002] With the wide application of Internet of Things technology, cloud service systems are connected and communicate with various Internet of Things devices to collect various data information such as sound, light, heat, electricity, mechanics, chemistry, biology, and location, and to issue Internet of Things instructions. Data communication has become the key point for realizing the connection between things and between things and people. Facing a large amount of heterogeneous device data, every time a cloud service system connects to a new type of device, system developers need to adapt to the protocol of the new device, and the cloud service is frequently upgraded, resulting in an increase in R & D costs and the system stability being affected. Therefore, it is of great significance to design a unified gateway with multiple protocol adapters built into the gateway to form a gateway system that is compatible with multiple protocols.
[0003] With the development of the Internet of Things, communication methods have become more and more diverse. Compared with existing patents, "A Cross-Segment Communication Method Based on DDS" (International Publication No. WO2020 / 098040A1) provides a communication method based on DDS, but mainly for cross-segment communication and does not manage protocol adaptation. "An Internet of Things Gateway Access Method and System" (Application Publication No. CN109257425A) only describes the protocol adaptation layer and does not form a gateway system responsible for protocol adaptation. "A Method and System for an Adaptive Device Based on an MQTT Gateway" (Application Publication No. CN201811536119) discloses a technical feature of gateway adaptation through MQTT, which requires presetting instructions in the hardware device, is relatively dependent on hardware support, supports sending several data per second for each device, and needs to rely on an MQTT broker to send data, using a centralized data sending form, resulting in low communication efficiency. Summary of the Invention
[0004] The technical problem to be solved by the present invention is aimed at the above-mentioned deficiencies of the prior art. The first object of the present invention is to provide an Internet of Things gateway communication method that can improve communication efficiency.
[0005] The second object of the present invention is to provide an Internet of Things gateway communication system that can improve communication efficiency.
[0006] The third object of the present invention is to provide a computer device.
[0007] The fourth object of the present invention is to provide a computer storage medium.
[0008] To achieve the first object above, the present invention provides an Internet of Things gateway communication method, including:
[0009] Scan the current network services to obtain the IP information of the ports of IoT devices, and achieve fast access to IoT devices based on the IP information of the ports;
[0010] Input the data and protocol types of different types of IoT devices into the conversion queue. The conversion queue uniformly converts according to the protocol type, converting the data into the DDS standard and converting the DDS standard into the specific protocol data of each IoT device;
[0011] Set specific communication policies according to the QoS policies provided by DDS;
[0012] Establish a DDS data center corresponding to each client and IoT device according to the DDS protocol. The DDS data center receives IoT device data and sends down client instructions through the publish-subscribe model, realizing two-way communication between the client and the IoT device, and each DDS data center constitutes a decentralized architecture.
[0013] As a further improvement, scan the current network services through any one of the service scanning and discovery tools of RTI Connext DDS, Linux NMP, and zenmap.
[0014] Further, during the initial scan, you can scan through the local IP segment to obtain sufficient device information of the local network. After obtaining the IoT device information, confirm it manually or filter it through the pre-set information. Finally, enter the communication network information into the local cache library and maintain the IP status;
[0015] During subsequent scans, you can specify an IP for scanning to improve the scanning efficiency;
[0016] For the remote IP end, manually specify an IP for scanning to form local IP information.
[0017] Further, calculate the weights of each communication protocol according to the number of connections of each communication protocol recorded by the IoT device ports. When automatically matching, preferentially select the communication protocol with a larger weight for parsing to improve the parsing success rate. The weight calculation is as follows:
[0018]
[0019] Where n is the type of protocol, and C(i) is the number of port connections of the i-th type of protocol.
[0020] Further, the communication policy includes a retry queue, and the data structure of the retry queue is:
[0021] {MSG:SEND_RETRY:EXPIRE_TIME},
[0022] Among them, MSG includes the generated data and connection target information, SEND_RETRY is the number of retries, and EXPIRE_TIME is the expiration time;
[0023] SEND_RETRY defaults to -1, and by default, it retries indefinitely. When retrying, it first consumes from the queue;
[0024] If SEND_RETRY > 0, after the message sending fails, it is put into the failure queue and waits for the next retry; if the next retry still fails, then SEND_RETRY is decremented by 1, and the message is put back into the queue again, and it retries until SEND_RETRY is decremented to 0;
[0025] By setting the expiration time EXPIRE_TIME, when the retry time is greater than the expiration time, the data will no longer be retried, and the user will be prompted that the sending has failed.
[0026] Furthermore, the communication strategy also includes data compression technology. The compression configuration information is provided through the cloud service. After the IoT device obtains the compression configuration information, it parses and compresses according to the compression information.
[0027] Furthermore, first, the user side sets the encoding table of the common data information for the current scenario according to the actual business requirements. The encoding table is set in the cloud or directly imported into the IoT device. When the IoT device connects to the cloud service, the encoding table is updated regularly;
[0028] Compress data with more than 2 bytes according to the encoding table.
[0029] To achieve the above-mentioned second objective, the present invention provides an IoT gateway communication system, including:
[0030] The device access module is used to scan the current network service to obtain the IP information of the IoT device port, and realize the rapid access to the IoT device according to the IP information of the port;
[0031] The protocol adaptation module is used to input the data and protocol types of different types of IoT devices into the conversion queue. The conversion queue uniformly converts according to the protocol type, converts the data into the DDS standard and converts the DDS standard into the specific protocol data of each IoT device;
[0032] The policy module is used to set the specific communication policy according to the QoS policy provided by DDS;
[0033] The data application module is used to establish a DDS data center corresponding to each user side and IoT device according to the DDS protocol. The DDS data center receives IoT device data and issues user-side instructions through the publish-subscribe model, realizes two-way communication between the user side and the IoT device, and each DDS data center constitutes a decentralized architecture.
[0034] To achieve the above-mentioned third objective, the present invention provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the above-mentioned Internet of Things gateway communication method is implemented.
[0035] To achieve the above-mentioned fourth objective, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Internet of Things gateway communication method is implemented.
[0036] Beneficial effects
[0037] Compared with the prior art, the present invention has the following advantages:
[0038] 1. The present invention can reduce labor costs. The present invention can realize automatic and intelligent identification and access of devices, provide a method for managing ports according to weights, reduce manual input, improve docking efficiency, and perform management.
[0039] 2. The present invention can improve the data transmission efficiency and reliability of Internet of Things devices. The present invention constructs a gateway system based on the DDS international communication protocol, adopts a publish-subscribe model, and realizes decentralization. Finally, a distributed gateway architecture solution driven by a data center is formed, which has 22 kinds of Qos (quality standards), has higher transmission efficiency, and the peak data transmission per device per second is 10,000 (the Qos of mqtt has only 3 kinds, and the data transmission per device per second is only a few). It supports communication between massive data and application services, and can be widely applied in scenarios with massive data and high real-time communication requirements, such as in many fields such as medicine, industry, national defense, and artificial intelligence. A retry mechanism and data compression technology are added to overcome the shortcomings of the original DDS and improve data transmission efficiency.
[0040] 3. The present invention is convenient to be in line with international standards. DDS is published by an international non-profit organization, and this gateway adopts the DDS protocol, which can be in line with more international business scenarios. Description of the drawings
[0041] Figure 1 is the architecture diagram of the present invention;
[0042] Figure 2 is the IP information diagram obtained by scanning;
[0043] Figure 3 is the schematic diagram of IP protocol access;
[0044] Figure 4 is the schematic diagram of port protocol weights;
[0045] Figure 5 is the schematic diagram of protocol adaptation;
[0046] Figure 6 It is a schematic diagram of the DDS data center;
[0047] Figure 7 It is a schematic diagram of the retry queue;
[0048] Figure 8 It is a schematic diagram of the compression configuration information representation;
[0049] Figure 9 It is a network diagram of a decentralized distributed data center. Specific implementation manner
[0050] The present invention will be further described below with reference to specific embodiments in the accompanying drawings.
[0051] Refer to Figures 1 to 9 , an Internet of Things gateway communication method, including:
[0052] Scan the current network service to obtain the IP information of the Internet of Things device ports, and realize quick access to the Internet of Things devices according to the IP information of the ports;
[0053] Input the data and protocol types of different types of Internet of Things devices into the conversion queue. The conversion queue uniformly converts according to the protocol types, converts the data into DDS standards and converts the DDS standards into the specific protocol data of each Internet of Things device;
[0054] Set specific communication policies according to the QoS policies provided by DDS;
[0055] Establish DDS data centers corresponding to each client and Internet of Things device one by one according to the DDS protocol. The DDS data centers receive the data of the Internet of Things devices and issue the instructions of the clients through the publish-subscribe model, realizing two-way communication between the clients and the Internet of Things devices, and each DDS data center constitutes a decentralized architecture.
[0056] Scan the current network service through any one of the service scanning and discovery tools such as RTI Connext DDS, Linux NMP (Network Monitoring Platform), and zenmap to quickly obtain the docking information of the Internet of Things devices.
[0057] The IP information can be provided manually or obtained according to the current network IP information.
[0058] Specific command: namp[IP / IP segment]. After scanning, the port (PORT), status (STATE), and service protocol name (SERVICE) of the corresponding IP can be obtained, as Figure 2 shown.
[0059] During the initial scan, the local IP segment can be used for scanning to obtain sufficient device information of the network. After obtaining the Internet of Things device information, it can be confirmed manually or screened through pre-set information. Finally, the communication network information is entered into the local cache library, and the IP status is maintained;
[0060] During subsequent scans, scanning can be specified by IP to improve the scanning efficiency;
[0061] For the remote IP side, the IP is specified manually for scanning to form local IP information.
[0062] After matching, the data is stored for maintenance (IP, PORT, TLS, APP_PROTOCOL, STATE). The IP is the IP information obtained from the current network, as Figure 3 shown, and a port protocol weight table is formed, as Figure 4 shown.
[0063] The weights of the port protocols are all 1 by default. Users can set them according to the convention, and then they will be calculated according to the access situation. The weight is the protocol usage weight. The greater the protocol usage weight, the higher the protocol priority selected during port matching.
[0064] Specifically, the weights of each communication protocol are calculated according to the connection numbers of each communication protocol recorded by the Internet of Things device ports. During automatic matching, the communication protocol with a greater weight is preferentially selected for parsing to improve the parsing success rate. The weight calculation is as follows:
[0065]
[0066] where n is the number of protocol types, and C(i) is the port connection times CONNECT_TIME of the i-th type of protocol. For example: there are two records of MQTT and HTTP set for port 1884, and the connection numbers are 6 and 2 respectively. So the weight of using mqtt for port 1884 in actual docking is: 6 / (6 + 2)*10 = 7.5, and the weight of using http is: 2 / (6 + 2)*10 = 2.5. During automatic matching, the user is prompted to preferentially select the mqtt protocol for parsing to improve the parsing success rate. If the user does not confirm, the protocol with a higher weight is also preferentially selected automatically for matching.
[0067] The main docking of the present invention includes MQTT, HTTP(S), CoAP, Modbus, Can, OPCUA, ODBC, and custom protocols. The data and protocol types are input into the conversion queue. Through the protocol adaptation converter, the data is converted into the DDS standard and the DDS standard is converted into the specific protocol data of each device to achieve two-way communication between devices, as Figure 5 shown.
[0068] The DDS protocol is a data-centric middleware protocol and API standard. The core communication function uses the publish-subscribe model DCPS (Data-Centric Publish-Subscribe) for data transmission. For example, Figure 6 as shown, all data to be transmitted is identified by topics, managed using a dedicated in-memory area, and an abstract unified API data standard is established. The publisher publishes data according to the topic, and the subscriber subscribes to the required topic data according to business needs, eliminating unnecessary subscriptions, reducing unnecessary data transmission, improving data transmission efficiency, and enhancing the system's data processing efficiency due to the use of a unified memory area for data management. The amount of data propagated per second exceeds several times that of MQTT, providing technical support for large-scale data transmission.
[0069] To improve data transmission reliability, 22 QoS policies (communication policies) are provided based on DDS. For the same role (publisher / subscriber), the same QoS can be used alone or multiple policies can be used. QoS is generally set through parameters. Kind = RELIABLE. If an error occurs in the network and the data reader may not receive the sample data from the data writer, the sample data will be resent to ensure that the data reader can receive the data. Kind = BEST_EFFORT. If an error occurs in the network, the data writer will not resend the lost sample data. In this way, it cannot be guaranteed that the data reader can receive the data. If this QoS policy is applied to the data writer and Kind = RELIABLE is set, all data published by the data writer can be received by the data reader.
[0070] Based on the original DDS, the present invention proposes two innovations: a retry queue and data compression technology.
[0071] The communication policy includes a retry queue. In previous applications, since DDS uses a data bus mode, it has high bandwidth requirements and is generally applied in relatively stable network environments such as local area networks, stand-alone devices, and dedicated lines. To enhance its application ability in weak network environments, a new memory-based retry queue is designed to provide a way to retry data that fails to be sent or times out due to network instability. The data structure of the retry queue is:
[0072] {MSG:SEND_RETRY:EXPIRE_TIME}, for example, Figure 7 as shown,
[0073] where MSG includes the generated data and connection target information, SEND_RETRY is the number of retries, and EXPIRE_TIME is the expiration time;
[0074] SEND_RETRY defaults to -1, which means it will retry indefinitely by default. When retrying, it first consumes from the queue.
[0075] If SEND_RETRY > 0, after the message sending fails, it is put into the failure queue and waits for the next retry. If the next retry still fails, SEND_RETRY is decremented by 1, and the message is put back into the queue again, and it will keep retrying until SEND_RETRY is decremented to 0.
[0076] To ensure that the queue can be consumed and the device memory will not be filled up due to long-term data generation, the expiration time EXPIRE_TIME can be set. When the retry time is greater than the expiration time, the data will no longer be retried, and the user will be prompted that the sending has failed.
[0077] The communication strategy also includes data compression technology. Between the server and the device, when transmitting relatively long data, it generally uploads in fragments and then combines them into complete data on the server side. The present invention proposes a special data compression technology for the Internet of Things, which is through cloud computing + edge compression. Since the device data formats in each industry may be different, the compression configuration information is provided through cloud services. After the Internet of Things device obtains the compression configuration information, it parses and compresses according to the compression information. First, the user end sets the common data information coding table for the current scenario according to the actual business requirements. The coding table is set in the cloud or directly imported into the Internet of Things device. When the Internet of Things device connects to the cloud service, the coding table is updated regularly.
[0078] Compress data with more than 2 bytes according to the coding table.
[0079] For example, according to Figure 8 the configuration rules shown, when the message body is: abcdefgh, it can be compressed to 123. It is expected that the message size can be compressed by more than 2 times, which can effectively reduce the amount of data sent, thereby improving the communication efficiency.
[0080] An Internet of Things gateway communication system includes:
[0081] A device access module, which is used to scan the current network service to obtain the IP information of the Internet of Things device port and achieve fast access to the Internet of Things device according to the IP information of the port.
[0082] A protocol adaptation module, which is used to input the data and protocol types of different types of Internet of Things devices into the conversion queue. The conversion queue uniformly converts according to the protocol type, converts the data into the DDS standard and converts the DDS standard into the specific protocol data of each Internet of Things device.
[0083] Specifically, the protocol adaptation module is responsible for adapting the protocols of multiple types of devices, mainly including device connectors, protocol managers, and data converters. The device connectors are mainly responsible for connecting heterogeneous devices and passing the connected data and protocol types into the conversion queue; the conversion queue uniformly performs conversions according to the protocol types; the protocol manager provides Internet of Things protocol management for the device connectors and converters.
[0084] The protocol adaptation module is mainly docked with MQTT, HTTP(S), CoAP, Modbus, Can, OPCUA, ODBC, and custom protocols. It inputs data and protocol types into the conversion queue and, through the protocol adaptation converter, converts the data into the DDS standard and converts the DDS standard into the specific protocol data of each device to achieve two-way device communication.
[0085] The policy module is used to set specific communication policies according to the QoS policies provided by DDS.
[0086] The data application module is used to establish a DDS data center corresponding to each client and Internet of Things device according to the DDS protocol. The DDS data center receives Internet of Things device data and issues client instructions through the publish-subscribe model to achieve two-way communication between the client and the Internet of Things device, and each DDS data center constitutes a decentralized architecture, as Figure 9 shown.
[0087] A computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the above-mentioned Internet of Things gateway communication method.
[0088] A computer-readable storage medium stores a computer program thereon, and when the computer program is executed by a processor, it implements the above-mentioned Internet of Things gateway communication method.
[0089] The present invention can realize automatic device identification and access, and support the access of MQTT, HTTP(S), CoAP, Modbus, Can, OPCUA, and ODBC devices. It can be customized and adapted, support users to adapt private protocols by themselves, and perform device protocol management, and provide a method for managing ports according to weights.
[0090] The present invention constructs a gateway system based on the DDS international communication protocol, adopts the publish-subscribe model, and realizes decentralization, and finally forms a distributed gateway architecture solution driven by data centers. A retry mechanism and data compression technology are added to overcome the shortcomings of the original DDS and improve data transmission efficiency.
[0091] The above are only the preferred embodiments of the present invention. It should be noted that for those skilled in the art, without departing from the structure of the present invention, several modifications and improvements can be made, which will not affect the implementation effect of the present invention and the practicability of the patent.
Claims
1. An Internet of Things gateway communication method, characterized in that, Including: Scanning the current network service to obtain the IP information of the ports of Internet of Things (IoT) devices, and achieving fast access to IoT devices based on the IP information of the ports; Inputting the data and protocol types of different types of IoT devices into a conversion queue, and the conversion queue uniformly performs conversions according to the protocol types, converting the data into the DDS standard and converting the DDS standard into the specific protocol data of each IoT device; Setting specific communication policies according to the QoS policies provided by DDS; Establishing a DDS data center corresponding to each client and IoT device one by one according to the DDS protocol. The DDS data center receives IoT device data and issues client instructions through the publish-subscribe model to achieve two-way communication between the client and the IoT device, and each DDS data center constitutes a decentralized architecture; Calculating the weights of each communication protocol based on the connection numbers of each communication protocol recorded by the IoT device ports. When automatically matching, preferentially select the communication protocol with a larger weight for parsing to improve the parsing success rate. The weight calculation is as follows: weight(i)= ) * 10 = C(i) / (C(1)+C(2)+...+C(n)) * 10, where n is the type of protocol, and C(i) is the number of port connections of the i-th type of protocol; The communication policy includes a retry queue, and the data structure of the retry queue is: {MSG:SEND_RETRY:EXPIRE_TIME}, where MSG includes the generated data and connection target information, SEND_RETRY is the number of retries, and EXPIRE_TIME is the expiration time; SEND_RETRY defaults to -1, and by default, it retries continuously. When retrying, it first consumes from the queue; If SEND_RETRY>0, after the message sending fails, it is put into the failure queue and waits for the next retry; if the next retry still fails, then SEND_RETRY is decremented by 1, and the message is put back into the queue again, and it retries continuously until SEND_RETRY is decremented to 0; By setting the expiration time EXPIRE_TIME, when the retry time is greater than the expiration time, the data will no longer be retried, and the user will be prompted that the sending has failed.
2. The method for communicating of an Internet of Things gateway according to claim 1, characterized in that, Scanning the current network service through any one of the service scanning and discovery tools such as RTI ConnextDDS, Linux NMP, and zenmap.
3. A method for communicating between an Internet of Things gateway, as claimed in claim 1, wherein, During the initial scan, scan through the local IP segment to obtain sufficient device information of the local network. After obtaining the IoT device information, confirm it manually or screen it through pre-set information. Finally, enter the communication network information into the local cache library and maintain the IP status; During subsequent scans, specify an IP for scanning to improve the scanning efficiency; For the remote IP end, manually specify an IP for scanning to form local IP information.
4. A method for Internet of Things gateway communication according to claim 1, characterized in that, The communication policy also includes data compression technology. Compression configuration information is provided through cloud services. After the IoT device obtains the compression configuration information, it parses and compresses according to the compression information.
5. A method for communicating an Internet of Things gateway according to claim 4, characterized in that, First, the client sets the common data information coding table for the current scenario according to the actual business requirements. The coding table is set in the cloud or directly imported into the IoT device. When the IoT device connects to the cloud service, the coding table is updated regularly; Compress data with more than 2 bytes according to the coding table.
6. An Internet of Things gateway communication system, characterized in that, Including: The device access module is used to scan the current network service to obtain the IP information of the Internet of Things device ports, and achieve fast access to the Internet of Things devices according to the IP information of the ports; The protocol adaptation module is used to input the data and protocol types of different types of Internet of Things devices into the conversion queue. The conversion queue uniformly converts according to the protocol types, converts the data into the DDS standard and converts the DDS standard into the specific protocol data of each Internet of Things device; The policy module is used to set specific communication policies according to the QoS policies provided by DDS; The data application module is used to establish a DDS data center corresponding to each client and Internet of Things device according to the DDS protocol. The DDS data center receives the data of the Internet of Things devices and issues the instructions of the clients through the publish-subscribe model, realizes two-way communication between the clients and the Internet of Things devices, and each DDS data center constitutes a decentralized architecture; Calculate the weights of each communication protocol according to the connection numbers of each communication protocol recorded by the Internet of Things device ports. When automatically matching, preferentially select the communication protocol with a larger weight for parsing to improve the parsing success rate. The weight calculation is as follows: weight(i)= )*10 = C(i) / (C(1)+C(2)+...+C(n))*10, where n is the type of protocol, and C(i) is the number of port connections of the i-th type of protocol; The communication policy includes a retry queue, and the data structure of the retry queue is: {MSG:SEND_RETRY:EXPIRE_TIME}, where MSG includes the generated data and connection target information, SEND_RETRY is the number of retries, and EXPIRE_TIME is the expiration time; SEND_RETRY defaults to -1, and it is default to retry continuously. When retrying, it consumes from the queue first; If SEND_RETRY>0, after the message sending fails, it is put into the failure queue and waits for the next retry; if the next retry still fails, SEND_RETRY is decremented by 1, and then the message is put back into the queue and retried until SEND_RETRY is decremented to 0; By setting the expiration time EXPIRE_TIME, when the retry time is greater than the expiration time, the data will no longer be retried, and the user will be prompted that the sending fails.
7. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements an Internet of Things gateway communication method according to any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements an Internet of Things gateway communication method according to any one of claims 1-5.
Citation Information
Patent Citations
New Internet of things gateway and working method of internet of things gateway
CN109257425A
Method and system for equipment adaptation based on MQTT (Message Queuing Telemetry Transport) gateway
CN109561096A
DDS-based cross-network segment communication method
WO2020098040A1
KR20230021790A