Tcp data analysis processing method and device and storage medium

By creating port configuration parameters on the visual configuration page of the IoT device access platform, supporting multiplexing of ports and decoding and business processing logic, the problem of insufficient port resources and serious coupling of decoding logic is solved, and the correct analysis and efficient processing of tcp messages are achieved.

CN119676101AActive Publication Date: 2025-03-21GUANGDONG ESHORE TECH

Patent Information

Application Number
CN202311213369.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-19
Publication Date
2025-03-21
Estimated Expiration
2043-09-19

AI Technical Summary

Technical Problem

When deploying to a customer's private environment, the Internet of Things device access platform faces problems such as insufficient port resources and serious coupling of decoding processing logic, resulting in the inability to correctly parse tcp messages, and message miss or errors in processing occur.

Method used

By creating configuration parameters of ports on the visual configuration page, multiplexed ports are supported, and the decoding logic is processed by the server side of the Internet of Things device access platform. The business logic is exposed through the parent interface, realizing the decoding between multiple protocols and the decoupling of business processing logic.

Benefits of technology

It avoids waste of port resources, reduces the coupling of decoding processing logic, improves the correct resolution of tcp messages, and reduces the probability of errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119676101A_ABST
    Figure CN119676101A_ABST
Patent Text Reader

Abstract

The invention provides a tcp data analysis processing method and device and a storage medium, and the method comprises the steps: obtaining a configuration parameter of a port of an access platform of Internet of Things equipment, and initializing the configuration parameter; when the port receives the tcp streaming data from the terminal equipment, reading a target protocol field in the tcp streaming data, and identifying a target tcp protocol of the tcp streaming data according to the target protocol field and the configuration parameters; analyzing the target tcp protocol to obtain protocol content; determining a target service logic processing class field of the target tcp protocol according to the configuration parameters; and according to the target service logic processing class field, exposing the service processing logic of the protocol content on the port in the form of a parent class interface. According to the method and the device, port multiplexing can be supported, port resource waste is avoided, and the problem of message omission or message processing error report caused by the situation that the tcp message cannot be correctly analyzed can also be avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of Internet of Things, and in particular to a method, device and storage medium for parsing and processing TCP data. Background Art

[0002] As an IoT device access platform, it is often necessary to connect to multiple terminal devices from different manufacturers. These terminal devices are connected to the IoT device access platform through TCP connections, and the TCP protocols used by these terminal devices are all customized by the manufacturers, and the protocol formats are often very different.

[0003] During the entire access process, since there are other applications in the customer's deployment environment when the IoT access platform is deployed to the customer's private environment, the range of ports that can be allocated to the IoT access platform for external exposure is strictly limited. If a single port corresponds to a TCP protocol, the IoT device access platform may face the problem of insufficient port resources. In addition, since the decoding logic of multiple TCP protocols is usually written together, if a single port corresponds to multiple TCP protocols, the decoding processing logic may be severely coupled, and TCP messages may not be parsed correctly, resulting in message omissions or message processing errors. Summary of the invention

[0004] The embodiment of the present application provides a method, device and storage medium for parsing and processing TCP data to solve the problems existing in the related technologies. The technical solution is as follows:

[0005] In a first aspect, an embodiment of the present application provides a method for parsing and processing TCP data, including:

[0006] Obtain configuration parameters of the port for the IoT device to access the platform, and initialize the configuration parameters, wherein the configuration parameters are created according to the configuration items on the visual configuration page, and the configuration parameters include N TCP protocols corresponding to the port, and the protocol field and the business logic processing class field of any TCP protocol, where N is an integer greater than or equal to 1;

[0007] When the port receives the TCP streaming data from the terminal device, the target protocol field in the TCP streaming data is read, and the target TCP protocol of the TCP streaming data is identified according to the target protocol field and the configuration parameters;

[0008] Parse the target TCP protocol to obtain the protocol content;

[0009] Determine the target service logic processing class field of the target TCP protocol according to the configuration parameters;

[0010] According to the target business logic processing class field, the business processing logic of the protocol content is exposed on the port in the form of a parent class interface.

[0011] In one embodiment, the protocol field of any of the TCP protocols includes three fields: a packet header, a packet tail, and a packet length, and the target protocol field is a packet header field;

[0012] Reading the target protocol field in the TCP streaming data, and identifying the target TCP protocol of the TCP streaming data according to the target protocol field and the configuration parameters includes:

[0013] Read the packet header field in the TCP streaming data;

[0014] The target TCP protocol of the TCP streaming data is identified according to the packet header field and the configuration parameters.

[0015] In one embodiment, reading the header field in the TCP streaming data includes:

[0016] Read the first 2 bytes of the TCP streaming data to obtain the packet header field;

