Dual-computer communication quality detection method, apparatus and device, and storage medium
By initializing counters between devices and dynamically updating the counter values to assess communication quality, the problem of low efficiency in manual testing is solved, and efficient and accurate dual-machine communication quality detection is achieved.
Patent Information
- Application Number
- CN202511719833.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-02-13
AI Technical Summary
In existing technologies, the quality detection of dual-machine communication relies on manual testing, which results in low testing efficiency and low accuracy, makes it difficult to conduct long-term continuous testing, and introduces subjective human error.
By initializing counters between devices and dynamically updating the counter values based on whether response data is received within a preset time, the communication quality is quantitatively evaluated and automated communication quality results are output.
It enables long-term, continuous automated testing, reducing manpower and time costs, improving testing efficiency, avoiding errors from subjective human judgment, and ensuring testing accuracy.
Smart Images

Figure CN121530889A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of communication quality testing, and in particular to a method, apparatus, device and storage medium for testing the communication quality of two machines. Background Technology
[0002] In embedded systems fields such as smart homes and industrial control, the reliability of dual-machine communication is crucial to ensuring stable system operation; therefore, it is essential to conduct thorough and effective testing of the quality of dual-machine communication during production testing and R&D verification.
[0003] Currently, the quality of communication between two devices is mostly tested manually. For example, the tester triggers a specific action on one end of the device, such as controlling the motor to rise and fall simultaneously, and observes whether the other end of the device can respond synchronously, in order to determine whether the communication data packets are lost.
[0004] However, this testing method, which relies on manual triggering and visual observation, has obvious limitations: First, for a large amount of test data, this method requires a lot of manpower and time, making it difficult to conduct long-term continuous testing and resulting in low testing efficiency; second, human judgment is subjective and prone to error, and cannot guarantee testing accuracy. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for dual-machine communication quality testing, which can realize automated dual-machine communication quality testing and significantly improve testing efficiency and accuracy.
[0006] In a first aspect, this application provides a method for detecting the quality of dual-device communication, applied to a communication system including a first device and a second device, comprising: after the first device and the second device complete a handshake operation, initializing a plurality of first counters in the first device and controlling the first device to send a test command to the second device; dynamically updating the first count values corresponding to the plurality of first counters based on whether the first device receives response data returned by the second device within a preset time; evaluating the communication quality between the first device and the second device based on the updated first count values, and outputting a communication quality result.
[0007] In one possible implementation, the plurality of first counters includes a first transmit counter, a first receive counter, a first retransmit counter, and a first failure counter.
[0008] In one possible implementation, initializing the plurality of first counters in the first device specifically includes: setting the first transmission count value corresponding to the first transmission counter, the first reception count value corresponding to the first reception counter, the first retransmission count value corresponding to the first retransmission counter, and the first failure count value corresponding to the first failure counter to zero, respectively.
[0009] In one possible implementation, controlling the first device to send a test command to the second device specifically includes: detecting whether the current first receive count value corresponding to the first receive counter is greater than a preset threshold; if so, incrementing the first send count value corresponding to the first send counter to obtain an updated first send count value, and obtaining the current first send count value of the first send counter and the current first receive count value of the first receive counter; otherwise, directly obtaining the current first send count value of the first send counter and the current first receive count value of the first receive counter; constructing a test command based on the current first send count value and the current first receive count value, and sending the test command to the second device.
[0010] In one possible implementation, the first count value corresponding to the plurality of first counters is dynamically updated based on whether the first device receives response data returned by the second device within a preset time. Specifically, this includes: starting a timeout timer after the first device sends a test command to the second device; if the first device does not receive response data returned by the second device within the preset time, decrementing the instruction count value corresponding to the instruction counter to obtain an updated instruction count value; performing an update operation on the first count value corresponding to the plurality of first counters based on the updated instruction count value, wherein the instruction count value corresponding to the instruction counter is updated to a preset maximum instruction count value when the first device first sends a test command to the second device within a single test command sending cycle; and dynamically updating the first count value corresponding to the plurality of first counters based on the response data if the first device receives response data returned by the second device within the preset time.
[0011] In one possible implementation, based on the updated instruction count value, an update operation is performed on the first count values corresponding to the plurality of first counters. Specifically, this includes: comparing the updated instruction count value with a preset target value; if the updated instruction count value is not the preset target value, controlling the first device to resend the test instruction to the second device, and incrementing the first retransmission count value corresponding to the first retransmission counter; if the updated instruction count value is the preset target value, and the current first transmission count value of the first transmission counter is greater than the preset target value, then incrementing the first failure count value corresponding to the first failure counter, and controlling the first device to resend the test instruction to the second device.
[0012] In one possible implementation, after the first device and the second device complete the handshake operation, the method further includes: initializing a plurality of second counters in the second device; after the second device receives the test instruction sent by the first device, updating the second count values corresponding to the plurality of second counters based on the test instruction; generating response data corresponding to the test instruction based on the updated second count values, and controlling the second device to send the response data to the first device.
[0013] In one possible implementation, the plurality of second counters includes a second transmit counter and a second receive counter.
[0014] In one possible implementation, updating the second count value corresponding to the plurality of second counters based on the test instruction specifically includes: the plurality of second counters includes a second transmit counter and a second receive counter; obtaining the current first transmit count value carried in the test instruction; if the current first transmit count value is zero, then initializing the second receive count value corresponding to the second receive counter; if the current first transmit count value is not zero, and the current first transmit count value is not equal to the second transmit count value corresponding to the second transmit counter, then updating the second receive count value corresponding to the second receive counter, and updating the second transmit count value to the current first transmit count value.
[0015] Secondly, this application provides a dual-device communication quality detection device, applied to a communication system including a first device and a second device, comprising: a test command sending module, a first value updating module, and a communication quality evaluation module; wherein, the test command sending module is used to initialize a plurality of first counters in the first device and control the first device to send test commands to the second device after the first device and the second device complete a handshake operation; the first value updating module is used to dynamically update the first count values corresponding to the plurality of first counters based on whether the first device receives response data returned by the second device within a preset time; the communication quality evaluation module is used to evaluate the communication quality between the first device and the second device based on the updated first count values and output the communication quality result.
[0016] Thirdly, embodiments of this application also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0017] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, can implement the above-described method.
[0018] This application provides a method, apparatus, device, and storage medium for detecting the quality of dual-machine communication, which has the following advantages compared with the prior art:
[0019] This method initializes multiple first counters in the first device after the first device and the second device complete a handshake operation, and controls the first device to send a test command to the second device. Based on whether the first device receives response data from the second device within a preset time, the method dynamically updates the first count values corresponding to the multiple first counters. Based on the updated first count values, the method evaluates the communication quality between the first device and the second device and outputs the communication quality result. Compared with existing technical solutions, this application's technical solution initializes multiple first counters in the first device, sends a test command to the second device, and dynamically updates the count values of the multiple first counters based on whether response data is received within a preset time, thereby quantitatively evaluating the communication quality. This method replaces the traditional manual triggering and visual observation methods, enabling long-term, continuous testing without manual intervention, greatly reducing manpower and time costs, and significantly improving testing efficiency. Simultaneously, based on the count values of the first counters, it avoids subjective judgment errors and can accurately capture issues such as packet loss during communication, outputting reliable communication quality results. Attached Figure Description
[0020] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0021] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0023] Figure 1 This is a flowchart illustrating one embodiment of a dual-machine communication quality detection method provided in this application;
[0024] Figure 2 This is a schematic diagram of one embodiment of a dual-machine communication quality detection device provided in this application;
[0025] Figure 3 This is a schematic diagram of the structure of a computer device provided in this application. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0027] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0028] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0029] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0030] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0031] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."
[0032] Example 1, see Figure 1 , Figure 1 This is a flowchart illustrating one embodiment of a dual-machine communication quality detection method provided in this application, as shown below. Figure 1 As shown, this method is applied to a communication system including a first device and a second device, and includes steps 101-103, as detailed below:
[0033] Step 101: After the first device and the second device complete the handshake operation, initialize multiple first counters in the first device and control the first device to send test commands to the second device.
[0034] In one embodiment, the first device is a master device and the second device is a slave device.
[0035] In one embodiment, the handshake operation between the first device and the second device can be implemented through a request-response mechanism.
[0036] Specifically, the handshake operation is initiated by the first device sending a handshake request instruction to the second device, and the first device starts a handshake timeout timer for a first preset duration after sending the handshake request instruction; if the first device receives a handshake response instruction corresponding to the handshake request instruction from the second device before the handshake timeout timer reaches the first preset duration, the handshake operation is determined to be successful; otherwise, the handshake operation is determined to be unsuccessful.
[0037] Specifically, the handshake operation between the first and second devices establishes a reliable communication foundation for subsequent automated testing of communication quality, ensuring that both devices are in a responsive and ready state, thus avoiding the waste of resources caused by blindly sending test commands before the communication link is established.
[0038] In one embodiment, the plurality of first counters includes a first transmit counter, a first receive counter, a first retransmit counter, and a first failure counter.
[0039] Specifically, the first transmit counter is used to count the total number of test commands effectively sent by the first device to the second device; the first receive counter is used to count the number of times the first device successfully receives response data from the second device; the first retransmit counter is used to count the number of times the first device retransmits test commands because it does not receive a response in time; and the first failure counter is used to count the number of test commands that the first device still fails to receive a response after the maximum number of retries.
[0040] In one embodiment, initializing the plurality of first counters in the first device specifically includes: setting the first transmission count value corresponding to the first transmission counter, the first reception count value corresponding to the first reception counter, the first retransmission count value corresponding to the first retransmission counter, and the first failure count value corresponding to the first failure counter to zero, respectively.
[0041] Specifically, during the initialization phase, the count values of the first transmit counter, the first receive counter, the first retransmit counter, and the first failure counter are reset to zero. This ensures that there is no historical data interference before the test begins, allowing the first transmit counter to start recording the number of command transmissions from zero, thus avoiding the influence of past transmission records on the current test data. The first receive counter starts counting valid responses from zero. Resetting the first retransmit counter and the first failure counter to zero can accurately count the actual number of data packet retransmissions and communication failures in this test, providing reliable raw data for subsequent evaluation of communication quality.
[0042] In one embodiment, controlling the first device to send a test command to the second device specifically includes: detecting whether the current first receive count value corresponding to the first receive counter is greater than a preset threshold; if so, incrementing the first send count value corresponding to the first send counter to obtain an updated first send count value, and obtaining the current first send count value of the first send counter and the current first receive count value of the first receive counter; otherwise, directly obtaining the current first send count value of the first send counter and the current first receive count value of the first receive counter; constructing a test command based on the current first send count value and the current first receive count value, and sending the test command to the second device.
[0043] Specifically, the preset threshold is 0.
[0044] Specifically, if the current first receive count value corresponding to the first receive counter is not greater than a preset threshold, it indicates that no effective communication has yet occurred between the first device and the second device. In this case, directly obtaining the current first send count value and the current first receive count value is to start communication from the baseline state. For example, when sending for the first time, the first send count value is 0 and the first receive count value is 0. After receiving the test command, the second device will recognize it as the initial test command and initialize its own second counter accordingly, establishing a unified counting starting point for subsequent communication. If the first send count value is incremented at this time, it may cause confusion in the second device's counting of the initial test command, which may hinder the establishment of the first communication.
[0045] Specifically, if the current first receive count value corresponding to the first receive counter is detected to be greater than a preset threshold, it indicates that the first device has successfully received response data returned by the second device at least once. In this case, the first send count value is incremented to generate a new instruction. The second device will compare the first send count value recorded in its previous processing with the current first send count value in the current test instruction to determine whether it is a new test instruction. If the increment is not performed, the new test instruction will carry the same current first send count value as the previous instruction. The second device may misjudge it as a duplicate old test instruction, resulting in no response or an incorrect response. After incrementing, the updated current first send count value and the current first receive count value can ensure that the data carried in the new test instruction is continuous and unique, and is connected with the communication history established between the two devices. This enables long-term continuous communication instruction testing.
[0046] Specifically, the current first transmit count value corresponding to the first transmit counter and the current first receive count value of the first receive counter are combined with a fixed test instruction CMD in a preset format to form a standardized test instruction. This standardized format allows the second device to quickly identify the instruction type and extract key count information after receiving the test instruction. Furthermore, the second device can use this to verify the communication quality of its downlink and determine whether its previous responses have been lost, thus achieving communication quality detection of both uplink and downlink channels based on simple instruction interaction.
[0047] Specifically, the format of the test command is "Test Command CMD + Send Counter + Receive Counter".
[0048] Specifically, after the test command is constructed, the first device sends the constructed test command to the communication bus through its physical communication interface, so as to transmit the test command to the second device through the communication bus.
[0049] Preferably, the instruction counter is used to control the number of times the master retransmits when it does not receive a response from the slave; the preset maximum instruction count value can be designed with a reasonable value according to product requirements to limit the upper limit of retransmission of test instructions.
[0050] Specifically, when controlling the first device to send a test command to the second device, it is also determined whether the first device sends a test command to the second device for the first time within a single test command sending cycle. If so, a preset maximum command count value is obtained, and the command count value corresponding to the command counter in the first device is updated to the preset maximum command count value. This step is to set an upper limit for retransmission of test commands. For example, if the host does not receive a response after a timeout, the command counter will decrement. If the command counter is not zero, retransmission will continue until the command counter is zero, at which point communication failure is determined and the failure counter is incremented.
[0051] Specifically, the instruction count is initialized to the preset maximum instruction count, which avoids the waste of test resources caused by unlimited retransmissions and reduces misjudgments caused by occasional network fluctuations by setting a reasonable number of retransmissions, thus ensuring that the test results are more in line with the actual communication scenario.
[0052] In one embodiment, after the first device and the second device complete the handshake operation, the method further includes: initializing a plurality of second counters in the second device; after the second device receives the test instruction sent by the first device, updating the second count values corresponding to the plurality of second counters based on the test instruction; generating response data corresponding to the test instruction based on the updated second count values, and controlling the second device to send the response data to the first device.
[0053] In one embodiment, the plurality of second counters includes a second transmit counter and a second receive counter.
[0054] Specifically, the second transmission counter is used to cache the current first transmission count value corresponding to the first transmission counter in the first device carried in the received test command; the second receiver is used to count the number of times the second device correctly receives and parses the test command sent by the first device.
[0055] Specifically, the second transmit count value corresponding to the second transmit counter and the second receive count value corresponding to the second receive counter are respectively set to zero.
[0056] Specifically, after a successful handshake, multiple second counters in the second device are also initialized to ensure that the first and second devices start testing on the same baseline, thus guaranteeing the synchronization and accuracy of subsequent statistical data.
[0057] In one embodiment, updating the second count value corresponding to the plurality of second counters based on the test instruction specifically includes: obtaining the current first transmission count value carried in the test instruction; if the current first transmission count value is zero, then initializing the second reception count value corresponding to the second reception counter; if the current first transmission count value is not zero and the current first transmission count value is not equal to the second transmission count value corresponding to the second transmission counter, then updating the second reception count value corresponding to the second reception counter and updating the second transmission count value to the current first transmission count value.
[0058] Specifically, after receiving the test command, the second device can quickly extract the current first transmission count value corresponding to the first transmission counter in the first device carried by the test command, based on the format of the test command.
[0059] Specifically, when the current first transmission count value is obtained, it is determined whether the current first transmission count value is zero. If it is, it means that the test command is the initial test command sent by the first device in the current test session. Therefore, in response, the second device also initializes the second receive count value corresponding to its own second receive counter, that is, sets the second receive count value to zero. This ensures that while the first device's first transmission counter starts counting from 0, the second device's second receive counter also starts recording from 0, achieving strict synchronization between the two on the counting benchmark.
[0060] Specifically, if the current first transmit count is not zero, it indicates that the entire test session has proceeded normally; if the current first transmit count is not equal to the second transmit count, it indicates that the received test command is a new command sent by the first device. In this case, updating the second receive count in the second device and synchronizing the second transmit count is to accurately record the number of valid receptions and maintain the consistency of the counts between the two devices.
[0061] Specifically, updating the second receive counter corresponding to the second receive counter means incrementing the second receive counter value, that is, adding one to the second receive counter value to record this valid reception; at the same time, updating the second transmit counter value to the current first transmit counter value, so as to keep it synchronized with the transmit counter of the first device, and providing a benchmark for comparison when receiving test commands next time.
[0062] In one embodiment, generating response data corresponding to the test instruction based on the updated second count value specifically includes: obtaining the current second transmit count value corresponding to the second transmit counter and the current second receive count value corresponding to the second receive counter in the second device; constructing response data corresponding to the test instruction based on the current second transmit count value and the current second receive count value, and sending the response data to the first device.
[0063] Specifically, the data format of the response data is the same as that of the test command, both being: Test Command CMD + Send Counter + Receive Counter.
[0064] Step 102: Based on whether the first device receives the response data returned by the second device within a preset time, dynamically update the first count value corresponding to the plurality of first counters.
[0065] In one embodiment, after the first device sends a test command to the second device, a timeout is started; if the first device does not receive response data from the second device within the preset time, the instruction count value corresponding to the instruction counter is decremented to obtain an updated instruction count value; based on the updated instruction count value, an update operation is performed on the first count values corresponding to the plurality of first counters, wherein the instruction count value corresponding to the instruction counter is updated to a preset maximum instruction count value when the first device first sends a test command to the second device within a single test command sending cycle.
[0066] Specifically, the timeout timer starts immediately after the first device sends the test command. This sets a clear time boundary for the communication response and is the core basis for judging whether the communication is timely.
[0067] Specifically, the preset time can be designed with a reasonable value according to product requirements, and is used to indicate the upper limit of reasonable delay in response when the two machines are communicating normally.
[0068] Specifically, the initial value of the command counter controls the number of retransmissions the master device will receive if it does not receive a response from the slave device, representing the maximum allowed number of retransmissions. When the first device does not receive a response from the second device within a preset time, the count value of the command counter is decremented. This is because the lack of response data may be an occasional situation caused by temporary interference rather than a permanent fault. The decrement operation records that one retransmission opportunity has been used. For example, if the command counter has a count value of 3, and it becomes 2 after the first timeout, it means that two more retransmissions can be attempted. This avoids the misjudgment of failure due to a single timeout, and prevents the waste of resources caused by unlimited retransmissions through limited number of attempts, thus balancing the fault tolerance and efficiency of the test.
[0069] In one embodiment, based on the updated instruction count value, an update operation is performed on the first count values corresponding to the plurality of first counters. Specifically, this includes: comparing the updated instruction count value with a preset target value; if the updated instruction count value is not the preset target value, controlling the first device to resend the test instruction to the second device, and incrementing the first retransmission count value corresponding to the first retransmission counter; if the updated instruction count value is the preset target value, and the current first transmission count value of the first transmission counter is greater than the preset target value, then incrementing the first failure count value corresponding to the first failure counter, and controlling the first device to resend the test instruction to the second device.
[0070] Specifically, the preset target value is 0.
[0071] Specifically, if the updated instruction count value is not the preset target value, it means that there are still remaining retransmission opportunities. In this case, the test instruction is resent and the first retransmission count value corresponding to the first retransmission counter is incremented. This is to eliminate occasional communication interference through multiple attempts and to accurately record the retransmission behavior. This operation not only improves the fault tolerance of the test, but also provides key data for subsequent evaluation of communication stability by statistically analyzing the first retransmission count value, avoiding the distortion of results caused by directly judging failure due to a single timeout.
[0072] Specifically, if the updated instruction count value is the preset target value, it means that the number of retransmissions has been exhausted; and if the current first transmission count value of the first transmission counter is greater than the preset target value, it means that the first device and the second device have previously successfully exchanged test instructions.
[0073] Specifically, if the current first transmission count value of the first transmission counter is not greater than the preset target value, it indicates that the current test command transmission is the first data interaction after the handshake between the first and second devices. At this time, the communication link may not be fully stable. Even if the command count value is reduced to 0, it may be an initial link adaptation problem rather than a normal communication failure. If the current first transmission count value of the first transmission counter is greater than the preset target value, it indicates that at least one valid test command has been successfully sent before. At this time, the link has been adapted. If no response data is received from the second device after exhausting the number of retransmissions, it indicates that a normal communication failure has occurred, rather than an occasional problem in the startup phase. Therefore, in this case, the first failure count value corresponding to the first failure counter is incremented by 1. This can avoid miscounting special adaptation failures in the startup phase as normal communication failures and improve the reliability of the count value.
[0074] Specifically, the step of controlling the first device to resend the test command to the second device is as described in step 101 above, and will not be repeated here.
[0075] In one embodiment, if the first device receives response data returned by the second device within the preset time, the first count value corresponding to the plurality of first counters is dynamically updated based on the response data.
[0076] Specifically, when dynamically updating the first count value corresponding to the plurality of first counters based on the response data, the first receive count value is updated to the current second receive count value by obtaining the current second receive count value carried in the response data; and it is determined whether the updated first receive count value is greater than zero. If not, the first send count value corresponding to the first send counter is set to 1.
[0077] Step 103: Based on the updated first count value, evaluate the communication quality between the first device and the second device, and output the communication quality result.
[0078] In one embodiment, the current first retransmission count value and the current first failure count value corresponding to the first device are obtained. If the current first retransmission count value is greater than 0 and the current first failure count value is greater than 0, the communication quality result is output as data retransmission and communication failure exist. If the current first retransmission count value is greater than 0 and the current first failure count value is not greater than 0, the communication quality result is output as data retransmission exists. If the current first retransmission count value is not greater than 0 and the current first failure count value is greater than 0, the communication quality result is output as communication failure exists. If the current first retransmission count value is not greater than 0 and the current first failure count value is not greater than 0, the communication quality result is output as no data retransmission and no communication failure exist.
[0079] In one embodiment, the updated first count value is used as a log packet by the first device and the log packet is sent to the cloud. Based on the interaction between the cloud and the terminal system, the log packet is displayed on the terminal device to achieve a visual display of communication quality.
[0080] Example 2, see Figure 2 , Figure 2 This is a schematic diagram of an embodiment of a dual-machine communication quality testing device provided in this application. Corresponding to the above-described dual-machine communication quality testing method, this application also provides a dual-machine communication quality testing device. This dual-machine communication quality testing device includes modules for executing the above-described dual-machine communication quality testing method. This dual-machine communication quality testing device can be configured in terminals such as desktop computers, tablet computers, and laptops. Specifically, this dual-machine communication quality testing device is applied to a communication system including a first device and a second device, and includes: a test command sending module 201, a first value update module 202, and a communication quality evaluation module 203.
[0081] The test instruction sending module 201 is used to initialize multiple first counters in the first device and control the first device to send test instructions to the second device after the first device and the second device complete the handshake operation.
[0082] The first value update module 202 is used to dynamically update the first count value corresponding to the plurality of first counters based on whether the first device receives the response data returned by the second device within a preset time.
[0083] The communication quality assessment module 203 is used to assess the communication quality between the first device and the second device based on the updated first count value, and output the communication quality result.
[0084] In one embodiment, the plurality of first counters includes a first transmit counter, a first receive counter, a first retransmit counter, and a first failure counter.
[0085] In one embodiment, the test instruction sending module 201 is used to initialize a plurality of first counters in the first device, specifically including: setting the first sending count value corresponding to the first sending counter, the first receiving count value corresponding to the first receiving counter, the first retransmission count value corresponding to the first retransmission counter, and the first failure count value corresponding to the first failure counter to zero respectively.
[0086] In one embodiment, the test instruction sending module 201 is used to control the first device to send a test instruction to the second device. Specifically, it includes: detecting whether the current first receive count value corresponding to the first receive counter is greater than a preset threshold; if so, incrementing the first send count value corresponding to the first send counter to obtain an updated first send count value; and obtaining the current first send count value of the first send counter and the current first receive count value of the first receive counter; otherwise, directly obtaining the current first send count value of the first send counter and the current first receive count value of the first receive counter; constructing a test instruction based on the current first send count value and the current first receive count value, and sending the test instruction to the second device.
[0087] In one embodiment, the first value update module 202 is used to dynamically update the first count value corresponding to the plurality of first counters based on whether the first device receives response data returned by the second device within a preset time. Specifically, this includes: starting a timeout count after the first device sends a test command to the second device; if the first device does not receive response data returned by the second device within the preset time, decrementing the instruction count value corresponding to the instruction counter to obtain an updated instruction count value; performing an update operation on the first count value corresponding to the plurality of first counters based on the updated instruction count value, wherein the instruction count value corresponding to the instruction counter is updated to a preset maximum instruction count value when the first device first sends a test command to the second device within a single test command sending cycle; and dynamically updating the first count value corresponding to the plurality of first counters based on the response data if the first device receives response data returned by the second device within the preset time.
[0088] In one embodiment, the first value update module 202 is used to perform an update operation on the first count values corresponding to the plurality of first counters based on the updated instruction count value. Specifically, it includes: comparing the updated instruction count value with a preset target value; if the updated instruction count value is not the preset target value, controlling the first device to resend the test instruction to the second device and incrementing the first retransmission count value corresponding to the first retransmission counter; if the updated instruction count value is the preset target value, and the current first transmission count value of the first transmission counter is greater than the preset target value, then incrementing the first failure count value corresponding to the first failure counter and controlling the first device to resend the test instruction to the second device.
[0089] In one embodiment, the dual-machine communication quality detection device provided in this application further includes: a second value update module.
[0090] In one embodiment, the second value update module is used to initialize a plurality of second counters in the second device; when the second device receives the test instruction sent by the first device, it updates the second count values corresponding to the plurality of second counters based on the test instruction; based on the updated second count values, it generates response data corresponding to the test instruction, and controls the second device to send the response data to the first device.
[0091] In one embodiment, the plurality of second counters includes a second transmit counter and a second receive counter.
[0092] In one embodiment, the second value update module is used to update the second count value corresponding to the plurality of second counters based on the test instruction, specifically including: the plurality of second counters include a second transmit counter and a second receive counter; obtaining the current first transmit count value carried in the test instruction; if the current first transmit count value is zero, then initializing the second receive count value corresponding to the second receive counter; if the current first transmit count value is not zero, and the current first transmit count value is not equal to the second transmit count value corresponding to the second transmit counter, then updating the second receive count value corresponding to the second receive counter, and updating the second transmit count value to the current first transmit count value.
[0093] The aforementioned dual-machine communication quality detection device can implement the dual-machine communication quality detection method described in the above method embodiments. The options described in the above method embodiments are also applicable to this embodiment, and will not be detailed here.
[0094] like Figure 3 As shown, Figure 3This is a schematic diagram of the structure of a computer device provided in this application; it includes a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112 and the memory 113 communicate with each other through the communication bus 114, and the memory 113 is used to store computer programs.
[0095] In one embodiment of this application, the processor 111, when executing the program stored in the memory 113, implements the dual-machine communication quality detection method provided in any of the foregoing method embodiments.
[0096] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program may be stored in a storage medium, which is a computer-readable storage medium. The computer program is executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0097] Therefore, embodiments of this application also provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the dual-machine communication quality detection method provided in any of the foregoing method embodiments.
[0098] The storage medium is a physical, non-transient storage medium, such as a USB flash drive, external hard drive, read-only memory (ROM), magnetic disk, or optical disk, or any other physical storage medium capable of storing program code. The computer-readable storage medium can be non-volatile or volatile.
[0099] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0100] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0101] The steps in the methods of this application embodiment can be adjusted, merged, or deleted according to actual needs. The units in the apparatus of this application embodiment can be merged, divided, or deleted according to actual needs. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0102] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0103] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0104] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Since these modifications and variations fall within the scope of the claims and their equivalents, this application also intends to include these modifications and variations.
[0105] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for detecting the quality of dual-device communication, applied to a communication system including a first device and a second device, characterized in that, include: After the first device and the second device complete the handshake operation, the first device initializes multiple first counters and controls the first device to send test commands to the second device. Based on whether the first device receives the response data returned by the second device within a preset time, the first count value corresponding to the plurality of first counters is dynamically updated; Based on the updated first count value, the communication quality between the first device and the second device is evaluated, and the communication quality result is output.
2. The dual-machine communication quality detection method as described in claim 1, characterized in that, The plurality of first counters include a first transmit counter, a first receive counter, a first retransmit counter, and a first failure counter; The initialization of the plurality of first counters in the first device specifically includes: The first transmit count value corresponding to the first transmit counter, the first receive count value corresponding to the first receive counter, the first retransmit count value corresponding to the first retransmit counter, and the first failure count value corresponding to the first failure counter are respectively set to zero.
3. The dual-machine communication quality detection method as described in claim 2, characterized in that, Controlling the first device to send test commands to the second device specifically includes: If the current first receive count value corresponding to the first receive counter is greater than a preset threshold, then the first send count value corresponding to the first send counter is incremented to obtain the updated first send count value, and the current first send count value of the first send counter and the current first receive count value of the first receive counter are obtained; otherwise, the current first send count value of the first send counter and the current first receive count value of the first receive counter are obtained directly. Based on the current first transmit count value and the current first receive count value, a test instruction is constructed and sent to the second device.
4. The dual-machine communication quality detection method as described in claim 3, characterized in that, Based on whether the first device receives response data returned by the second device within a preset time, the first count values corresponding to the plurality of first counters are dynamically updated, specifically including: After the first device sends a test command to the second device, the timeout period is started; If the first device does not receive response data from the second device within the preset time, the instruction count value corresponding to the instruction counter in the first device is decremented to obtain the updated instruction count value. Based on the updated instruction count value, the first count value corresponding to the plurality of first counters is updated. The instruction count value corresponding to the instruction counter is updated to the preset maximum instruction count value when the first device first sends a test instruction to the second device within a single test instruction sending cycle. If the first device receives response data from the second device within the preset time, it dynamically updates the first count value corresponding to the plurality of first counters based on the response data.
5. The dual-machine communication quality detection method as described in claim 4, characterized in that, Based on the updated instruction count value, an update operation is performed on the first count values corresponding to the plurality of first counters, specifically including: The updated instruction count value is compared with the preset target value; If the updated instruction count value is not the preset target value, then the first device is controlled to resend the test instruction to the second device, and the first retransmission count value corresponding to the first retransmission counter is incremented. If the updated instruction count value is the preset target value, and the current first transmission count value of the first transmission counter is greater than the preset target value, then the first failure count value corresponding to the first failure counter is incremented, and the first device is controlled to resend the test instruction to the second device.
6. The dual-machine communication quality detection method as described in claim 3, characterized in that, After the first device and the second device complete the handshake operation, the process further includes: Initialize multiple second counters in the second device; When the second device receives the test command sent by the first device, it updates the second count value corresponding to the plurality of second counters based on the test command; Based on the updated second count value, response data corresponding to the test command is generated, and the second device is controlled to send the response data to the first device.
7. The dual-machine communication quality detection method as described in claim 6, characterized in that, The plurality of second counters includes a second transmit counter and a second receive counter; Specifically, updating the second count values corresponding to the plurality of second counters based on the test instruction includes: The plurality of second counters includes a second transmit counter and a second receive counter; Obtain the current first transmission count value carried in the test instruction; if the current first transmission count value is zero, initialize the second reception count value corresponding to the second reception counter. If the current first transmit count value is not zero, and the current first transmit count value is not equal to the second transmit count value corresponding to the second transmit counter, then update the second receive count value corresponding to the second receive counter, and update the second transmit count value to the current first transmit count value.
8. A dual-device communication quality detection device, applied to a communication system including a first device and a second device, characterized in that, include: The test instruction sending module, the first value update module, and the communication quality evaluation module; The test instruction sending module is used to initialize multiple first counters in the first device and control the first device to send test instructions to the second device after the first device and the second device complete the handshake operation. The first value update module is used to dynamically update the first count value corresponding to the plurality of first counters based on whether the first device receives the response data returned by the second device within a preset time. The communication quality assessment module is used to assess the communication quality between the first device and the second device based on the updated first count value, and output the communication quality result.
9. A computer device, characterized in that, The computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, can implement the method as described in any one of claims 1-7.