Network status detection method, device, computer equipment and storage medium
By constructing and sending call and reply packets, using the service fields and type fields in the preset protocol, the network status detection problem under the Wireguard protocol is solved, and accurate detection of network status and performance improvement is achieved.
Patent Information
- Application Number
- CN202410775369.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-06-17
AI Technical Summary
When using the Wireguard protocol, it is difficult to accurately understand the status of the current network link, resulting in network performance being affected.
A network state detection method is provided, by constructing and sending call data packets and answer packets, using service fields and type fields in preset protocols to characterize the call response service type and path, and judge the reception situation to determine the network state.
Accurate detection of network status is achieved, and can improve different network status indicators and improve network performance.
Smart Images

Figure CN118353811B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data communication technology, and in particular to a method, device, computer equipment and storage medium for detecting a network status. Background Art
[0002] Virtual Private Network (VPN) is a communication method commonly used to connect medium and large enterprises or private networks between groups. It uses tunneling protocols to achieve functions such as sender authentication, message confidentiality and accuracy. Specific communication protocols are usually used when using virtual private networks. Wireguard is a high-performance virtual private network protocol that is simple, efficient, easy to use, and highly secure. It has become a popular modern VPN solution.
[0003] Indicators such as network reachability, network rate, and the maximum amount of data that can be transmitted can be used to judge the network status. Accurately perceiving the impact of network links on tunnels helps improve network performance. When using the Wireguard protocol, it is usually difficult to accurately understand the status of the current network link, which may affect network performance. Summary of the invention
[0004] In view of this, the present disclosure provides a method, apparatus, computer device and storage medium for detecting a network status to solve the problem of being unable to determine the current network status.
[0005] In a first aspect, the present disclosure provides a method for detecting a network status, the method comprising:
[0006] Constructing a call data packet matching the current detection scenario, wherein the call data packet is constructed based on a preset protocol, and in the call data packet, a service field in the preset protocol is set to represent a call answering service type, and a type field in the preset protocol is set to represent a call path under the current detection scenario;
[0007] Sending the call data packet to a receiving device, and determining whether a response data packet corresponding to the call data packet returned by the receiving device is received, the response data packet being constructed based on the preset protocol, and in the response data packet, the service field in the preset protocol is set to represent the call answering service type, and the type field in the preset protocol is set to represent the answering path in the current detection scenario;
[0008] According to the reception status of the response data packet represented by the judgment result, the network status corresponding to the current detection scenario is determined.
[0009] The network status detection method provided in this embodiment first determines the current detection scenario, constructs a call data packet matching the current detection scenario, and the calling device sends a call data packet to the receiving device, and then determines the reception status of the corresponding call data packet returned by the receiving device. The call data packet and the answer data packet are both constructed based on a preset protocol. The service field in the call data packet and the answer data packet can be used to characterize the call answering service type. The type field in the call data packet can be used to characterize the call path of the current detection scenario. The type field in the answer data packet can be used to characterize the answer path of the current detection scenario. A group of corresponding call data packets and answer data packets constitute a group of call answering services. After the call answering service is implemented, the network status between the calling device and the receiving device can be accurately described. The network status can be further improved in a targeted manner for different network status indicators to enhance network performance.
[0010] In a second aspect, the present disclosure provides a device for detecting a network status, comprising:
[0011] Constructing a call module to construct a call data packet matching the current detection scenario, wherein the call data packet is constructed based on a preset protocol, and in the call data packet, a service field in the preset protocol is set to represent a call answering service type, and a type field in the preset protocol is set to represent a call path in the current detection scenario;
[0012] an answer receiving module, configured to send the call data packet to a receiving device, and determine whether an answer data packet corresponding to the call data packet returned by the receiving device is received, wherein the answer data packet is constructed based on the preset protocol, and in the answer data packet, the service field in the preset protocol is set to represent the call answering service type, and the type field in the preset protocol is set to represent the answering path in the current detection scenario;
[0013] The state determination module is used to determine the network state corresponding to the current detection scenario according to the reception status of the response data packet represented by the judgment result.
[0014] In a third aspect, the present disclosure provides a computer device, comprising: a memory and a processor, the memory and the processor are communicatively connected to each other, computer instructions are stored in the memory, and the processor executes the network status detection method of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0015] In a fourth aspect, the present disclosure provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for detecting a network status of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0017] Figure 1 is a flowchart of a method for detecting a network status according to an embodiment of the present disclosure;
[0018] Figure 2 is a schematic diagram of the structure of a preset protocol according to an embodiment of the present disclosure;
[0019] Figure 3 is a scenario diagram of a method for detecting a network status according to an embodiment of the present disclosure;
[0020] Figure 4 is a flow chart of another method for detecting a network status according to an embodiment of the present disclosure;
[0021] Figure 5 is a scenario schematic diagram of another method for detecting a network status according to an embodiment of the present disclosure;
[0022] Figure 6 is a flow chart of another method for detecting a network status according to an embodiment of the present disclosure;
[0023] Figure 7 is a flow chart of another method for detecting a network status according to an embodiment of the present disclosure;
[0024] Figure 8 is a schematic diagram of a scenario flow of a method for detecting a network status according to an embodiment of the present disclosure;
[0025] Fig. 9 is a structural block diagram of a device for detecting a network status according to an embodiment of the present disclosure;
[0026] Fig.10 It is a schematic diagram of the hardware structure of the computer device of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.
[0028] In the description of the embodiments of the present disclosure, the term "including" and similar terms should be understood as open inclusion, that is, "including but not limited to". The term "based on" should be understood as "based at least in part on". The term "one embodiment" or "the embodiment" should be understood as "at least one embodiment". The term "some embodiments" should be understood as "at least some embodiments". Other explicit and implicit definitions may also be included below.
[0029] Herein, unless explicitly stated, executing a step “in response to A” does not mean executing the step immediately after “A” but may include one or more intermediate steps.
[0030] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition, use, storage or deletion of the data) shall comply with the requirements of relevant laws, regulations and relevant provisions.
[0031] It is understandable that before using the technical solutions disclosed in the various embodiments of the present disclosure, the types, scopes of use, usage scenarios, etc. of the information involved in the present disclosure should be informed to relevant users and their authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations. The relevant users may include any type of right holders, such as individuals, enterprises, and groups.
[0032] For example, in response to receiving an active request from a user, a prompt message is sent to the relevant user to clearly prompt the relevant user that the operation requested to be performed will require obtaining and using the information of the relevant user, so that the relevant user can independently choose whether to provide information to software or hardware such as an electronic device, application, server or storage medium that executes the operation of the technical solution of the present disclosure based on the prompt message.
[0033] As an optional but non-limiting implementation, in response to receiving an active request from a relevant user, a prompt message is sent to the relevant user, for example, in the form of a pop-up window, in which the prompt message may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to select "agree" or "disagree" to provide information to the electronic device.
[0034] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation of the present disclosure. Other methods that meet relevant laws and regulations may also be applied to the implementation of the present disclosure.
[0035] Office security usually involves the security management of networks, identities, and terminals. By implementing private network networking, access control, terminal management in private networks, and information security protection, digital office can be made safer, more efficient, and easier to use. Security management at the network level can ensure that private networks such as office networks can operate safely and efficiently, thereby ensuring that business data can be safely transmitted and stored. Security management at the identity level can improve the efficiency and security of identity authentication for users accessing private networks. Security management at the terminal level can achieve unified management of terminal devices within the private network, data leakage prevention, and terminal threat protection, thereby ensuring the security of corporate data.
[0036] In actual applications, the security management of networks, identities, and terminals can achieve technical linkage in multiple technical branches such as networking strategies, network access and control, remote access, unified terminal management, terminal detection and response, enterprise data leakage prevention, and identity authentication management, making digital office simpler, more efficient, and easier to implement.
[0037] Wireguard is an easy-to-configure, fast and secure open source VPN that uses the latest encryption technology to provide a faster, simpler and more streamlined universal VPN that can be easily deployed on a variety of low-end devices and high-end servers. There is no call answering service in the current Wireguard protocol, so it is difficult for the ends of the tunnel to accurately understand the current network status, which can include a variety of indicators, such as network reachability, network latency, etc.
[0038] Based on this, the present disclosure provides a private extension protocol for the situation where the Wireguard protocol does not have a call answering service, which can be used for enterprise offices. The private extension protocol provides a call answering service. The call answering service in the private extension protocol can be used to determine the network status, including core indicators such as network reachability, network latency, and maximum data carrying capacity, and then subsequent operations can be performed for various network statuses.
[0039] According to an embodiment of the present disclosure, an embodiment of a method for detecting a network status is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0040] In this embodiment, a method for detecting a network status is provided. Figure 1 is a flow chart of a method for detecting a network status according to an embodiment of the present disclosure, such as Figure 1 As shown, the process includes the following steps:
[0041] Step S101: construct a call data packet matching the current detection scenario.
[0042] The call data packet is constructed based on a preset protocol, and in the call data packet, the service field in the preset protocol is set to characterize the call answering service type, and the type field in the preset protocol is set to characterize the call path in the current detection scenario.
[0043] The preset protocol is a private extension protocol provided by the present disclosure. The structure of the private extension protocol can be the same as that of the Wireguard protocol. Figure 2 As shown in the figure, the service field is Wireguard type, which can represent the call answering service type. Figure 2 The type in is the type field, which can represent the call path in the current detection scenario, that is, the detection scenario specified under the call answering service type, where the call path refers to the path from the calling device to the receiving device. The value of the service field can be extended to more service types according to actual needs. Each service type can realize one or more application scenarios. In actual applications, the call data packet corresponding to the current detection scenario can be constructed according to actual needs.
[0044] by Figure 2 For example, "type:=0x81 (1 byte)" in the example indicates that the current service is a call answering service. The call answering service can be used in a variety of scenarios to detect network status, including network availability detection, network speed measurement, MTU detection, etc. Figure 2 The "type:=13(1byte)" in the private extension protocol indicates the Echo service, which can be further used for speed test service. In addition, the reserved field in the private extension protocol is 3 bytes long and is a reserved field that can be extended according to actual needs. For example, when the current protocol is not available, some special flags can be marked here; the Protocol Version is 2 bytes long. When "ProtocolVersion:=0", it means that the current version is the 0th speed test packet protocol (little endian); Code indicates the status code, which is used to describe the current operation status. Figure 2For example, "code:=0" indicates the status of the call answering service; Seq indicates the sequence number, which can be used to indicate a group of call answers. The same and unique seq is used to indicate that a pair of uplink datagrams and downlink datagrams are a pair of calls and answers, that is, in a call answering operation, the seq values in the call data packet and the answer data packet are the same; Payload is the payload field, which indicates the data content carried by the current data packet. The customizable Payload allows the current service to deliver related payloads according to different application scenarios, so as to have better scalability and richer data representation capabilities in the load scenario.
[0045] The structure of the first 6 bytes in the private extended protocol can be the same as Wireguard, which is used to ensure that the current network link status is consistent with the status of the tunnel in the actual network link.
[0046] Step S102: sending a call data packet to a receiving device, and determining whether a response data packet corresponding to the call data packet returned by the receiving device is received.
[0047] The answer data packet is constructed based on a preset protocol, and in the answer data packet, the service field in the preset protocol is set to characterize the call answering service type, and the type field in the preset protocol is set to characterize the answering path in the current detection scenario.
[0048] The calling device sends a call data packet to the receiving device, and the receiving device may return a response data packet within a certain period of time based on the received call data packet. Due to network delays, network link failures, etc., the receiving device may not return a response data packet. Therefore, after sending a call data packet to the receiving device, it is necessary to determine whether the response data packet returned by the receiving device is received, and then perform subsequent operations.
[0049] The reply data packet is constructed based on a preset protocol. In the present disclosure, the preset protocol can be a private extended protocol. The structure and field description of the protocol are shown in step S101. The service field in the reply data packet can be used to characterize the call answering service type. For the same service type, the service field in the call data packet and the corresponding reply data packet is the same. For example, when the service type is a call answering service, the service field in the call data packet and the reply data packet are both set to "type:=0x81 (1 byte)". In the reply data packet, the type field in the preset protocol is set to characterize the reply path in the current detection scenario, and the reply path is from the receiving device to the calling device. In the same application scenario, the type fields of the call data packet and the reply data packet respectively represent the call path and the reply path corresponding to the application scenario. Taking the current detection scenario as network availability detection as an example, the type field in the call data packet is used to represent the Ping service, and the type mark is 8. Correspondingly, the type field in the received reply data packet is used to represent the Pong service, and the type mark is 0.
[0050] Step S103, determining the network state corresponding to the current detection scenario according to the reception status of the response data packet represented by the judgment result.
[0051] Based on step S102, the reception status of the reply data packet is determined. The reception status may include various information such as whether the reply data packet is received, the timestamp of the received reply data packet, and the count status of the reply data packet. Specifically, when the reply data packet sent by the receiving device is not received, the reception status is no; when the reply data packet sent by the receiving device is received, the reception status is yes. When the reply data packet is received, the reception status also includes the time interval from sending the call data packet to receiving the reply data packet. When multiple call data packets are sent regularly within a period of time, multiple reply data packets may be received for each call data packet. At this time, the reception status may also include the count status of the received reply data packets. For different detection scenarios, the counting method of the reply data packet may be different, and the corresponding operation can be performed according to the actual situation.
[0052] The network status corresponding to each detection scenario is determined according to the reception status of the response data packet. Taking the current detection scenario as the speed measurement scenario as an example, the network delay can be calculated according to the return time of the response data packet in the reception status, thereby completing the speed measurement.
[0053] After determining the network status, subsequent operations can be performed according to the current detection scenario. Taking the current detection scenario as network availability detection as an example, when the network status is determined to be unreachable, node switching or protocol switching can be performed according to the actual situation.
[0054] The network status detection method provided in this embodiment first constructs a call data packet matching the current detection scenario, the calling device sends a call data packet to the receiving device, and then determines the reception status of the corresponding call data packet returned by the receiving device. The process is as follows: Figure 3 As shown. The call data packet and the answer data packet are constructed based on the preset protocol. The service field in the call data packet and the answer data packet can be used to characterize the call answering service type. The type field in the call data packet can be used to characterize the call path of the current detection scenario. The type field in the answer data packet can be used to characterize the answer path of the current detection scenario. A group of corresponding call data packets and answer data packets constitute a group of call answering services. After the call answering service is implemented, the network status between the calling device and the receiving device can be accurately described. According to different network status indicators, the network status can be further improved in a targeted manner to enhance network performance.
[0055] In this embodiment, a method for detecting a network status is provided. When a current detection scenario represents a network availability detection, a type field in a call data packet is set to a first value, a type field in a response data packet corresponding to the call data packet is set to a second value by the device, and a payload field in the call data packet is empty. The first value represents a call path of the network availability detection, and the second value represents a response path of the network availability detection. At least one detection tunnel is established between a calling device that sends the call data packet and a receiving device, wherein each detection tunnel has its own communication protocol. Figure 4 is a flow chart of a method for detecting a network status according to an embodiment of the present disclosure, such as Figure 4 As shown, the process includes the following steps:
[0056] Step S201: construct a call data packet matching the current detection scenario.
[0057] When the current detection scenario is network availability detection, it can be used to detect whether the network is available. According to the support of the current calling device for the communication protocol, a detection tunnel is established between the calling device and the receiving device. The protocol may include UDP protocol, TCP protocol, etc. When the calling device supports multiple communication protocols, a detection tunnel corresponding to each protocol is established, and corresponding detection is enabled for different detection tunnels, that is, a call data packet corresponding to each detection tunnel is constructed. When the current detection scenario is network availability detection, the type field in the call data packet is set to the first value. Specifically, the first value is 8, that is, the type tag is 8, indicating Ping service.
[0058] For details, please see Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0059] Step S202: Send a call data packet to a receiving device, and determine whether a response data packet corresponding to the call data packet returned by the receiving device is received.
[0060] Specifically, the above step S202 includes:
[0061] Step S2021: for any target detection tunnel, a call data packet is sent to a receiving device multiple times based on a first time interval.
[0062] The calling device continuously sends call data packets to the receiving device multiple times at a first time interval. When the calling device supports multiple communication protocols, multiple target detection tunnels between the calling device and the receiving device established based on different communication protocols can send call data packets to the receiving device multiple times through each target detection tunnel.
[0063] Step S2022: for any sent call data packet, determine whether a response data packet corresponding to the call data packet is received from the receiving device through the target detection tunnel within a first timeout period.
[0064] Each detection has its corresponding first timeout period, and for different target detection tunnels, the set first timeout period may be different. It is determined whether a response data packet corresponding to each sent call data packet is received to obtain a determination result. The type field in the response data packet is set to the second value, specifically, the second value is 0, that is, the type mark is 0, indicating a Pong service.
[0065] Step S203: determining the network state corresponding to the current detection scenario according to the reception status of the response data packet represented by the determination result.
[0066] Specifically, the above step S203 includes:
[0067] Step S2031, identifying the reception status of the response data packets corresponding to each call data packet from the judgment result, and updating the availability information of the target detection tunnel based on the identified reception status;
[0068] Based on the judgment results obtained in the above steps, the reception status of the response data packets corresponding to each call data packet is identified, and the reception status includes whether the response data packet is received, the time interval of the received response data packet, the count of the response data packet, etc. For the detection scenario in this embodiment, when detecting the network availability, the information in the reception status will be processed in a certain way according to the set rules to determine the availability information related to the target detection tunnel, and the availability information may include indicators such as the number of available times and the number of unavailable times. The method for determining the availability information can be determined according to the following steps a1 and a2.
[0069] In some optional implementations, the above step S2031 includes:
[0070] Step a1, for any call data packet sent, when a response data packet is received through the target detection tunnel within the first timeout period, the unavailable number is cleared and the available number is incremented;
[0071] Step a2: When no response data packet is received through the target detection tunnel within the first timeout period, the available times are cleared and the unavailable times are incremented.
[0072] For each target detection tunnel, there is corresponding availability information. For each call data packet sent, it is necessary to determine whether the corresponding response data packet of the call data packet is received. When the response data packet is received, the available number or unavailable number is determined based on whether the time interval between sending the call data packet and receiving the response data packet exceeds the first timeout period.
[0073] Step S2032: If the number of unavailability times represented by the availability information is greater than or equal to a first threshold, it is determined that the current network status is unavailable.
[0074] The first threshold is set to the maximum number of unavailable times of the target detection tunnel. When the number of unavailable times represented by the availability information is greater than or equal to the first threshold, it is determined that the target detection tunnel corresponding to the availability information is unavailable. When the target detection tunnel is unavailable, it means that the network link from the calling device to the receiving device is not connected, that is, the current network status is unavailable.
[0075] In some optional implementations, after determining that the current network status is unavailable, the method further includes:
[0076] Step a3, determining whether the receiving device supports protocol switching;
[0077] When the receiving device supports more than one protocol and there are multiple target detection tunnels, it is determined whether the receiving device can switch the protocol.
[0078] When the receiving device supports only one protocol, the current receiving device is switched to a redundant receiving device.
[0079] Step a4: When the receiving device supports protocol switching, the target detection tunnel is switched to the backup detection tunnel, wherein the number of available times represented by the availability information of the backup detection tunnel is greater than or equal to a second threshold.
[0080] The backup detection tunnel refers to other detection tunnels other than the target detection tunnel that has been determined to be unavailable. The second threshold is set to the minimum number of available times of the backup detection tunnel. When the available times represented by the availability information is greater than or equal to the second threshold, the backup detection tunnel is determined to be available.
[0081] When the receiving device supports protocol switching, and the number of available times represented by the availability information of the backup detection tunnel is greater than or equal to the second threshold, the target detection tunnel is switched to the backup detection tunnel.
[0082] Step a5: When the receiving device does not support protocol switching or there is no available backup detection tunnel, the current receiving device is switched to a redundant receiving device.
[0083] When the number of available times of the backup detection tunnel is less than the second threshold, it means that the backup detection tunnel is unavailable. If the receiving device does not support protocol switching and the backup detection tunnels are all unavailable, the current receiving device is switched to a redundant receiving device. The priority of protocol switching is higher than the switching of the receiving device. If the protocol cannot be switched, the receiving device is switched.
[0084] Before switching the receiving device, it is also necessary to determine whether the current receiving device can be switched. When the receiving device only supports one protocol or does not support switching detection tunnels, the number of unavailable times of the target detection tunnel or the time interval of the downlink traffic must reach the node switching threshold. When the number of unavailable times or the time interval of the most recent downlink traffic reaches the corresponding node switching threshold, the receiving device is switched.
[0085] In some optional embodiments, the method further comprises:
[0086] Step a6: If the number of unavailability times represented by the availability information is less than the first threshold, determine whether the time interval of the most recently received downlink traffic is greater than or equal to the third threshold.
[0087] When the number of unavailable times of the target detection tunnel is less than the first threshold, the target detection tunnel can be considered to be available, that is, network transmission can be performed between the calling device and the receiving device, but it cannot be determined whether data can be transmitted between the calling device and the receiving device, that is, the traffic of the data transmission tunnel between the calling device and the receiving device is not necessarily accessible. Traffic may not be forwarded due to protocol non-compliance or encryption and decryption failure. In practical applications, it can be understood that the network is accessible, but the browser cannot access the target page.
[0088] The third threshold refers to the maximum value of the most recently received downlink traffic time interval. The most recently received downlink traffic time interval and availability information are both indicators for determining whether the network is available, representing out-of-band and in-band situations, respectively. It is necessary to further determine whether the most recently received downlink traffic time interval is greater than or equal to the third threshold.
[0089] Step a7, when the time interval of the most recently received downlink traffic is greater than or equal to the third threshold, determining whether the receiving device supports protocol switching;
[0090] When the time interval of the most recently received downlink traffic is greater than or equal to the third threshold, the target detection tunnel can be considered unavailable. In this embodiment, a heartbeat packet can be sent from the calling device to the receiving device at a fixed time interval. If no heartbeat packet is received within a certain period of time, the tunnel corresponding to the current communication protocol can be considered unavailable.
[0091] When the receiving device supports more than one protocol and there are multiple target detection tunnels, it is determined whether the receiving device can switch protocols.
[0092] When the receiving device supports only one protocol, the current receiving device is switched to a redundant receiving device.
[0093] Step a8: When the receiving device supports protocol switching, the target detection tunnel is switched to the backup detection tunnel, wherein the number of available times represented by the availability information of the backup detection tunnel is greater than or equal to a second threshold.
[0094] When the receiving device supports protocol switching, and the number of available times represented by the availability information of the backup detection tunnel is greater than or equal to the second threshold, the target detection tunnel is switched to the backup detection tunnel, as described in step a4 above.
[0095] When the receiving device does not support protocol switching, or there is no available standby detection tunnel, the current receiving device is switched to a redundant receiving device, as described in step a5 above.
[0096] In some optional implementations, after determining that the current network status is unavailable, the method further includes:
[0097] Step a9: after switching the detection tunnel or switching the receiving device, resetting the availability information of the target detection tunnel and the standby detection tunnel.
[0098] After switching the detection tunnel or switching the receiving device, the availability information of all detection tunnels is reset.
[0099] In some embodiments, Figure 5 As shown, taking the case where the calling device supports two communication protocols, UDP and TCP, communication protocols corresponding to UDP and TCP are established respectively, and detection is initiated respectively.
[0100] Identify the reception status of the response data packets corresponding to each call data packet, and update the availability information of the target detection tunnel based on the identified reception status. Determine the available times, unavailable times and downlink traffic time interval of each detection tunnel in the current mode according to the availability information. Determine whether the current mode is dual stack mode. If it is not dual stack mode, determine whether the unavailable times of the current detection tunnel is greater than or equal to the switching node threshold. When the unavailable times of the current detection tunnel is greater than or equal to the switching node threshold, node switching will be performed; when the unavailable times of the current detection tunnel is less than the switching node threshold, determine whether the most recent downlink traffic time interval is greater than or equal to the switching node threshold. When the result is yes, node switching will be performed. If the result is no, the detection process ends.
[0101] If dual stack mode is supported, determine whether it is currently working in UDP mode or TCP mode. If it is currently in UDP mode, determine whether the number of unavailable times of the detection tunnel corresponding to UDP is greater than or equal to the refresh threshold. When the result is yes, continue to determine whether the number of available times of the detection tunnel corresponding to TCP is greater than or equal to the UDP2TCP threshold. When the result is yes, perform protocol switching, that is, switch UDP to TCP. When the number of available times of the detection tunnel corresponding to TCP is less than the second threshold, further determine whether the number of unavailable times of the detection tunnel of UDP reaches the UDP2TCP threshold. When the result is yes, perform node switching. When the result is no, end the detection. When the number of unavailable times of the detection tunnel corresponding to UDP is less than the refresh threshold, determine whether its downstream traffic time interval reaches the switching protocol threshold. When the result is yes, switch UDP to TCP when the number of available times of the detection tunnel of TCP reaches the UDP2TCP threshold. Otherwise, perform node switching when the downstream traffic time interval reaches the node switching threshold. The judgment process in TCP mode is consistent with that in UDP mode and will not be repeated here.
[0102] The network status detection method provided in this embodiment is applied to the network availability detection scenario. Based on the call answering service, calls and answers can be made between the two ends of the established tunnel without interruption. The availability information of the corresponding tunnel is determined by detecting the reception of the answer data packet corresponding to each call data packet. Each detection tunnel is established based on a different communication protocol. When it is determined that a detection tunnel is unavailable, the detection tunnel or the receiving device can be switched in time to ensure the availability of the network tunnel.
[0103] In this embodiment, a method for detecting a network status is provided. When the current detection scenario represents a transmission unit detection, the type field in the call data packet is set to a first value, and the type field in the response data packet corresponding to the call data packet is set to a second value. The first value represents the call path detected by the transmission unit, and the second value represents the response path detected by the transmission unit. The length of the payload field in the call data packet is set to a specified message length. Figure 6 is a flow chart of a method for detecting a network status according to an embodiment of the present disclosure, such as Figure 6 As shown, the process includes the following steps:
[0104] Step S301: construct a call data packet matching the current detection scenario.
[0105] The current detection scenario represents the transmission unit detection, namely MTU (Maximum Transmission Unit) detection. MTU is used to describe the maximum amount of data that can be transmitted at one time in the current network environment. Adjusting MTU is an important aspect of network tuning, especially in some special scenarios, such as through a virtual private network (VPN) or using certain network technologies (such as IPv6). By optimizing MTU, you can improve network transmission efficiency, reduce fragmentation and packet retransmission, and thus improve network performance.
[0106] When used for MTU detection, the type field in the constructed call packet is set to the first value, that is, the type tag is 8, indicating the Ping service. For details, see Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0107] Step S302: Send a call data packet to the receiving device, and determine whether a response data packet corresponding to the call data packet returned by the receiving device is received.
[0108] Specifically, the above step S302 includes:
[0109] Step S3021: When the receiving device supports both the first protocol and the second protocol, and the current protocol is the first protocol, a call data packet is sent to the receiving device multiple times based on a second time interval.
[0110] The reliability of the first protocol is weaker than the reliability of the second protocol.
[0111] MTU detection occurs in a virtual private network. When a virtual private network is established, the current device operating system specifies the current network card MTU. The payload field in the call data packet is Payload, which is set to the specified message length. In this embodiment, the specified message length is the current network card MTU. In Payload, except for the basic content of the protocol, other content is filled with 0 to the specified message length.
[0112] At the beginning of the detection, the maximum length of the MTU can be used as the length of the specified data message. Taking the first protocol as the UDP protocol and the second protocol as the TCP protocol as an example, when the calling device supports both UDP protocols and is currently working in the UDP protocol, the MTU detection is started, otherwise the MTU detection process is terminated. The calling data packet is continuously sent to the receiving device multiple times at the second time interval.
[0113] Step S3022: for any paging data packet sent, determine whether a response data packet corresponding to the paging data packet is received from the receiving device within a second timeout period.
[0114] After each call data packet is sent, it is determined whether a response data packet returned by the receiving device can be received within a second timeout period, and the response data packet corresponds to the call data packet. The type field in the response data packet is set to a second value, specifically, the second value is 0, that is, the type mark is 0, indicating a Pong service.
[0115] Step S303: determining the network state corresponding to the current detection scenario according to the reception status of the response data packet represented by the judgment result.
[0116] Specifically, the above step S303 includes:
[0117] Step S3031, counting the number of response data packets;
[0118] Step S3032: When the number of response data packets reaches a preset detection threshold, it is determined that the length of the currently bearable transmission unit is a specified message length.
[0119] The preset detection threshold is an indicator set according to actual needs and can be used to determine whether the current network link can carry the current MTU length. The preset detection threshold can be set to 1, which means that when 1 response data packet is received, it can be considered that the current network link can carry the current MTU length, that is, the specified message length is used as the length of the transmission unit that the current tunnel can carry.
[0120] Taking the MTU length of 1420 as an example, set three call data packets to be sent with this message length. For any operation of sending a call data packet, if a response data packet corresponding to any call data packet is received, it can be considered that the current network link can carry an MTU of 1420 in length, and the MTU detection ends.
[0121] In some optional implementations, after step S3031, when the number of response data packets does not reach a preset detection threshold, the method further includes:
[0122] Step b1, decrementing the designated message length based on a preset rule.
[0123] When the number of response data packets does not reach the preset detection threshold, in this embodiment, it can be considered that for each call data packet, the corresponding response data packet has not been received within the second timeout period, indicating that the current network link cannot carry the current MTU length, and it is necessary to reduce the specified message length, that is, reduce the MTU length.
[0124] Taking the MTU length of 1420 as an example, if a call data packet sent with 1420 as the specified message length does not receive a corresponding response data packet within the second timeout period, it can be decremented by 1420 according to the set rule (for example, decremented by 200 each time).
[0125] Step b2: resending the call data packet to the receiving device multiple times based on a second time interval, and determining whether a response data packet corresponding to the call data packet is received from the receiving device within a second timeout period.
[0126] After changing the length field, the call data packet is resent, and it is determined whether a response data packet returned by the receiving device can be received within the second timeout period after each call data packet is sent, and the response data packet corresponds to the call data packet.
[0127] Step b3, counting the number of response data packets received within the second timeout period, when the number of response data packets does not reach the preset detection threshold and the specified message length reaches the minimum length threshold, it is determined that the current transmission unit length cannot carry the specified message length.
[0128] Based on each length field, multiple call data packets are sent and statistics are counted whether the corresponding response data packets are received. For each length field, if no response data packet is received, that is, the number of response data packets is 0, then the specified message length in the length field is decremented until the data message length in the length field reaches the minimum length threshold and the corresponding response data packet is still not received. It can be considered that the current transmission unit length cannot carry the specified message length, that is, the current network link cannot carry the current MTU.
[0129] In some optional implementations, after determining in the above step b3 that the current transmission unit length cannot carry the specified message length, the method further includes:
[0130] Step b4: Switch the current protocol of the receiving device from the first protocol to the second protocol.
[0131] In some embodiments, taking the first protocol as UDP protocol and the second protocol as TCP protocol as an example, when the receiving device supports both UDP protocol and UDP protocol and currently works in UDP protocol, MTU detection is started, otherwise the MTU detection process is terminated. Call data packets are sent to the receiving device multiple times without interruption according to the second time interval. Call data packets are sent with MTU length of 1420 at the beginning, and it is set to send up to three call data packets for each length field. If the corresponding response data packet is received within the second timeout period in any of the three times, it is considered that the current network tunnel can carry the current MTU and the detection is terminated. If the corresponding response data packet is not received within the second timeout period for three times, it is recorded as a detection failure, the data packet length is changed, and the call data packet is resent up to three times, and so on, until the data packet length reaches the set minimum value. If the corresponding response data packet is still not received within the second timeout period, it can be considered that the continuous failure exceeds the maximum failure threshold, and it can be considered that the current network tunnel cannot carry the current MTU, and the UDP protocol is switched to the TCP protocol.
[0132] The network status detection method provided in this embodiment performs transmission unit detection (MTU detection) through a call answering service, and can construct data fragments of a specified data message length between tunnels, thereby determining whether the current network tunnel can carry the current data message length. The data message length is set to the length of the MTU, and the data message length can be reduced according to actual conditions and a call data packet is issued to detect the reception of the answering data packet, which is used to determine whether the current network tunnel can carry the current MTU. If not, the protocol is switched. This method can avoid the impact of the MTU restriction on the protocol, thereby improving network transmission efficiency, reducing fragmentation and data packet retransmission, and thus improving network performance.
[0133] In this embodiment, a method for detecting a network status is provided. When the current detection scenario represents a speed measurement scenario, the type field in the call data packet is set to a third value, the type field in the response data packet corresponding to the call data packet is set to a fourth value, the payload field in the call data packet is empty, the third value represents the call path of the speed measurement scenario, and the fourth value represents the response path of the speed measurement scenario. Figure 7 is a flow chart of a method for detecting a network status according to an embodiment of the present disclosure, such as Figure 7 As shown, the process includes the following steps:
[0134] Step S401: construct a call data packet matching the current detection scenario.
[0135] When the current detection scenario is a speed measurement scenario, the type field in the call data packet is set to a third value. Specifically, type may be marked as 13, indicating an Echo service, and the payload field in the call data packet is empty.
[0136] For details, please see Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0137] Step S402: Send a call data packet to the receiving device, and determine whether a response data packet corresponding to the call data packet returned by the receiving device is received.
[0138] The corresponding speed test is initiated based on the support of the calling device for the communication protocol. When the UDP protocol is supported, the UDP speed test is initiated first, and the calling data packet is sent to the receiving device based on the set protocol.
[0139] For details, please see Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0140] Step S403: determining the network state corresponding to the current detection scenario according to the reception status of the response data packet represented by the determination result.
[0141] Specifically, the above step S403 includes:
[0142] Step S4031, when the number of sent call data packets reaches the speed measurement number threshold, calculate the time interval between each reception of a response data packet and the sending of a call data packet, and determine whether the time interval exceeds a third timeout period.
[0143] The speed measurement times threshold refers to the maximum times of speed measurement, which can be set according to the actual situation. When a response data packet is received, the time interval between each received response data packet and the sent call data packet is recorded, and it is determined whether the time interval exceeds the third timeout period.
[0144] If no response data packet is received within the third timeout period, it can also be considered that the speed measurement has timed out.
[0145] Step S4032: When the time interval exceeds the third timeout duration, the time interval is counted as the timeout time interval.
[0146] If the time interval exceeds the third timeout period, the time interval is the timeout time interval and can be regarded as a speed measurement timeout.
[0147] Step S4033: When the time interval does not exceed the third timeout period, the time interval is recorded as a valid time interval, and an average value of all valid time intervals is calculated to determine the network delay of the first protocol corresponding to the speed measurement scenario.
[0148] The effective time interval can be counted as an effective RTT (Round-Trip Time), which refers to the time interval from when the sender sends data to when the receiver receives the confirmation. In network communications, RTT is usually used to measure the time it takes for a data packet to travel from the sender to the receiver and then back to the sender. Network applications and protocols often use RTT to measure network performance, optimize data transmission, and determine the stability of network connections.
[0149] When the speed measurement times reaches the speed measurement times threshold, that is, the number of sent call data packets reaches the speed measurement times threshold, the average value of all valid time intervals is calculated as the current network delay of the first protocol.
[0150] In some optional embodiments, the method further comprises:
[0151] Step c1: when the number of timeout time intervals reaches a speed measurement times threshold, the first protocol is switched to the second protocol, and the network delay of the second protocol corresponding to the speed measurement scenario is determined.
[0152] When the number of timeout intervals reaches the speed measurement threshold, it indicates that there is no valid RTT, the first protocol is switched to the second protocol, and the speed measurement is performed based on the second protocol to determine the network delay of the second protocol. The speed measurement process can refer to the above steps S4031 to S4033.
[0153] In some implementations, taking the current calling device supporting the UDP protocol and the TCP protocol as an example, a speed measurement process is initiated according to the support status of the current calling device for the two protocols. The speed measurement process is as follows: Figure 8 As shown. If both protocols are supported at the same time, UDP speed measurement is initiated first. For each call data packet sent, if the corresponding response data packet is received within the third timeout period, the time interval between receiving the response data packet and sending the call data packet is taken as an RTT, the RTT is recorded, and a speed measurement is completed. If no response is received within the third timeout period, the speed measurement is considered to have timed out, and a speed measurement process is completed. After the speed measurement process is completed, check whether three speed measurements have been completed. If not, initiate the next speed measurement. If three speed measurements are completed, it is recorded as the end of the speed measurement process of the current protocol. After the speed measurement process of the current protocol is completed, check whether there is a valid RTT. If so, take the average of all valid RTTs and record it as the current network delay; if there is no valid RTT and the current speed measurement protocol is UDP, initiate a speed measurement for TCP, and use the TCP network delay as the network delay of this speed measurement scenario.
[0154] The network status detection method provided in this embodiment can describe the current network delay by calculating the time interval. By performing multiple speed measurements and taking the average of the results, the influence of network jitter on the speed measurement results can be reduced, thereby effectively improving the speed measurement efficiency. Multiple speed measurements can be performed in a shorter time, and the automatic routing function can be better realized.
[0155] In this embodiment, a network status detection device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0156] This embodiment provides a network status detection device, such as Fig. 9 As shown, including:
[0157] A call building module 501 builds a call data packet matching the current detection scenario, wherein the call data packet is built based on a preset protocol, and in the call data packet, a service field in the preset protocol is set to represent a call answering service type, and a type field in the preset protocol is set to represent a call path in the current detection scenario;
[0158] A response receiving module 502 is used to send the call data packet to a receiving device, and determine whether a response data packet corresponding to the call data packet returned by the receiving device is received, wherein the response data packet is constructed based on the preset protocol, and in the response data packet, the service field in the preset protocol is set to represent the call answering service type, and the type field in the preset protocol is set to represent the answering path in the current detection scenario;
[0159] The state determination module 503 is used to determine the network state corresponding to the current detection scenario according to the reception status of the response data packet represented by the judgment result.
[0160] In some optional embodiments, when the current detection scenario represents a network availability detection, the type field in the call data packet is set to a first value, the type field in the response data packet corresponding to the call data packet is set to a second value by the device, the payload field in the call data packet is empty, the first value represents a call path of the network availability detection, the second value represents a response path of the network availability detection, and at least one detection tunnel has been established between the calling device that sends the call data packet and the receiving device, wherein each detection tunnel has its own communication protocol.
[0161] In some optional implementations, when the current detection scenario represents a network availability detection, the response receiving module 502 includes:
[0162] A first sending unit, configured to send a call data packet to the receiving device multiple times based on a first time interval for any target detection tunnel;
[0163] The first judgment unit is used to judge, for any sent call data packet, whether a response data packet corresponding to the call data packet returned by the receiving device is received through the target detection tunnel within a first timeout period.
[0164] In some optional implementations, the state determination module 503 includes:
[0165] An available information determination unit, configured to identify the reception status of the response data packets corresponding to each call data packet from the determination result, and update the availability information of the target detection tunnel based on the identified reception status;
[0166] The tunnel judgment unit is used to determine that the current network status is unavailable if the number of unavailability times represented by the availability information is greater than or equal to a first threshold.
[0167] In some optional implementations, the available information determining unit includes:
[0168] The available number determination subunit is used for clearing the unavailable number and increasing the available number for any call data packet sent when a response data packet is received through the target detection tunnel within a first timeout period;
[0169] The unavailable times determining subunit is used to clear the available times and increment the unavailable times when the response data packet is not received through the target detection tunnel within a first timeout period.
[0170] In some optional implementations, the state determination module 503 further includes:
[0171] A protocol determination unit, used to determine whether the receiving device supports protocol switching;
[0172] a tunnel switching unit, configured to switch from the target detection tunnel to a backup detection tunnel when the receiving device supports protocol switching, wherein the number of available times represented by the availability information of the backup detection tunnel is greater than or equal to a second threshold;
[0173] The device switching unit is used to switch from the current receiving device to the redundant receiving device when the receiving device does not support protocol switching or there is no available backup detection tunnel.
[0174] In some optional implementations, the available information determining unit further includes:
[0175] A downlink traffic judgment subunit, configured to judge whether a time interval of the most recently received downlink traffic is greater than or equal to a third threshold value if the number of unavailability times represented by the availability information is less than the first threshold value;
[0176] A protocol judgment subunit, configured to judge whether the receiving device supports protocol switching when the time interval of the most recently received downlink traffic is greater than or equal to a third threshold;
[0177] The tunnel switching subunit is used to switch from the target detection tunnel to the backup detection tunnel when the receiving device supports protocol switching, wherein the number of available times represented by the availability information of the backup detection tunnel is greater than or equal to a second threshold.
[0178] In some optional implementations, the state determination module 503 further includes:
[0179] The information resetting unit is used to reset the availability information of the target detection tunnel and the standby detection tunnel after switching the detection tunnel or switching the receiving device.
[0180] In some optional embodiments, when the current detection scenario represents transmission unit detection, the type field in the call data packet is set to a first value, and the type field in the response data packet corresponding to the call data packet is set to a second value, the first value represents the call path detected by the transmission unit, the second value represents the response path detected by the transmission unit, and the length of the payload field in the call data packet is set to a specified message length.
[0181] In some optional implementations, when the current detection scenario represents a transmission unit detection, the response receiving module 502 includes:
[0182] a second sending unit, configured to send the call data packet to the receiving device multiple times based on a second time interval when the receiving device supports both the first protocol and the second protocol and the current protocol is the first protocol, and the reliability of the first protocol is weaker than the reliability of the second protocol;
[0183] The second judgment unit is used to judge, for any sent call data packet, whether a response data packet corresponding to the call data packet returned by the receiving device is received within a second timeout period.
[0184] In some optional implementations, the state determination module 503 includes:
[0185] A quantity counting unit, used for counting the quantity of the response data packets;
[0186] The message determination unit is used to determine that the length of the currently carryable transmission unit is a specified message length when the number of the response data packets reaches a preset detection threshold.
[0187] In some optional implementations, when the number of the response data packets does not reach a preset detection threshold, the state determination module 503 further includes:
[0188] A length decreasing unit, used to decrease the length of the specified message based on a preset rule;
[0189] a resending unit, configured to resend the call data packet to the receiving device multiple times based on a second time interval, and determine whether a response data packet corresponding to the call data packet returned by the receiving device is received within a second timeout period;
[0190] A re-statistics unit is used to count the number of the response data packets received within a second timeout period. When the number of the response data packets does not reach a preset detection threshold and the specified message length reaches a minimum length threshold, it is determined that the current transmission unit length cannot carry the specified message length.
[0191] In some optional implementations, after determining that the current transmission unit length cannot carry the specified message length, the device further includes:
[0192] A protocol switching module is used to switch the current protocol of the receiving device from the first protocol to the second protocol.
[0193] In some optional implementations, when the current detection scenario represents a speed measurement scenario, the type field in the call data packet is set to a third value, the type field in the response data packet corresponding to the call data packet is set to a fourth value, the payload field in the call data packet is empty, the third value represents a call path of the speed measurement scenario, and the fourth value represents a response path of the speed measurement scenario. The state determination module 503 includes:
[0194] a time interval calculation unit, configured to calculate the time interval between each reception of the response data packet and the sending of the call data packet when the number of the call data packets sent reaches a speed measurement number threshold, and determine whether the time interval exceeds a third timeout period;
[0195] A first recording unit, configured to count the time interval as a timeout time interval when the time interval exceeds a third timeout duration;
[0196] The second recording unit is used to record the time interval as a valid time interval when the time interval does not exceed a third timeout period, and calculate an average value of all valid time intervals to determine the network delay of the first protocol corresponding to the speed measurement scenario.
[0197] In some optional implementations, the state determination module 503 further includes:
[0198] The delay determination unit is used to switch the first protocol to the second protocol when the number of timeout time intervals reaches a speed measurement number threshold, and determine the network delay of the second protocol corresponding to the speed measurement scenario.
[0199] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0200] The network status detection device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0201] The present disclosure also provides a computer device having the above Fig. 9 The network status detection device is shown.
[0202] See also Fig.10 , Fig.10 is a schematic diagram of a computer device provided by an optional embodiment of the present disclosure, such as Fig.10 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig.10 A processor 10 is taken as an example.
[0203] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0204] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0205] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0206] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0207] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.
[0208] The embodiments of the present disclosure also provide a computer-readable storage medium. The above-mentioned method according to the embodiments of the present disclosure can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium and downloaded through a network, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state drive, etc.; further, the storage medium can also include a combination of the above-mentioned types of memory. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0209] Although the embodiments of the present disclosure have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for detecting a network status, characterized in that: The method comprises: Constructing a call data packet matching the current detection scenario, wherein the call data packet is constructed based on a preset protocol, and in the call data packet, a service field in the preset protocol is set to represent a call answering service type, and a type field in the preset protocol is set to represent a call path under the current detection scenario; Sending the call data packet to a receiving device, and determining whether a response data packet corresponding to the call data packet returned by the receiving device is received, the response data packet being constructed based on the preset protocol, and in the response data packet, the service field in the preset protocol is set to represent the call answering service type, and the type field in the preset protocol is set to represent the answering path in the current detection scenario; Determine the network state corresponding to the current detection scenario according to the reception status of the response data packet represented by the judgment result; The current detection scenario includes one of the following scenarios: network availability detection; transmission unit detection; speed measurement scenario; The call data packet further includes a payload field, and the payload field is set to the data content carried by the call data packet in the current detection scenario.
2. The method according to claim 1, characterized in that When the current detection scenario represents a network availability detection, the type field in the call data packet is set to a first value, the type field in the response data packet corresponding to the call data packet is set to a second value by the device, the payload field in the call data packet is empty, the first value represents a call path of the network availability detection, the second value represents a response path of the network availability detection, and at least one detection tunnel has been established between the calling device that sends the call data packet and the receiving device, wherein each detection tunnel has its own communication protocol.
3. The method according to claim 2, characterized in that The step of sending the call data packet to the receiving device and determining whether a response data packet corresponding to the call data packet returned by the receiving device is received comprises: For any target detection tunnel, sending a call data packet to the receiving device multiple times based on a first time interval; For any sent call data packet, it is determined whether a response data packet corresponding to the call data packet returned by the receiving device is received through the target detection tunnel within a first timeout period.
4. The method according to claim 3, characterized in that The determining, based on the reception status of the response data packet represented by the judgment result, a network status corresponding to the current detection scenario, includes: Identify the reception status of the response data packets corresponding to each call data packet from the determination result, and update the availability information of the target detection tunnel based on the identified reception status; If the number of unavailability times represented by the availability information is greater than or equal to a first threshold, it is determined that the current network status is unavailable.
5. The method according to claim 4, characterized in that The step of identifying the reception status of the response data packets corresponding to each call data packet from the judgment result, and updating the availability information of the target detection tunnel based on the identified reception status, includes: For any call data packet sent, when a response data packet is received through the target detection tunnel within the first timeout period, the unavailable number is cleared and the available number is incremented; When the response data packet is not received through the target detection tunnel within the first timeout period, the available times are cleared and the unavailable times are incremented.
6. The method according to claim 4, characterized in that After determining that the current network state is unavailable, the method further includes: Determining whether the receiving device supports protocol switching; When the receiving device supports protocol switching, the target detection tunnel is switched to the backup detection tunnel, wherein the number of available times represented by the availability information of the backup detection tunnel is greater than or equal to a second threshold; When the receiving device does not support protocol switching, or there is no available standby detection tunnel, the current receiving device is switched to a redundant receiving device.
7. The method according to claim 4, characterized in that The method further comprises: If the number of unavailability times represented by the availability information is less than the first threshold, determining whether the time interval of the most recently received downlink traffic is greater than or equal to a third threshold; When the time interval of the most recently received downlink traffic is greater than or equal to a third threshold, determining whether the receiving device supports protocol switching; When the receiving device supports protocol switching, the target detection tunnel is switched to the backup detection tunnel, wherein the number of available times represented by the availability information of the backup detection tunnel is greater than or equal to a second threshold.
8. The method according to claim 4, characterized in that After determining that the current network state is unavailable, the method further includes: After switching the detection tunnel or switching the receiving device, reset the availability information of the target detection tunnel and the backup detection tunnel.
9. The method according to claim 1, characterized in that: When the current detection scenario represents transmission unit detection, the type field in the call data packet is set to a first value, and the type field in the response data packet corresponding to the call data packet is set to a second value, the first value represents the call path detected by the transmission unit, the second value represents the response path detected by the transmission unit, and the length of the payload field in the call data packet is set to a specified message length.
10. The method according to claim 9, characterized in that The sending of the call data packet to the receiving device and determining whether a response data packet corresponding to the call data packet returned by the receiving device is received includes: When the receiving device supports both the first protocol and the second protocol, and the current protocol is the first protocol, sending the call data packet to the receiving device multiple times based on a second time interval, and the reliability of the first protocol is weaker than the reliability of the second protocol; For any sent call data packet, it is determined whether a response data packet corresponding to the call data packet returned by the receiving device is received within a second timeout period.
11. The method according to claim 9, characterized in that The determining, based on the reception status of the response data packet represented by the judgment result, a network status corresponding to the current detection scenario, includes: Counting the number of the response packets; When the number of the response data packets reaches a preset detection threshold, it is determined that the length of the currently bearable transmission unit is the specified message length.
12. The method according to claim 11, characterized in that When the number of the response data packets does not reach the preset detection threshold, determining the network state corresponding to the current detection scenario according to the reception status of the response data packets represented by the judgment result, further comprising: Decrementing the designated message length based on a preset rule; resending the call data packet to the receiving device multiple times based on a second time interval, and determining whether a response data packet corresponding to the call data packet returned by the receiving device is received within a second timeout period; The number of the response data packets received within the second timeout period is counted, and when the number of the response data packets does not reach a preset detection threshold and the specified message length reaches a minimum length threshold, it is determined that the current transmission unit length cannot carry the specified message length.
13. The method according to claim 10, characterized in that After determining that the current transmission unit length cannot carry the specified message length, the method further includes: The current protocol of the receiving device is switched from the first protocol to the second protocol.
14. The method according to claim 1, characterized in that When the current detection scenario represents a speed measurement scenario, the type field in the call data packet is set to a third value, the type field in the response data packet corresponding to the call data packet is set to a fourth value, the payload field in the call data packet is empty, the third value represents a call path of the speed measurement scenario, the fourth value represents a response path of the speed measurement scenario, and the network state corresponding to the current detection scenario is determined according to the reception status of the response data packet represented by the judgment result, including: When the number of the sent call data packets reaches the speed measurement number threshold, calculate the time interval between each reception of the response data packet and the sending of the call data packet, and determine whether the time interval exceeds a third timeout period; When the time interval exceeds a third timeout duration, the time interval is counted as a timeout time interval; When the time interval does not exceed the third timeout duration, the time interval is recorded as a valid time interval, and an average value of all valid time intervals is calculated to determine the network delay of the first protocol corresponding to the speed measurement scenario.
15. The method according to claim 14, characterized in that The determining, according to the reception status of the response data packet represented by the judgment result, the network status corresponding to the current detection scenario also includes: When the number of the timeout time intervals reaches the speed measurement number threshold, the first protocol is switched to the second protocol, and the network delay of the second protocol corresponding to the speed measurement scenario is determined.
16. A network status detection device, characterized in that: The device comprises: Constructing a call module, constructing a call data packet matching the current detection scenario, wherein the call data packet is constructed based on a preset protocol, and in the call data packet, a service field in the preset protocol is set to represent a call answering service type, and a type field in the preset protocol is set to represent a call path in the current detection scenario; an answer receiving module, configured to send the call data packet to a receiving device, and determine whether an answer data packet corresponding to the call data packet returned by the receiving device is received, wherein the answer data packet is constructed based on the preset protocol, and in the answer data packet, the service field in the preset protocol is set to represent the call answering service type, and the type field in the preset protocol is set to represent the answering path in the current detection scenario; A state determination module, used to determine the network state corresponding to the current detection scenario according to the reception status of the response data packet represented by the judgment result; The current detection scenario includes one of the following scenarios: network availability detection; transmission unit detection; speed measurement scenario; The call data packet further includes a payload field, and the payload field is set to the data content carried by the call data packet in the current detection scenario.
17. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the network status detection method according to any one of claims 1 to 15 by executing the computer instructions.
18. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the network status detection method according to any one of claims 1 to 15.