[0017] If the number of bytes currently read is less than 2, the bytes currently read are cached and the subsequent bytes are waited for to arrive until the first 2 bytes in the TCP streaming data are read.

[0018] In one implementation, initializing the configuration parameters includes:

[0019] Load any of the tcp protocols;

[0020] For any of the TCP protocols, generate a decoder instance of any of the TCP protocols;

[0021] According to any one of the decoder instances of the TCP protocol, a decoder of any one of the TCP protocols is generated.

[0022] In one implementation, parsing the target TCP protocol to obtain the protocol content includes:

[0023] The decoder of the target TCP protocol is called to parse the legal complete byte stream data in the target TCP protocol to obtain the protocol content.

[0024] In one embodiment, the configuration parameters also include a protocol field conversion result class field of any of the TCP protocols;

[0025] According to the target business logic processing class field, exposing the business processing logic of the protocol content on the port in the form of a parent class interface includes:

[0026] Determine the target protocol field conversion result class field of the target TCP protocol according to the configuration parameters;

[0027] According to the target protocol field conversion result class field, convert the protocol content into a protocol field conversion result class instance;

[0028] Generate a business logic processing class instance according to the target business logic processing class field;

[0029] The protocol field conversion result class instance is passed to the business logic processing class to expose the business processing logic of the protocol content on the port in the form of a parent class interface.

[0030] In one implementation, the configuration parameter further includes a protocol content check field of any of the TCP protocols; and the method further includes:

[0031] Determine the target protocol content check class field of the target TCP protocol according to the configuration parameters;

[0032] According to the target protocol content verification class field, calling a general verification processor to verify the protocol content;

[0033] After the protocol content is verified, the target business logic processing class field of the target TCP protocol is determined according to the configuration parameters.

[0034] In one embodiment, the method further comprises:

[0035] In the case of adding any new TCP protocol, in response to the new addition operation on the protocol configuration item, the protocol field configuration item and the business logic processing class configuration item on the visualization configuration page, the configuration parameters are updated.

[0036] In a second aspect, an embodiment of the present application further provides a tcp data parsing and processing device, including:

[0037] A processing unit, used to obtain configuration parameters of a port for an IoT device to access the platform, and initialize the configuration parameters, wherein the configuration parameters are created according to various configuration items on a visual configuration page, and the configuration parameters include N types of TCP protocols corresponding to the port, and a protocol field and a business logic processing class field of any TCP protocol, where N is an integer greater than or equal to 1;

[0038] an identification unit, configured to read a target protocol field in the TCP streaming data when the port receives the TCP streaming data from the terminal device, and identify a target TCP protocol of the TCP streaming data according to the target protocol field and the configuration parameters;

[0039] A parsing unit is used to parse the target TCP protocol to obtain the protocol content; determine the target business logic processing class field of the target TCP protocol according to the configuration parameters; and expose the business processing logic of the protocol content on the port in the form of a parent class interface according to the target business logic processing class field.

[0040] In one implementation, the protocol field of any of the TCP protocols includes: a packet header, a packet tail, and a packet length, and the target protocol field is a packet header field; the identification unit is specifically used to:

[0041] Read the packet header field in the TCP streaming data;

[0042] The target TCP protocol of the TCP streaming data is identified according to the packet header field and the configuration parameters.

[0043] In one embodiment, the identification unit is specifically used for:

[0044] Read the first 2 bytes of the TCP streaming data to obtain the packet header field;

[0045] If the number of bytes currently read is less than 2, the bytes currently read are cached and the subsequent bytes are waited for to arrive until the first 2 bytes in the TCP streaming data are read.

[0046] In one embodiment, the processing unit is specifically configured to:

[0047] Load any of the tcp protocols;

[0048] For any of the TCP protocols, generate a decoder instance of any of the TCP protocols;

[0049] According to any one of the decoder instances of the TCP protocol, a decoder of any one of the TCP protocols is generated.

[0050] In one implementation, the parsing unit is specifically used to:

[0051] The decoder of the target TCP protocol is called to parse the legal complete byte stream data in the target TCP protocol to obtain the protocol content.

[0052] In one implementation, the configuration parameters further include a protocol field conversion result class field of any of the TCP protocols; and the parsing unit is specifically configured to:

[0053] Determine the target protocol field conversion result class field of the target TCP protocol according to the configuration parameters;

[0054] According to the target protocol field conversion result class field, convert the protocol content into a protocol field conversion result class instance;

[0055] Generate a business logic processing class instance according to the target business logic processing class field;

[0056] The protocol field conversion result class instance is passed to the business logic processing class to expose the business processing logic of the protocol content on the port in the form of a parent class interface.

