A method and system for parsing a labeling protocol
By using a tag-based protocol parsing method and leveraging registration codes and tag databases, valid data segments can be quickly extracted, solving the problems of low parsing efficiency and security in high-concurrency multi-device communication and achieving efficient and secure communication protocol parsing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-13
- Publication Date
- 2026-03-31
AI Technical Summary
In multi-device communication, existing technologies suffer from low communication protocol parsing efficiency under high concurrency, making it easy to obtain useless information, and thread blocking issues make it difficult to quickly obtain effective information.
By obtaining the registration code of the external device and comparing it with the database, a connection is established. Then, the tag number and parsing algorithm in the tag database are used to extract valid data information segments, avoiding the parsing of lengthy fields and ensuring connection security and parsing efficiency.
It improves the efficiency of communication protocol parsing, ensures the accuracy and integrity of the information obtained, prevents intrusion by unknown devices, and enhances the security and stability of communication connections.
Smart Images

Figure CN116634041B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication protocols, and in particular to the tagging and parsing of communication protocols. Background Technology
[0002] Currently, in equipment testing and operation, we often encounter situations with high concurrency communication between multiple devices. Multiple devices need to collect a large number of signals simultaneously during operation. At the same time, with the addition of more and more online devices rather than designated devices, the communication protocols used by different devices have also increased. This results in the server needing to spend a lot of time parsing the communication protocols, and at the same time, it also needs to deal with the thread blocking problem caused by high concurrency.
[0003] In current related technologies, when parsing different communication protocols of multiple devices, different devices send a lot of strings, and the information streams corresponding to different communication protocols are in different positions. In addition, some long fields are parsed at the same time, resulting in low parsing efficiency, slow speed of obtaining effective information, and easy acquisition of useless information. Summary of the Invention
[0004] The purpose of this application is to provide a tag-based protocol parsing method and system that can quickly parse valid information segments when communicating with multiple devices, improving parsing efficiency while ensuring that the obtained valid information segments are not lost.
[0005] In a first aspect, embodiments of the present invention provide a tagging protocol parsing method, including:
[0006] Obtain the registration code from the external device's information stream, compare it with the existing registration code in the database, and establish a connection with the external device;
[0007] Obtain valid data segments from the external device's information stream, extract the identifiers from the segments, compare the identifiers with the tag database, and output the tag numbers that match the fields.
[0008] Obtain the tag number, find the tag parsing algorithm through the addressing method, and parse the valid data information segment through the tag parsing algorithm.
[0009] By adopting the above technical solution, when factory testing equipment communicates with multiple external devices, the system first prevents intrusion by unknown external devices based on their registration codes, thus preventing unauthorized injection into the communication and ensuring that the external devices establishing the connection are registered and recorded in the database, thereby improving connection security. To obtain valid data segments from the external device's information stream, the system compares the obtained valid data segments with the identifiers of the information parameter fields that the factory testing equipment must obtain. This avoids obtaining a large number of redundant data segments due to differences in communication protocols. Finally, the system extracts the necessary data segments from the lengthy data segments, reducing parsing time and increasing parsing efficiency. Then, existing parsing algorithms are used to parse each information segment one by one.
[0010] Optionally, the registration code may include at least a domain name field and a device name field.
[0011] By adopting the above technical solution, the domain name field and the device name field are reflected in the registration code, which can better reflect the current domain name status of the device, improve the security of the factory testing equipment as much as possible, and prevent the commonly used domain name of the device name field from suddenly changing or becoming abnormal. This can also prevent the device name field from being tampered with by a domain name from another location and then being used to establish a connection in disguise.
[0012] Optionally, after the steps of obtaining the registration code from the external device information stream, comparing it with the existing registration code in the database, and establishing a connection with the external device, the following steps are included:
[0013] Send heartbeat data packets to the server and listen for the server's response signals.
[0014] By adopting the above technical solution, when the server receives a heartbeat packet, it will immediately respond by obtaining the information of the factory testing equipment and sending it to the external device. At the same time, the factory testing equipment can monitor whether the external device is maintaining a connection, ensuring the stability of the communication connection.
[0015] Optionally, the feedback signal may include at least one external device location data field and one connection status field.
[0016] By adopting the above technical solution, the external device will send its own location data to the server. The server can then send the acquired external device location data fields and connection status back to the factory testing equipment. This allows the testing equipment to obtain real-time information on the health of the external device's connection environment and monitor whether the external device's location data is normal, thus improving connection security.
[0017] Optionally, the tag database includes at least header tags, delimiter tags, data tags, and end tags.
[0018] By adopting the above technical solution, when processing information flow, the presence of header tags, delimiter tags, data tags, and end tags in the tag database enables faster parsing of information segments. It allows for the acquisition of necessary data segments from the information segments by comparing them with the tags in the tag database, reducing the analysis of lengthy information segments.
[0019] Optionally, the tag parsing algorithm includes header marking, delimiter marking, data parsing algorithm, and end-of-label marking.
[0020] By adopting the above technical solution, the parsing algorithm can parse the information segments corresponding to the data header, delimiter, data, and end character fields to obtain the corresponding data content, thereby packaging it into a data packet that can be read by the factory testing equipment. When facing different communication protocols, it can exclude lengthy fields and only perform corresponding algorithm parsing on the necessary parameter information segments.
[0021] Optionally, the steps of obtaining the tag number, finding the tag parsing algorithm through the addressing method, and parsing the valid data information segment through the tag parsing algorithm further include:
[0022] Get the tag number and verify that the tag number includes at least one header tag number and at least one end-of-data tag number;
[0023] If the tag number does not include at least one header tag number and at least one end-of-line tag number, an incomplete information stream warning is sent.
[0024] By adopting the above technical solution, it is possible to verify whether the valid data information segment in the currently acquired external device information stream is a complete information segment. If there is a missing data header tag number or end tag number, it proves that this information segment is an incomplete information segment, which will affect the accuracy of the data in the data packet. Therefore, this judgment can ensure the integrity of subsequent information segment parsing.
[0025] Optionally, the step of obtaining the registration code from the external device information stream, comparing it with an existing registration code in the database, and establishing a connection with the external device further includes:
[0026] If no existing registration code is found in the database, a warning instruction is returned, and a listener is started.
[0027] By adopting the above technical solution, when no existing registration code corresponding to the external device is found, a warning instruction will be sent to the factory testing equipment, and the domain name port will be started to listen to prevent illegal request responses initiated by this external device.
[0028] Secondly, the tag-based protocol parsing system provided in this application adopts the following technical solution, including:
[0029] Matching and connection module: Obtains the registration code from the external device's information stream, compares it with the existing registration codes in the database, and establishes a connection with the external device;
[0030] Information segment acquisition module: Acquires valid data information segments from the information stream of external devices, extracts the identifiers in the information segments, compares the identifiers of the information segments with the fields in the tag database, and outputs the tag numbers with the same fields;
[0031] Information segment analysis module: Obtain the tag number, find the tag parsing algorithm through the addressing method, and parse the valid data information segment through the tag parsing algorithm.
[0032] By adopting the above technical solution, when the factory testing equipment communicates with multiple external devices, the matching connection module first prevents intrusion by unknown external devices based on the registration code of the external devices, preventing unauthorized injection into the communication and ensuring that the external devices establishing the connection are registered and recorded in the database, thus improving connection security. The information segment acquisition module obtains valid data segments from the external device's information stream by comparing them with the identifiers of the information parameter fields that the factory testing equipment must obtain. This avoids obtaining a large number of redundant data segments due to different communication protocols. Finally, the required data segments are extracted from the lengthy data segments, reducing parsing time and increasing parsing efficiency. Then, the parsing algorithm of the information segment analysis module parses each information segment one by one.
[0033] In summary, this application includes at least one of the following beneficial technical effects:
[0034] 1. By including the domain name and device name fields in the registration code, the current domain name status of the device can be better reflected, thereby improving the security of the factory testing equipment and preventing sudden changes or anomalies in the commonly used domain name of the device name field. This also prevents the device name field from being tampered with by domains from other locations and then used to establish a connection in disguise.
[0035] 2. By sending heartbeat data packets to the server, when the server receives the heartbeat packet, it will immediately respond by obtaining the information of the factory testing equipment and sending it to the external device. At the same time, the factory testing equipment can monitor whether the external device is maintaining a connection, ensuring the stability of the communication connection.
[0036] 3. By using a tag database that includes at least header tags, delimiter tags, data tags, and end tags, when processing information streams, the necessary data segments in the information segments can be obtained by comparing them with the tags in the tag database, thus reducing the analysis of lengthy information segments.
[0037] 4. By sending an incomplete information stream prompt when the tag number does not include at least one data header tag number and at least one end-of-stream tag number, it is possible to verify whether the valid data information segment in the currently acquired external device information stream is a complete information segment. If a data header tag number or an end-of-stream tag number is missing, it proves that this information segment is incomplete, which will affect the accuracy of the data in the data packet and ensure the integrity of subsequent information segment parsing. Attached Figure Description
[0038] Figure 1 This is a diagram of the information transmission main body of Embodiment 1 of this application;
[0039] Figure 2 This is a logic flowchart of Embodiment 1 of this application;
[0040] Figure 3 This is a logic flowchart of Embodiment 2 of this application;
[0041] Figure 4 This is a structural diagram of the tag database in embodiments 1 and 2 of this application; Detailed Implementation
[0042] The following is in conjunction with the appendix Figure 1 - Appendix Figure 4 This application will be described in further detail below.
[0043] Example 1: A tag-based protocol parsing method, referring to... Figure 1 , Figure 2 and Figure 3 ,include:
[0044] S101. Obtain the registration code from the external device's information stream, compare it with the existing registration codes in the database, and establish a connection with the external device.
[0045] The process involves obtaining the registration code from the external device's information stream. This information stream includes data segments, registration code segments, and other information segments. The registration code also includes at least a domain name field and a device name field. When the factory testing equipment receives the registration code from the external device's information stream, it can also obtain the external device's registered domain name and device identification name. This ensures that the device's registration in a certain region is legitimate. Only after confirming that the registration is legitimate can the factory testing equipment establish a connection with the external device.
[0046] S102. Obtain valid data segments from the external device's information stream, extract the identifiers from the segments, compare the identifiers with the tag database, and output the tag numbers that match the identifiers.
[0047] After establishing a connection, the factory testing equipment receives the information stream transmitted from external devices. Different external devices use different communication protocols, resulting in different information stream formats and additional redundant communication segments. For example, an information segment sent by external device A might be formatted as A1-A2-A3-A4, while an information segment sent by external device B might be formatted as A1-A3-A5-A6-A2. The different protocols of external devices A and B result in different information segment formats. The factory testing equipment may only need to read the A1-A2 data segment. In this case, the testing equipment will extract each data segment, compare the identifiers in A1, A2, and A3 with the identifiers stored in the tag database. If the fields match, the corresponding tag number will be output. The factory testing equipment can identify the required data segment in advance, without needing to parse the lengthy A4, A5, A6, etc., fields due to different communication protocols.
[0048] S103. Obtain the tag number, find the tag parsing algorithm using the addressing method, and parse the valid data information segment using the tag parsing algorithm.
[0049] By comparing and filtering with the label database, corresponding label numbers are identified. These include header labels, separator labels, data labels, and end-of-segment labels for a specific information segment. Each information segment required by the testing equipment will contain these labels. Then, using the parsing algorithm address corresponding to the label number in the database, the corresponding algorithm tool is found through address lookup. The data header and data are then parsed using the algorithm tool to obtain the parameters required by the factory testing equipment. The algorithm tools include, for example, header calibration, separator calibration, data parsing algorithms, and end-of-segment calibration. Header calibration, separator calibration, and end-of-segment calibration mark the data information segments for the complete detection and parsing of subsequent information segments, while the data parsing algorithm parses the data to extract the corresponding parameters required by the factory testing equipment.
[0050] The implementation principle of Embodiment 1 of this application is as follows: The registration code in the external device information stream is obtained. This external device information stream includes data information segments, registration code information segments, etc. The registration code also includes at least a domain name field and a device name field. When the factory testing equipment receives the registration code from the external device information stream, it can also obtain the registered domain name and device identification name of the external device. This ensures that the device's registration in a certain region is legal. Only after confirming legal registration can the factory testing equipment establish a connection with the external device. After establishing a connection, the factory testing equipment obtains the information stream transmitted from the external device. Different external devices have different communication protocols, which result in different information stream formats and additional redundant communication information segments. For example, the information segment sent by external device A is formatted as A1-A2-A3-A4, while the information segment sent by external device B is formatted as A1-A3-A5-A6-A2. External devices A and B have different information segment formats due to their different protocols. The factory testing equipment might only need two data segments (A1-A2) from the external device information it needs to read. In this case, the testing equipment will extract each data segment, remove the identifiers from A1, A2, and A3, and compare them with the identifiers stored in the tag database. If the fields match, the corresponding tag number will be output. The factory testing equipment can identify the data segments it needs in advance, without having to parse the lengthy fields (A4, A5, A6, etc.) due to different communication protocols. Finally, by comparing with the tag database, the corresponding tag numbers are selected. For example, a data segment's header tag, separator tag, data tag, and end tag. Each data segment needed by the testing equipment will contain these tags. Then, by using the parsing algorithm address corresponding to the tag number in the database, the corresponding algorithm tool is found through address lookup. The data header and data are parsed using the algorithm tool to obtain the parameters required by the factory testing equipment. The algorithm tools include, for example, data header marking, separator marking, data parsing algorithms, and end tag marking. The header marking, delimiter marking, and end-of-line marking refer to marking the data information segments for the purpose of detecting and parsing the completeness of subsequent information segments. The data parsing algorithm is used to parse the data and extract the parameters required by the corresponding factory testing equipment.
[0051] Example 2: A tag-based protocol parsing method, referring to... Figure 1 3 and Figure 4 ,include:
[0052] S1011. Obtain the registration code from the external device's information stream, compare it with existing registration codes in the database, and establish a connection with the external device.
[0053] The process involves obtaining the registration code from the external device's information stream. This information stream includes data segments, registration code segments, and other information segments. The registration code also includes at least a domain name field and a device name field. When the factory testing equipment receives the registration code from the external device's information stream, it can also obtain the external device's registered domain name and device identification name. This ensures that the device's registration in a certain region is legitimate. Only after confirming that the registration is legitimate can the factory testing equipment establish a connection with the external device.
[0054] S1012. If no existing registration code is found in the database, a warning command is returned, and a listener activation message is sent.
[0055] If no matching registration code is found in the database, the server will return a warning command and send the domain name information of the external device and the request response information back to the factory testing equipment, so that the factory testing equipment can monitor the external device's access behavior.
[0056] S102. Obtain valid data segments from the external device's information stream, extract the identifiers from the segments, compare the identifiers with the tag database, and output the tag numbers that match the identifiers.
[0057] After establishing a connection, the factory testing equipment receives the information stream transmitted from external devices. Different external devices use different communication protocols, resulting in different information stream formats and additional redundant communication segments. For example, an information segment sent by external device A might be formatted as A1-A2-A3-A4, while an information segment sent by external device B might be formatted as A1-A3-A5-A6-A2. The different protocols of external devices A and B result in different information segment formats. The factory testing equipment may only need to read the A1-A2 data segment. In this case, the testing equipment will extract each data segment, compare the identifiers in A1, A2, and A3 with the identifiers stored in the tag database. If the fields match, the corresponding tag number will be output. The factory testing equipment can identify the required data segment in advance, without needing to parse the lengthy A4, A5, A6, etc., fields due to different communication protocols.
[0058] S1031. Obtain the tag number, find the tag parsing algorithm using the addressing method, and parse the valid data information segment using the tag parsing algorithm.
[0059] By comparing and filtering with the label database, corresponding label numbers are identified. These include header labels, separator labels, data labels, and end-of-segment labels for a specific information segment. Each information segment required by the testing equipment will contain these labels. Then, using the parsing algorithm address corresponding to the label number in the database, the corresponding algorithm tool is found through address lookup. The data header and data are then parsed using the algorithm tool to obtain the parameters required by the factory testing equipment. The algorithm tools include, for example, header calibration, separator calibration, data parsing algorithms, and end-of-segment calibration. Header calibration, separator calibration, and end-of-segment calibration mark the data information segments for the complete detection and parsing of subsequent information segments, while the data parsing algorithm parses the data to extract the corresponding parameters required by the factory testing equipment.
[0060] S1032. Obtain the tag number and verify whether the tag number includes at least one header tag number and at least one end-of-line tag number. If the tag number does not include at least one header tag number and at least one end-of-line tag number, send an incomplete information stream notification.
[0061] For the tag numbers in the acquired information stream, the tag numbers are verified to ensure that there is at least one header tag number and one end tag number, thereby confirming that the information stream segment is accurately and completely captured, rather than being a missing information stream.
[0062] The implementation principle of Embodiment 2 of this application is as follows: The registration code is obtained from the external device information stream. This external device information stream includes data segments, registration code segments, and other information segments. The registration code also includes at least a domain name field and a device name field. When the factory testing device receives the registration code from the external device information stream, it can also obtain the external device's registered domain name and device identification name. This ensures that the device's registration in a certain region is legitimate. Only after confirming legitimate registration can the factory testing device establish a connection with the external device. If no matching registration code is found in the database, the server returns a warning command and sends back the external device's domain name information and request / response information to the factory testing device, allowing the factory testing device to monitor the external device's access behavior. After establishing a connection, the factory testing equipment receives the information stream transmitted from external devices. Different external devices use different communication protocols, resulting in different information stream formats and additional redundant communication segments. For example, an information segment sent by external device A might be formatted as A1-A2-A3-A4, while an information segment sent by external device B might be formatted as A1-A3-A5-A6-A2. The different protocols of external devices A and B result in different information segment formats. The factory testing equipment may only need to read the A1-A2 data segment. In this case, the testing equipment will extract each data segment, compare the identifiers in A1, A2, and A3 with the identifiers stored in the tag database. If the fields match, the corresponding tag number will be output. The factory testing equipment can identify the required data segment in advance, without needing to parse the lengthy A4, A5, A6, etc., fields due to different communication protocols. Finally, by comparing with the tag database, the corresponding tag numbers were selected. For each tag number in the obtained information stream, verification was performed to ensure that there was at least one header tag number and one end-of-line tag number. This confirmed that the extracted information stream was accurate and complete, rather than incomplete. For example, if an information segment has header tags, delimiter tags, data tags, and end-of-line tags, then each testing device's required information segment will contain these tags. Using the parsing algorithm address corresponding to the tag number in the database, the corresponding algorithm tool is found through address lookup. The data header and data are then parsed using the algorithm tool to obtain the parameters required by the factory testing equipment. The algorithm tools include, for example, header calibration, delimiter calibration, data parsing algorithms, and end-of-line tagging. Header calibration, delimiter calibration, and end-of-line tagging refer to calibrating the data information segment for the complete detection and parsing of subsequent information segments, while the data parsing algorithm parses the data to extract the corresponding parameters required by the factory testing equipment.
[0063] The embodiments described in this specific implementation are preferred embodiments of this application and are not intended to limit the scope of protection of this application. Identical components are represented by the same reference numerals. Therefore, all equivalent changes made to the structure, shape, and principle of this application should be covered within the scope of protection of this application.
Claims
1. A method of parsing a labeling protocol, characterized by, The application relates to a method for identifying and analyzing information flow transmitted by external devices, and belongs to the field of information flow analysis. The method comprises the following steps: acquiring a registration code in the information flow of the external device, comparing the registration code with an existing registration code in a database, and establishing a connection with the external device; acquiring an effective data information segment in the information flow of the external device, intercepting an identifier in the information segment, comparing the identifier of the information segment with a tag database in a field, and outputting a tag number of the same field, so that the required effective data information segment in the information flow transmitted by different external devices using different communication protocols is identified, and long fields of different communication protocols do not need to be parsed; acquiring the tag number, finding a tag analysis algorithm through an addressing method, and analyzing the effective data information segment through the tag analysis algorithm, wherein the tag analysis algorithm comprises a data head calibration, a separator calibration, a data analysis algorithm, and an end symbol calibration, and the tag analysis algorithm further comprises the following steps: acquiring the tag number, and checking whether the tag number comprises at least one data head tag number and at least one end symbol tag number. The registration code comprises at least one domain name field and one device name field. The method further comprises the following steps after the step of acquiring the registration code in the information flow of the external device, comparing the registration code with an existing registration code in a database, and establishing a connection with the external device:
2. The method of claim 1, wherein, Sending a heartbeat data packet to a server and listening to a feedback signal of the server.
3. The method of claim 1, wherein, The feedback signal comprises at least one external device positioning data field and one connection state field. The method further comprises the following steps after the step of acquiring the tag number and checking whether the tag number comprises at least one data head tag number and at least one end symbol tag number:
4. The method of claim 3, wherein, When the tag number does not comprise at least one data head tag number and at least one end symbol tag number, a prompt of incomplete information flow is sent.
5. The method of claim 1, wherein, The method further comprises the following steps after the step of acquiring the registration code in the information flow of the external device, comparing the registration code with an existing registration code in a database, and establishing a connection with the external device: If no existing registration code is matched in the database, a warning instruction is returned, and a listening start is sent.
6. The method of claim 1, wherein, The application relates to a method for identifying and analyzing information flow transmitted by external devices, and belongs to the field of information flow analysis. The method comprises the following steps: acquiring a registration code in the information flow of the external device, comparing the registration code with an existing registration code in a database, and establishing a connection with the external device; acquiring an effective data information segment in the information flow of the external device, intercepting an identifier in the information segment, comparing the identifier of the information segment with a tag database in a field, and outputting a tag number of the same field, so that the required effective data information segment in the information flow transmitted by different external devices using different communication protocols is identified, and long fields of different communication protocols do not need to be parsed; acquiring the tag number, finding a tag analysis algorithm through an addressing method, and analyzing the effective data information segment through the tag analysis algorithm, wherein the tag analysis algorithm comprises a data head calibration, a separator calibration, a data analysis algorithm, and an end symbol calibration, and the tag analysis algorithm further comprises the following steps: acquiring the tag number, and checking whether the tag number comprises at least one data head tag number and at least one end symbol tag number.
7. A tagged protocol parsing system characterized by,
Citation Information
Patent Citations
Method and system for equipment to safely access Internet of things
CN102882676A
Message processing method and device
CN104144156A
Configurable communication protocol identifying and parsing system
CN104780140A