Search

CN-116248544-B - Link detection method and device

CN116248544BCN 116248544 BCN116248544 BCN 116248544BCN-116248544-B

Abstract

The application provides a link detection method and device, and relates to the technical field of communication. The method comprises the steps of sending bidirectional forwarding detection BFD messages to network equipment corresponding to each private network address in an address pool for load balancing, receiving response messages of each BFD message sent by the network equipment, confirming the state of the network equipment represented by each response message received in set time, confirming that a link between the load balancing equipment and the network equipment is unavailable if the state represented by response messages exceeding a first set number in the set time is an inactive state, and confirming that the link between the load balancing equipment and the network equipment is available if the state represented by response messages exceeding a second set number in the set time is an active state and the state represented by response messages exceeding a third set number recently is an active state.

Inventors

  • Shu biao

Assignees

  • 新华三技术有限公司合肥分公司

Dates

Publication Date
20260505
Application Date
20221222

Claims (10)

  1. 1. A method for detecting a link, which is applied to a load balancing device, the method comprising: for each private network address in an address pool for load balancing, sending a Bidirectional Forwarding Detection (BFD) message to network equipment corresponding to the private network address; receiving a response message of each BFD message sent by the network equipment; Confirming the state of the network equipment represented by each response message received in the set time; if the state represented by the response messages exceeding the first set number in the set time is an inactive state, confirming that a link between the load balancing equipment and the network equipment is unavailable; And if the state represented by the response messages exceeding the second set number in the set time is an active state and the state represented by the response messages of the third set number which is received recently is an active state, confirming that a link between the load balancing equipment and the network equipment is available.
  2. 2. The method of claim 1, wherein sending the bidirectional forwarding detection BFD packet to the network device corresponding to the private network address comprises: And sending a BFD echo message to the network equipment corresponding to the private network address.
  3. 3. The method according to claim 2, wherein the BFD echo message is generated as follows: Determining a first IP address of the load balancing device and a second IP address of the network device; assembling the first IP address and the second IP address to obtain target information; And writing the target information into a setting field of the BFD echo message.
  4. 4. A method according to claim 3, wherein validating the status of the network device characterized by each response message received within the set time comprises: If the response message is consistent with the BFD echo message, confirming that the state of the network equipment represented by the response message is an active state; and if the response message is a message obtained by modifying the second IP address of the BFD echo message into the set content, confirming that the state of the network equipment represented by the response message is an inactive state.
  5. 5. The method of claim 1, wherein validating the status of the network device characterized by each response message received within the set time comprises: after confirming the state of the network equipment represented by the first response message, starting a timing function; And confirming the state of the network equipment represented by other response messages within a set time, wherein the set time is represented by the timing function.
  6. 6. The method according to claim 1, wherein for each private network address in the address pool for load balancing, sending a bidirectional forwarding detection BFD packet to a network device corresponding to the private network address, includes: When the timing function is started, sending a Bidirectional Forwarding Detection (BFD) message to network equipment corresponding to each private network address in an address pool for load balancing, wherein the set time is represented by the timing function.
  7. 7. A link detection apparatus, disposed in a load balancing device, the apparatus comprising: A sending module, configured to send, for each private network address in the address pool for load balancing, a bidirectional forwarding detection BFD packet to a network device corresponding to the private network address; a receiving module, configured to receive a response message of each BFD message sent by the network device; The determining module is used for determining the state of the network equipment represented by each response message received in the set time; The detection module is used for confirming that a link between the load balancing equipment and the network equipment is unavailable if the state represented by the response messages exceeding the first set number in the set time is an inactive state; The detection module is further configured to confirm that a link between the load balancing device and the network device is available if a state represented by the response messages exceeding the second set number is an active state within the set time and a state represented by the response messages of the third set number received recently is an active state.
  8. 8. The apparatus of claim 7, wherein the device comprises a plurality of sensors, The sending module is specifically configured to send a BFD echo packet to a network device corresponding to the private network address.
  9. 9. The apparatus as recited in claim 8, further comprising: the generation module is used for determining a first IP address of the load balancing equipment and a second IP address of the network equipment, performing splicing processing on the first IP address and the second IP address to obtain target information, and writing the target information into a setting field of the BFD echo message.
  10. 10. The apparatus of claim 9, wherein the device comprises a plurality of sensors, The determining module is specifically configured to determine that the state of the network device represented by the response message is an active state if the response message is consistent with the BFD echo message, and determine that the state of the network device represented by the response message is an inactive state if the response message is a message obtained by modifying the second IP address of the BFD echo message into a set content.

Description

Link detection method and device Technical Field The present application relates to the field of communications technologies, and in particular, to a link detection method and apparatus. Background With the rise of the access quantity, when one server is difficult to be qualified, the polling mode is needed to be adopted, so that each server has equal access opportunities, and finally a large number of accesses are reasonably distributed to a plurality of network devices. When load balancing is achieved, the scheme is provided at present that the reachability of the internal local address is detected by using a ping mode, so that the internal local address distributed by load balancing is guaranteed to be reachable. However, in this method, the reachability detection of the internal local address is simply implemented, but is not flexible per se, And the reliability is poor, and the time delay of ping is too long to be suitable for being applied to the existing network. Therefore, how to guarantee the link reachability and the reliability of load balancing during load balancing is one of the technical problems to be considered. Disclosure of Invention In view of the above, the present application provides a link detection method and device for ensuring the link reachability and the reliability of load balancing during load balancing. Specifically, the application is realized by the following technical scheme: According to a first aspect of the present application, there is provided a link detection method applied to a load balancing device, the method comprising: for each private network address in an address pool for load balancing, sending a Bidirectional Forwarding Detection (BFD) message to network equipment corresponding to the private network address; receiving a response message of each BFD message sent by the network equipment; Confirming the state of the network equipment represented by each response message received in the set time; if the state represented by the response messages exceeding the first set number in the set time is an inactive state, confirming that a link between the load balancing equipment and the network equipment is unavailable; And if the state represented by the response messages exceeding the second set number in the set time is an active state and the state represented by the response messages of the third set number which is received recently is an active state, confirming that a link between the load balancing equipment and the network equipment is available. According to a second aspect of the present application, there is provided a link detection apparatus provided in a load balancing device, the apparatus comprising: A sending module, configured to send, for each private network address in the address pool for load balancing, a bidirectional forwarding detection BFD packet to a network device corresponding to the private network address; a receiving module, configured to receive a response message of each BFD message sent by the network device; The determining module is used for determining the state of the network equipment represented by each response message received in the set time; The detection module is used for confirming that a link between the load balancing equipment and the network equipment is unavailable if the state represented by the response messages exceeding the first set number in the set time is an inactive state; The detection module is further configured to confirm that a link between the load balancing device and the network device is available if a state represented by the response messages exceeding the second set number is an active state within the set time and a state represented by the response messages of the third set number received recently is an active state. According to a third aspect of the present application there is provided an electronic device comprising a processor and a machine-readable storage medium storing a computer program executable by the processor, the processor being caused by the computer program to perform the method provided by the first aspect of the embodiment of the present application. According to a fourth aspect of the present application there is provided a machine-readable storage medium storing a computer program which, when invoked and executed by a processor, causes the processor to carry out the method provided by the first aspect of the embodiments of the present application. The embodiment of the application has the beneficial effects that: The link detection method and device provided by the embodiment of the application aim at each private network address in an address pool for load balancing, send a bidirectional forwarding detection BFD message to network equipment corresponding to the private network address, receive a response message of each BFD message sent by the network equipment, confirm the state of the network equipment represented by each response message received within a set time,