[0057] In one implementation, the configuration parameter further includes a protocol content check field of any of the TCP protocols; and the parsing unit is further configured to:

[0058] Determine the target protocol content check class field of the target TCP protocol according to the configuration parameters;

[0059] According to the target protocol content verification class field, calling a general verification processor to verify the protocol content;

[0060] After the protocol content is verified, the target business logic processing class field of the target TCP protocol is determined according to the configuration parameters.

[0061] In one embodiment, the processing unit is further configured to:

[0062] In the case of adding any new TCP protocol, in response to the new addition operation on the protocol configuration item, the protocol field configuration item and the business logic processing class configuration item on the visualization configuration page, the configuration parameters are updated.

[0063] In a third aspect, an embodiment of the present application further provides a computer device, the computer device comprising: a memory and a processor. The memory stores instructions, the instructions are loaded and executed by the processor to implement the method in any of the above-mentioned embodiments. The memory and the processor communicate with each other through an internal connection path.

[0064] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program runs on a computer, the method in any one of the above-mentioned embodiments is implemented.

[0065] The advantages or beneficial effects of the above technical solution include at least:

[0066] This application supports port reuse and avoids waste of port resources by creating port configuration parameters on a visual configuration page. It can also provide a unified management interface. Business developers or managers can use this visual configuration page to understand which ports are currently exposed and which protocols are supported by the IoT device access platform. At the same time, this configuration parameter can agree on a set of programming paradigms. The decoding logic is processed by the server of the IoT device access platform, and the business logic is exposed to specific business developers in the form of a parent class interface. Overall, the decoding and business processing logic between multiple protocols are decoupled, reducing the error probability caused by mutual influence, thereby avoiding the situation where the TCP message cannot be parsed correctly, resulting in message omissions or message processing errors.

[0067] The above summary is for illustrative purposes only and is not intended to be limiting in any way. In addition to the illustrative aspects, embodiments and features described above, further aspects, embodiments and features of the present application will be readily apparent by reference to the accompanying drawings and the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the multiple drawings represent the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings only depict some embodiments disclosed in the present application and should not be regarded as limiting the scope of the present application.

[0069] Figure 1 A flowchart of a TCP data parsing method provided in this application;

[0070] Figure 2 An example diagram of a visual configuration page provided for this application;

[0071] Figure 3 An example diagram of the server-side decoding and business processing process of an IoT device access platform provided in this application;

[0072] Figure 4 An example diagram of a protocol field conversion result class instance provided by this application;

[0073] Figure 5 A structural block diagram of a TCP data parsing and processing device provided by this application;

[0074] Figure 6 This is a structural block diagram of a computer device provided in this application. DETAILED DESCRIPTION

[0075] In the following, only some exemplary embodiments are briefly described. As those skilled in the art will appreciate, the described embodiments may be modified in various ways without departing from the spirit or scope of the present application. Therefore, the drawings and descriptions are considered to be exemplary and non-restrictive in nature.

[0076] The TCP protocol is a streaming protocol. When decoding on the server side, it must deal with the problem of sticky packets and half packets. In addition, some custom protocols also define some verification logic to prevent data tampering, which also needs to be handled during decoding. When a single port is connected to a terminal device, the decoding logic is relatively easy to handle; when a single port corresponds to multiple terminal devices, the decoding processing logic is severely coupled, and TCP messages often cannot be correctly parsed, resulting in message omissions or message processing errors.

[0077] In the related technology, in the scenario of single-port single-protocol, according to the principle of development best practices, the decoding logic and business logic are usually processed separately; in the scenario of single-port multiple protocols, the decoding logic (such as protocol identification, protocol content parsing, decoding exception handling, etc.) usually relies on the design and coding capabilities of business developers, and the decoding logic of multiple protocols is usually written together, forming a strong coupling, and the decoding logic processing is also relatively complicated; after decoding, the subsequent business processing process is also easy to form a strong coupling. The essential reason is that when the capabilities of business developers are uneven, it is easy to write good quality program code.

[0078] Figure 1 A flowchart of a method for parsing and processing TCP data according to an embodiment of the present application is shown. Figure 1 As shown, the method may include the following steps:

[0079] S110, obtaining configuration parameters of the port for the IoT device to access the platform, and initializing the configuration parameters, where the configuration parameters are created according to various configuration items on the visual configuration page.

[0080] In one implementation, the configuration parameters may include, but are not limited to: N TCP protocols corresponding to the port, and the protocol field and business logic processing class field of any TCP protocol, where N is an integer greater than or equal to 1.

[0081] In this application, by creating a port for the IoT device access platform to connect to N types of TCP protocols, port reuse can be supported. When adding any new TCP protocol, there is no need to open a new port, which saves the port resources of the IoT device access platform and avoids waste of port resources. At the same time, it can also reduce the operation and maintenance workload of the IoT device access platform.

