An Adaptive Message Processing Method Based on TCP Protocol
By introducing a cache queue in the adaptation layer of the NB-IoT terminal, matching and sending processed response messages, the resource consumption problem caused by multiple resentation of downlink instructions is solved, and resource saving is achieved without changing the usage of the TCP protocol.
Patent Information
- Application Number
- CN202211731480.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-30
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2042-12-30
AI Technical Summary
Prior Art In NB-IoT terminals, multiple resends and complex processing flows of downlink instructions lead to increased resource consumption, and the processing flow cannot be simplified without changing the TCP protocol.
The cache queue is introduced in the adaptation layer of the NB-IoT terminal to match the instructions and response messages issued by the Internet of Things platform, and directly send the processed response messages to avoid duplicate processing.
It simplifies the downlink instruction processing process of NB-IoT terminals, reduces resource consumption, and does not change user usage habits and TCP protocol specifications.
Smart Images

Figure CN116055588B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of wireless communication technologies, and in particular, to an adaptive message processing method based on the TCP protocol. Background Art
[0002] At present, for NB-IoT terminals using the TCP protocol, when it is necessary to ensure the quality of message transmission, multiple retransmissions of messages and ACK (or RSP) messages at the protocol layer are used to ensure communication between the NB-IoT terminal and the Internet of Things platform. When the Internet of Things platform sends certain instructions to the NB-IoT terminal, a maximum number of retransmissions and a response timeout are defined for each sent instruction. Whenever the response timeout is reached and no response message is received, a retransmission is performed once and the timeout is doubled until the corresponding ACK (or RSP) is received or the maximum number of transmissions is reached and the response is still timed out. Therefore, there will be a scenario where the same downlink instruction from the Internet of Things platform is received and processed by the NB-IoT terminal multiple times. This scenario will cause some unnecessary resource consumption to the NB-IoT terminal, especially in scenarios where the instruction processing flow is relatively complex. In the prior art, reducing unnecessary resource consumption can generally only be processed at the application layer of the TCP protocol, but at the same time, it will change the usage mode of the NB-IoT terminal of the TCP protocol.
[0003] Therefore, there is a need for a solution that can simplify the downlink instruction response process and reduce the resource consumption of the NB-IoT terminal without changing the usage mode of the NB-IoT terminal of the TCP protocol. Summary of the Invention
[0004] In view of this, an embodiment of the present invention provides an adaptive message processing method based on the TCP protocol that can simplify the downlink instruction response process and reduce the resource consumption of the NB-IoT terminal without changing the usage mode of the NB-IoT terminal of the TCP protocol.
[0005] One aspect of the embodiment of the present invention provides an adaptive message processing method based on the TCP protocol, including:
[0006] Receiving a first downlink instruction sent by the Internet of Things platform;
[0007] Matching the first downlink instruction with a second downlink instruction in a preset cache queue in the adaptation layer, where the cache queue is used to cache multiple first response messages and multiple second downlink instructions sent by the Internet of Things platform;
[0008] If there is a target downlink instruction in the second downlink instructions that matches the first downlink instruction, and there is a target response message corresponding to the first downlink instruction in the first response messages, then sending the target response message to the Internet of Things platform.
[0009] Preferably, it further includes:
[0010] If there is a target downlink instruction in the second downlink instruction that matches the first downlink instruction, and there is no target response message corresponding to the first downlink instruction in the first response message, then end the message processing flow of the first downlink instruction.
[0011] Preferably, it further includes:
[0012] If there is no target downlink instruction in the second downlink instruction that matches the first downlink instruction, then parse the first downlink instruction through the TCP protocol layer to obtain a parsed message;
[0013] Transparently transmit the parsed message to the application service layer through the adaptation layer;
[0014] Complete the service operation corresponding to the parsed message through the application service layer and obtain a second response message;
[0015] Transparently transmit the second response message to the TCP protocol layer through the adaptation layer;
[0016] Perform compact binary encoding of the second response message through the TCP protocol layer, and send the encoded second response message to the Internet of Things platform.
[0017] Preferably, it further includes:
[0018] Cache the first downlink instruction and the second response message corresponding to the first downlink instruction in the cache queue.
[0019] Preferably, the matching of the first downlink instruction with the second downlink instruction in the preset cache queue in the adaptation layer includes:
[0020] Parse the first downlink instruction through the TCP protocol layer to obtain the ServiceID and MsgID of the first downlink instruction;
[0021] Register a response callback function for the first downlink instruction in the adaptation layer;
[0022] Use the response callback function to match the ServiceID and MsgID of the first downlink instruction with the ServiceID and MsgID of the second downlink instruction in the cache queue;
[0023] If the ServiceID of the first downlink instruction is the same as the ServiceID of the second downlink instruction, and the MsgID of the first downlink instruction is the same as the MsgID of the second downlink instruction, then determine that the first downlink instruction matches the second downlink instruction.
[0024] Preferably, if the ServiceID of the first downlink instruction is the same as the ServiceID of the second downlink instruction, and the MsgID of the first downlink instruction is the same as the MsgID of the second downlink instruction, it is determined that the first downlink instruction matches the second downlink instruction, including:
[0025] If the source address of the ServiceID of the first downlink instruction is the same as the source address of the ServiceID of the second downlink instruction, and the MsgID of the first downlink instruction is the same as the MsgID of the second downlink instruction, it is determined that the first downlink instruction matches the second downlink instruction.
[0026] Preferably, if the cache queue is full of the second downlink instructions, the replacement algorithm is used to replace the second downlink instructions in the cache queue.
[0027] Another aspect of the embodiments of the present invention further provides an adaptive message processing device based on the TCP protocol, including:
[0028] An instruction receiving unit, configured to receive a first downlink instruction sent by an Internet of Things platform;
[0029] An instruction matching unit, configured to match the first downlink instruction with a second downlink instruction in a preset cache queue in an adaptation layer, where the cache queue is used to cache a plurality of first response messages and a plurality of second downlink instructions sent by the Internet of Things platform;
[0030] A message sending unit, configured to, if there is a target downlink instruction in the second downlink instructions that matches the first downlink instruction, and there is a target response message corresponding to the first downlink instruction in the first response messages, send the target response message to the Internet of Things platform.
[0031] Another aspect of the embodiments of the present invention further provides an electronic device, including a processor and a memory;
[0032] The memory is used to store a program;
[0033] The processor executes the program to implement the above-mentioned adaptive message processing method based on the TCP protocol.
[0034] Another aspect of the embodiments of the present invention further provides a computer-readable storage medium, where the storage medium stores a program, and the program is executed by a processor to implement the above-mentioned adaptive message processing method based on the TCP protocol.
[0035] An embodiment of the present invention also discloses a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned adaptive message processing method based on the TCP protocol.
[0036] The present invention discloses an adaptive message processing method based on the TCP protocol, including: receiving a first downlink instruction sent by an Internet of Things platform; matching the first downlink instruction with a second downlink instruction in a preset cache queue in an adaptation layer, where the cache queue is used to cache a plurality of first response messages and a plurality of second downlink instructions sent by the Internet of Things platform; wherein, the first response message may be a response message obtained after an NB-IoT terminal has executed an instruction sent by the Internet of Things platform; when there is a target downlink instruction in the second downlink instructions in the cache queue that matches the first downlink instruction, and there is a target response message corresponding to the first downlink instruction in the first response messages, it can be considered that the NB-IoT terminal has received the first downlink instruction from the Internet of Things platform and at least executed it once, and then obtained the target response message, and the first downlink instruction is used as a second cached instruction, and the target response message is cached as the first response message in the cache queue; at this time, the target response message can be directly obtained from the cache queue and sent to the Internet of Things platform without repeating the execution of the first downlink instruction, which simplifies the message processing flow of the NB-IoT terminal for the first downlink instruction and can achieve the technical effect of reducing the resource consumption of the NB-IoT terminal. At the same time, the present invention pre-adds a cache queue for the first downlink instruction and a corresponding queue storage space in the adaptation layer, and performs screening and filtering on whether to return the downlink message without changing the original TCP protocol specification. The method of the present invention is completely transparent to the upper layer, and whether to apply the method of the present invention is not perceived by the upper layer.
[0037] Furthermore, the present invention does not change the normal processing flow of the original TCP protocol and is not perceived by users, so it can not change the user's usage habits. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0039] Figure 1 It is a schematic flowchart of an adaptive message processing method based on the TCP protocol provided by an embodiment of the present invention;
[0040] Figure 2 This is a timing diagram of the processing flow of a downlink instruction by an NB-IoT terminal provided by an embodiment of the present invention;
[0041] Figure 3 This is a coding schematic diagram of the compact binary encoding of a message provided by an embodiment of the present invention;
[0042] Figure 4 This is a specific example diagram of the storage information of a cache queue node provided by an embodiment of the present invention;
[0043] Figure 5 This is a timing diagram of the adaptive processing of TCP messages provided by an embodiment of the present invention;
[0044] Figure 6 This is a structural block diagram of an adaptive message processing device based on the TCP protocol provided by an embodiment of the present invention. Detailed implementation manners
[0045] In order to make the objectives, technical solutions and advantages of the present invention more clear and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0046] Refer to Figure 1 , an embodiment of the present invention provides an adaptive message processing method based on the TCP protocol, which specifically includes the following steps:
[0047] Step S100: Receive a first downlink instruction sent by the Internet of Things platform.
[0048] Specifically, the NB-IoT terminal can receive the downlink instruction sent by the Internet of Things platform, and the downlink instruction sent by the Internet of Things platform can be used as the first downlink instruction.
[0049] Step S110: Match the first downlink instruction with a second downlink instruction in a preset cache queue in the adaptation layer. The cache queue is used to cache multiple first response messages and multiple second downlink instructions sent by the Internet of Things platform.
[0050] Specifically, a cache queue can be added in advance in the adaptation layer of the NB-IoT terminal to cache multiple downlink instructions recently sent by the Internet of Things platform. The downlink instruction can be used as the second downlink instruction. Among them, the number of second downlink instructions that can be cached in the cache queue can be configured by the user himself, and the present invention does not make strict limitations. In addition, the response messages corresponding to each second downlink instruction can also be cached in the cache queue as the first response messages.
[0051] Furthermore, the first downlink instruction can be matched in the cache queue to determine whether there is a second downlink instruction that meets the matching conditions in the cache queue.
[0052] Step S120: If there is a target downlink instruction in the second downlink instructions that matches the first downlink instruction, and there is a target response message corresponding to the first downlink instruction in the first response message, then send the target response message to the IoT platform.
[0053] Specifically, if there is a downlink instruction in the multiple second downlink instructions in the cache queue that matches the first downlink instruction, this downlink instruction can be used as the target downlink instruction. And if there is a target response message corresponding to the first downlink instruction in the multiple first response messages in the cache queue, it can be considered that the NB-IoT terminal has received the first downlink instruction and executed it at least once. Therefore, the target response message can be directly used as the response message corresponding to the first downlink instruction, and then the target response message is uploaded to the IoT platform, thus completing the processing flow of the first downlink instruction.
[0054] The present invention can simplify the message processing flow of the NB-IoT terminal for downlink instructions, without repeatedly executing the downlink instructions sent by the IoT platform multiple times. Without changing the usage mode of the NB-IoT terminal of the TCP protocol, the technical effect of reducing the resource consumption of the NB-IoT terminal can be achieved.
[0055] Furthermore, if there is no target response message corresponding to the first downlink instruction in the cache queue, the embodiments of the present invention can also add the following process:
[0056] Specifically, if there is a target downlink instruction in the second downlink instructions that matches the first downlink instruction, and there is no target response message corresponding to the first downlink instruction in the first response message, it can be considered that the NB-IoT terminal is processing the first downlink instruction previously sent by the IoT platform. Therefore, the message processing flow of the current first downlink instruction can be ended.
[0057] Furthermore, if there is no target downlink instruction in the cache queue that matches the first downlink instruction, the embodiments of the present invention can also add the following process:
[0058] S1: If there is no target downlink instruction in the second downlink instructions that matches the first downlink instruction, then parse the first downlink instruction through the TCP protocol layer to obtain a parsed message.
[0059] S2: Transparently transmit the parsed message to the application service layer through the adaptation layer.
[0060] S3: Complete the service operation corresponding to the parsed message through the application service layer and obtain a second response message.
[0061] S4. Transparently transmit the second response message to the TCP protocol layer through the adaptation layer.
[0062] S5. Perform compact binary encoding of the second response message through the TCP protocol layer, and send the encoded second response message to the IoT platform.
[0063] Specifically, if there is no target downlink instruction in the cache queue that matches the first downlink instruction, the NB-IoT terminal can perform the Figure 2 processing flow shown. Among them, when there is no target downlink instruction in the cache queue that matches the first downlink instruction, the processing flow performed by the NB-IoT terminal on the first downlink instruction can be used as the default process.
[0064] Specifically, the above default process may include: after the TCP protocol layer receives the first downlink instruction, it parses it. After the parsing of the first downlink instruction is completed, a parsed message is obtained. Then, the parsed message is handed over to the adaptation layer, and the adaptation layer transparently transmits the parsed message to the application service layer for processing. The application service layer completes corresponding service operations according to the content of the parsed message, obtains a second response message, and hands the second response message to the adaptation layer. The adaptation layer transparently transmits the second response message to the TCP protocol layer, and the TCP protocol layer performs compact binary encoding again. A specific example diagram of the encoding can be referred to Figure 3 , and finally send the encoded second response message to the IoT platform.
[0065] Considering that the IoT platform may send the first downlink instruction to the NB-IoT terminal again later, the first downlink instruction and the second response message corresponding to the first downlink instruction can be cached in the cache queue. When the NB-IoT terminal receives the first downlink instruction again later, it can directly obtain the second response message from the cache queue and send it to the IoT platform, which can save the processing flow of executing the first downlink instruction again.
[0066] In some embodiments of the present invention, the above step S110, the process of matching the first downlink instruction with the second downlink instruction in the preset cache queue in the adaptation layer is introduced. Next, the matching process will be further described.
[0067] Specifically, the matching process may include:
[0068] S1. Parse the first downlink instruction through the TCP protocol layer to obtain the ServiceID and MsgID of the first downlink instruction.
[0069] S2. Register the response callback function of the first downlink instruction in the adaptation layer.
[0070] S3. Use the response callback function to match the ServiceID and MsgID of the first downlink instruction with the ServiceID and MsgID of the second downlink instruction in the cache queue.
[0071] S4. If the ServiceID of the first downlink instruction is the same as the ServiceID of the second downlink instruction, and the MsgID of the first downlink instruction is the same as the MsgID of the second downlink instruction, it is determined that the first downlink instruction matches the second downlink instruction.
[0072] Specifically, the cacheable number of the cache queue pre-added in the adaptation layer can be set by the user. In the embodiment of the present invention, taking the cacheable number as 5 as an example, refer to Figure 4 , each node of the cache queue can store the following information: the MsgID of the second downlink instruction, the ServiceID of the second downlink instruction, and the first response message corresponding to the second downlink instruction, etc. In addition, other information specified by the user can also be saved in the cache queue to adapt to some specific scenarios.
[0073] Among them, when the cache queue is full, a replacement algorithm can be used to replace the second downlink instruction and the above-related data in the cache queue. The replacement algorithm can use the FIFO (First Input First Output) algorithm, or the LRU (Least Recently Used) algorithm, etc., as well as other optional replacement algorithms.
[0074] The matching process between the first downlink instruction and the second downlink instruction in the cache queue may include:
[0075] Register the response callback function of the first downlink instruction in the adaptation layer. After the TCP protocol layer parses the first downlink instruction to obtain the ServiceID and MsgID of the first downlink instruction, it is passed to the response callback function. In the response callback function, the ServiceID and MsgID of the first downlink instruction are matched with the data in the cache queue. The matching content includes the ServiceID and MsgID of the second downlink instruction. When the ServiceID and MsgID of the first and second downlink instructions are both the same, it can be considered that the two match.
[0076] Since, in most cases, the MsgID is required by the specification to be strictly incremented, and considering the situation that the NB-IoT terminal may be connected to multiple Internet of Things platforms at the same time, therefore, within the set time period, the first downlink instructions with the same MsgID sent by the Internet of Things platform with the same source address can all be considered as the same downlink instruction.
[0077] Next, a specific example will be used to illustrate the process of the adaptive message processing based on the TCP protocol according to the present invention. Refer to Figure 5 , Figure 5 FIG. shows a timing diagram of the TCP message adaptive processing provided by an embodiment of the present invention.
[0078] Specifically, a cache queue is pre-added to the adaptation layer of the NB-IoT terminal. The cache queue can be used to cache the N (N is configurable) second downlink instructions and the corresponding NB-IoT terminal response messages recently sent by the IoT platform. When the cache queue is full, a replacement algorithm (such as FIFO, LRU, etc.) can be used to replace the second downlink instructions and their related data in the cache queue. When the NB-IoT terminal receives the first downlink instruction sent by the IoT platform, the first downlink instruction can be first matched with the second downlink instructions in the cache queue in the adaptation layer. According to different matching results, there can be the following different processing flows: If no matching target downlink instruction is found, after caching the first downlink instruction in the cache queue, continue to process the message corresponding to the first downlink instruction according to the default process, and store the response message of the first downlink instruction into the corresponding node of the cache queue; If a matching target downlink instruction is found but there is no corresponding target response message, it is considered that the first downlink instruction is being processed, and then the current message processing flow can be ended; If a matching target downlink instruction is found and the cache queue contains the corresponding target response message, the target response message can be directly returned to the IoT platform, and then the processing flow of this message is ended.
[0079] Refer to Figure 6 , an embodiment of the present invention provides an adaptive message processing device based on the TCP protocol, including:
[0080] An instruction receiving unit, configured to receive the first downlink instruction sent by the IoT platform;
[0081] An instruction matching unit, configured to match the first downlink instruction with the second downlink instructions in a preset cache queue in the adaptation layer, where the cache queue is used to cache multiple first response messages and multiple second downlink instructions sent by the IoT platform;
[0082] A message sending unit, configured to, if there is a target downlink instruction in the second downlink instructions that matches the first downlink instruction, and there is a target response message corresponding to the first downlink instruction in the first response messages, send the target response message to the IoT platform.
[0083] An embodiment of the present invention also discloses a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes Figure 1 the method shown.
[0084] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order mentioned in the operation diagrams. For example, depending on the functions / operations involved, two consecutive blocks shown may actually be executed substantially simultaneously or the blocks can sometimes be executed in the reverse order. In addition, the embodiments presented and described in the flowcharts of the present invention are provided by way of example for the purpose of providing a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logical flows presented herein. Alternative embodiments are contemplated, in which the order of various operations is changed and the sub-operations described as part of a larger operation are executed independently.
[0085] In addition, although the present invention has been described in the context of functional modules, it should be understood that unless otherwise stated to the contrary, one or more of the functions and / or features described may be integrated in a single physical device and / or software module, or one or more functions and / or features may be implemented in separate physical devices or software modules. It can also be understood that a detailed discussion of the actual implementation of each module is not necessary for understanding the present invention. More precisely, considering the attributes, functions and internal relationships of the various functional modules in the devices disclosed herein, the actual implementation of the modules will be understood within the ordinary skills of an engineer. Therefore, those skilled in the art can implement the present invention as set forth in the claims without undue experimentation. It can also be understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.
[0086] If the above-mentioned functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.
[0087] The logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a predefined sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in combination with these instruction execution systems, apparatuses, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in combination with an instruction execution system, apparatus, or device.
[0088] More specific examples (non-exhaustive list) of computer-readable media include the following: electrical connection parts with one or more wirings (electronic devices), portable computer disk cartridges (magnetic devices), random access memories (RAMs), read-only memories (ROMs), erasable programmable read-only memories (EPROMs or flash memories), optical fiber devices, and portable compact disc read-only memories (CDROMs). Additionally, a computer-readable medium can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, then editing, interpreting, or otherwise processing it as appropriate, and then storing it in a computer memory.
[0089] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, any one or a combination of the following techniques well known in the art can be used: discrete logic circuits with logic gate circuits for implementing logical functions on data signals, application specific integrated circuits with appropriate combinational logic gate circuits, programmable gate arrays (PGAs), field programmable gate arrays (FPGAs), etc.
[0090] In the description of this specification, the descriptions with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc. mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0091] Although the embodiments of the present invention have been shown and described, those of ordinary skill in the art can understand that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and purposes of the present invention, and the scope of the present invention is defined by the claims and their equivalents.
[0092] The above has specifically described the preferred embodiments of the present invention, but the present invention is not limited to the described embodiments. Those skilled in the art can also make various equivalent deformations or substitutions without departing from the spirit of the present invention, and these equivalent deformations or substitutions are all included within the scope defined by the claims of the present invention.
Claims
1. An adaptive message processing method based on the TCP protocol, characterized in that Including: Receiving a first downlink instruction sent by an Internet of Things platform; Matching the first downlink instruction with a second downlink instruction in a preset cache queue in the adaptation layer, where the cache queue is used to cache multiple first response messages and multiple second downlink instructions sent by the Internet of Things platform; If there is a target downlink instruction in the second downlink instructions that matches the first downlink instruction, and there is a target response message corresponding to the first downlink instruction in the first response messages, then sending the target response message to the Internet of Things platform; The method further includes: If there is no target downlink instruction in the second downlink instructions that matches the first downlink instruction, then parsing the first downlink instruction through the TCP protocol layer to obtain a parsed message; Transparently transmitting the parsed message to the application service layer through the adaptation layer; Completing the service operation corresponding to the parsed message through the application service layer and obtaining a second response message; Transparently transmitting the second response message to the TCP protocol layer through the adaptation layer; Performing compact binary encoding on the second response message through the TCP protocol layer and sending the encoded second response message to the Internet of Things platform; The matching the first downlink instruction with the second downlink instruction in the preset cache queue in the adaptation layer includes: Parsing the first downlink instruction through the TCP protocol layer to obtain the ServiceID and MsgID of the first downlink instruction; Registering a response callback function for the first downlink instruction in the adaptation layer; Using the response callback function to match the ServiceID and MsgID of the first downlink instruction with the ServiceID and MsgID of the second downlink instruction in the cache queue; If the ServiceID of the first downlink instruction is the same as the ServiceID of the second downlink instruction, and the MsgID of the first downlink instruction is the same as the MsgID of the second downlink instruction, then determining that the first downlink instruction matches the second downlink instruction.
2. The adaptive message processing method based on the TCP protocol according to claim 1, wherein Further including: If there is a target downlink instruction in the second downlink instructions that matches the first downlink instruction, and there is no target response message corresponding to the first downlink instruction in the first response messages, then ending the message processing flow of the first downlink instruction.
3. The adaptive message processing method based on the TCP protocol according to claim 1, wherein Further including: Caching the first downlink instruction and the second response message corresponding to the first downlink instruction in the cache queue.
4. The adaptive message processing method based on the TCP protocol according to claim 1, wherein, The determining that the first downlink instruction matches the second downlink instruction if the ServiceID of the first downlink instruction is the same as the ServiceID of the second downlink instruction, and the MsgID of the first downlink instruction is the same as the MsgID of the second downlink instruction includes: If the source address of the ServiceID of the first downlink instruction is the same as the source address of the ServiceID of the second downlink instruction, and the MsgID of the first downlink instruction is the same as the MsgID of the second downlink instruction, then determining that the first downlink instruction matches the second downlink instruction.
5. The adaptive message processing method based on the TCP protocol according to any one of claims 1 to 4, characterized in that If the cache queue is full after storing the second downlink instruction, the replacement algorithm is used to replace the second downlink instruction in the cache queue.
6. An adaptive message processing device based on the TCP protocol, characterized in that, It includes: An instruction receiving unit for receiving the first downlink instruction sent by the IoT platform; An instruction matching unit for matching the first downlink instruction with the second downlink instructions in a preset cache queue in the adaptation layer, where the cache queue is used to cache multiple first response messages and multiple second downlink instructions sent by the IoT platform; A message sending unit for, if there is a target downlink instruction in the second downlink instructions that matches the first downlink instruction, and there is a target response message corresponding to the first downlink instruction in the first response messages, sending the target response message to the IoT platform; The device is further configured to: If there is no target downlink instruction in the second downlink instructions that matches the first downlink instruction, parse the first downlink instruction through the TCP protocol layer to obtain a parsed message; Transparently transmit the parsed message to the application service layer through the adaptation layer; Complete the service operation corresponding to the parsed message through the application service layer and obtain a second response message; Transparently transmit the second response message to the TCP protocol layer through the adaptation layer; Perform compact binary encoding on the second response message through the TCP protocol layer and send the encoded second response message to the IoT platform; The matching of the first downlink instruction with the second downlink instructions in the preset cache queue in the adaptation layer includes: Parsing the first downlink instruction through the TCP protocol layer to obtain the ServiceID and MsgID of the first downlink instruction; Registering the response callback function of the first downlink instruction in the adaptation layer; Using the response callback function to match the ServiceID and MsgID of the first downlink instruction with the ServiceID and MsgID of the second downlink instructions in the cache queue; If the ServiceID of the first downlink instruction is the same as the ServiceID of the second downlink instruction, and the MsgID of the first downlink instruction is the same as the MsgID of the second downlink instruction, it is determined that the first downlink instruction matches the second downlink instruction.
7. An electronic device, characterized in that, It includes a processor and a memory; The memory is used to store programs; The processor executes the program to implement the TCP protocol-based adaptive message processing method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The storage medium stores a program, and the program is executed by the processor to implement the TCP protocol-based adaptive message processing method according to any one of claims 1 to 5.
Citation Information
Patent Citations
An application function running method and device
CN109840133A
Instruction response method and network equipment
CN112804076A
TCP connection method, system, network device, and storage medium
WO2022268137A1