Protocol test optimization system and method based on Hash survival sequence
Through the hash survival sequence optimization system, the problems of resource waste and excessive time in traditional protocol testing are solved, and an efficient testing process is achieved. It is suitable for power supply, communication and Internet of Things equipment, and reduces testing costs.
Patent Information
- Application Number
- CN202511106146.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-08
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-08-08
AI Technical Summary
Traditional protocol testing suffers from problems of resource waste and excessively long testing time. Especially in power supply and fast charging protocol testing, frequent message sending leads to increased load on the test machine and network bandwidth occupation.
A protocol test optimization system based on hash survival sequence is adopted. The test item sequence is stored in a hash table. The status check module is used to query the sequence status, skip unnecessary test steps, reduce repeated operations, and use the status update module to dynamically manage the sequence status.
It improves test efficiency, reduces resource consumption, shortens test time and network bandwidth usage, is suitable for power supply, communication and IoT equipment, reduces test tool adaptation costs, and supports multiple protocol types.
Smart Images

Figure CN120639673A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of protocol testing, and in particular to a protocol testing optimization system and method based on hash survival sequences. Background Art
[0002] With the rapid development of the Internet of Things, industrial automation, and communications technologies, protocol testing has become a critical step in ensuring device functionality and reliability. Its core principle is to ensure strict compliance with protocol specifications by sending specific messages such as connection confirmation and status queries and verifying device responses. For example, power supply protocol testing requires frequent ping messages to monitor device connection status. In the fast charging protocol field, both USB PD and UFCS standards require periodic capacity negotiation messages to accurately configure power. However, traditional protocol testing generally adopts a linear process, which has significant disadvantages. Every time a new test item is performed, public messages must be sent repeatedly, which greatly prolongs the test time and seriously wastes resources. In the power supply protocol test scenario, before each test item is started, a handshake must be completed with the other device and a Ping message must be sent to ensure that the communication link is unobstructed. A single operation takes about 10ms. If there are 1,000 test items, the status confirmation link alone will consume an additional 10 seconds. Fast charging protocol testing also faces the same problem. The Source_Capabilities message of the PD protocol and the negotiation packet of UFCS are frequently sent, which not only increases the load on the test machine and occupies network bandwidth, but also causes the CPU usage of the test machine to soar due to the large number of message parsing.
[0003] Therefore, how to improve testing efficiency is a current research direction. Summary of the Invention
[0004] (1) Purpose of the invention The purpose of the present invention is to provide a protocol test optimization system and method based on hash survival sequence, which can skip unnecessary test steps through sequence status, reduce resource consumption and improve test efficiency.
[0005] (2) Technical solution To solve the above problems, the present invention provides a protocol test optimization system based on hash survival sequence, comprising: Sequence management module, status check module, test execution module and status update module; The sequence management module is used to store a sequence of multiple test items, and the sequence is stored based on a hash table; The status checking module is connected to the sequence management module, and the status checking module is used to query the corresponding sequence status in the sequence management module based on the test items; The test execution module is connected to the status checking module, and the test execution module is used to execute the test according to the sequence status of the test items; The status update module is connected to the sequence management module and the test execution module, and is used to update the corresponding sequence in the sequence management module according to the execution result of the test execution module.
[0006] In another aspect of the present invention, preferably, the test execution module includes a jump unit and a sending unit. The jump unit is configured to skip sending the test item and execute a preset test path associated with the surviving sequence when the status check module determines that the sequence status is surviving; The sending unit is configured to generate a test message of the test item and send the test message to a target node to wait for a response when the status checking module determines that the sequence status is dead.
[0007] In another aspect of the present invention, preferably, the state update module includes a live marking unit and a dead marking unit; The survival marking unit is configured to mark the state of the corresponding sequence in the sequence management module as alive when the sending unit receives a response message that complies with a preset format; The death marking unit is configured to mark the state of the corresponding sequence as dead when the sending unit does not receive a response message or times out.
[0008] In another aspect of the present invention, preferably, the status checking module includes: a hash generation unit, an index query unit, and a status parsing unit; The hash generation unit is used to perform a hash operation on the input test item to generate a corresponding hash value; The index query unit is configured to use the hash value as a key value to query a matching sequence record in the hash table of the sequence management module; The state parsing unit is used to extract the current state field from the sequence record and output the sequence state.
[0009] In another aspect of the present invention, preferably, the sequence management module includes: a hash storage unit and a state maintenance unit; The hash storage unit is used to store a sequence of multiple test items based on a hash table structure; The state maintenance unit is used to respond to the request of the state update module, rewrite the sequence state in the hash storage unit, and generate a state change log.
[0010] In another aspect of the present invention, preferably, a protocol test optimization method based on hash survival sequence includes: Based on the started test item, query the sequence status of the test item; Execute the test according to the sequence status of the test items and obtain the test results; According to the test result, the sequence status of the test item is updated.
[0011] In another aspect of the present invention, preferably, querying the sequence status of the test item based on the activated test item includes: Performing a hash operation on the test item to generate a hash value; Using the hash value as a key value, searching for matching sequence records in the hash table; The current state field and the timestamp field are extracted from the sequence record. If the timestamp is within a preset validity period and the state is alive, the sequence state is determined to be alive; otherwise, it is determined to be dead.
[0012] In another aspect of the present invention, preferably, performing a test and obtaining a test result according to the sequence status of the test items includes: If the sequence status is surviving, skipping the sending operation of the test item and executing the preset test path associated with the surviving sequence; If the sequence status is dead, a test message of the test item is generated and sent to a target node, and a response is waited for.
[0013] In another aspect of the present invention, preferably, if the sequence status is dead, generating a test message for the test item and sending the test message to a target node, and waiting for a response, includes: If a response message that conforms to a preset format is received, the preset test path associated with the survival sequence is executed; If no response message is received or the received response message times out, the test fails.
[0014] In another aspect of the present invention, preferably, updating the sequence status of the test item according to the test result includes: If a response message that conforms to the preset format is received, the state of the sequence is updated to alive: If no response message is received or the received response message times out, the state of the corresponding sequence is marked as dead.
[0015] (3) Beneficial effects The above technical solution of the present invention has the following beneficial technical effects: This invention uses sequence states to skip unnecessary test steps, reducing repeated testing, reducing resource consumption, and improving test efficiency. It supports a variety of test messages and protocol types, making it suitable for devices in multiple fields such as power supply, communications, and the Internet of Things, while reducing the cost of test tool adaptation. Sequence survival time can be dynamically configured on demand, enabling precise adaptation for both fast-responding and slow-responding devices. A state update module drives survival management and asynchronous updates, reducing manual intervention and ensuring test consistency. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 is an overall flow chart of an embodiment of the present invention; Figure 2 is a flow chart of another embodiment of the present invention; Figure 3 It is a timing diagram of a test execution module according to an embodiment of the present invention. DETAILED DESCRIPTION
[0017] To make the objectives, technical solutions, and advantages of the present invention more clearly understood, the present invention will be further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings. It should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present invention.
[0018] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0019] In addition, the technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0020] Example 1 A protocol test optimization system based on hash survival sequence, suitable for protocol testing of power supply equipment, communication equipment and other scenarios, including: Sequence management module, status check module, test execution module and status update module; The sequence management module is used to store a sequence of multiple test items. The sequence is stored based on a hash table. The key information of the test item is mapped to a hash value using a hash function. The corresponding test sequence is quickly located and accessed through the hash value, which greatly improves the efficiency of data retrieval. Taking the power supply equipment protocol test as an example, it may include multiple test items such as power supply parameter configuration and communication protocol interaction. The sequences of these test items are stored in an orderly manner in the hash table. When a test item sequence needs to be retrieved, the system can complete the search in a very short time. The sequence of the test item records the message identifier, sequence status, survival time and last update time. The sequence is stored in a hash table. The key is the message identifier, such as PD's "Ping" and UFCS's "Negotiation", and the value is the state structure. The query time complexity is O(1). The survival time can be configured to 5-30 seconds. The survival time can be dynamically adjusted according to the protocol, such as the high-frequency interaction of PD, the negotiation cycle of UFCS or the response speed of the device.
[0021] In this embodiment, further, the sequence management module includes: a hash storage unit and a state maintenance unit; The hash storage unit is used to store a sequence of multiple test items based on a hash table structure; the corresponding hash value is calculated through a hash function, and the test item sequence is stored in the corresponding position in the hash table. When the test execution module needs to call a certain test item sequence, it can also quickly locate the storage location based on the hash function and efficiently obtain the required data, avoiding the problem of low retrieval efficiency caused by the huge amount of data in traditional storage methods. Even in complex protocol testing scenarios of communication equipment, faced with massive test item sequence data, the hash storage unit can rely on its efficient storage and retrieval mechanism to ensure that the system responds quickly to test requirements. Specifically, Table 1 shows the data structure of the sequence. The data structure of the sequence is shown in Table 1. Table 1 Sequence data structure
[0022] The state maintenance unit is configured to respond to a request from the state update module, rewrite the sequence state in the hash storage unit, and generate a state change log. When the test execution module is testing a test item, the state update module transmits the test result to the state maintenance unit. The state maintenance unit then rewrites the state of the corresponding test item sequence in the hash storage unit based on the test result, such as survival.
[0023] The status check module is connected to the sequence management module, and the status check module is used to query the corresponding sequence status in the sequence management module based on the test item; by querying the sequence status in real time, it provides a basis for the test process of the subsequent test execution module. When the test item is triggered, the status check module quickly queries the surviving sequence through the message ID and returns the sequence status flag. The status check module supports batch queries, such as checking the Ping and Source_Capabilities of the PD at the same time; through the interface of the sequence management module, the sequence status is quickly located. The status check module optimizes the batch query logic and is suitable for multiple types of protocol test scenarios. The query time complexity is O(1). The status check module outputs the sequence status to drive the test execution decision. Further, in this embodiment, the status check module includes: a hash generation unit, an index query unit and a status parsing unit; The hash generation unit is used to perform a hash operation on the input test item to generate a corresponding hash value; the hash operation converts the test item into a unique identifier, i.e., a hash value, to quickly locate its associated record in the system; the index query unit is used to use the hash value as a key value to query the matching sequence record in the hash table of the sequence management module; based on the key-value pair storage structure of the hash table, the sequence record is directly located by the hash value, i.e., the key, to achieve a query efficiency of O(1) time complexity. The state parsing unit is used to extract the current state field from the sequence record and output the sequence state.
[0024] The test execution module is connected to the status checking module, and the test execution module is used to execute the test according to the sequence status of the test items; Figure 1 shows an overall flow chart of an embodiment of the present invention, Figure 2 is a flow chart of another embodiment of the present invention, such as Figure 1 and Figure 2 As shown, further, in this embodiment, the test execution module includes a jump unit and a sending unit, The jump unit is used to skip the sending operation of the test item and execute the preset test path associated with the survival sequence when the status check module determines that the sequence status is survival; when the status check module determines that the sequence status is survival, it means that the sequence corresponding to the test item has been verified and passed in the previous test process and is in normal working state. At this time, the jump unit plays a role and skips the sending operation of the test item. The skip mechanism avoids repeated testing of known normal sequences, greatly improving the test efficiency. At the same time, the jump unit will execute the preset test path associated with the survival sequence. The preset test path is pre-set according to the system logic and test requirements, and is intended to conduct further in-depth testing of other functions or links associated with the survival sequence to ensure that the entire system can operate stably on the basis of the normal operation of the sequence. Skip the test step and directly call the subsequent test item entry function; the jump mechanism reduces the sending of redundant messages by about 50%, reducing test time and bandwidth occupancy.
[0025] The sending unit is used to generate a test message for the test item and send the test message to the target node to wait for a response when the status check module determines that the sequence status is dead. The sending unit is mainly responsible for processing the sequence status determined to be dead by the status check module. When the sequence status is determined to be dead, it indicates that the sequence corresponding to the test item has not gone through the process of sending and waiting for a response within the previous survival time. The sending unit now generates a test message for the test item and sends it to the target node, and then enters the waiting for a response stage. The result of the response includes executing the preset test path associated with the survival sequence when a response message that conforms to the preset format is received; when no response message is received or the received response message times out, the test fails.
[0026] The state update module is connected to the sequence management module and the test execution module, and is used to update the corresponding sequence in the sequence management module according to the execution result of the test execution module. Furthermore, in this embodiment, the state update module includes a live marking unit and a dead marking unit; The survival marking unit is configured to mark the state of the corresponding sequence in the sequence management module as alive when the sending unit receives a response message that complies with a preset format; The death marking unit is used to mark the status of the corresponding sequence as dead when the sending unit does not receive a response message or times out. If the expected response is received, such as the ACK of the PD and the negotiation confirmation of the UFCS, the sequence is revived and the survival time is reset; if it times out, such as the tACKReceive time, the death status is marked. The module operates asynchronously and records timestamps to ensure state consistency in high-concurrency scenarios. The application scenarios of this embodiment are wide, including: power supply equipment testing, optimizing the verification process of Ping messages and ACK responses, and improving batch testing efficiency. Communication equipment testing, managing multiple protocol messages, such as status queries and handshakes, and reducing redundant communications. Internet of Things device testing, supporting parallel testing of multiple devices, and dynamically adjusting the survival time to adapt to heterogeneous networks. The automated testing platform is integrated into the test machine as a general optimization module to improve overall performance.
[0027] This invention uses sequence states to skip unnecessary test steps, reducing repeated testing, reducing resource consumption, and improving test efficiency. It supports a variety of test messages and protocol types, making it suitable for devices in multiple fields such as power supply, communications, and the Internet of Things, while reducing the cost of test tool adaptation. Sequence survival time can be dynamically configured on demand, enabling precise adaptation for both fast-responding and slow-responding devices. A state update module drives survival management and asynchronous updates, reducing manual intervention and ensuring test consistency.
[0028] Example 2 A protocol testing optimization method based on hash survival sequence, such as Figure 1 and Figure 2 Shown, including: Based on the activated test items, query the sequence status of the test items; initialize the test item sequence and load the configuration, such as a ping survival time of 10 seconds. Further, in this embodiment, querying the sequence status of the test items based on the activated test items includes: performing a hash operation on the test items to generate a hash value; using the hash value as a key value to query the hash table for a matching sequence record; extracting the current status field and timestamp field from the sequence record; if the timestamp is within a preset validity period and the status is alive, then determining the sequence status is alive; otherwise, determining it is dead.
[0029] Executing a test and obtaining a test result according to the sequence status of the test item; jumping or sending a message according to the sequence status flag, and feeding back the result to the status update module; further, in this embodiment, executing a test and obtaining a test result according to the sequence status of the test item includes: If the sequence status is survival, skip sending the test item and execute the preset test path associated with the survival sequence; skip the test steps and directly call the subsequent test item entry function; the skip mechanism reduces the sending of redundant messages by about 50%, reducing test time and bandwidth usage.
[0030] If the sequence status is dead, generate a test message for the test item and send the test message to the target node, waiting for a response, wherein the response includes executing a preset test path associated with the survival sequence if a response message that conforms to a preset format is received; if no response message is received or the received response message times out, the test fails.
[0031] Updating the sequence status of the test item according to the test result includes: If a response message that conforms to a preset format is received, the state of the sequence is updated to alive; if no response message is received or the received response message times out, the state of the corresponding sequence is marked as dead.
[0032] The following is a partial breakdown of the protocol layer tests for the GPMI power compliance test. Each test item requires a handshake and a Ping message response for protocol identification. Typically, the Ping message test requires the PSE to respond to the Ping message and reply with an ACK message. The test steps include: After a successful handshake between the tester and the PSE, the tester sends a Ping message to the PSE and checks that it receives the ACK message within tACKReceive (100ms). Test result: Receiving an ACK indicates a pass.
[0033] Device_Information message test requirements: The PSE responds to the Get_Device_Info message with an ACK and a Device_Information message. Test steps: After a successful handshake between the tester and the PSE, the tester sends a Ping message to complete GPMI protocol identification. The tester then sends a Get_Device_Info message and checks that the ACK is received within tACKReceive (100ms) and the Device_Information message is received within tSenderResponseMsg1 (200ms). Test result: The test passes if the ACK and Device_Information messages are returned within the specified time.
[0034] The test method of this embodiment includes: initializing the survival sequence, creating a hash table to store the message status, the key is the message ID, such as "Handshake" and "Ping", and the value is a structure containing the survival status, survival / death, survival time, such as seconds and the last update time. The hash table uses the hash value of the message ID to map the storage location, the query time complexity is O(1), and the memory usage is <100 bytes. Batch insertion and query are supported, such as processing the handshake, Ping and Get_Device_Info states at the same time. Table 2 is the data structure of the handshake, Ping and Get_Device_Info states. The data structure of the handshake, Ping and Get_Device_Info states is shown in Table 2. Table 2 Hash table storage message status
[0035] In the traditional test process, each test item performs a handshake in accordance with the test requirements, which takes 20ms, a Ping message in 10ms, and tACKReceive in 100ms.
[0036] The repeated handshake and ping times in 100 test items are: 100 × (20ms + 10ms) = 3000ms, increasing the CPU load by about 20%.
[0037] In this embodiment, after a test item is triggered, the status check module enters the "checking state" and queries the management module for a ping. If the test item is in the dead state, the test execution module sends a ping. After receiving an ACK, the status update module enters the update state and resurrects the ping. If the test item is alive, the test execution module enters the jump state and invokes subsequent tests.
[0038] Figure 3 FIG. 1 shows a timing diagram of a test execution module according to an embodiment of the present invention. Figure 3 As shown, at time t0: the status check module confirms that the ping is alive, and the test execution module skips the test. At time t1: the ping is not alive, and the test execution module sends a ping. At time t2: after receiving the ACK, the status update module reactivates the ping and updates the survival time. At time t3: the test execution module executes the subsequent test items.
[0039] Test results: 100 test items were tested. While maintaining a normal communication link, 30 handshakes and 60 ping messages were skipped, saving approximately 1200ms. The test machine's CPU usage decreased by 15%, and network bandwidth usage was reduced by 20%.
[0040] This invention optimizes protocol testing through efficient storage in the survival sequence management module, rapid querying in the status check module, dynamic hopping in the test execution module, and closed-loop management in the status update module. Event-driven communication between modules supports high concurrency and is suitable for scenarios such as power supply equipment and communications equipment, with low resource consumption and high automation.
[0041] It should be understood that the above-described specific embodiments of the present invention are merely illustrative or illustrative of the principles of the present invention and do not constitute limitations of the present invention. Therefore, any modifications, equivalent substitutions, improvements, etc. made without departing from the spirit and scope of the present invention should be included within the scope of protection of the present invention. In addition, the appended claims are intended to cover all variations and modifications that fall within the scope and metes and bounds of the appended claims, or equivalents thereof.
[0042] The present invention has been described above with reference to the embodiments thereof. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present invention. The scope of the present invention is defined by the appended claims and their equivalents. Those skilled in the art may make various substitutions and modifications without departing from the scope of the present invention, and such substitutions and modifications are intended to fall within the scope of the present invention.
[0043] Although the embodiments of the present invention have been described in detail, it should be understood that the various changes, substitutions, and alterations could be made hereto without departing from the spirit and scope of the invention.
[0044] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the implementation methods. Those skilled in the art will readily appreciate that other variations or modifications based on the above descriptions are possible. It is not necessary and impossible to enumerate all implementation methods here. Obvious variations or modifications arising therefrom remain within the scope of protection of the present invention.
Claims
1. A protocol test optimization system based on hash survival sequence, characterized in that: include: Sequence management module, status check module, test execution module and status update module; The sequence management module is used to store a sequence of multiple test items, and the sequence is stored based on a hash table; The status checking module is connected to the sequence management module, and the status checking module is used to query the corresponding sequence status in the sequence management module based on the test items; The test execution module is connected to the status checking module, and the test execution module is used to execute the test according to the sequence status of the test items; The status update module is connected to the sequence management module and the test execution module, and is used to update the corresponding sequence in the sequence management module according to the execution result of the test execution module.
2. The protocol test optimization system based on hash survival sequence according to claim 1, characterized in that: The test execution module includes a jump unit and a sending unit, The jump unit is configured to skip sending the test item and execute a preset test path associated with the surviving sequence when the status check module determines that the sequence status is surviving; The sending unit is configured to generate a test message of the test item and send the test message to a target node to wait for a response when the status checking module determines that the sequence status is dead.
3. The protocol test optimization system based on hash survival sequence according to claim 2 is characterized in that: The state update module includes a survival marking unit and a death marking unit; The survival marking unit is configured to mark the state of the corresponding sequence in the sequence management module as alive when the sending unit receives a response message that complies with a preset format; The death marking unit is configured to mark the state of the corresponding sequence as dead when the sending unit does not receive a response message or times out.
4. The protocol test optimization system based on hash survival sequence according to claim 1, characterized in that: The status check module includes: a hash generation unit, an index query unit and a status parsing unit; The hash generation unit is used to perform a hash operation on the input test item to generate a corresponding hash value; The index query unit is configured to use the hash value as a key value to query a matching sequence record in the hash table of the sequence management module; The state parsing unit is used to extract the current state field from the sequence record and output the sequence state.
5. The protocol test optimization system based on hash survival sequence according to claim 1 is characterized in that: The sequence management module includes: a hash storage unit and a state maintenance unit; The hash storage unit is used to store a sequence of multiple test items based on a hash table structure; The state maintenance unit is used to respond to the request of the state update module, rewrite the sequence state in the hash storage unit, and generate a state change log.
6. A protocol test optimization method based on hash survival sequence, characterized in that: include: Based on the started test item, query the sequence status of the test item; Execute the test according to the sequence status of the test items and obtain the test results; According to the test result, the sequence status of the test item is updated.
7. The protocol test optimization method based on hash survival sequence according to claim 6 is characterized in that: The querying of the sequence status of the test item based on the started test item includes: Performing a hash operation on the test item to generate a hash value; Using the hash value as a key value, searching for matching sequence records in the hash table; The current state field and the timestamp field are extracted from the sequence record. If the timestamp is within a preset validity period and the state is alive, the sequence state is determined to be alive; otherwise, it is determined to be dead.
8. The protocol test optimization method based on hash survival sequence according to claim 7 is characterized in that: Executing the test according to the sequence status of the test items and obtaining the test results include: If the sequence status is surviving, skipping the sending operation of the test item and executing the preset test path associated with the surviving sequence; If the sequence status is dead, a test message of the test item is generated and sent to a target node, and a response is waited for.
9. The protocol test optimization method based on hash survival sequence according to claim 8, characterized in that: If the sequence status is dead, generating a test message for the test item and sending the test message to a target node, and waiting for a response, including: If a response message that conforms to a preset format is received, the preset test path associated with the survival sequence is executed; If no response message is received or the received response message times out, the test fails.
10. The protocol test optimization method based on hash survival sequence according to claim 7, characterized in that: The updating of the sequence status of the test item according to the test result includes: If a response message that conforms to the preset format is received, the state of the sequence is updated to alive: If no response message is received or the received response message times out, the state of the corresponding sequence is marked as dead.
Citation Information
Patent Citations
Protocol fuzz testing method and device based on test case automatic generation
CN116248337A
Stateful protocol difference fuzzy test method and system based on behavior difference guidance
CN116805928A
Network protocol automatic fuzzy test system
CN119211091A
Method and apparatus for dynamic protocol conformancetesting
KR1020010000267A
Test executive system with automatic expression logging and parameter logging
US20060230318A1