[0082] In specific implementation, the port may refer to the TCP listening port exposed by the backend service of the IoT device access platform. N TCP protocols may include various custom TCP protocols, such as the Internet of Vehicles protocol and the water meter protocol. The protocol fields of any TCP protocol may include fields such as the packet header, packet tail, and packet length, where these fields contain the starting position and field length in any TCP protocol. All business logic processing fields need to implement a parent interface specified by the backend service and rewrite the business logic processing method agreed upon in the parent interface.

[0083] In the specific implementation, for each field in the protocol field, its starting position can be calculated relative to the message header or message tail of the TCP protocol, or it can be calculated through a corresponding expression, and its field length can be a certain value, or it can be calculated through a corresponding expression. This application does not limit this.

[0084] As an example, port 9807 can be configured as follows Figure 2 The Internet of Vehicles protocol shown in Figure 1. Figure 2 Take the calculation of the offset of the starting position in the protocol field relative to the message header of the TCP protocol as an example.

[0085] In the present application, by configuring the starting position and field length of the corresponding field in the TCP protocol, it is convenient to retrieve the corresponding field value in the TCP protocol in the subsequent TCP field flow according to the configured starting position and field length.

[0086] In one embodiment, the visualization configuration page may include but is not limited to: port configuration items, protocol configuration items, protocol field configuration items, and business logic processing class configuration items. Among them, in the port configuration item, one port can be configured. In the protocol configuration item, N protocols can be configured. When N is greater than or equal to 2, the port can be used as a multiplexed port. In the protocol field configuration item, M fields of any TCP protocol can be configured, wherein the M fields include three fields: packet header, packet tail, and packet length, that is, M is an integer greater than or equal to 3. In the business logic processing class configuration item, a business logic processing class field of any TCP protocol can be configured.

[0087] As an example, in the protocol field configuration item, the two fields of main signaling and pseudo IP of any TCP protocol can also be configured, that is, the M fields also include the two fields of main signaling and pseudo IP. Figure 2 The protocol field in the Internet of Vehicles protocol shown also includes two fields: main signaling and pseudo IP.

[0088] In this application, through the visual configuration page, you can use the port as a dimension, and under each port, you can configure multiple TCP data decoding capabilities, and each TCP data decoding capability corresponds to a TCP protocol. At the same time, by creating the configuration parameters of each port through the visual configuration page, you can quickly add any new TCP protocol format or modify the existing TCP protocol format. Terminal equipment manufacturers do not need to modify their existing custom TCP protocols, and support the widespread use of corresponding TCP protocols. It can adapt to the TCP protocols of various terminal equipment manufacturers, and there is no need for the terminal equipment manufacturer to re-connect according to the protocol on the IoT device access platform side; and it can automatically read the configuration parameters to parse the TCP streaming data received by the port, which can greatly reduce the amount of code and the error rate when accessing any new TCP protocol, which is convenient for speeding up business development and reducing the probability of business development errors.

[0089] As an example, taking a customized Internet of Vehicles protocol as shown in Table 1 as an example, combined with Figure 2 Explain the instruction structure and names of the TCP protocol.

[0090] Table 1

[0091] 2 1 2 4 n 1 1 Baotou Main signaling Package Length Fake IP content check wrap tail

[0092] Packet header and packet trailer: refer to the frame boundary of the data. The packet header occupies 2 bytes and the packet trailer occupies 1 byte. The packet header is a fixed character (such as 0x29 0x29) and the packet trailer is represented by (0x0D).

[0093] Main signaling: occupies 1 byte, indicating the message type, such as 80 for the vehicle terminal location reporting information, 85 for the vehicle terminal to send a confirmation packet of the server command.

[0094] Packet length: refers to the length of the data packet content, starting from the first byte after the packet length byte position to the end of the packet, occupying 2 bytes.

[0095] Checksum: refers to the XOR of all bytes from the header of the data packet to the byte before the checksum, which occupies 1 byte.

[0096] Pseudo IP address: refers to the pseudo IP address converted by the device ID number through the specified method. It occupies 4 bytes.

[0097] It should be understood that the general principle of the custom TCP protocol format is that there are three fields that must exist: the packet header, the packet trailer, and the packet length. The packet header and the packet trailer are used as byte stream separators, which are generally special characters and have a length of 2-4 bytes.

[0098] In one implementation, after obtaining the configuration parameters, the configuration parameters can be initialized. For example, any configured TCP protocol can be loaded; then, for any TCP protocol, a decoder instance of any TCP protocol can be generated; finally, according to the decoder instance of any TCP protocol, a decoder of any TCP protocol can be generated to complete the initialization of the configuration parameters. For example, Figure 3 As shown, the process of initializing the configuration parameters includes loading the configured protocols and instantiating the corresponding decoder instance for each protocol to generate the corresponding decoder.

