[go: up one dir, main page]

WO2024159957A1 - 网络健康探测方法、装置、电子设备及存储介质 - Google Patents

网络健康探测方法、装置、电子设备及存储介质 Download PDF

Info

Publication number
WO2024159957A1
WO2024159957A1 PCT/CN2023/140013 CN2023140013W WO2024159957A1 WO 2024159957 A1 WO2024159957 A1 WO 2024159957A1 CN 2023140013 W CN2023140013 W CN 2023140013W WO 2024159957 A1 WO2024159957 A1 WO 2024159957A1
Authority
WO
WIPO (PCT)
Prior art keywords
resource
current
health detection
remote resource
remote
Prior art date
Application number
PCT/CN2023/140013
Other languages
English (en)
French (fr)
Inventor
邓捷
梁勇
郭爱杰
杨泽润
任正
何姗姗
孙鹏翔
Original Assignee
天翼云科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 天翼云科技有限公司 filed Critical 天翼云科技有限公司
Publication of WO2024159957A1 publication Critical patent/WO2024159957A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/50Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate

Definitions

  • the embodiments of the present application relate to the field of computer technology, and in particular to a network health detection method, device, electronic device and storage medium.
  • the methods for network health detection are usually UDP (User Datagram Protocol), TCP (Transmission Control Protocol), HTTP (Hyper Text Transfer Protocol) and HTTPS (Hypertext Transfer Protocol Secure), and a socket connection is confirmed by a four-tuple source IP (Internet Protocol) address, source port, destination IP address, and destination port. Since the number of source ports is limited, 65535 different port numbers are generally allowed, so when there are large-scale periodic health detection tasks, there will be insufficient resources for the source port.
  • the socket connection enters the time waiting (TIME_WAIT) state, and it needs to wait for 2MSL (Maximum Segment Lifetime) time before the socket connection can be completely released. In this case, a large number of health detection tasks that need to establish TCP connections are more likely to encounter insufficient resources.
  • the main methods are: enable port reuse, and the operating system allocates ports; reduce the waiting time of the time waiting state; set the tcp_max_tw_buckets parameter to control the maximum value of the time waiting state connection, and the time waiting state connection exceeding the maximum value will be released immediately; increase the source IP address, and perform health detection through different source IP addresses.
  • the first three methods reduce the security of the connection, and may cause the newly established connection to be immediately disconnected because it is disturbed by the message of the previous connection with the same four-tuple that survives in the network, thereby affecting the accuracy of health detection.
  • the fourth method in an environment that supports public network health detection, requires more public network IP addresses for health detection, which increases the use of IP addresses and increases costs.
  • the embodiments of the present application provide a network health detection method, device, electronic device and storage medium, which help to improve the accuracy and security of health detection without increasing the source IP address.
  • an embodiment of the present application provides a network health detection method, including:
  • the current local resource is obtained from the local resource list.
  • the local resources in the local resource list include the source IP address and the source port.
  • the current local resource includes the current source IP address and the current source port.
  • the remote resource list includes the remote resources that are historically bound to the current local resource.
  • the remote resources include the destination IP address and destination port.
  • the current health detection task is established.
  • the first binding relationship between the health detection task and the current local resource
  • the current health detection task is executed.
  • an embodiment of the present application provides a network health detection device, including:
  • a local resource acquisition module is used to obtain the current local resources from the local resource list when the current health detection task meets the concurrent control conditions.
  • the local resources in the local resource list include the source IP address and the source port.
  • the current local resources include the current source IP address and the current source port.
  • a remote resource acquisition module is used to obtain a remote resource list corresponding to the current local resource, the remote resource list includes remote resources historically bound to the current local resource, and the remote resources include a destination IP address and a destination port;
  • a first binding relationship establishment module is used to establish a first binding relationship between the current health detection task and the current local resource if the remote resource in the remote resource list is not in a time waiting state, or the remote resource in the remote resource list that is in a time waiting state is different from the target remote resource of the current health detection task;
  • a task execution module is used to execute the current health detection task according to the first binding relationship.
  • an embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the network health detection method of the embodiment of the present application is implemented when the processor executes the computer program.
  • an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the network health detection method disclosed in the embodiment of the present application is implemented.
  • the network health detection method, device, electronic device and storage medium provided in the embodiments of the present application obtain the current local resource from the local resource list and obtain the remote resource list corresponding to the current local resource when the current health detection task meets the concurrent control conditions. If the remote resource in the remote resource list is not in a time waiting state, or the remote resource in the time waiting state is different from the target remote resource of the current health detection task, a first binding relationship between the current health detection task and the current local resource is established, and the current health detection task is executed according to the first binding relationship.
  • the current local resource can be used to execute the current health detection task, thereby realizing port multiplexing and ensuring that no two identical four-tuple socket connections appear within 2MSL time, thereby improving the security and accuracy of the health detection task, and no source IP address needs to be added, thus saving source IP address resources and supporting a large number of concurrent health detection tasks.
  • FIG1 is a flow chart of a network health detection method provided by an embodiment of the present application.
  • FIG. 2 is a flowchart of determining whether a current local resource is a local resource available for a current health detection task based on a remote resource list in an embodiment of the present application;
  • FIG3 is a flow chart of another network health detection method provided by an embodiment of the present application.
  • FIG4 is a flow chart of another network health detection method provided in an embodiment of the present application.
  • FIG5 is a schematic diagram of an implementation of a remote resource link table in an embodiment of the present application.
  • FIG6 is a schematic diagram of an implementation of a local resource linked list in an embodiment of the present application.
  • FIG7 is an overall topology diagram of the network health detection method provided in an embodiment of the present application.
  • FIG8 is a structural block diagram of a network health detection device provided in an embodiment of the present application.
  • FIG. 9 is a structural block diagram of an electronic device provided in an embodiment of the present application.
  • FIG1 is a flow chart of a network health detection method provided in an embodiment of the present application.
  • the method can be executed by an electronic device such as a computer. As shown in FIG1 , the method includes the following steps.
  • Step 110 when the current health detection task meets the concurrency control condition, the current local resource is obtained from the local resource list, the local resources in the local resource list include the source IP address and the source port, and the current local resource includes the current source IP address and the current source port.
  • the local resource linked list is used to store the local resources available for the health detection task in the form of a linked list, each linked list node stores a local resource, and each local resource includes a source IP address and a source port for health detection.
  • the number of health detection tasks being executed can be controlled based on the number of available local resources.
  • the health detection task can be added to the concurrent control queue, and the health detection tasks in the concurrent control queue are queued for execution.
  • a health detection task is taken out from the concurrent control queue as the current health detection task.
  • the current health detection task meets the concurrent control conditions, and the local resources available to the current health detection task are obtained from the local resource linked list to execute the current health detection task.
  • a local resource can be obtained from the local resource linked list as the current local resource.
  • the number of health detection tasks being executed can be recorded by a counter.
  • the count value of the counter is increased by 1.
  • the count value of the counter is decreased by 1.
  • Step 120 obtaining a remote resource linked list corresponding to the current local resource, the remote resource linked list includes remote resources historically bound to the current local resource, and the remote resources include a destination IP address and a destination port.
  • each local resource corresponds to a remote resource linked list
  • the remote resource linked list stores the remote resources that have been historically bound to the local resources corresponding to the remote resource linked list in the form of a linked list.
  • Each linked list node stores a remote resource
  • the linked list node also stores the execution completion time corresponding to the remote resource.
  • the execution completion time is the execution completion time of the historical health detection task corresponding to the remote resource, that is, when the communicating parties want to disconnect the socket connection, they disconnect by waving four times.
  • the electronic device that executes the network health detection method enters the time waiting (TIME_WAIT) state after sending the FIN packet in the four waves of the historical health detection task being executed, that is, the remote resource of the historical health detection task is in the time waiting state, and the time of sending the FIN packet is recorded as the execution completion time corresponding to the remote resource.
  • the remote resource historically bound to the current local resource is the remote resource in the health detection task that is historically executed using the current local resource.
  • Step 130 If the remote resource in the remote resource list is not in a time waiting state, or the remote resource in the remote resource list in a time waiting state is different from the target remote resource of the current health detection task, a first binding relationship between the current health detection task and the current local resource is established.
  • the remote resource in the time waiting state is different from the target remote resource of the current health detection task, it means that there will not be two socket connections of the same four-tuple within 2MSL time, and the first binding relationship between the current health detection task and the current local resource can be established; if the remote resource in the time waiting state is the same as the target remote resource of the current health detection task, then in order to avoid two socket connections of the same four-tuple within 2MSL time, the current local resource cannot be bound to the current health detection task, and the next local resource can be obtained from the local resource linked list and used as the current local resource again, and the remote resource in the above remote resource linked list is judged until the first binding relationship between the current health detection task and the current local resource is established or all local resources in the local resource linked list are judged to be completed.
  • FIG2 is a flowchart of determining whether the current local resource is a local resource available for the current health detection task based on the remote resource linked list in an embodiment of the present application. As shown in FIG2, if the remote resource in the remote resource linked list is not in a time waiting state, or the remote resource in the remote resource linked list that is in a time waiting state is different from the target remote resource of the current health detection task, then a first binding relationship between the current health detection task and the current local resource is established, including:
  • Step 131 traverse the remote resources in the remote resource list, and determine the currently traversed remote resource as the current remote resource.
  • Step 132 determining whether the current remote resource is in a time waiting state, if the current remote resource is not in a time waiting state, executing step 133, if the current remote resource is in a time waiting state, executing step 134.
  • Step 133 establishing a first binding relationship between the current health detection task and the current local resource; then executing step 135 .
  • Step 134 determining whether the current remote resource and the target remote resource are the same remote resource, if the current remote resource and the target remote resource are the same remote resource, executing step 135, if the current remote resource and the target remote resource are not the same remote resource, executing step 131.
  • step 131 can be executed to traverse the next remote resource in the remote resource list, redefine the next remote resource as the current remote resource, and loop through steps 131-134, that is, loop through the operations of determining whether the current remote resource is in a time waiting state and determining whether the current remote resource and the target remote resource are the same remote resource, until the traversal of the remote resource list is stopped.
  • each remote resource is stored in the order of the execution completion time corresponding to the remote resource from the latest to the earliest, that is, the remote resource stored in the first remote resource node in the remote resource linked list is the remote resource with the latest execution completion time, that is, the remote resource closest to the current time, the remote resource stored in the second remote resource node in the remote resource linked list is the remote resource with a later execution completion time than the remote resource stored in the first remote resource node, and so on, the remote resource stored in the last remote resource node in the remote resource linked list is the remote resource with the earliest execution completion time.
  • the remote resource linked list stores remote resources in the above order, by traversing the remote resource linked list in the above manner starting from the head, it can be quickly determined whether the current local resource is available for the current health detection task.
  • Step 140 Execute the current health detection task according to the first binding relationship.
  • the current health detection task is executed, the current local resource is used to establish a socket connection with the target remote resource in the current health detection task, and a health detection is performed to determine the health level between the current local resource and the target remote resource.
  • the current health detection task is executed, including: according to the first binding relationship, setting the current source IP address and the current source port in the current local resource as the target source IP address and the target source port of the socket connection to be established; setting the IP address multiplexing attribute of the target source IP address, and setting the port multiplexing attribute of the target source port; executing the current health detection task according to the target source IP address and the target source port.
  • the socket connection to be established is the socket connection to be established when executing the current health detection task.
  • the current source IP address and the current source port in the current local resource are set as the target source IP address and the target source port of the socket connection to be established, and the IP address reuse attribute of the target source IP address is set, and the port reuse attribute of the target source port is set, that is, the SO_REUSEADDR attribute and the SO_REUSEPORT attribute are set to ensure that the target source IP address and the target source port can be reused in the time waiting state, and then the current health detection task is executed based on the target source IP address and the target source port to complete the health detection.
  • SO_REUSEADDR allows the port to be reused immediately after it is released;
  • SO_REUSEPORT is an option setting of the network, which allows multiple processes or threads to bind/listen to the same IP address or port (PORT).
  • TCP it is a load balancing function for the distribution of new connections, which improves the distribution performance of new connections.
  • the target source IP address and the target source port can be reused, thereby avoiding insufficient resources.
  • the grid health detection method provided in the embodiment of the present application obtains the current local resource from the local resource list and obtains the remote resource list corresponding to the current local resource when the current health detection task meets the concurrent control condition. If the remote resource in the remote resource list is not in a time waiting state, or the remote resource in the time waiting state is different from the target remote resource of the current health detection task, a first binding relationship between the current health detection task and the current local resource is established, and the current health detection task is executed according to the first binding relationship.
  • the current local resource can be used to execute the current health detection task, thereby realizing port multiplexing and ensuring that no two identical four-tuple socket connections appear within 2MSL time, thereby improving the security and accuracy of the health detection task, and there is no need to increase the source IP address, thus saving source IP address resources and supporting a large number of concurrent health detection tasks.
  • the current health detection task when the current health detection task meets the concurrent control conditions, before obtaining the current local resources from the local resource list, it also includes: obtaining the source IP address list and the first source port range for health detection; generating local resources based on the source IP address list and the first source port range, and adding the local resources to the local resource list.
  • the user can set the source IP address list and the first source port range required for health detection, so that the electronic device executing the network health detection method obtains the source IP address list and the first source port range required for health detection allocated by the user to the system, and then can generate local resources available for health detection through the allocated source IP address list and the first source port range, and add all local resources to the local resource list.
  • the number of available local resources is the product of the number of source IP addresses in the source IP address list and the number of source ports in the first source port range.
  • Generate a health detection by obtaining the source IP address list and the first source port range to be detected.
  • the local resources used can then be used to perform health detection tasks.
  • the source IP address list and the first source port range for health detection after obtaining the source IP address list and the first source port range for health detection, it also includes: determining the number of concurrently executed health detection tasks according to the source IP address list and the first source port range as the number of concurrently executed tasks.
  • the number of concurrently executed tasks is determined by the source IP address list and the first source port range. When there are many health detection tasks to be executed, a larger first source port range can be set.
  • the current health detection task when the current health detection task meets the concurrency control conditions, before obtaining the current local resources from the local resource list, it also includes: when the number of health detection tasks currently being executed is less than the number of concurrently executed tasks, determining that the current health detection task meets the concurrency control conditions.
  • a user can also set a second source port range reserved by the system, and can set the reserved second source port range by configuring the ip_local_port_range parameter through sysctl, and can use the source ports in the second source port range to perform other tasks.
  • the sysctl command is used to dynamically modify the operating parameters of the kernel when the kernel is running.
  • the available kernel parameters are in the directory /proc/sys/, which contains some advanced options for the TCP/ip stack and virtual memory system. The sysctl command can improve system performance.
  • FIG3 is a flow chart of another network health detection method provided in an embodiment of the present application.
  • the method can be executed by an electronic device such as a computer. As shown in FIG3 , the method includes the following steps.
  • Step 310 When the current health detection task meets the concurrency control condition, the local resource list is traversed, and the currently traversed local resource is determined as the current local resource.
  • available local resources are obtained from the local resource list.
  • the available local resources can be obtained by traversing the local resource list. The traversal can be started from the head of the local resource list, and the currently traversed local resource is determined as the current local resource.
  • Step 320 obtaining a remote resource linked list corresponding to the current local resource, the remote resource linked list includes remote resources historically bound to the current local resource, and the remote resources include a destination IP address and a destination port.
  • Step 330 If the remote resource in the remote resource list is not in a time waiting state, or the remote resource in the remote resource list in a time waiting state is different from the target remote resource of the current health detection task, a first binding relationship between the current health detection task and the current local resource is established.
  • Step 340 Execute the current health detection task according to the first binding relationship.
  • Step 350 If the remote resource in the remote resource list in the time waiting state is equal to the target remote resource If the target remote resource exists in the remote resources in the time waiting state in the remote resource list, it means that the current local resource is unavailable. In this case, the next local resource of the current local resource in the local resource list is re-determined as the current local resource, and steps 320 to 350 are executed until the first binding relationship is established or the traversal of the local resource list is completed.
  • This embodiment obtains available local resources in the local resource list by traversing the local resource list, so that the available local resources can be obtained relatively quickly and accurately, and a first binding relationship between the current health detection task and the available local resources can be established.
  • the local resource list after traversing the local resource list, it also includes: if after the local resource list traversal is completed, the current health detection task has not established a first binding relationship with the local resources in the local resource list, then the current health detection task is added to the emergency health detection list.
  • the emergency health detection list is used to store health detection tasks that have reached the execution time but cannot be bound to available local resources.
  • Emergency health detection tasks in the emergency health detection list can be executed first, that is, after a health detection task is executed, the local resources used by the health detection task that has just been executed can be used first to execute the emergency health detection task.
  • the current health detection task is added to the emergency health detection list to facilitate the subsequent priority execution of the health detection tasks in the emergency health detection list.
  • FIG4 is a flowchart of another network health detection method provided in an embodiment of the present application.
  • the method can be executed by an electronic device such as a computer. As shown in FIG4 , the method includes the following steps.
  • Step 410 when the current health detection task meets the concurrency control condition, the current local resource is obtained from the local resource list, the local resources in the local resource list include the source IP address and the source port, and the current local resource includes the current source IP address and the current source port.
  • Step 420 obtaining a remote resource linked list corresponding to the current local resource, the remote resource linked list includes remote resources historically bound to the current local resource, and the remote resources include a destination IP address and a destination port.
  • Step 430 If the remote resource in the remote resource list is not in a time waiting state, or the remote resource in the remote resource list in a time waiting state is different from the target remote resource of the current health detection task, a first binding relationship between the current health detection task and the current local resource is established.
  • Step 440 Execute the current health detection task according to the first binding relationship.
  • Step 450 After the current health detection task is executed, the first binding relationship between the current health detection task and the current local resource is released.
  • the current health detection task After the current health detection task is executed, it is unbound from the current local resource, that is, the first binding relationship between the current health detection task and the current local resource is released, and the current health detection task waits for the next executable time to arrive.
  • Step 460 record the target remote resource into the remote resource linked list, and record the execution completion time of the current health detection task as the execution completion time corresponding to the target remote resource.
  • the target remote resource of the health detection of the current health detection task is recorded in the remote resource linked list corresponding to the current local resource, and the execution completion time of the current health detection task is recorded.
  • the target remote resource is recorded in the remote resource link table, and the current health
  • the execution completion time of the Kang detection task is recorded as the execution completion time corresponding to the target remote resource, including: if the remote resource in the tail node of the remote resource linked list is in a time waiting state, a new remote resource node is generated, the target remote resource and the execution completion time are recorded in the new remote resource node, and the new remote resource node is inserted into the head of the remote resource linked list;
  • the tail node is taken out from the remote resource linked list, the remote resource record in the tail node is overwritten with the target remote resource and the execution completion time, and the tail node is inserted into the head of the remote resource linked list.
  • the target remote resource of the current health detection task and the corresponding execution completion time are recorded in the remote resource linked list corresponding to the current local resource.
  • the tail node can be reused, that is, the tail node is taken out from the remote resource linked list, the target remote resource and the execution completion time are recorded in the tail node, and the remote resource previously recorded in the tail node is overwritten, and the tail node is inserted into the head of the remote resource linked list. If the remote resource in the tail node of the remote resource chain list is in a time waiting state, a new remote resource node can be generated, the target remote resource and the execution completion time are recorded in the new remote resource node, and the new remote resource node is inserted into the head of the remote resource chain list.
  • Figure 5 is a schematic diagram of the implementation of the remote resource chain list in the embodiment of the present application.
  • the remote resource chain list corresponding to the current local resource is traversed, and the traversal starts from the head of the remote resource chain list, and it is judged whether the remote resource in the remote resource chain list that is in a time waiting state (i.e., the remote resource bound within 2MSL time) is the same as the target remote resource.
  • a time waiting state i.e., the remote resource bound within 2MSL time
  • the remote resource in the remote resource chain list that is in a time waiting state is the same as the target remote resource, the current local resource is not available for the current health detection task, and then it can be judged whether the next local resource in the local resource chain list is available for the current health detection task. If the remote resource in the remote resource chain list that is in a time waiting state is different from the target remote resource, the current local resource is available for the current health detection task, and the loop traversal is immediately jumped out. After the current health detection task is completed, the target remote resource and execution completion time of the current health detection task need to be recorded in the remote resource linked list, and the remote resource in the tail node is judged.
  • the tail node is taken out from the tail of the linked list for reuse. If the difference between the current time and the execution completion time of the remote resource is less than 2MSL, that is, the remote resource is in a time waiting state, then a new remote resource node is applied for, the target remote resource and the corresponding execution completion time are recorded in the new remote resource node, and the taken out tail node or the new remote resource node is inserted into the head of the remote resource linked list.
  • the tail node of the remote resource linked list is reused first, and the tail node is inserted into the head of the remote resource linked list, which can avoid the remote resources that are not in the time waiting state (that is, greater than 2MSL) from occupying too much storage space. If the remote resource in the tail node is in the time waiting state, a new remote resource node is applied for, and the target remote resource and the execution completion time are recorded in the new remote resource node.
  • the new remote resource node is inserted into the head of the remote resource linked list, which can ensure that the execution completion time of the remote resource linked list from beginning to end is in order from late to early, that is, the execution completion time of the remote resource linked list from beginning to end is getting longer and longer from the current time.
  • the remote resource linked list if the traversed remote resource is not in the time waiting state (that is, the difference between the current time and the execution completion time is greater than 2MSL), the remote resources after the remote resource are not in the time waiting state. In the time waiting state, there is no need to traverse the subsequent remote resources, which can improve the traversal speed of the remote resource list.
  • the method further includes:
  • the remote resource in the remote resource linked list is not in a time waiting state, or the remote resource in the remote resource linked list in a time waiting state is different from the remote resource of the emergency health detection task, then a second binding relationship between the emergency health detection task and the current local resource is established;
  • an emergency health detection task is performed.
  • the current local resource is attempted to be bound to the emergency health detection task in the emergency health detection list, that is, to determine whether the current local resource is available to the emergency health detection task in the emergency health detection list, that is, to determine whether there is a remote resource in the time waiting state in the remote resource linked list; if there is no remote resource in the time waiting state in the remote resource linked list, that is, all remote resources in the remote resource linked list are not in the time waiting state, then the current local resource is available to the emergency health detection task, and a second binding relationship between the emergency health detection task and the current local resource can be established; if there is a remote resource in the time waiting state in the remote resource linked list If the remote resource in the time waiting state in the remote resource linked list is the same as the remote resource of the emergency health detection task, it is further determined whether the remote resource in the time waiting state in the remote resource linked list is the same as the remote resource of the emergency health detection task.
  • the current local resource is available to the emergency health detection task, and a second binding relationship between the emergency health detection task and the current local resource can be established. If the remote resource in the time waiting state in the remote resource linked list is the same as the remote resource of the emergency health detection task, the current local resource is not available to the emergency health detection task, and then it can be determined whether the current local resource is available to the next emergency health detection task in the emergency health detection list until the second binding relationship is established or the emergency health detection list is traversed.
  • the emergency health detection task After establishing the second binding relationship between the emergency health detection task and the current local resources, the emergency health detection task is executed immediately. In this way, after a health detection task is completed, the current local resources used by the health detection task can be used to prioritize the execution of the emergency health detection tasks in the emergency health detection list, thereby avoiding the failure to execute the emergency health detection tasks when the execution time arrives.
  • the emergency health detection tasks in the emergency health detection list after traversing the emergency health detection tasks in the emergency health detection list, it also includes: if there is no emergency health detection task in the emergency health detection list, or the remote resource in the time waiting state in the remote resource linked list is the same remote resource as the remote resource of the emergency health detection task, then the current local resource is added to the local resource linked list.
  • the current local resources can be released directly, that is, the current local resources can be added to the end of the local resource linked list to facilitate the use of subsequent health detection tasks; or, when the current local resources are not available for all emergency health detection tasks in the emergency health detection list, the current local resources are released, that is, the current local resources are added to the end of the local resource linked list to facilitate the use of subsequent health detection tasks.
  • FIG6 is a schematic diagram of the implementation of the local resource linked list in the embodiment of the present application.
  • each local resource can be traversed from the head of the local resource linked list until the local resource available for the current health detection task is found; after a health detection task is completed, when the corresponding local resource needs to be released, the local resource is inserted into the tail of the local resource linked list.
  • the available local resources are implemented using a linked list, and the local resources to be released are directly inserted into the tail of the linked list to ensure that the last use time of the nodes from the beginning to the end of the linked list increases in sequence.
  • FIG. 7 is an overall topological diagram of a network health detection method provided in an embodiment of the present application.
  • the concurrent control module controls the concurrent execution of the health detection tasks that have reached the executable time.
  • the total number of health detection tasks being executed is less than the number of concurrently executed tasks (the product of the number of source IP addresses and the number of source ports)
  • the total number of health detection tasks being executed is increased by 1; the current health detection task is ready to be executed, and attempts to bind local resources.
  • the current health detection task can be bound to the local resource; determine whether the current health detection task has been bound to the local resource. If not, add the current health detection task to the emergency health detection list. If it has been bound, execute the health detection task and perform network health detection based on UDP, TCP, HTTP, and HTTPS.
  • the concurrent control module reduces the total number of health detection tasks being executed by 1; recycle the local resources to be released, and add the local resources to be released to the end of the local resource list; if the local resources are bound to the health detection tasks in the emergency health detection list, because the current health detection task has been executed, the concurrent control module reduces the total number of health detection tasks being executed by 1.
  • FIG8 is a structural block diagram of a network health detection device provided in an embodiment of the present application. As shown in FIG8 , the device includes:
  • the local resource acquisition module 810 is used to acquire the current local resource from the local resource list when the current health detection task meets the concurrency control condition.
  • the local resources in the local resource list include the source IP address and the source port.
  • the current local resource includes the current source IP address and the current source port.
  • the remote resource acquisition module 820 is used to obtain a remote resource linked list corresponding to the current local resource, the remote resource linked list includes the remote resources historically bound to the current local resource, and the remote resources include a destination IP address and a destination port;
  • the first binding relationship establishing module 830 is used to establish the first binding relationship between the current health detection task and the current local resource if the remote resource in the remote resource list is not in a time waiting state, or the remote resource in the remote resource list that is in a time waiting state is different from the target remote resource of the current health detection task; the task execution module 840 is used to execute the current health detection task according to the first binding relationship.
  • the task execution module includes:
  • a resource setting unit configured to set, according to the first binding relationship, a current source IP address and a current source port in a current local resource as a target source IP address and a target source port of a socket connection to be established;
  • a multiplexing attribute setting unit used to set an IP address multiplexing attribute of a target source IP address and to set a port multiplexing attribute of a target source port;
  • a task execution unit is used to execute the current health detection task according to the target source IP address and the target source port.
  • the local resource acquisition module includes:
  • a traversal unit used to traverse the local resource list and determine the currently traversed local resource as the current local resource
  • the device also includes:
  • the traversal control module is used to re-determine the next local resource in the local resource chain list as the current local resource if the remote resource in the time waiting state in the remote resource chain list is the same as the target remote resource.
  • the device further includes:
  • the task adding module is used to add the current health detection task to the emergency health detection task list if the current health detection task has not established a first binding relationship with the local resources in the local resource list after the local resource list traversal is completed. Health detection list.
  • the device further includes:
  • a binding relationship release module used to release the first binding relationship between the current health detection task and the current local resource after the current health detection task is completed
  • the remote resource recording module is used to record the target remote resource into the remote resource linked list, and record the execution completion time of the current health detection task as the execution completion time corresponding to the target remote resource.
  • the remote resource recording module is specifically used to:
  • the remote resource in the tail node of the remote resource linked list is in a time waiting state, a new remote resource node is generated, the target remote resource and the execution completion time are recorded in the new remote resource node, and the new remote resource node is inserted into the head of the remote resource linked list;
  • the tail node is taken out from the remote resource linked list, the remote resource record in the tail node is overwritten with the target remote resource and the execution completion time, and the tail node is inserted into the head of the remote resource linked list.
  • the device further includes:
  • An emergency task traversal module is used to traverse the emergency health detection tasks in the emergency health detection list
  • a second binding relationship establishing module used for establishing a second binding relationship between the emergency health detection task and the current local resource if the remote resource in the remote resource chain list is not in a time waiting state, or the remote resource in the remote resource chain list that is in a time waiting state is different from the remote resource of the emergency health detection task;
  • the emergency task execution module is used to execute the emergency health detection task according to the second binding relationship.
  • the device further includes:
  • the local resource release module is used to add the current local resource to the local resource linked list if there is no emergency health detection task in the emergency health detection list, or the remote resource in the time waiting state in the remote resource linked list is the same remote resource as the remote resource of the emergency health detection task.
  • the device further includes:
  • a resource range acquisition module used to obtain a source IP address list and a first source port range for health detection
  • the local resource generation module is used to generate local resources according to the source IP address list and the first source port range, and add the local resources to the local resource linked list.
  • the device further includes:
  • the concurrent number determination module is used to determine the number of concurrently executed health detection tasks according to the source IP address list and the first source port range as the number of concurrently executed tasks.
  • the device further includes:
  • the concurrency control module is used to determine whether the current health detection task meets the concurrency control condition when the number of health detection tasks currently being executed is less than the number of concurrently executed tasks.
  • the device further includes:
  • the reserved port range acquisition module is used to acquire a reserved second source port range, where the first source port range and the second source port range do not have any intersection.
  • the network health detection device provided in the embodiment of the present application is used to implement each step of the network health detection method in the embodiment of the present application.
  • the specific implementation methods of each module of the device refer to the corresponding steps and will not be repeated here.
  • the network health detection device provided in the embodiment of the present application obtains the current local resource from the local resource list when the current health detection task meets the concurrent control conditions, and obtains the remote resource list corresponding to the current local resource. If the remote resource in the remote resource list is not in a time waiting state, or the remote resource in the time waiting state is different from the target remote resource of the current health detection task, a first binding relationship between the current health detection task and the current local resource is established, and the current health detection task is executed according to the first binding relationship.
  • the current local resource can be used to execute the current health detection task, thereby realizing port multiplexing and ensuring that no two identical four-tuple socket connections will appear within 2MSL time, thereby improving the security and accuracy of the health detection task and not requiring an increase in the source IP address, thus saving source IP address resources and supporting a large number of concurrent health detection tasks.
  • FIG9 is a block diagram of an electronic device provided in an embodiment of the present application.
  • the electronic device 900 may include one or more processors 910 and one or more memories 920 connected to the processors 910.
  • the electronic device 900 may also include an input interface 930 and an output interface 940 for communicating with another device or system.
  • the program code executed by the processor 910 may be stored in the memory 920.
  • the processor 910 in the electronic device 900 calls the program code stored in the memory 920 to execute the network health detection method in the above embodiment.
  • a computer-readable storage medium includes but is not limited to a disk storage, a CD-ROM, an optical storage, etc.
  • a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the network health detection method of the aforementioned embodiment is implemented.
  • each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware.
  • the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM/RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Environmental & Geological Engineering (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

提供了一种网络健康探测方法、装置、电子设备及存储介质,方法包括:在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,本地资源链表中的本地资源包括源IP地址和源端口(110);获取当前本地资源对应的远程资源链表,远程资源链表包括当前本地资源历史绑定的远程资源,远程资源包括目的IP地址和目的端口(120);如果远程资源链表中的远程资源未处于时间等待状态,或者处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系(130);根据第一绑定关系,执行当前健康探测任务(140)。提高了健康探测任务的安全性和准确性,节约源IP地址资源。

Description

网络健康探测方法、装置、电子设备及存储介质
相关申请的交叉引用:
本申请要求于2023年01月30日提交中国专利局,申请号为202310045735.5,申请名称为“网络健康探测方法、装置、电子设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及计算机技术领域,特别是涉及一种网络健康探测方法、装置、电子设备及存储介质。
背景技术
对网络进行健康探测的方式通常为UDP(User Datagram Protocol,用户数据协议)、TCP(Transmission Control Protocol,传输控制协议)、HTTP(Hyper Text Transfer Protocol,超文本传输协议)和HTTPS(Hypertext Transfer Protocol Secure,超文本传输安全协议)等方式,且通过四元组源IP(Internet Protocol,国际互联协议)地址、源端口、目的IP地址、目的端口来确认一条Socket连接。由于源端口数量有限,一般可允许65535个不同的端口号,所以在存在大规模周期性健康探测任务时,源端口便存在资源不足的情况。另外,在TCP连接中,客户端关闭TCP连接后,Socket连接进入时间等待(TIME_WAIT)状态,且需要等待2MSL(Maximum Segment Lifetime,报文最大生存时间)时间后,才能完全释放Socket连接。在这种情况下,大量需要建立TCP连接的健康探测任务便更容易遇到资源不足的情况。
现有技术中,可以采用多种方式来缓解资源不足的情况,主要方式为:开启端口复用,由操作系统分配端口;减小时间等待状态的等待时间;设置tcp_max_tw_buckets参数来控制时间等待状态连接的最大值,超过最大值的时间等待状态连接将立即释放;增加源IP地址,通过不同的源IP地址进行健康检测。前三种方式降低了连接的安全性,可能导致刚建立起来的连接,因为受到上一个相同四元组的连接存活于网络中的报文所干扰,而导致新连接立即断开,从而影响健康探测的准确性,而第四种方式,在支持公网健康探测的环境中,需要更多的公网IP地址进行健康探测,增加了IP地址的使用量,提高了成本。
发明内容
本申请实施例提供一种网络健康探测方法、装置、电子设备及存储介质,有助于在不增加源IP地址的情况下提高健康探测的准确性和安全性。
为了解决上述问题,第一方面,本申请实施例提供了一种网络健康探测方法,包括:
在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,本地资源链表中的本地资源包括源IP地址和源端口,当前本地资源包括当前源IP地址和当前源端口;
获取当前本地资源对应的远程资源链表,远程资源链表包括当前本地资源历史绑定的远程资源,远程资源包括目的IP地址和目的端口;
如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前 健康探测任务与当前本地资源的第一绑定关系;
根据第一绑定关系,执行当前健康探测任务。
第二方面,本申请实施例提供了一种网络健康探测装置,包括:
本地资源获取模块,用于在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,本地资源链表中的本地资源包括源IP地址和源端口,当前本地资源包括当前源IP地址和当前源端口;
远程资源获取模块,用于获取当前本地资源对应的远程资源链表,远程资源链表包括当前本地资源历史绑定的远程资源,远程资源包括目的IP地址和目的端口;第一绑定关系建立模块,用于如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系;任务执行模块,用于根据第一绑定关系,执行当前健康探测任务。
第三方面,本申请实施例还提供了一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时实现本申请实施例的网络健康探测方法。
第四方面,本申请实施例提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时本申请实施例公开的网络健康探测方法。
本申请实施例提供的网络健康探测方法、装置、电子设备及存储介质,通过在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,获取当前本地资源对应的远程资源链表,如果远程资源链表中的远程资源未处于时间等待状态,或者处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系,根据第一绑定关系执行当前健康探测任务,由于在当前本地资源历史绑定过的远程资源未处于时间等待状态,或者处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同时,可以使用当前本地资源执行当前健康探测任务,实现了端口复用,而且保证了2MSL时间内不会出现两个相同四元组的套接字连接,提高了健康探测任务的安全性和准确性,而且不需要增加源IP地址,节约源IP地址资源,支持大量并发的健康探测任务。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请实施例提供的一种网络健康探测方法的流程图;
图2是本申请实施例中基于远程资源链表来确定当前本地资源是否是当前健康探测任务可用的本地资源的流程图;
图3是本申请实施例提供的另一种网络健康探测方法的流程图;
图4是本申请实施例提供的又一种网络健康探测方法的流程图;
图5是本申请实施例中远程资源链表的实现示意图;
图6是本申请实施例中本地资源链表的实现示意图;
图7是本申请实施例提供的网络健康探测方法的整体拓扑图;
图8是本申请实施例提供的一种网络健康探测装置的结构框图;
图9是本申请实施例提供的一种电子设备的结构框图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
图1是本申请实施例提供的一种网络健康探测方法的流程图,该方法可以由计算机等电子设备执行,如图1所示,该方法包括如下步骤。
步骤110,在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,本地资源链表中的本地资源包括源IP地址和源端口,当前本地资源包括当前源IP地址和当前源端口。
其中,本地资源链表用于以链表的形式存储健康探测任务可用的本地资源,每个链表节点存储一个本地资源,每个本地资源包括用于进行健康探测的源IP地址和源端口。
可以基于可用的本地资源的数量来控制正在执行的健康探测任务的数量,在到达健康探测任务的可执行时间时,可以将健康探测任务添加至并发控制队列中,并发控制队列中的健康探测任务排队等待执行。在当前正在执行的健康探测任务的数量小于可用的本地资源的数量时,从并发控制队列中取出一个健康探测任务,作为当前健康探测任务,当前健康探测任务满足并发控制条件,从本地资源链表中获取当前健康探测任务可用的本地资源,以便执行当前健康探测任务。可以从本地资源链表中获取一个本地资源,作为当前本地资源。
示例性的,正在执行的健康探测任务的数量可以通过计数器来进行记录,在当前健康探测任务满足并发控制条件时,将计数器的计数值加1,在当前健康探测任务执行完成后,将计数器的计数值减1。
步骤120,获取当前本地资源对应的远程资源链表,远程资源链表包括当前本地资源历史绑定的远程资源,远程资源包括目的IP地址和目的端口。
其中,每个本地资源对应一个远程资源链表,远程资源链表是以链表的形式存储该远程资源链表所对应的本地资源历史绑定过的远程资源,每个链表节点存储一个远程资源,链表节点中还存储该远程资源所对应的执行完成时间,该执行完成时间是该远程资源所对应的历史健康探测任务的执行完成时间,即在通信双方要断开套接字(Socket)连接时,通过四次挥手来断开,执行网络健康探测方法的电子设备在执行的历史健康探测任务的四次挥手中发送FIN包后进入时间等待(TIME_WAIT)状态,也就是该历史健康探测任务的远程资源处于时间等待状态,并将发送FIN包的时间记录为该远程资源对应的执行完成时间。当前本地资源历史绑定的远程资源是使用当前本地资源历史执行的健康探测任务中的远程资源。
步骤130,如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系。
基于当前本地资源对应的远程资源链表来确定当前本地资源是否可用。首先判断远程资源链表中的所有远程资源是否均未处于时间等待状态,从远程资源链表中获取远程资源和与远程资源对应的执行完成时间,如果当前时间与执行完成时间的差值大于或等于2MSL,则确定该远程资源未处于时间等待状态,如果远程资源链表中的所有远程资源均未处于时间等待状态,则说明2MSL时间内不会出现 两个相同四元组的套接字连接,可以建立当前健康探测任务与当前本地资源的第一绑定关系。如果远程资源链表中存在处于时间等待状态的远程资源,即远程资源链表中存在当前时间与执行完成时间的差值小于2MSL的远程资源,需要进一步判断处于时间等待状态的远程资源与当前健康探测任务的目标远程资源是否相同,如果处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则说明2MSL时间内不会出现两个相同四元组的套接字连接,可以建立当前健康探测任务与当前本地资源的第一绑定关系;如果处于时间等待状态的远程资源与当前健康探测任务的目标远程资源为同一远程资源,则为了避免2MSL时间内出现两个相同四元组的套接字连接,不能将当前本地资源绑定到当前健康探测任务中,可以从本地资源链表中获取下一个本地资源,重新作为当前本地资源,并进行上述远程资源链表中远程资源的判断,直至建立当前健康探测任务与当前本地资源的第一绑定关系或者本地资源链表中的所有本地资源均判断完成。
在基于远程资源链表来确定当前本地资源是否是当前健康探测任务可用的本地资源时,可以通过对远程资源链表遍历的方式来进行判断。图2是本申请实施例中基于远程资源链表来确定当前本地资源是否是当前健康探测任务可用的本地资源的流程图,如图2所示,如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系,包括:
步骤131,遍历远程资源链表中的远程资源,将当前遍历到的远程资源确定为当前远程资源。
步骤132,判断当前远程资源是否处于时间等待状态,若当前远程资源未处于时间等待状态,则执行步骤133,若当前远程资源处于时间等待状态,则执行步骤134。
步骤133,建立当前健康探测任务与当前本地资源的第一绑定关系;之后执行步骤135。
步骤134,判断当前远程资源与目标远程资源是否为同一远程资源,若当前远程资源与目标远程资源为同一远程资源,则执行步骤135,若当前远程资源与目标远程资源不是同一远程资源,则执行步骤131。
在当前远程资源与目标远程资源不是同一远程资源时,可以执行步骤131,遍历远程资源链表中的下一个远程资源,将下一个远程资源重新确定为当前远程资源,并循环执行步骤131-步骤134,即循环执行判断当前远程资源是否处于时间等待状态以及判断当前远程资源与目标远程资源是否为同一远程资源的操作,直至停止遍历远程资源链表。
步骤135,停止遍历远程资源链表。
在远程资源链表中,各远程资源是按照远程资源所对应的执行完成时间从晚到早的顺序进行存储的,即远程资源链表中第一个远程资源节点中存储的远程资源是执行完成时间最晚的远程资源,也就是距离当前时间最近的远程资源,远程资源链表中第二个远程资源节点中存储的远程资源是执行完成时间晚于第一个远程资源节点中所存储远程资源的远程资源,以此类推,远程资源链表中最后一个远程资源节点中存储的远程资源是执行完成时间最早的远程资源。远程资源链表按照上述顺序存储远程资源时,通过从远程资源链表的头部开始进行上述方式的遍历,可以较为快速的判断出当前本地资源对当前健康探测任务是否可用。
步骤140,根据第一绑定关系,执行当前健康探测任务。
基于第一绑定关系,执行当前健康探测任务,使用当前本地资源建立与当前健康探测任务中的目标远程资源之间的套接字连接,并进行健康探测,确定当前本地资源与目标远程资源之间的健康程度。
在本申请的一个实施例中,根据第一绑定关系,执行当前健康探测任务,包括:根据第一绑定关系,将当前本地资源中的当前源IP地址和当前源端口设置为待建立的套接字连接的目标源IP地址和目标源端口;设置目标源IP地址的IP地址复用属性,并设置目标源端口的端口复用属性;根据目标源IP地址和目标源端口执行当前健康探测任务。
其中,待建立的套接字连接就是执行当前健康探测任务时要建立的套接字连接。根据第一绑定关系,将当前本地资源中的当前源IP地址和当前源端口设置为待建立的套接字连接的目标源IP地址和目标源端口,设置目标源IP地址的IP地址复用属性,设置目标源端口的端口复用属性,也就是设置SO_REUSEADDR属性和SO_REUSEPORT属性,保证目标源IP地址和目标源端口在时间等待状态中可以复用,之后基于目标源IP地址和目标源端口执行当前健康探测任务,完成健康探测。其中,SO_REUSEADDR是让端口释放后立即就可以被再次使用;SO_REUSEPORT是网络的一个选项设置,它允许多个进程或线程bind/listen相同的IP地址或端口(PORT),在TCP的应用中,它是一个新连接分发的负载均衡功能,它提升了新连接的分配性能。
通过执行当前健康探测任务前设置目标源IP地址的IP地址复用属性和目标源端口的端口复用属性,可以保证执行当前健康探测任务时使用目标源IP地址和目标源端口建立的套接字连接在时间等待状态时,目标源IP地址和目标源端口可以复用,可以避免出现资源不足的情况。
本申请实施例提供的网格健康探测方法,通过在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,获取当前本地资源对应的远程资源链表,如果远程资源链表中的远程资源未处于时间等待状态,或者处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系,根据第一绑定关系执行当前健康探测任务,由于在当前本地资源历史绑定过的远程资源未处于时间等待状态,或者处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同时,可以使用当前本地资源执行当前健康探测任务,实现了端口复用,而且保证了2MSL时间内不会出现两个相同四元组的套接字连接,提高了健康探测任务的安全性和准确性,而且不需要增加源IP地址,节约源IP地址资源,支持大量并发的健康探测任务。
在上述技术方案的基础上,在在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源之前,还包括:获取待进行健康探测的源IP地址列表和第一源端口范围;根据源IP地址列表和第一源端口范围,生成本地资源,并将本地资源添加至本地资源链表中。
用户可以设置进行健康探测所需要的源IP地址列表和第一源端口范围,从而执行网络健康探测方法的电子设备获取到用户为系统分配的健康探测所需要的源IP地址列表和第一源端口范围,进而可以通过所分配的源IP地址列表和第一源端口范围,生成健康探测可用的本地资源,将所有的本地资源添加至本地资源链表中。其中,可用的本地资源的数量为源IP地址列表中源IP地址的数量与第一源端口范围中源端口数量的乘积。
通过获取待进行健康探测的源IP地址列表和第一源端口范围,生成健康探测可 用的本地资源,后续可以使用这些本地资源执行健康探测任务。
在上述技术方案的基础上,在获取待进行健康探测的源IP地址列表和第一源端口范围之后,还包括:根据源IP地址列表和第一源端口范围,确定并发执行的健康探测任务数量,作为并发执行任务数量。
确定源IP地址列表中的源IP地址数量,并确定第一源端口范围中的源端口数量;将源IP地址数量与源端口数量的乘积确定为并发执行的健康探测任务数量,该并发执行的健康探测任务数量就是并发执行任务数量。通过源IP地址列表和第一源端口范围确定并发执行任务数量,在需要执行的健康探测任务较多时,可以设置较大的第一源端口范围。
在上述技术方案的基础上,在在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源之前,还包括:在当前正在执行的健康探测任务的数量小于并发执行任务数量时,确定当前健康探测任务满足并发控制条件。
比较当前正在执行的健康探测任务的数量与并发执行任务数量,如果当前正在执行的健康探测任务的数量等于并发执行任务数量,确定当前健康探测任务不满足并发控制条件,如果正在执行的健康探测任务的数量小于并发执行任务数量,确定当前满足并发控制条件,可以从并发控制队列中获取一个健康探测任务,作为当前健康探测任务,并可以确定该当前健康探测任务满足并发控制条件。通过比较当前正在执行的健康探测任务的数量与并发执行任务数量,并基于比较结果对健康探测任务进行并发控制,可以避免并发控制任务没有本地资源可用的情况。在上述技术方案的基础上,在获取待进行健康探测的源IP地址列表和第一源端口范围之前,还包括:获取保留的第二源端口范围,第一源端口范围与第二源端口范围不存在交集。
在执行网络健康探测方法的电子设备上,用户还可以设置系统保留的第二源端口范围,可以通过sysctl配置ip_local_port_range参数,来设置保留的第二源端口范围,可以使用第二源端口范围中的源端口执行其他的任务,第一源端口范围与第二源端口范围不存在交集,可以避免健康探测所使用的源端口在使用过程中被系统占用导致健康探测不准确,以保证健康探测任务执行的准确性。其中,sysctl命令被用于在内核运行时动态地修改内核的运行参数,可用的内核参数在目录/proc/sys/中,它包含一些TCP/ip堆栈和虚拟内存系统的高级选项,通过sysctl命令可以提高系统性能。
图3是本申请实施例提供的另一种网络健康探测方法的流程图,该方法可以由计算机等电子设备执行,如图3所示,该方法包括如下步骤。
步骤310,在当前健康探测任务满足并发控制条件时,遍历本地资源链表,将当前遍历到的本地资源确定为当前本地资源。
在当前健康探测任务满足并发控制条件时,从本地资源链表中获取可用的本地资源,这时可以通过对本地资源链表遍历的方式来获取可用的本地资源,可以从本地资源链表的头部开始遍历,将当前遍历到的本地资源确定为当前本地资源。
步骤320,获取当前本地资源对应的远程资源链表,远程资源链表包括当前本地资源历史绑定的远程资源,远程资源包括目的IP地址和目的端口。
步骤330,如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系。
步骤340,根据第一绑定关系,执行当前健康探测任务。
步骤350,如果远程资源链表中处于时间等待状态的远程资源与目标远程资源为 同一远程资源,则将本地资源链表中的下一个本地资源重新确定为当前本地资源。如果远程资源链表中处于时间等待状态的远程资源中存在目标远程资源,则说明当前本地资源不可用,这时将本地资源链表中当前本地资源的下一个本地资源重新确定为当前本地资源,并执行步骤320至步骤350,直至建立第一绑定关系或者本地资源链表遍历完成。
本实施例通过对本地资源链表进行遍历的方式来获取本地资源链表中可用的本地资源,可以较为快速准确的获取到可用的本地资源,并建立当前健康探测任务与可用的本地资源之间的第一绑定关系。
在上述技术方案的基础上,在遍历本地资源链表之后,还包括:若在本地资源链表遍历完成后,当前健康探测任务未与本地资源链表中的本地资源建立第一绑定关系,则将当前健康探测任务添加至紧急健康探测列表中。
其中,紧急健康探测列表用于存储已到达执行时间但是无法绑定可用的本地资源的健康探测任务。
如果对本地资源链表遍历完成后,本地资源链表中不存在当前健康探测任务可用的本地资源,即本地资源链表中所有的本地资源都无法与当前健康探测任务建立第一步绑定关系,当前健康探测任务绑定本地资源失败,将当前健康探测任务加入紧急健康探测列表中。紧急健康探测列表中的紧急健康探测任务可以优先执行,即在一个健康探测任务执行完成后,可以优先使用刚执行完成的健康探测任务所使用的本地资源再执行紧急健康探测任务。
通过在本地资源链表遍历完成后,无法建立当前健康探测任务与本地资源链表中本地资源的第一绑定关系时,将当前健康探测任务添加至紧急健康探测列表中,便于后续优先执行紧急健康探测列表中的健康探测任务。
图4是本申请实施例提供的又一种网络健康探测方法的流程图,该方法可以由计算机等电子设备执行,如图4所示,该方法包括如下步骤。
步骤410,在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,本地资源链表中的本地资源包括源IP地址和源端口,当前本地资源包括当前源IP地址和当前源端口。
步骤420,获取当前本地资源对应的远程资源链表,远程资源链表包括当前本地资源历史绑定的远程资源,远程资源包括目的IP地址和目的端口。
步骤430,如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系。
步骤440,根据第一绑定关系,执行当前健康探测任务。
步骤450,在当前健康探测任务执行完成后,解除当前健康探测任务与当前本地资源的第一绑定关系。
在当前健康探测任务执行完成后,与当前本地资源解绑,即解除当前健康探测任务与当前本地资源之间的第一绑定关系,当前健康探测任务等待下一次可执行时间的到来。
步骤460,将目标远程资源记录到远程资源链表中,并将当前健康探测任务的执行完成时间记录为与目标远程资源对应的执行完成时间。
在解除当前健康探测任务与当前本地资源的第一绑定关系后,将当前健康探测任务此次健康探测的目标远程资源记录到当前本地资源对应的远程资源链表中,且记录当前健康探测任务的执行完成时间。
在本申请的一个实施例中,将目标远程资源记录到远程资源链表中,并将当前健 康探测任务的执行完成时间记录为与目标远程资源对应的执行完成时间,包括:若远程资源链表尾部节点中的远程资源处于时间等待状态,则生成新的远程资源节点,将目标远程资源和执行完成时间记录到新的远程资源节点中,并将新的远程资源节点插入至远程资源链表的头部;
若远程资源链表尾部节点中的远程资源未处于时间等待状态,则从远程资源链表中取出尾部节点,将目标远程资源和执行完成时间覆盖尾部节点中的远程资源记录,并将尾部节点插入至远程资源链表的头部。
在当前健康探测任务执行完成后,要将当前健康探测任务的目标远程资源和对应的执行完成时间记录到当前本地资源所对应的远程资源链表中。在要记录目标远程资源和执行完成时间时,可以首先判断远程资源链表尾部节点中的远程资源是否处于时间等待状态,即确定当前时间与尾部节点中远程资源所对应执行完成时间之间的差值,如果差值大于或等于2MSL,则确定尾部节点中的远程资源未处于时间等待状态,如果差值小于2MSL,则确定尾部节点中的远程资源处于时间等待状态。如果远程资源链表尾部节点中的远程资源未处于时间等待状态,则可以复用该尾部节点,即从远程资源链表中取出尾部节点,将目标远程资源和执行完成时间记录到尾部节点中,并覆盖该尾部节点中之前记录的远程资源,将尾部节点插入至远程资源链表的头部。如果远程资源链表尾部节点中的远程资源处于时间等待状态,则可以生成新的远程资源节点,将目标远程资源和执行完成时间记录到该新的远程资源节点中,将新的远程资源节点插入至远程资源链表的头部。图5是本申请实施例中远程资源链表的实现示意图。如图5所示,在判断当前健康探测任务(目标远程资源)是否可以绑定当前本地资源时,对当前本地资源所对应的远程资源链表进行遍历,从远程资源链表的头部开始遍历,判断远程资源链表中处于时间等待状态的远程资源(即2MSL时间内绑定过的远程资源)与目标远程资源是否相同,如果远程资源链表中处于时间等待状态的远程资源与目标远程资源为同一远程资源,则当前本地资源对当前健康探测任务不可用,之后可以判断本地资源链表中的下一个本地资源对当前健康探测任务是否可用,如果远程资源链表中处于时间等待状态的远程资源与目标远程资源不同,则当前本地资源对当前健康探测任务可用,立即跳出循环遍历。在当前健康探测任务执行完成后,当前健康探测任务的目标远程资源和执行完成时间需要记录至远程资源链表中,对尾部节点中的远程资源进行判断,如果当前时间与该远程资源的执行完成时间的差值大于或等于2MSL,即该远程资源未处于时间等待状态,则将该尾部节点从链表尾部取出复用,如果当前时间与该远程资源的执行完成时间的差值小于2MSL,即该远程资源处于时间等待状态,则申请新的远程资源节点,将目标远程资源和对应的执行完成时间记录到新的远程资源节点中,将取出的尾部节点或新的远程资源节点插入至远程资源链表的头部。
在当前健康探测任务执行完成后保存目标远程资源和执行完成时间时,优先复用远程资源链表的尾部节点,并将尾部节点插入至远程资源链表的头部,可以避免未处于时间等待状态(即大于2MSL)的远程资源占用过多的存储空间,如果尾部节点中的远程资源处于时间等待状态,则申请新的远程资源节点,并将目标远程资源和执行完成时间记录到新的远程资源节点中,将新的远程资源节点插入至远程资源链表的头部,可以保证远程资源链表从头到尾的执行完成时间是从晚到早的顺序,即远程资源链表从头到尾的执行完成时间距离当前时间越来越长,在遍历远程资源链表时,如果遍历到的远程资源未处于时间等待状态(即当前时间与执行完成时间之间的差值大于2MSL),则该远程资源之后的远程资源均未处 于时间等待状态,无需再遍历之后的远程资源,可以提高远程资源链表的遍历速度。
在上述技术方案的基础上,在解除当前健康探测任务与当前本地资源的第一绑定关系之后,还包括:
遍历紧急健康探测列表中的紧急健康探测任务;
如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与紧急健康探测任务的远程资源不同,则建立紧急健康探测任务与当前本地资源的第二绑定关系;
根据第二绑定关系,执行紧急健康探测任务。
在解除当前健康探测任务与当前本地资源的第一绑定关系后,将当前本地资源尝试与紧急健康探测列表中的紧急健康探测任务绑定,即判断当前本地资源对紧急健康探测列表中的紧急健康探测任务是否可用,也就是判断远程资源链表中是否存在处于时间等待状态的远程资源;如果远程资源链表中不存在处于时间等待状态的远程资源,也就是远程资源链表中的所有远程资源均未处于时间等待状态,则当前本地资源对该紧急健康探测任务可用,可以建立该紧急健康探测任务与当前本地资源的第二绑定关系;如果远程资源链表中存在处于时间等待状态的远程资源,则进一步判断远程资源链表中处于时间等待状态的远程资源与紧急健康探测任务的远程资源是否相同,如果不同,则当前本地资源对该紧急健康探测任务可用,可以建立该紧急健康探测任务与当前本地资源的第二绑定关系,如果远程资源链表中处于时间等待状态的远程资源与紧急健康探测任务的远程资源为同一远程资源,则当前本地资源对该紧急健康探测任务不可用,之后可以再判断当前本地资源对紧急健康探测列表中的下一个紧急健康探测任务是否可用,直至建立第二绑定关系或者紧急健康探测列表遍历完成。
在建立紧急健康探测任务与当前本地资源的第二绑定关系后,立即执行该紧急健康探测任务,这样在一个健康探测任务执行完成后,可以使用该健康探测任务所使用的当前本地资源来优先执行紧急健康探测列表中的紧急健康探测任务,可以避免到达执行时间的紧急健康探测任务无法及时执行。
在上述技术方案的基础上,在遍历紧急健康探测列表中的紧急健康探测任务之后,还包括:如果紧急健康探测列表中不存在紧急健康探测任务,或者远程资源链表中处于时间等待状态的远程资源与紧急健康探测任务的远程资源为同一远程资源,则将当前本地资源添加至本地资源链表中。
在紧急健康探测列表中不存在紧急健康探测任务时,可以直接释放当前本地资源,即将当前本地资源添加至本地资源链表的尾部,便于后续的健康探测任务使用;或者,当前本地资源对紧急健康探测列表中的所有紧急健康探测任务都不可用时,释放当前本地资源,即将当前本地资源添加至本地资源链表的尾部,便于后续的健康探测任务使用。
图6是本申请实施例中本地资源链表的实现示意图,如图6所示,在当前健康探测任务满足并发控制条件时,需要从本地资源链表中获取可用的本地资源,这时可以从本地资源链表的头部开始遍历各本地资源,直到找到当前健康探测任务可用的本地资源;在一个健康探测任务执行完成后,需要释放对应的本地资源时,将该本地资源插入至本地资源链表的尾部。可用的本地资源采用链表实现,待释放的本地资源直接插入链表尾部,保证链表从头到尾的节点最后一次使用时间依次递增。
图7是本申请实施例提供的网络健康探测方法的整体拓扑图,如图7所示,在健 康探测任务到达可执行时间时,由并发控制模块来控制到达可执行时间的健康探测任务的并发执行,正在执行的健康探测任务的总数量小于并发执行任务数量(源IP地址数量与源端口数量的乘积)时,正在执行的健康探测任务的总数量加1;当前健康探测任务准备执行,尝试绑定本地资源,若本地资源2MSL内未绑定与当前健康探测任务的目标远程资源相同的远程资源,则当前健康探测任务可以绑定该本地资源;判断当前健康探测任务是否已绑定本地资源,若未绑定,则将当前健康探测任务加入紧急健康探测列表,若已绑定,则执行健康探测任务,基于UDP、TCP、HTTP和HTTPS等方式进行网络健康探测;当前健康探测任务执行完成后,等待下次可执行时间;当前健康探测任务执行完成后,与本地资源解绑,将当前健康探测任务的远程资源加入本地资源绑定过的远程资源链表的头部;解绑后的本地资源尝试与紧急健康探测列表中的健康探测任务绑定;本地资源未与紧急健康探测列表中的健康探测任务绑定,该本地资源为待释放本地资源,并发控制模块将正在执行的健康探测任务的总数量减1;回收待释放的本地资源,将待释放的本地资源加入本地资源链表的尾部;如果本地资源与紧急健康探测列表中的健康探测任务绑定,因为当前健康探测任务已执行完成,所以并发控制模块将正在执行的健康探测任务的总数量减1。
图8是本申请实施例提供的一种网络健康探测装置的结构框图,如图8所示,装置包括:
本地资源获取模块810,用于在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,本地资源链表中的本地资源包括源IP地址和源端口,当前本地资源包括当前源IP地址和当前源端口;
远程资源获取模块820,用于获取当前本地资源对应的远程资源链表,远程资源链表包括当前本地资源历史绑定的远程资源,远程资源包括目的IP地址和目的端口;
第一绑定关系建立模块830,用于如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系;任务执行模块840,用于根据第一绑定关系,执行当前健康探测任务。
在本申请一些实施例中,任务执行模块包括:
资源设置单元,用于根据第一绑定关系,将当前本地资源中的当前源IP地址和当前源端口设置为待建立的套接字连接的目标源IP地址和目标源端口;
复用属性设置单元,用于设置目标源IP地址的IP地址复用属性,并设置目标源端口的端口复用属性;
任务执行单元,用于根据目标源IP地址和目标源端口执行当前健康探测任务。在本申请一些实施例中,本地资源获取模块包括:
遍历单元,用于遍历本地资源链表,将当前遍历到的本地资源确定为当前本地资源;
装置还包括:
遍历控制模块,用于如果远程资源链表中处于时间等待状态的远程资源与目标远程资源为同一远程资源,则将本地资源链表中的下一个本地资源重新确定为当前本地资源。
在本申请一些实施例中,装置还包括:
任务添加模块,用于若在本地资源链表遍历完成后,当前健康探测任务未与本地资源链表中的本地资源建立第一绑定关系,则将当前健康探测任务添加至紧急健 康探测列表中。
在本申请一些实施例中,装置还包括:
绑定关系解除模块,用于在当前健康探测任务执行完成后,解除当前健康探测任务与当前本地资源的第一绑定关系;
远程资源记录模块,用于将目标远程资源记录到远程资源链表中,并将当前健康探测任务的执行完成时间记录为与目标远程资源对应的执行完成时间。
在本申请一些实施例中,远程资源记录模块具体用于:
若远程资源链表尾部节点中的远程资源处于时间等待状态,则生成新的远程资源节点,将目标远程资源和执行完成时间记录到新的远程资源节点中,并将新的远程资源节点插入至远程资源链表的头部;
若远程资源链表尾部节点中的远程资源未处于时间等待状态,则从远程资源链表中取出尾部节点,将目标远程资源和执行完成时间覆盖尾部节点中的远程资源记录,并将尾部节点插入至远程资源链表的头部。
在本申请一些实施例中,装置还包括:
紧急任务遍历模块,用于遍历紧急健康探测列表中的紧急健康探测任务;
第二绑定关系建立模块,用于如果远程资源链表中的远程资源未处于时间等待状态,或者远程资源链表中处于时间等待状态的远程资源与紧急健康探测任务的远程资源不同,则建立紧急健康探测任务与当前本地资源的第二绑定关系;
紧急任务执行模块,用于根据第二绑定关系,执行紧急健康探测任务。
在本申请一些实施例中,装置还包括:
本地资源释放模块,用于如果紧急健康探测列表中不存在紧急健康探测任务,或者远程资源链表中处于时间等待状态的远程资源与紧急健康探测任务的远程资源为同一远程资源,则将当前本地资源添加至本地资源链表中。
在本申请一些实施例中,装置还包括:
资源范围获取模块,用于获取待进行健康探测的源IP地址列表和第一源端口范围;
本地资源生成模块,用于根据源IP地址列表和第一源端口范围,生成本地资源,并将本地资源添加至本地资源链表中。
在本申请一些实施例中,装置还包括:
并发数量确定模块,用于根据源IP地址列表和第一源端口范围,确定并发执行的健康探测任务数量,作为并发执行任务数量。
在本申请一些实施例中,装置还包括:
并发控制模块,用于在当前正在执行的健康探测任务的数量小于并发执行任务数量时,确定当前健康探测任务满足并发控制条件。
在本申请一些实施例中,装置还包括:
保留端口范围获取模块,用于获取保留的第二源端口范围,第一源端口范围与第二源端口范围不存在交集。
本申请实施例提供的网络健康探测装置,用于实现本申请实施例中的网络健康探测方法的各步骤,装置的各模块的具体实施方式参见相应步骤,此处不再赘述。本申请实施例提供的网络健康探测装置,通过在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,获取当前本地资源对应的远程资源链表,如果远程资源链表中的远程资源未处于时间等待状态,或者处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同,则建立当前健康探测任务与当前本地资源的第一绑定关系,根据第一绑定关系执行当前健康探测任 务,由于在当前本地资源历史绑定过的远程资源未处于时间等待状态,或者处于时间等待状态的远程资源与当前健康探测任务的目标远程资源不同时,可以使用当前本地资源执行当前健康探测任务,实现了端口复用,而且保证了2MSL时间内不会出现两个相同四元组的套接字连接,提高了健康探测任务的安全性和准确性,而且不需要增加源IP地址,节约源IP地址资源,支持大量并发的健康探测任务。
图9是本申请实施例提供的一种电子设备的结构框图,如图9所示,该电子设备900可以包括一个或多个处理器910以及与处理器910连接的一个或多个存储器920。电子设备900还可以包括输入接口930和输出接口940,用于与另一装置或系统进行通信。被处理器910执行的程序代码可存储在存储器920中。
电子设备900中的处理器910调用存储在存储器920的程序代码,以执行上述实施例中的网络健康探测方法。
根据本申请的一个实施例,还提供了一种计算机可读存储介质,计算机可读存储介质包括但不限于磁盘存储器、CD-ROM、光学存储器等,计算机可读存储介质上存储有计算机程序,计算机程序被处理器执行时实现前述实施例的网络健康探测方法。
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
以上对本申请实施例提供的一种网络健康探测方法、装置、电子设备及存储介质进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本申请的限制。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到各实施方式可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件实现。基于这样的理解,上述技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品可以存储在计算机可读存储介质中,如ROM/RAM、磁碟、光盘等,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行各个实施例或者实施例的某些部分的方法。

Claims (15)

  1. 一种网络健康探测方法,其特征在于,包括:
    在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,所述本地资源链表中的本地资源包括源IP地址和源端口,所述当前本地资源包括当前源IP地址和当前源端口;
    获取所述当前本地资源对应的远程资源链表,所述远程资源链表包括所述当前本地资源历史绑定的远程资源,所述远程资源包括目的IP地址和目的端口;
    如果所述远程资源链表中的远程资源未处于时间等待状态,或者所述远程资源链表中处于时间等待状态的远程资源与所述当前健康探测任务的目标远程资源不同,则建立所述当前健康探测任务与所述当前本地资源的第一绑定关系;
    根据所述第一绑定关系,执行所述当前健康探测任务。
  2. 根据权利要求1所述的方法,其特征在于,所述根据所述第一绑定关系,执行所述当前健康探测任务,包括:
    根据所述第一绑定关系,将所述当前本地资源中的当前源IP地址和当前源端口设置为待建立的套接字连接的目标源IP地址和目标源端口;
    设置所述目标源IP地址的IP地址复用属性,并设置所述目标源端口的端口复用属性;
    根据所述目标源IP地址和所述目标源端口执行所述当前健康探测任务。
  3. 根据权利要求1所述的方法,其特征在于,所述从本地资源链表中获取当前本地资源,包括:
    遍历所述本地资源链表,将当前遍历到的本地资源确定为所述当前本地资源;所述方法还包括:
    如果所述远程资源链表中处于时间等待状态的远程资源与所述目标远程资源为同一远程资源,则将本地资源链表中的下一个本地资源重新确定为当前本地资源。
  4. 根据权利要求3所述的方法,其特征在于,在所述遍历所述本地资源链表之后,还包括:
    若在所述本地资源链表遍历完成后,所述当前健康探测任务未与所述本地资源链表中的本地资源建立第一绑定关系,则将所述当前健康探测任务添加至紧急健康探测列表中。
  5. 根据权利要求1-4任一项所述的方法,其特征在于,在所述根据所述第一绑定关系,执行所述当前健康探测任务之后,还包括:
    在所述当前健康探测任务执行完成后,解除所述当前健康探测任务与所述当前本地资源的第一绑定关系;
    将所述目标远程资源记录到所述远程资源链表中,并将所述当前健康探测任务的执行完成时间记录为与所述目标远程资源对应的执行完成时间。
  6. 根据权利要求5所述的方法,其特征在于,所述将所述目标远程资源记录到所述远程资源链表中,并将所述当前健康探测任务的执行完成时间记录为与所述目标远程资源对应的执行完成时间,包括:
    若所述远程资源链表尾部节点中的远程资源处于时间等待状态,则生成新的远程资源节点,将所述目标远程资源和所述执行完成时间记录到所述新的远程资源节点中,并将所述新的远程资源节点插入至所述远程资源链表的头部;
    若所述远程资源链表尾部节点中的远程资源未处于时间等待状态,则从所述远程资源链表中取出所述尾部节点,将所述目标远程资源和所述执行完成时间覆盖所述尾部节点中的远程资源记录,并将所述尾部节点插入至所述远程资源链表的头 部。
  7. 根据权利要求5所述的方法,其特征在于,在所述解除所述当前健康探测任务与所述当前本地资源的第一绑定关系之后,还包括:
    遍历紧急健康探测列表中的紧急健康探测任务;
    如果所述远程资源链表中的远程资源未处于时间等待状态,或者所述远程资源链表中处于时间等待状态的远程资源与所述紧急健康探测任务的远程资源不同,则建立所述紧急健康探测任务与所述当前本地资源的第二绑定关系;
    根据所述第二绑定关系,执行所述紧急健康探测任务。
  8. 根据权利要求7所述的方法,其特征在于,在所述遍历紧急健康探测列表中的紧急健康探测任务之后,还包括:
    如果所述紧急健康探测列表中不存在所述紧急健康探测任务,或者所述远程资源链表中处于时间等待状态的远程资源与所述紧急健康探测任务的远程资源为同一远程资源,则将所述当前本地资源添加至所述本地资源链表中。
  9. 根据权利要求1-4任一项所述的方法,其特征在于,在所述在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源之前,还包括:获取待进行健康探测的源IP地址列表和第一源端口范围;
    根据所述源IP地址列表和所述第一源端口范围,生成所述本地资源,并将所述本地资源添加至所述本地资源链表中。
  10. 根据权利要求9所述的方法,其特征在于,在所述获取待进行健康探测的源IP地址列表和第一源端口范围之后,还包括:
    根据所述源IP地址列表和所述第一源端口范围,确定并发执行的健康探测任务数量,作为并发执行任务数量。
  11. 根据权利要求10所述的方法,其特征在于,在所述在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源之前,还包括:
    在当前正在执行的健康探测任务的数量小于所述并发执行任务数量时,确定所述当前健康探测任务满足所述并发控制条件。
  12. 根据权利要求9所述的方法,其特征在于,在所述获取待进行健康探测的源IP地址列表和第一源端口范围之前,还包括:
    获取保留的第二源端口范围,所述第一源端口范围与所述第二源端口范围不存在交集。
  13. 一种网络健康探测装置,其特征在于,包括:
    本地资源获取模块,用于在当前健康探测任务满足并发控制条件时,从本地资源链表中获取当前本地资源,所述本地资源链表中的本地资源包括源IP地址和源端口,所述当前本地资源包括当前源IP地址和当前源端口;
    远程资源获取模块,用于获取所述当前本地资源对应的远程资源链表,所述远程资源链表包括所述当前本地资源历史绑定的远程资源,所述远程资源包括目的IP地址和目的端口;
    第一绑定关系建立模块,用于如果所述远程资源链表中的远程资源未处于时间等待状态,或者所述远程资源链表中处于时间等待状态的远程资源与所述当前健康探测任务的目标远程资源不同,则建立所述当前健康探测任务与所述当前本地资源的第一绑定关系;
    任务执行模块,用于根据所述第一绑定关系,执行所述当前健康探测任务。
  14. 一种电子设备,包括存储器、处理器及存储在所述存储器上并可在处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现权利要 求1至12任意一项所述的网络健康探测方法。
  15. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现权利要求1至12任意一项所述的网络健康探测方法。
PCT/CN2023/140013 2023-01-30 2023-12-19 网络健康探测方法、装置、电子设备及存储介质 WO2024159957A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310045735.5A CN115914328B (zh) 2023-01-30 2023-01-30 网络健康探测方法、装置、电子设备及存储介质
CN202310045735.5 2023-01-30

Publications (1)

Publication Number Publication Date
WO2024159957A1 true WO2024159957A1 (zh) 2024-08-08

Family

ID=86472853

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/140013 WO2024159957A1 (zh) 2023-01-30 2023-12-19 网络健康探测方法、装置、电子设备及存储介质

Country Status (2)

Country Link
CN (1) CN115914328B (zh)
WO (1) WO2024159957A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115914328B (zh) * 2023-01-30 2023-06-23 天翼云科技有限公司 网络健康探测方法、装置、电子设备及存储介质

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1725757A (zh) * 2004-07-21 2006-01-25 三星电子株式会社 管理和检查套接字连接
CN103841148A (zh) * 2012-11-23 2014-06-04 京信通信系统(中国)有限公司 监控程序中利用可靠与非可靠网络的主从通信方法及系统
US20170230261A1 (en) * 2014-10-31 2017-08-10 Beijing Baidu Netcom Science And Technology Co., Ltd. Method and device for checking health of link
CN107332740A (zh) * 2017-08-25 2017-11-07 广东欧珀移动通信有限公司 一种网络检测方法、网络检测装置及智能终端
CN109586947A (zh) * 2018-10-11 2019-04-05 上海交通大学 分布式设备信息采集系统和方法
CN110674034A (zh) * 2019-09-12 2020-01-10 北京浪潮数据技术有限公司 一种健康检查方法、装置及电子设备和存储介质
CN112769651A (zh) * 2021-01-13 2021-05-07 杭州迪普科技股份有限公司 一种tcp连接检测方法、装置及电子设备
CN115914328A (zh) * 2023-01-30 2023-04-04 天翼云科技有限公司 网络健康探测方法、装置、电子设备及存储介质

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109246164A (zh) * 2017-07-10 2019-01-18 中兴通讯股份有限公司 一种基于云虚拟化网络的访问方法、装置及系统
CN114328156B (zh) * 2021-12-28 2023-06-16 苏州万店掌网络科技有限公司 协议端口的健康检测方法、装置、设备及可读存储介质

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1725757A (zh) * 2004-07-21 2006-01-25 三星电子株式会社 管理和检查套接字连接
CN103841148A (zh) * 2012-11-23 2014-06-04 京信通信系统(中国)有限公司 监控程序中利用可靠与非可靠网络的主从通信方法及系统
US20170230261A1 (en) * 2014-10-31 2017-08-10 Beijing Baidu Netcom Science And Technology Co., Ltd. Method and device for checking health of link
CN107332740A (zh) * 2017-08-25 2017-11-07 广东欧珀移动通信有限公司 一种网络检测方法、网络检测装置及智能终端
CN109586947A (zh) * 2018-10-11 2019-04-05 上海交通大学 分布式设备信息采集系统和方法
CN110674034A (zh) * 2019-09-12 2020-01-10 北京浪潮数据技术有限公司 一种健康检查方法、装置及电子设备和存储介质
CN112769651A (zh) * 2021-01-13 2021-05-07 杭州迪普科技股份有限公司 一种tcp连接检测方法、装置及电子设备
CN115914328A (zh) * 2023-01-30 2023-04-04 天翼云科技有限公司 网络健康探测方法、装置、电子设备及存储介质

Also Published As

Publication number Publication date
CN115914328A (zh) 2023-04-04
CN115914328B (zh) 2023-06-23

Similar Documents

Publication Publication Date Title
WO2019184164A1 (zh) 自动部署Kubernetes从节点的方法、装置、终端设备及可读存储介质
KR101855541B1 (ko) 컴퓨트 클러스터에서의 디버거 런칭 및 첨부 기법
CN105100232B (zh) 一种不中断服务的服务端程序平滑升级的方法
JP6091724B2 (ja) リンクのヘルスチェック方法および装置
CN111641583A (zh) 一种物联网资源接入系统及资源接入方法
WO2019184116A1 (zh) 自动搭建Kubernetes主节点的方法、装置、终端设备及可读存储介质
JPH10320220A (ja) 記述子を転送する方法および装置
CN107613037B (zh) 一种域名重定向方法和系统
WO2019006808A1 (zh) 一种处理长连接建立请求的方法和装置
WO2024159957A1 (zh) 网络健康探测方法、装置、电子设备及存储介质
WO2019056203A1 (zh) 一种低延时音视频传输方法、装置及计算机可读存储介质
CN112395049A (zh) 一种业务服务器调用方法、系统、设备及存储介质
US7769828B2 (en) System for provisioning time sharing option (TSO) and interactive productivity system facility (ISPF) services in a network environment
CN108804711B (zh) 一种数据处理的方法、装置和计算机可读存储介质
CN114490071A (zh) 一种基于云游戏的资源调度方法、装置、设备及介质
WO2015058594A1 (zh) 一种进程加载方法、装置及系统
WO2024217338A1 (zh) 网关、网关热升级方法及系统
CN107317880B (zh) 一种实现负载均衡的方法及装置
JP5262329B2 (ja) スケジューリングプログラム,スケジューリング方法及びスケジューリング装置
CN108848175B (zh) 一种创建tcp连接的方法及装置
JP2008276322A (ja) 情報処理装置、情報処理システムおよび情報処理方法
JP3950752B2 (ja) 装置
CN118445030B (zh) OpenCL计算卸载方法、装置及存储介质
JP5390947B2 (ja) ジョブ管理システム、ジョブ管理装置及びそのプログラム
JP2007507762A (ja) ステートレスなセッションの透過的なサーバ間移送

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23919519

Country of ref document: EP

Kind code of ref document: A1