Method, apparatus, and storage medium for network quality detection
By performing precise filtering and asynchronous processing at the kernel level, the problem of resource waste in TCP port scanning is solved, achieving high efficiency and accuracy in network quality detection.
Patent Information
- Application Number
- CN202410984570.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2044-07-22
AI Technical Summary
Existing technologies waste significant resources in TCP port scanning and have low efficiency in network quality detection, failing to quickly and accurately check network quality.
A precise filtering mechanism is implemented at the kernel level, and asynchronous processing is achieved through technologies such as multithreading and lock-free blocking queues. This decouples the sending, receiving, calculation, and output of measurement packets, avoids resource waste, and improves throughput.
It achieves efficient network quality detection at the kernel level, reduces resource consumption, and improves the accuracy and speed of network quality detection.
Smart Images

Figure CN118714039B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and in particular to a method, apparatus, electronic device, and storage medium for network quality detection. Background Technology
[0002] In recent years, with the booming development of the digital economy, data centers have grown larger and larger, and more and more digital services are running on them. In the future, people will become increasingly reliant on digital services, which can also be referred to as computing power. The network quality within a data center determines whether digital services can be stably supplied. Therefore, how to quickly and accurately check network quality has become an important issue.
[0003] In related technologies, efficient methods have been proposed for TCP port scanning scenarios. One approach is to use concurrent sending and receiving threads, and another is to improve efficiency by using TCP packets instead of the TCP three-way handshake mechanism. By quickly constructing TCP handshake request probe packets and employing a dual-channel send-receive separation approach, packets can be sent and processed rapidly. This allows for the detection and recording of open TCP ports on the host in a very short time, ensuring both accuracy and speed in port identification. However, due to insufficient precision in the filtering conditions during the sending and receiving processes, many invalid and irrelevant TCP packets are copied from kernel space to user space for comparison, resulting in wasted resources. Summary of the Invention
[0004] This disclosure provides a method, apparatus, electronic device, and storage medium for network quality detection. Its main purpose is to implement a precise screening mechanism at the kernel level, ensuring minimal resource consumption on the host machine when probing a large number of targets. Furthermore, it decouples the sending, receiving, calculation, and result output of measurement messages, achieving asynchronous processing of each stage based on multithreading and lock-free blocking queues, thus maximizing concurrent probing and improving the throughput of the entire measurement system.
[0005] According to a first aspect of this disclosure, a method for network quality detection is provided, comprising:
[0006] The kernel receives the original reply message sent by the destination and determines whether the third attribute information carried by the original reply message meets the preset filtering conditions.
[0007] When it is determined that the third attribute information meets the preset filtering conditions, the original reply message is determined to be the target reply message;
[0008] The target response message is transmitted from the kernel space to the user space, and it is determined whether the first attribute information carried by the target response message is the same as the second attribute information carried by the target measurement message.
[0009] When it is determined that the first attribute information is the same as the second attribute information, the round-trip time delay is calculated for the first timestamp of the target measurement message sent and the second timestamp of the target reply message received, and the round-trip time delay calculation result is obtained.
[0010] The round-trip delay calculation results are stored;
[0011] When the number of stored round-trip delay calculation results meets a preset quantity condition, the network quality score is calculated for all stored round-trip delay calculation results.
[0012] Optionally, after storing the round-trip delay calculation result, the method includes:
[0013] The system sequentially checks whether there are any elements in the bidirectional list that meet the preset timeout conditions. The elements are the target measurement messages stored in the bidirectional list before the target measurement message is sent.
[0014] When it is determined that there is a target element in the bidirectional list that meets the preset timeout condition, check whether the fourth attribute information and the third timestamp corresponding to the target element have been deleted.
[0015] If it is determined that neither the fourth attribute information nor the third timestamp has been deleted, the target response message corresponding to the target element is lost, and the packet loss result is stored in the first target storage queue.
[0016] The target element is removed from the bidirectional list, and the fourth attribute information and the third timestamp are also removed.
[0017] Optionally, after checking whether the fourth attribute information and the third timestamp corresponding to the target element have been deleted, the method includes:
[0018] If it is determined that both the fourth attribute information and the third timestamp have been deleted, the target element is removed from the bidirectional list.
[0019] Optionally, after calculating the network quality score from all stored round-trip latency calculation results, the method includes:
[0020] After performing multiple network quality tests on the destination, multiple network quality scores are obtained. An aggregate index is obtained by calculating the multiple network quality scores.
[0021] Store the aggregated metrics to the target storage queue;
[0022] When it is determined that the size of the target storage queue meets the preset size condition or the storage time of the first aggregate index stored in the target storage queue meets the preset time window condition, all aggregate indicators stored in the target storage queue are compressed.
[0023] All the compressed aggregated metrics are transmitted to the analysis module.
[0024] Optionally, transmitting all the compressed aggregated metrics to the analysis module includes:
[0025] Determine whether the network link corresponding to the aggregated index is an important network link;
[0026] If it is determined that the network link corresponding to the aggregated index is a non-critical network link, then when the network link is abnormal, all the compressed aggregated indexes will be transmitted to the analysis module.
[0027] If the network link corresponding to the aggregated index is determined to be an important network link, then whether the network link is normal or abnormal, all the compressed aggregated indexes will be transmitted to the analysis module.
[0028] Optionally, after storing the round-trip delay calculation result, the method includes:
[0029] Delete the first timestamp and the second attribute information.
[0030] Optionally, when it is determined that the number of stored round-trip delay calculation results meets a preset quantity condition, calculating all stored round-trip delay calculation results includes:
[0031] When the number of target measurement messages sent to the destination is equal to the number of stored round-trip delay calculation results, the network quality score is obtained by calculating all stored round-trip delay calculation results.
[0032] Optionally, if the target measurement message is a UDP protocol message, the step of receiving the original reply message sent by the destination in kernel mode includes:
[0033] If the original reply message is not received from the original port of the destination, then network quality checks are performed on other ports of the destination until the original reply message is received from the other port.
[0034] Optionally, if the target measurement message belongs to a TCP protocol message, the step of receiving the original reply message sent by the destination in kernel mode includes:
[0035] If the target reply message sent by the original port of the destination is a TCP synchronization acknowledgment message, then the network quality check is switched to other ports of the destination until a TCP reset message is received from the switched other ports.
[0036] According to a second aspect of this disclosure, an apparatus for network quality detection is provided, comprising:
[0037] The first judgment unit is used to receive the original reply message sent by the destination in kernel mode and determine whether the third attribute information carried by the original reply message meets the preset filtering conditions.
[0038] The determining unit is configured to determine the original reply message as the target reply message when it is determined that the third attribute information meets the preset filtering conditions;
[0039] The first transmission unit is used to transmit the target reply message from the kernel space to the user space;
[0040] The second judgment unit is used to determine whether the first attribute information carried in the target reply message is the same as the second attribute information carried in the target measurement message;
[0041] The first calculation unit is used to calculate the round-trip time delay for the first timestamp of the target measurement message sent and the second timestamp of the target reply message received when it is determined that the first attribute information and the second attribute information are the same, and to obtain the round-trip time delay calculation result.
[0042] The first storage unit is used to store the round-trip delay calculation results;
[0043] The second calculation unit is used to calculate all the stored round-trip delay calculation results to obtain a network quality score when the number of stored round-trip delay calculation results meets a preset quantity condition.
[0044] Optionally, the device includes:
[0045] The first checking unit is used to sequentially check whether there are elements in the bidirectional list that meet the preset timeout conditions. The elements are target measurement messages stored in the bidirectional list before the target measurement message is sent.
[0046] The second checking unit is used to check whether the fourth attribute information and the third timestamp corresponding to the target element have been deleted when it is determined that there is a target element in the bidirectional list that meets the preset timeout condition.
[0047] The determining unit is configured to determine that the target response message corresponding to the target element is lost when it is determined that neither the fourth attribute information nor the third timestamp has been deleted, and to store the packet loss result in the first target storage queue.
[0048] The first deletion unit is used to delete the target element from the bidirectional list and to delete the fourth attribute information and the third timestamp.
[0049] Optionally, the device includes:
[0050] The second deletion unit is used to delete the target element from the bidirectional list when it is determined that both the fourth attribute information and the third timestamp have been deleted.
[0051] Optionally, the device includes:
[0052] The third calculation unit is used to obtain multiple network quality scores after performing multiple network quality tests on the destination, and to calculate the multiple network quality scores to obtain an aggregate index.
[0053] The second storage unit is used to store the aggregation index into the target storage queue;
[0054] The compression unit is used to compress all aggregate indicators stored in the target storage queue when it is determined that the size of the target storage queue meets a preset size condition or the storage time of the first aggregate indicator stored in the target storage queue meets a preset time window condition.
[0055] A transmission unit is used to transmit all the compressed aggregated indicators to the analysis module.
[0056] Optionally, the transmission unit includes:
[0057] The judgment module is used to determine whether the network link corresponding to the aggregation index is an important network link;
[0058] The transmission module is used to transmit all the compressed aggregated indicators to the analysis module when it is determined that the network link corresponding to the aggregated indicator is a non-critical network link, and when the network link is abnormal.
[0059] The transmission module is further configured to transmit all the compressed aggregated indicators to the analysis module when it is determined that the network link corresponding to the aggregated indicator is an important network link, and whether the network link is normal or abnormal.
[0060] Optionally, the device includes:
[0061] The third deletion unit is used to delete the first timestamp and the second attribute information.
[0062] Optionally, the second computing unit is further configured to:
[0063] When the number of target measurement messages sent to the destination is equal to the number of stored round-trip delay calculation results, the network quality score is obtained by calculating all stored round-trip delay calculation results.
[0064] Optionally, the first determining unit is further configured to switch to network quality detection on other ports of the destination when the target reply message sent by the original port of the destination is not received, until the target reply message is received from the switched other port.
[0065] Optionally, the switching module is further configured to switch to other ports of the destination for network quality detection when the target reply message sent by the original port of the destination is a TCP protocol synchronization acknowledgment message, until a TCP protocol reset message is received from the switched other port.
[0066] According to a third aspect of this disclosure, an electronic device is provided, comprising:
[0067] At least one processor; and
[0068] A memory communicatively connected to the at least one processor; wherein,
[0069] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect above.
[0070] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method described in the first aspect above.
[0071] According to a fifth aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method described in the first aspect above.
[0072] In summary, this embodiment achieves the following effects:
[0073] 1. A mechanism for precise screening at the kernel level is proposed for ICMP / TCP / UDP probes. At the same time, TCP probes avoid the half-open connection problem caused by the three-way handshake, ensuring that the host machine's resource consumption is controlled when a large number of probe targets are involved.
[0074] 2. Detailed measurement schemes are proposed for ICMP / TCP / UDP probes, decoupling the sending, receiving, calculation, and result output of measurement messages. Asynchronous processing of each step is achieved based on multi-threading, lock-free blocking queues, and other technologies, maximizing concurrent probes and improving the throughput of the entire measurement system.
[0075] 3. The network quality is detected by calculating the round-trip delay result based on the first timestamp and the second timestamp, and then calculating the network quality score based on the round-trip delay result.
[0076] 4. A round-trip message mapping mechanism is proposed for TCP / UDP probing, which does not require any configuration of the probe target and does not depend on the payload of the reply message, thus reducing the cost of including the measurement object in the measurement.
[0077] 5. To address the issue of how to efficiently output large batches of detection results, a multi-dimensional compression scheme is proposed, which includes index compression based on the detection objective, quantity compression based on time or quantity windows, and strategy compression based on monitoring level classification, thereby reducing the bandwidth consumption of the output results.
[0078] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description
[0079] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0080] Figure 1 This is a schematic flowchart of a network quality detection method provided in an embodiment of the present disclosure;
[0081] Figure 2 A schematic diagram of a network quality detection device provided in an embodiment of this disclosure;
[0082] Figure 3 A schematic diagram of another network quality detection device provided in an embodiment of this disclosure;
[0083] Figure 4 A schematic block diagram of an example electronic device 300 provided for embodiments of this disclosure. Detailed Implementation
[0084] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0085] The following description, with reference to the accompanying drawings, outlines a method, apparatus, electronic device, and storage medium for network quality detection according to embodiments of the present disclosure.
[0086] Figure 1 This is a schematic flowchart illustrating a network quality detection method provided in an embodiment of this disclosure.
[0087] like Figure 1 As shown, the method includes the following steps:
[0088] Step 101: Receive the original reply message sent by the destination in kernel mode, and determine whether the third attribute information carried by the original reply message meets the preset filtering conditions.
[0089] Step 102: When it is determined that the third attribute information meets the preset filtering conditions, the original reply message is determined to be the target reply message;
[0090] To facilitate understanding of the above detailed explanation, this embodiment provides an exemplary description, including: When a computer performs a packet retrieval operation, the CPU processes all data sent by the network card. First, this processing occurs at high speed in the kernel's memory. If an application needs specific packets, these packets are copied to the memory allocated by the application, i.e., user space. Then, the application determines whether the packets require further processing. To minimize overhead, preset filtering conditions are set for the original reply packets based on the operating system's open interface capabilities. This allows the original reply packets to be filtered within the kernel space. Only original reply packets that meet the preset filtering conditions are copied to user space for further analysis.
[0091] In some embodiments, if network quality detection is performed based on the ICMP protocol, the preset filtering condition can be set to an identifier as a process number. That is, if the identifier in the third attribute information carried by the original reply message is equal to the process number, it means that the original reply message meets the preset filtering condition, and the original reply message is transmitted from the kernel mode to the user mode. The process number is the process number of the program performing the network quality detection.
[0092] A mechanism for precise screening at the kernel level is proposed for ICMP / TCP / UDP probes. Meanwhile, TCP probes avoid the half-open connection problem caused by the three-way handshake, ensuring that the host machine's resource consumption is controlled when a large number of probe targets are involved.
[0093] Step 103: Transmit the target reply message from the kernel state to the user state and determine whether the first attribute information carried by the target reply message is the same as the second attribute information carried by the target measurement message;
[0094] As a refinement of step 103 above, in order to determine whether the target response message and the target measurement message correspond, after the execution end sends the target measurement message to the destination end, the destination end responds to the target measurement message by sending a response message, namely the target response message, to the execution end. The execution end receives the target response message sent by the destination end and determines whether the first attribute information carried by the target response message and the second attribute information carried by the target measurement message are the same, so as to determine whether the target response message and the target measurement message correspond.
[0095] Step 104: When it is determined that the first attribute information and the second attribute information are the same, the round-trip time delay is calculated for the first timestamp of the target measurement message sent and the second timestamp of the target reply message received, and the round-trip time delay calculation result is obtained.
[0096] As a refinement of step 104 above, in order to obtain an indicator that can describe network quality, the round-trip time is calculated by taking the first timestamp corresponding to the sending of the target measurement message and the second timestamp of the receiving of the target reply message, thereby obtaining the round-trip time calculation result, which can indicate the network quality at the current moment.
[0097] The network quality is detected by calculating the round-trip delay result based on the first timestamp and the second timestamp, and then calculating the network quality score based on the round-trip delay result.
[0098] Step 105: Store the round-trip delay calculation results;
[0099] As a refinement of step 105 above, the calculated round-trip time delay result is stored, wherein the storage method includes, but is not limited to, queue storage, stack storage, heap storage, and tree storage. By storing the round-trip time delay calculation result, the richness of the round-trip time delay calculation result as a sample in the storage structure is improved.
[0100] Step 106: When it is determined that the number of stored round-trip delay calculation results meets the preset quantity condition, calculate all stored round-trip delay calculation results to obtain the network quality score.
[0101] As a refinement of step 106 above, when it is determined that the number of stored round-trip delay calculation results meets a preset quantity condition, that is, when it is determined that the richness of the stored round-trip delay calculation results as samples has reached a preset standard, in the above case, all the stored round-trip delay calculation results are calculated to obtain the network quality score that can better describe the network quality. Wherein, when the round-trip delay calculation results are stored in any kind of storage structure, the number of round-trip delay calculation results stored in that storage structure will increase. When the number of round-trip delay calculation results stored in that storage structure is greater than or equal to the preset quantity condition, it is determined that the number of stored round-trip delay calculation results meets the preset quantity condition. It should be understood that the foregoing description is only exemplary and does not constitute a limitation on the judgment of meeting the preset quantity condition described in this disclosure.
[0102] A mechanism for precise screening at the kernel level is proposed for ICMP / TCP / UDP probes. Meanwhile, TCP probes avoid the half-open connection problem caused by the three-way handshake, ensuring that the host machine's resource consumption is controlled when a large number of probe targets are involved.
[0103] As a refinement of the above embodiments, after storing the round-trip delay calculation result, the method may also adopt, but is not limited to, the following implementation methods, for example: sequentially checking whether there is an element in the bidirectional list that meets the preset timeout condition, wherein the element is the target measurement message stored in the bidirectional list before the target measurement message is sent; when it is determined that there is a target element in the bidirectional list that meets the preset timeout condition, checking whether the fourth attribute information and the third timestamp corresponding to the target element have been deleted; when it is determined that neither the fourth attribute information nor the third timestamp has been deleted, determining that the target reply message corresponding to the target element has been lost, storing the packet loss result in the first target storage queue; deleting the target element from the bidirectional list and deleting the fourth attribute information and the third timestamp.
[0104] To facilitate understanding of the above detailed explanation, this embodiment provides an exemplary description, such as: when performing network quality detection based on the ICMP protocol, including: during Round-Trip Time (RTT) measurement, using the Echo and Reply fields in the ICMP query message. The ICMP query message refers to the target measurement message. The type and code in the ICMP query message content are fixed and constrained by the protocol standard. In its identifier field, the PID (Process ID) of the measurement program is entered to ensure global uniqueness within the server scope; the sequence number starts from 1 and accumulates to ensure the uniqueness and one-to-one correspondence of each ICMP measurement message. The Payload portion is filled with a fixed number of bytes according to the size of the probe message. The information of the lower-layer IP and data link layers of ICMP is filled in normally, mainly writing the correct source and destination IPs and MAC addresses. Before the ICMP query message is sent to the destination, relevant information needs to be stored in memory using two data structures. First, a hash table is used, where the key consists of the ICMP query message's identifier and sequence number, and the value is the timestamp when the ICMP query message was sent. The data stored in the hash table is the attribute information of the ICMP query message, i.e., the second attribute information carried by the target measurement message. Second, a doubly linked list is used to store the ICMP query message in an ordered manner for convenient subsequent calculation and analysis. After completion, the ICMP query message is immediately sent to the destination. The destination responds to the ICMP query message with a target reply message. During the process of receiving the target reply message from the execution end to the kernel state, other types of messages may be mixed in. Therefore, the received original reply message is filtered using the aforementioned preset filtering conditions to obtain the target reply message. After receiving the target reply message, the second timestamp of the received target reply message is saved, and the first attribute information of the target reply message is extracted and stored in an attribute information storage queue. This embodiment does not limit the storage structure for storing the attribute information to a queue. By continuously consuming the first attribute information stored in the attribute information storage queue based on a background target thread, each time an attribute information is retrieved, it is compared and calculated with the second attribute information stored in memory. If the identifier (filled with PID) and sequence number of the ICMP query message and the target reply message are consistent, they are considered to be a round-trip message pair. At this time, the round-trip delay is calculated, and the calculation result is put into the calculation result storage queue. Then, the corresponding information in the hash table is deleted.The process of calculating round-trip time delay described above in step 102 is used here as an example to illustrate the calculation of round-trip time delay during network quality measurement via the ICMP protocol. In addition to consuming the attribute information storage queue, the target thread continuously checks the bidirectional list created and continuously populated during the ICMP query message sending phase, sequentially checking for elements that meet the timeout period. When a timeout target element is found, it checks whether the target measurement message (i.e., the ICMP query message) still exists in the hash table. If it does, it is considered that the target response message for the target measurement message (i.e., the ICMP query message) has not been received in time, indicating packet loss. The packet loss result is written to the calculation result storage queue, and the ICMP query message is removed from the hash table and the bidirectional list. If it does not exist, it is considered that the target response message for the target measurement message (i.e., the ICMP query message) has been received, and the ICMP query message information is normally removed from the bidirectional list. Specifically, due to the ordered nature of the queue, scanning can stop when the first element that has not yet timed out is encountered, preventing subsequent meaningless scanning operations.
[0105] As a refinement of the above embodiments, after checking whether the fourth attribute information and the third timestamp corresponding to the target element have been deleted, the method may also adopt, but is not limited to, the following implementation: for example, if it is determined that both the fourth attribute information and the third timestamp have been deleted, the target element is deleted from the bidirectional list. The content involved in the foregoing refinement has been involved in the above exemplary description, and this embodiment will not repeat it.
[0106] After calculating the network quality score from all stored round-trip latency calculation results, the method may also adopt, but is not limited to, the following implementation methods: after performing multiple network quality tests on the destination, multiple network quality scores are obtained; multiple network quality scores are calculated to obtain an aggregate index; the aggregate index is stored in a target storage queue; when it is determined that the size of the target storage queue meets a preset size condition or the storage time of the first aggregate index stored in the target storage queue meets a preset time window condition, all aggregate indices stored in the target storage queue are compressed; and all compressed aggregate indices are transmitted to the analysis module.
[0107] To facilitate understanding of the detailed explanation above, this embodiment provides an exemplary description. For example, after obtaining the network quality detection result (i.e., the network quality score) for each destination, directly sending the network quality score to the analysis module would consume a significant amount of network bandwidth. To minimize the resource consumption of non-business systems, a compression transmission mechanism can be adopted. First, destination-based compression involves calculating the average, maximum, and minimum values of the network quality scores obtained from multiple detections of the same destination. Second, quantity-based compression involves writing the aggregated indicators into a target storage queue. When the size of the target storage queue meets a preset size condition or a preset time window condition, all aggregated indicators stored in the target storage queue are packaged using a compression algorithm and transmitted to the analysis module.
[0108] As a refinement of the above embodiments, when transmitting all the compressed aggregated indicators to the analysis module, the following implementation methods can also be adopted, but are not limited to: determining whether the network link corresponding to the aggregated indicator is an important network link; if it is determined that the network link corresponding to the aggregated indicator is a non-important network link, then when the network link is abnormal, all the compressed aggregated indicators are transmitted to the analysis module; if it is determined that the network link corresponding to the aggregated indicator is an important network link, then whether the network link is normal or abnormal, all the compressed aggregated indicators are transmitted to the analysis module. That is, a hierarchical strategy can be implemented for the monitored links. Non-important links do not need to be transmitted to the upper layer when in a normal state, and the specific indicators are only sent up when there is an abnormality. For important links, the indicators are sent up regardless of whether there is an abnormality. The distinction between normal and abnormal is based on whether the link packet loss and latency meet certain conditions.
[0109] As a refinement of the above embodiments, after storing the round-trip delay calculation results, the method may also employ, but is not limited to, the following implementation methods, for example: deleting the first timestamp and the second attribute information. The process involved in this embodiment has been described in the above exemplary description using the ICMP protocol as an example, that is, after storing the round-trip delay calculation results, deleting the first timestamp and the second attribute information, which in the exemplary description using ICMP as an example means deleting the information stored in the hash table. As a refinement of the above embodiments, when performing step 101, when determining that the number of stored round-trip delay calculation results meets a preset quantity condition, when calculating all stored round-trip delay calculation results, the method may also employ, but is not limited to, the following implementation methods, for example: when determining that the number of target measurement packets sent to the destination is the same as the number of stored round-trip delay calculation results, calculating all stored round-trip delay calculation results to obtain the network quality score.
[0110] In some embodiments, to calculate the network quality score, the following implementation methods can also be used, but are not limited to: continuously consuming the first attribute information inserted into the attribute information storage queue by the target thread, incrementing the number of packets received at the destination by 1 each time the first attribute information is retrieved, and when it is equal to the number of packets sent by the destination in each cycle, it means that all reply packets in this cycle have been received. Since a timeout will also generate a packet loss result internally, there will always be a result in the calculation result storage queue. When the number of packets sent in each cycle is equal to the number of round-trip delay calculation results in the calculation result storage queue, that is, when the number of target measurement messages sent is the same as the number of stored round-trip delay calculation results, the network quality score such as average latency and packet loss rate can be calculated.
[0111] The network quality detection method disclosed herein can be implemented based on the ICMP protocol, UDP protocol, or TCP protocol. However, since the standards of ICMP, UDP, and TCP protocols are not the same, corresponding modifications have been made when the method is implemented based on UDP or TCP protocols. Please refer to the following content for specific solutions.
[0112] As a refinement of the above embodiments, if the target test message and target measurement message are UDP protocol messages, i.e., network quality measurement is implemented based on the UDP protocol, the original reply message sent by the destination end in the kernel mode can also be implemented in the following ways, but not limited to: if the original reply message sent by the original port of the destination end is not received, then switch to other ports of the destination end for network quality detection until the original reply message is received from the other switched ports.
[0113] To facilitate understanding of the above content, this embodiment provides an exemplary description, using the UDP protocol as an example. As a connectionless and unreliable transport layer protocol, UDP does not necessarily require the server (destination) to send a response message to the client (executor). In many cases, UDP is simply a one-way message transmission. Therefore, when using UDP packets for RTT measurement, it is necessary to rely on a characteristic of ICMP: the ICMP error message, "Port Unreachable." During network quality testing, when probing a port that is not open at the destination, that port will respond with an ICMP error message. The payload portion of the responded ICMP error message will be filled with the header information of the sent UDP protocol packet, i.e., the second attribute information. For example, if the execution end fills the identifier field of the UDP protocol packet with 1024 when sending, the identifier field of the IP packet in the payload portion of the responded ICMP error message will also be 1024. Therefore, by combining the identifier field of the IP packet and the source and destination ports of the UDP protocol packet, a one-to-one correspondence is established between the sent UDP protocol packet and the responded ICMP error packet, thereby calculating the RTT latency. In special cases, if a service at the destination happens to be listening on the UDP port, the destination will not respond with an ICMP error packet. In this case, if the executing end does not receive the ICMP error packet (i.e., the target response packet), there are two possibilities: first, a service at the destination is listening on the specified UDP port, and the sent packet was received normally, so the destination service will not respond with an ICMP message; second, the network is down, or there is packet loss in the process. The handling strategy is to mark the result of the current round of network quality detection as "suspected packet loss," switch the destination port to another, less frequently used port for probing, and if it is still not working, repeat the above series of actions, marking the previous round of probing results as packet loss. If an ICMP error packet is received, the switching of the destination port is stopped.
[0114] As a refinement of the above embodiments, if the target test message or target measurement message belongs to the TCP protocol message, that is, when the network quality measurement is implemented based on the TCP protocol, the original reply message sent by the destination end in the kernel mode can also be implemented in the following ways, but not limited to: if the target reply message sent by the original port of the destination end is a TCP protocol synchronization acknowledgment message, then switch to other ports of the destination end for network quality detection until a TCP protocol reset message is received from the switched other ports.
[0115] To facilitate understanding of the above content, this embodiment provides an exemplary description, which takes the TCP protocol as an example. The description includes the following: When measuring the port connectivity of the destination, the interaction process is as follows: the client, i.e., the execution end, sends a SYN packet, i.e., the measurement packet, and the server, i.e., the destination, replies with a SYN+ACK packet, i.e., the synchronization confirmation packet. Since it is not necessary to actually establish a TCP connection, the client will reply with an RST packet, i.e., the reset packet, to disconnect the connection. However, on the server, this half-open connection will exist for a certain period of time. If the number of measurements on the server is relatively large, it will cause unnecessary waste of resources.
[0116] Therefore, when port connectivity measurement is not required, this process can be optimized to avoid this situation. The optimized process is as follows: The client first sends a SYN packet, but the destination port is an uncommon port or a port that the server is not listening on. If the server is not listening on that port, it will directly reply with an RST packet, without creating a half-open connection. At this time, the RTT metrics of the two servers are also obtained based on the reset packet. In addition, a round-trip packet is identified by the source port, destination port, and flags (SYN / ACK). Furthermore, if the destination port is being listened to by the service, the destination will normally reply with a SYN+ACK packet. If a SYN+ACK packet is received, although the RTT metric can be obtained at this point, the normal three-way handshake process will cause a half-open connection problem. Therefore, it is necessary to first mark the network quality test result of this round as no packet loss and attach the calculated RTT value, and then send an RST packet to switch the destination port to another, less frequently used port for the next round of network quality test. If the destination still replies with a SYN+ACK packet, the above series of processes are repeated. If an RST packet is received, the switching of the destination port is stopped.
[0117] In some embodiments, the original reply message is filtered from the kernel state. The preset filtering conditions involved have different designs in network quality detection schemes implemented based on different transport protocols. The specific distinctions are as follows:
[0118] In ICMP measurement scenarios, the PID number of the detection program process is filled with the identifier in the ICMP header to ensure accurate filtering of the target reply message.
[0119] In UDP measurement scenarios, the destination reply message is an ICMP error message. The payload of the ICMP error message is filled with the header information of the sent UDP protocol message, i.e., the target test message. Therefore, by using a fixed offset, the header information of the UDP protocol message in the ICMP error message can be obtained, and precise filtering can be achieved by comparing the source and destination ports. In TCP scenarios, the TCP RST reply message returns with the source and destination ports reversed. Therefore, precise filtering can be achieved by directly setting conditions based on the source and destination port information. In both TCP and UDP scenarios, as mentioned above, port switching at the destination end may occur in special cases. To solve the filtering problem of the original reply message during port switching, the destination measurement message is constructed based on a port range. Regardless of the switch, the source and destination ports will only change within a few ports included in the specified port range. Therefore, the filtering condition can be specified as a set of ports.
[0120] In some embodiments, the network quality detection involved in this application further supports the detection of the quality of service interfaces and supports application layer protocols such as HTTP and HTTPS.
[0121] Corresponding to the network quality detection method described above, this invention also proposes a network quality detection apparatus. Since the apparatus embodiments of this invention correspond to the method embodiments described above, details not disclosed in the apparatus embodiments can be referred to the method embodiments described above, and will not be repeated here.
[0122] Figure 2 This is a schematic diagram of the structure of a network quality detection device provided in an embodiment of the present disclosure, as shown below. Figure 2 As shown, it includes:
[0123] The first judgment unit 21 is used to receive the original reply message sent by the destination in kernel mode and judge whether the third attribute information carried by the original reply message meets the preset filtering conditions.
[0124] The determining unit 22 is used to determine the original reply message as the target reply message when it is determined that the third attribute information meets the preset filtering conditions;
[0125] The first transmission unit 23 is used to transmit the target reply message from the kernel mode to the user mode;
[0126] The second judgment unit 24 is used to determine whether the first attribute information carried by the target reply message is the same as the second attribute information carried by the target measurement message;
[0127] The first calculation unit 25 is used to calculate the round-trip time delay for the first timestamp of the target measurement message sent and the second timestamp of the target reply message received when it is determined that the first attribute information and the second attribute information are the same, and to obtain the round-trip time delay calculation result.
[0128] The first storage unit 26 is used to store the round-trip delay calculation results;
[0129] The second calculation unit 27 is used to calculate all the stored round-trip delay calculation results to obtain a network quality score when the number of stored round-trip delay calculation results meets a preset quantity condition.
[0130] A mechanism for precise screening at the kernel level is proposed for ICMP / TCP / UDP probes. Meanwhile, TCP probes avoid the half-open connection problem caused by the three-way handshake, ensuring that the host machine's resource consumption is controlled when a large number of probe targets are involved.
[0131] Detailed measurement schemes are proposed for ICMP / TCP / UDP probes, decoupling the sending, receiving, calculation, and result output of measurement messages. Asynchronous processing of each step is achieved based on multi-threading, lock-free blocking queues, and other technologies, maximizing concurrent probes and improving the throughput of the entire measurement system.
[0132] The network quality is detected by calculating the round-trip delay result based on the first timestamp and the second timestamp, and then calculating the network quality score based on the round-trip delay result.
[0133] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 3 As shown, the device includes:
[0134] The first checking unit 28 is used to sequentially check whether there are elements in the bidirectional list that meet the preset timeout conditions. The elements are target measurement messages stored in the bidirectional list before the target measurement message is sent.
[0135] The second inspection unit 29 is used to check whether the fourth attribute information and the third timestamp corresponding to the target element have been deleted when it is determined that there is a target element in the bidirectional list that meets the preset timeout condition.
[0136] The determining unit 210 is used to determine that the target reply message corresponding to the target element is lost when it is determined that neither the fourth attribute information nor the third timestamp has been deleted, and to store the packet loss result in the first target storage queue.
[0137] The first deletion unit 211 is used to delete the target element from the bidirectional list and to delete the fourth attribute information and the third timestamp.
[0138] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 3 As shown, the device includes:
[0139] The second deletion unit 212 is used to delete the target element from the bidirectional list when it is determined that both the fourth attribute information and the third timestamp have been deleted.
[0140] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 3 As shown, the device includes:
[0141] The third calculation unit 213 is used to obtain multiple network quality scores after performing multiple network quality tests on the destination, and to calculate the multiple network quality scores to obtain an aggregate index.
[0142] The second storage unit 214 is used to store the aggregation index into the target storage queue;
[0143] Compression unit 215 is used to compress all aggregate indicators stored in the target storage queue when it is determined that the size of the target storage queue meets a preset size condition or the storage time of the first aggregate indicator stored in the target storage queue meets a preset time window condition.
[0144] The second transmission unit 216 is used to transmit all the compressed aggregated indicators to the analysis module.
[0145] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 3 As shown, the transmission unit 216 includes:
[0146] The judgment module 2161 is used to determine whether the network link corresponding to the aggregation index is an important network link;
[0147] The transmission module 2162 is used to transmit all the compressed aggregated indicators to the analysis module when it is determined that the network link corresponding to the aggregated indicator is a non-critical network link, and when the network link is abnormal.
[0148] The transmission module 2162 is further configured to transmit all the compressed aggregated indicators to the analysis module when it is determined that the network link corresponding to the aggregated indicator is an important network link, and whether the network link is normal or abnormal.
[0149] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 3 As shown, the device includes:
[0150] The third deletion unit 217 is used to delete the first timestamp and the second attribute information.
[0151] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 3 As shown, the second computing unit 27 is also used for:
[0152] When the number of target measurement messages sent to the destination is equal to the number of stored round-trip delay calculation results, the network quality score is obtained by calculating all stored round-trip delay calculation results.
[0153] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 3 As shown, the first judgment unit 21 is further configured to switch to network quality detection on other ports of the destination when the original reply message sent by the original port of the destination is not received, until the original reply message is received from the switched other port.
[0154] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 3 As shown, the first judgment unit 21 is further configured to switch to network quality detection on other ports of the destination when the target reply message sent by the original port of the destination is a TCP protocol synchronization confirmation message, until a TCP protocol reset message is received from the switched other port.
[0155] It should be noted that the foregoing explanation of the method embodiments also applies to the apparatus of the embodiments of this disclosure, and the principle is the same. Therefore, the embodiments of this disclosure are not limited thereto.
[0156] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0157] Figure 4A schematic block diagram of an example electronic device 300 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0158] like Figure 4 As shown, device 300 includes a computing unit 301, which can perform various appropriate actions and processes based on a computer program stored in ROM (Read-Only Memory) 302 or a computer program loaded from storage unit 308 into RAM (Random Access Memory) 303. RAM 303 can also store various programs and data required for the operation of device 300. The computing unit 301, ROM 302, and RAM 303 are interconnected via bus 304. I / O (Input / Output) interface 305 is also connected to bus 304.
[0159] Multiple components in device 300 are connected to I / O interface 305, including: input unit 306, such as keyboard, mouse, etc.; output unit 307, such as various types of monitors, speakers, etc.; storage unit 308, such as disk, optical disk, etc.; and communication unit 309, such as network card, modem, wireless transceiver, etc. Communication unit 309 allows device 300 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0160] The computing unit 301 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, CPUs (Central Processing Units), GPUs (Graphics Processing Units), various special-purpose AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, DSPs (Digital Signal Processors), and any suitable processor, controller, microcontroller, etc. The computing unit 301 performs the various methods and processes described above, such as methods for network quality detection. For example, in some embodiments, the network quality detection method may be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on device 300 via ROM 302 and / or communication unit 309. When the computer program is loaded into RAM 303 and executed by the computing unit 301, one or more steps of the methods described above may be performed. Alternatively, in other embodiments, the computing unit 301 may be configured to perform the aforementioned network quality detection method by any other suitable means (e.g., by means of firmware).
[0161] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application-Specific Standard Products), SOCs (System-on-Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0162] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0163] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0164] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0165] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication (e.g., communication networks) of any form or medium. Examples of communication networks include LANs (Local Area Networks), WANs (Wide Area Networks), the Internet, and blockchain networks.
[0166] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service ecosystem, addressing the shortcomings of traditional physical hosts and VPS (Virtual Private Server, or simply "VPS") services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.
[0167] It's important to note that artificial intelligence (AI) is the study of enabling computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.
[0168] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0169] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for network quality detection, characterized in that, include: The kernel receives the original reply message sent by the destination and determines whether the third attribute information carried by the original reply message meets the preset filtering conditions. When it is determined that the third attribute information meets the preset filtering conditions, the original reply message is determined to be the target reply message; The target response message is transmitted from the kernel space to the user space, and it is determined whether the first attribute information carried by the target response message is the same as the second attribute information carried by the target measurement message. When it is determined that the first attribute information is the same as the second attribute information, the round-trip time delay is calculated for the first timestamp of the target measurement message sent and the second timestamp of the target reply message received, and the round-trip time delay calculation result is obtained. The round-trip delay calculation results are stored; When the number of stored round-trip delay calculation results meets a preset quantity condition, the network quality score is calculated for all stored round-trip delay calculation results.
2. The method according to claim 1, characterized in that, After storing the round-trip delay calculation result, the method includes: The system sequentially checks whether there are any elements in the bidirectional list that meet the preset timeout conditions. The elements are the target measurement messages stored in the bidirectional list before the target measurement message is sent. When it is determined that there is a target element in the bidirectional list that meets the preset timeout condition, check whether the fourth attribute information and the third timestamp corresponding to the target element have been deleted. If it is determined that neither the fourth attribute information nor the third timestamp has been deleted, the target reply message corresponding to the target element is lost, and the packet loss result is stored in the first target storage queue. The target element is removed from the bidirectional list, and the fourth attribute information and the third timestamp are also removed.
3. The method according to claim 2, characterized in that, After checking whether the fourth attribute information and the third timestamp corresponding to the target element have been deleted, the method includes: If it is determined that both the fourth attribute information and the third timestamp have been deleted, the target element is removed from the bidirectional list.
4. The method according to claim 1, characterized in that, After calculating the network quality score from all stored round-trip latency calculation results, the method includes: After performing multiple network quality tests on the destination, multiple network quality scores are obtained. An aggregate index is obtained by calculating the multiple network quality scores. Store the aggregated metrics to the second target storage queue; When it is determined that the size of the second target storage queue meets the preset size condition or the storage time of the first aggregate index stored in the second target storage queue meets the preset time window condition, all aggregate indicators stored in the second target storage queue are compressed. All the compressed aggregated metrics are transmitted to the analysis module.
5. The method according to claim 4, characterized in that, The step of transmitting all the compressed aggregated metrics to the analysis module includes: Determine whether the network link corresponding to the aggregated index is an important network link; If it is determined that the network link corresponding to the aggregated index is a non-critical network link, then when the network link is abnormal, all the compressed aggregated indexes will be transmitted to the analysis module. If the network link corresponding to the aggregated index is determined to be an important network link, then whether the network link is normal or abnormal, all the compressed aggregated indexes will be transmitted to the analysis module.
6. The method according to claim 1, characterized in that, After storing the round-trip delay calculation result, the method includes: Delete the first timestamp and the second attribute information.
7. The method according to claim 1, characterized in that, The step of calculating all stored round-trip delay calculation results when the number of stored round-trip delay calculation results meets a preset quantity condition includes: When the number of target measurement messages sent to the destination is equal to the number of stored round-trip delay calculation results, the network quality score is obtained by calculating all stored round-trip delay calculation results.
8. The method according to claim 1, characterized in that, If the target measurement message is a UDP protocol message, the process of receiving the original reply message sent by the destination in kernel mode includes: If the original reply message is not received from the original port of the destination, then network quality checks are performed on other ports of the destination until the original reply message is received from the other port.
9. The method according to claim 1, characterized in that, If the target measurement message is a TCP protocol message, the original reply message sent by the destination in kernel mode includes: If the original reply message sent by the original port of the destination is a TCP synchronization acknowledgment message, then the network quality check is switched to other ports of the destination until a TCP reset message is received from the switched other ports.
10. A device for network quality detection, characterized in that, include: The first judgment unit is used to receive the original reply message sent by the destination in kernel mode and determine whether the third attribute information carried by the original reply message meets the preset filtering conditions. The determining unit is configured to determine the original reply message as the target reply message when it is determined that the third attribute information meets the preset filtering conditions; The first transmission unit is used to transmit the target reply message from the kernel space to the user space; The second judgment unit is used to determine whether the first attribute information carried in the target reply message is the same as the second attribute information carried in the target measurement message; The first calculation unit is used to calculate the round-trip time delay for the first timestamp of the target measurement message sent and the second timestamp of the target reply message received when it is determined that the first attribute information and the second attribute information are the same, and to obtain the round-trip time delay calculation result. The first storage unit is used to store the round-trip delay calculation results; The second calculation unit is used to calculate all the stored round-trip delay calculation results to obtain a network quality score when the number of stored round-trip delay calculation results meets a preset quantity condition.
11. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-9.
12. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-9.
13. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method according to any one of claims 1-9.
Citation Information
Patent Citations
Universal TCP performance diagnosis method and device
CN110138590A
Time delay measurement method and related device
CN116192694A