[0099] In the present application, by initializing the configuration parameters, any configured TCP protocol can be loaded and a decoder for any TCP protocol can be generated. That is, by parsing the visually configured configuration parameters, a decoder for the corresponding TCP protocol can be automatically generated, which is convenient for subsequent decoding of the corresponding TCP protocol accessed by the port. There is no need for business developers to handle the decoding logic. At the same time, the decoding logic of TCP data and the core business processing logic can be split and decoupled, thereby reducing the workload and error probability of business developers, and supporting the rapid access of new TCP protocols.

[0100] S120: When the port receives the TCP streaming data from the terminal device, the target protocol field in the TCP streaming data is read, and the target TCP protocol of the TCP streaming data is identified according to the target protocol field and the configuration parameters.

[0101] In one embodiment, the corresponding TCP protocol can be identified based on the packet header field. Specifically, when the port receives TCP streaming data from the terminal device, the target protocol field in the TCP streaming data, i.e., the packet header field, can be read. Based on the read packet header field and configuration parameters, the target TCP protocol of the TCP streaming data can be identified.

[0102] For example, if the bytes of the header field in the configuration parameters are equal to 0x29 0x29, indicating that it is a vehicle networking protocol, when the bytes of the read header field are equal to 0x29 0x29, it means that the target TCP protocol is a vehicle networking protocol.

[0103] In a specific implementation, the first two bytes in the TCP streaming data can be read to obtain the header field, that is, the header field is the first two bytes in the TCP streaming data. If the number of bytes currently read is less than two, the currently read bytes are cached and the subsequent bytes are waited for to arrive until the first two bytes in the TCP streaming data are read.

[0104] For example, if the number of bytes currently read is only 1, that is, the first byte in the TCP streaming data, then you can continue to wait for subsequent bytes to arrive until the first 2 bytes in the TCP streaming data are read.

[0105] As an example, in the process of identifying the target TCP protocol of TCP streaming data, some common abnormal scenarios can also be considered. For example, after traversing the protocol field of any TCP protocol in the configuration parameters, if no legal packet header field (such as 0x29 0x29) is identified, and the received byte stream data has reached a certain amount (such as more than 1M bytes), the currently received TCP streaming data is directly discarded to prevent memory overflow.

[0106] It should be understood that Figure 1 and Figure 3 As shown, step S120 is the protocol identification in the decoding process performed by the server of the IoT device access platform.

[0107] S130, parsing the target TCP protocol to obtain the protocol content.

[0108] In one implementation, the decoder of the target TCP protocol can be called to parse the legal complete byte stream data in the target TCP protocol to obtain the protocol content. Any TCP protocol decoder can inherit a base class, which can encapsulate processing logic such as processing of sticky packet and half-packet data and exception processing. The basis for judging the sticky packet and half-packet data is the values ​​corresponding to the packet header, packet tail and packet length fields.

[0109] In the related art, both the decoder and the decoding logic need to be implemented by the business developers themselves. In the scenario of multiple protocols on the same port, if different protocols are implemented by different business developers, it is easy to cause strong coupling. In this application, by calling the decoder of the target TCP protocol to parse the target TCP protocol, the legal and complete byte stream data in the target TCP protocol can be obtained, and the protocol content of the target TCP protocol can be obtained, that is, this application can separate the decoding logic such as sticky packet and half-packet processing, provide scalability (referring to support the addition of decoding logic without modifying the original decoding code), and the decoding process in this application can be automatically implemented, and the sticky packet and half-packet problem of TCP data under the same port can be automatically processed to ensure correct parsing of data. At the same time, the decoding implementation logic is shielded from the business developers, and the business developers can use it out of the box, which can improve development efficiency and reduce the probability of errors.

[0110] In an applicable scenario provided by the present application, before executing step S140, the protocol content of the target TCP protocol may also be verified.

[0111] In one implementation, the configuration parameters also include a protocol content check field of any TCP protocol.

[0112] In specific implementation, the target protocol content verification class field of the target TCP protocol can be determined according to the configuration parameters; then, according to the target protocol content verification class field, the general verification processor is called to verify the protocol content; after the protocol content verification passes, step S140 is executed.

[0113] Among them, by calling the verification processor, several common existing protocol content verification fields can be verified.

[0114] In the present application, by checking the class field according to the target protocol content and calling a general check processor to check the protocol content, the protocol content can be prevented from being tampered with.

[0115] S140. Determine the target business logic processing class field of the target TCP protocol according to the configuration parameters.

[0116] In one implementation, the protocol field and the business logic processing class field of any TCP protocol have been configured in the configuration parameters, and the target business logic processing class field of the target TCP protocol can be determined according to the configuration parameters.

[0117] S150. According to the target business logic processing class field, the business processing logic of the protocol content is exposed on the port in the form of a parent class interface.

[0118] In one implementation, the configuration parameters may also include a protocol field conversion result class field of any TCP protocol. The protocol field conversion result class field may be a json class by default, in which case the key is the field name in the TCP protocol, and the value is the value corresponding to the protocol field; the protocol field conversion result class field may also be a custom vo class, which is not limited in this application.

[0119] In one implementation, the target protocol field conversion result class field of the target TCP protocol can be determined according to the configuration parameters; then, according to the target protocol field conversion result class field, the protocol content is converted into a protocol field conversion result class instance. Figure 2-4 As shown, the fields and values ​​in the protocol content can be extracted and processed according to the target protocol field conversion result class field, and then assembled into a protocol field conversion result class instance.

[0120] In one implementation, a business logic processing class instance can be generated according to the target business logic processing class field. After decoding the TCP streaming data into a protocol field conversion result class instance, the protocol field conversion result class instance can be passed to the business logic processing class to expose the business processing logic of the protocol content on the port in the form of a parent class interface, so that it can be exposed to business developers, so that business developers only need to write business logic code and do not need to pay attention to the decoding logic, which can reduce the workload and error probability of business developers.

[0121] In specific implementation, after the protocol field conversion result class instance is passed to the business logic processing class instance, the business logic processing class instance can perform subsequent specific business logic processing.

[0122] In an applicable scenario provided by the present application, when any new TCP protocol is added, the configuration parameters can be updated in response to the new operations on the protocol configuration items, protocol field configuration items and business logic processing class configuration items on the visualization configuration page to complete the new access of any TCP protocol.

[0123] Among them, when adding any new TCP protocol, business developers only need to focus on business logic processing, that is, business developers only need to add business logic code, which can greatly speed up the access speed of any TCP protocol. In the subsequent process, through the business logic processing class field of any newly added TCP protocol, the business logic processing class instance of any newly added TCP protocol can be automatically generated, and its corresponding business logic processing method can be determined.

[0124] From the above description, it can be seen that this application supports port reuse and avoids waste of port resources by creating port configuration parameters on a visual configuration page. It can also provide a unified management interface. Business developers or managers can use this visual configuration page to understand which ports are currently exposed and which protocols are supported by the IoT device access platform. At the same time, this configuration parameter can agree on a set of programming paradigms. The decoding logic is processed by the server of the IoT device access platform, and the business logic is exposed to specific business developers in the form of a parent class interface. Overall, the decoding and business processing logic between multiple protocols are decoupled, reducing the error probability caused by mutual influence, thereby avoiding the situation where TCP messages cannot be parsed correctly, resulting in message omissions or message processing errors.

[0125] Figure 5 FIG. 1 is a block diagram showing a device for analyzing and processing TCP data according to an embodiment of the present application. Figure 5 As shown, the device may include:

[0126] The processing unit 210 is used to obtain the configuration parameters of the port for the IoT device to access the platform and initialize the configuration parameters, where the configuration parameters are created according to the configuration items on the visual configuration page, and the configuration parameters include N types of TCP protocols corresponding to the port, and the protocol field and the business logic processing class field of any TCP protocol, where N is an integer greater than or equal to 1;

[0127] The identification unit 220 is used to read the target protocol field in the TCP streaming data when the port receives the TCP streaming data from the terminal device, and identify the target TCP protocol of the TCP streaming data according to the target protocol field and the configuration parameters;

[0128] The parsing unit 230 is used to parse the target TCP protocol to obtain the protocol content; determine the target business logic processing class field of the target TCP protocol according to the configuration parameters; and expose the business processing logic of the protocol content in the form of a parent class interface on the port according to the target business logic processing class field.

[0129] In one implementation, the protocol field of any TCP protocol includes: a packet header, a packet tail, and a packet length, and the target protocol field is a packet header field; the identification unit 220 is specifically used to:

[0130] Read the packet header field in TCP streaming data;

[0131] Identify the target TCP protocol of TCP streaming data based on the packet header fields and configuration parameters.

[0132] In one implementation, the identification unit 220 is specifically configured to:

[0133] Read the first 2 bytes of the TCP streaming data to obtain the packet header field;

[0134] If the number of bytes currently read is less than 2, the bytes currently read are cached and wait for the subsequent bytes to arrive until the first 2 bytes in the TCP streaming data are read.

[0135] In one implementation, the processing unit 210 is specifically configured to:

[0136] Load any tcp protocol;

[0137] For any TCP protocol, generate any TCP protocol decoder instance;

[0138] Generate a decoder for any TCP protocol based on a decoder instance for any TCP protocol.

[0139] In one implementation, the parsing unit 230 is specifically configured to:

[0140] Call the decoder of the target TCP protocol, parse the legal and complete byte stream data in the target TCP protocol, and obtain the protocol content.

[0141] In one implementation, the configuration parameters also include a protocol field conversion result class field of any TCP protocol; the parsing unit 230 is specifically used to:

[0142] According to the configuration parameters, determine the target protocol field conversion result class field of the target TCP protocol;

[0143] According to the target protocol field conversion result class field, the protocol content is converted into a protocol field conversion result class instance;

[0144] Generate a business logic processing class instance based on the target business logic processing class field;

[0145] Pass the protocol field conversion result class instance to the business logic processing class to expose the business processing logic of the protocol content on the port in the form of a parent class interface.

[0146] In one implementation, the configuration parameters further include a protocol content check field of any TCP protocol; the parsing unit 230 is further configured to:

[0147] According to the configuration parameters, determine the target protocol content verification class field of the target TCP protocol;

[0148] According to the target protocol content verification class field, call the general verification processor to verify the protocol content;

[0149] After the protocol content is verified, the target business logic processing class field of the target TCP protocol is determined according to the configuration parameters.

[0150] In one implementation, the processing unit 210 is further configured to:

[0151] In the case of adding any new TCP protocol, the configuration parameters are updated in response to the new addition operation on the protocol configuration items, protocol field configuration items and business logic processing class configuration items on the visualization configuration page.

[0152] The functions of each unit in each device in the embodiments of the present application can be found in the corresponding description in the above method, and will not be repeated here.

[0153] Figure 6 FIG. 2 shows a block diagram of a computer device according to an embodiment of the present application. Figure 6 As shown, the computer device includes: a memory 310 and a processor 320. The memory 310 stores instructions, and the instructions are loaded and executed by the processor 320 to implement the TCP data parsing processing method in the above embodiment. The number of the memory 310 and the processor 320 can be one or more.

[0154] The computer device also includes:

[0155] The communication interface 330 is used to communicate with external devices and perform data exchange transmission.

[0156] If the memory 310, the processor 320 and the communication interface 330 are implemented independently, the memory 310, the processor 320 and the communication interface 330 can be connected to each other through a bus and communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0157] Optionally, in a specific implementation, if the memory 310, the processor 320 and the communication interface 330 are integrated on a chip, the memory 310, the processor 320 and the communication interface 330 can communicate with each other through an internal interface.

[0158] An embodiment of the present application provides a computer-readable storage medium storing a computer program, which implements the method provided in the embodiment of the present application when the program is executed by a processor.

[0159] An embodiment of the present application also provides a chip, which includes a processor for calling and executing instructions stored in a memory, so that a communication device equipped with the chip executes the method provided in the embodiment of the present application.

[0160] An embodiment of the present application also provides a chip, including: an input interface, an output interface, a processor and a memory, wherein the input interface, the output interface, the processor and the memory are connected via an internal connection path, and the processor is used to execute the code in the memory. When the code is executed, the processor is used to execute the method provided in the embodiment of the application.

[0161] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. It is worth noting that the processor may be a processor supporting the advanced RISC machines (ARM) architecture.

[0162] Further, optionally, the above-mentioned memory may include a read-only memory and a random access memory, and may also include a non-volatile random access memory. The memory may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. Among them, the non-volatile memory may include a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may include a random access memory (RAM), which is used as an external cache. By way of example but not limitation, many forms of RAM are available. For example, static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM) and direct rambus RAM (DR RAM).

[0163] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of computer program cosmetics. Computer program cosmetics include one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.

[0164] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples, unless they are contradictory.

[0165] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0166] Any process or method description in the flow chart or otherwise described herein can be understood to represent a module, fragment or portion of a code including one or more executable instructions for implementing the steps of a specific logical function or process. And the scope of the preferred embodiment of the present application includes other implementations, in which the functions may not be performed in the order shown or discussed, including in a substantially simultaneous manner or in a reverse order according to the functions involved.

[0167] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, which can be embodied 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 system that can fetch instructions from an instruction execution system, apparatus or device and execute instructions), or used in combination with these instruction execution systems, apparatuses or devices.

[0168] It should be understood that the various parts of the present application can be implemented with hardware, software, firmware or a combination thereof. In the above embodiments, multiple steps or methods can be implemented with software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the above embodiment method can be completed by instructing the relevant hardware through a program, which can be stored in a computer-readable storage medium, and when the program is executed, it includes one of the steps of the method embodiment or a combination thereof.

[0169] In addition, each functional unit in each embodiment of the present application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the above-mentioned integrated module is implemented in the form of a software functional module and sold or used as an independent cosmetic, it can also be stored in a computer-readable storage medium. The storage medium can be a read-only memory, a disk or an optical disk, etc.

[0170] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A method for analyzing and processing TCP data, characterized in that: include: Obtain configuration parameters of the port for the IoT device to access the platform, and initialize the configuration parameters, wherein the configuration parameters are created according to the configuration items on the visual configuration page, and the configuration parameters include N TCP protocols corresponding to the port, and the protocol field and the business logic processing class field of any TCP protocol, where N is an integer greater than or equal to 1; When the port receives the TCP streaming data from the terminal device, the target protocol field in the TCP streaming data is read, and the target TCP protocol of the TCP streaming data is identified according to the target protocol field and the configuration parameters; Parse the target TCP protocol to obtain the protocol content; Determine the target service logic processing class field of the target TCP protocol according to the configuration parameters; According to the target business logic processing class field, the business processing logic of the protocol content is exposed on the port in the form of a parent class interface.

2. The method according to claim 1, characterized in that The protocol fields of any of the TCP protocols include: a packet header, a packet tail, and a packet length, and the target protocol field is a packet header field; Reading the target protocol field in the TCP streaming data, and identifying the target TCP protocol of the TCP streaming data according to the target protocol field and the configuration parameters includes: Read the packet header field in the TCP streaming data; The target TCP protocol of the TCP streaming data is identified according to the packet header field and the configuration parameters.

3. The method according to claim 2, characterized in that Reading the packet header field in the TCP streaming data includes: Read the first 2 bytes of the TCP streaming data to obtain the packet header field; If the number of bytes currently read is less than 2, the bytes currently read are cached and the subsequent bytes are waited for to arrive until the first 2 bytes in the TCP streaming data are read.

4. The method according to claim 1, characterized in that: Initializing the configuration parameters includes: Load any of the tcp protocols; For any of the TCP protocols, generate a decoder instance of any of the TCP protocols; According to any one of the decoder instances of the TCP protocol, a decoder of any one of the TCP protocols is generated.

5. The method according to claim 4, characterized in that Parse the target TCP protocol and obtain the following protocol contents: The decoder of the target TCP protocol is called to parse the legal complete byte stream data in the target TCP protocol to obtain the protocol content.

6. The method according to claim 1, characterized in that The configuration parameters also include a protocol field conversion result class field of any of the TCP protocols; According to the target business logic processing class field, exposing the business processing logic of the protocol content on the port in the form of a parent class interface includes: Determine the target protocol field conversion result class field of the target TCP protocol according to the configuration parameters; According to the target protocol field conversion result class field, convert the protocol content into a protocol field conversion result class instance; Generate a business logic processing class instance according to the target business logic processing class field; The protocol field conversion result class instance is passed to the business logic processing class to expose the business processing logic of the protocol content on the port in the form of a parent class interface.

7. The method according to claim 1, characterized in that The configuration parameters also include a protocol content check field of any of the TCP protocols; the method also includes: Determine the target protocol content check class field of the target TCP protocol according to the configuration parameters; According to the target protocol content verification class field, calling a general verification processor to verify the protocol content; After the protocol content is verified, the target business logic processing class field of the target TCP protocol is determined according to the configuration parameters.

8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: In the case of adding any new TCP protocol, in response to the new addition operation on the protocol configuration item, the protocol field configuration item and the business logic processing class configuration item on the visualization configuration page, the configuration parameters are updated.

9. A tcp data analysis and processing device, characterized in that: include: A processing unit, used to obtain configuration parameters of a port for an IoT device to access the platform, and initialize the configuration parameters, wherein the configuration parameters are created according to various configuration items on a visual configuration page, and the configuration parameters include N types of TCP protocols corresponding to the port, and a protocol field and a business logic processing class field of any TCP protocol, where N is an integer greater than or equal to 1; an identification unit, configured to read a target protocol field in the TCP streaming data when the port receives the TCP streaming data from the terminal device, and identify a target TCP protocol of the TCP streaming data according to the target protocol field and the configuration parameters; A parsing unit, used for parsing the target TCP protocol to obtain the protocol content; Determine the target service logic processing class field of the target TCP protocol according to the configuration parameters; According to the target business logic processing class field, the business processing logic of the protocol content is exposed on the port in the form of a parent class interface.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed on a computer, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Message transmission method and device based on TCP protocol

    CN110086703A

  • Method and device for equipment to actively register to Internet of Things platform, equipment and medium

    CN114244648A

  • Method and system for generic multiprotocol convergence over wireless air interface

    US20080008159A1

Cited By

  • Interface analysis method and device, equipment and medium

    CN122179485A