Network status detection method, device, electronic device and storage medium
By sending user datagram protocol broadcast messages and receiving response messages in the intranet, determining the network status and selecting the target resource with the shortest detection time for monitoring, the bandwidth consumption and access denial caused by frequent requests from resources to the external network in the prior art are solved. Problem, network state sharing and bandwidth saving between resources are achieved.
Patent Information
- Application Number
- CN202211725597.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-28
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-12-28
AI Technical Summary
In the prior art, multiple resources need to frequently send requests to the external network when detecting the network status, resulting in large server bandwidth consumption and may be denied access due to high frequency connections to the external network server.
By sending a user datagram protocol broadcast message in the intranet, receiving a reply message to obtain the current network status, and determining the network status detection time of other resources based on the reply message, selecting the target resource with the shortest detection time for monitoring to obtain the real-time network status.
It avoids sending requests to the external network for each resource, saves server bandwidth, and solves the access denial problem caused by high-frequency connections to the external network server.
Smart Images

Figure CN116132324B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a network status detection method, device, electronic device and storage medium. Background Art
[0002] In the related art, since when there are multiple resources, each software needs to detect the current network status by sending a connection request to the external network, there is a problem of large server bandwidth consumption. Summary of the invention
[0003] In view of this, the purpose of the present application is to provide a network status detection method, device, electronic device and storage medium.
[0004] Based on the above objectives, in a first aspect, the present application provides a network status detection method, the method comprising:
[0005] In response to determining that the current resource is activated, sending a user datagram protocol broadcast message;
[0006] In response to receiving a response message from other resources for the user datagram protocol broadcast message, determining whether the response message carries a current network state;
[0007] In response to determining that the response message carries the current network state, acquiring the current network state according to the response message, and determining a first network state detection time corresponding to the other resources according to the response message;
[0008] Determining a target resource corresponding to the shortest first network status detection time;
[0009] The current resource is controlled to monitor the target resource to obtain a real-time network status.
[0010] In a second aspect, the present application provides a network status detection device, the device comprising:
[0011] a sending module, configured to send a user datagram protocol broadcast message in response to determining that the current resource is started;
[0012] A first determination module is configured to determine, in response to receiving a response message from other resources for the user datagram protocol broadcast message, whether the response message carries the acquisition of the current network status;
[0013] A second determining module is configured to, in response to determining that the response message carries the current network state, obtain the current network state according to the response message, and determine the first network state detection time corresponding to the other resources according to the response message;
[0014] A third determination module is configured to determine a target resource corresponding to the shortest first network status detection time;
[0015] The control module is configured to control the current resource to monitor the target resource to obtain a real-time network status.
[0016] In a third aspect, the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the network status detection method as described in the first aspect is implemented.
[0017] In a fourth aspect, the present application provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, wherein the computer instructions are used to enable a computer to execute the network status detection method as described in the first aspect.
[0018] From the above description, it can be seen that the network status detection method, device, electronic device and storage medium provided by the present application can send a user datagram protocol broadcast message to the network when determining that the current resource is started; when receiving a response message from other resources for the user datagram protocol broadcast message, it can be determined whether the response message carries the current network status. If it is determined that the response message carries the current network status, the current network status can be obtained according to the response message, and the first network status detection time corresponding to other resources can be determined according to the response message, that is, the time spent by other resources for detecting the current network status; further, the target resource corresponding to the shortest first network status detection time can be determined, and then the current resource can be controlled to monitor the target resource, and then the real-time network status can be obtained through the target resource. It avoids that each resource sends a request to the external network to obtain the real-time network status by itself when it needs to detect the network status, and it also avoids excessive use of the server network bandwidth. When there is a resource in the internal network that can obtain the network status, the remaining resources can obtain the current network status by monitoring it, saving network bandwidth, and also preventing the problem of external network server denial of access due to multiple resources in the same IP address frequently connecting to the external network server. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1A schematic diagram of an exemplary flow chart of a network status detection method provided in an embodiment of the present application is shown.
[0021] Figure 2 A schematic diagram of an exemplary structure of a network status detection device provided in an embodiment of the present application is shown.
[0022] Figure 3 A schematic diagram of an exemplary structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0023] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0024] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0025] As described in the background technology section, when existing software detects the network status, due to the existence of multiple resources, each software needs to detect the current network status by sending a connection request to the external network. Specifically, it will connect to the company's external network server through the ping command or TCP protocol. If the connection is successful, it is judged that the current network status is normal.
[0026] Through the inventor's research, it was found that in related technologies, for example, when multiple software are running in a device, multiple software detecting the network status will cause frequent connections to external servers, consuming server bandwidth; if the firewall security level set by the server is high, it may reject high-frequency connection requests from the same IP, resulting in failure to judge the network status.
[0027] For this reason, the present application provides a network status detection method, device, electronic device and storage medium. When it is determined that the current resource is started, a user datagram protocol broadcast message can be sent to the network; when a response message is received from other resources for the user datagram protocol broadcast message, it can be determined whether the response message carries the current network status. If it is determined that the response message carries the current network status, the current network status can be obtained according to the response message, and the first network status detection time corresponding to other resources can be determined according to the response message, that is, the time spent by other resources for detecting the current network status; further, the target resource corresponding to the shortest first network status detection time can be determined, and then the current resource can be controlled to monitor the target resource, and then the real-time network status can be obtained through the target resource. It avoids that each resource sends a request to the external network to obtain the real-time network status when it needs to detect the network status, and it also avoids excessive use of the server network bandwidth. When there is a resource in the internal network that can obtain the network status, the remaining resources can obtain the current network status by monitoring it, saving network bandwidth, and also preventing the problem of external network server denial of access due to multiple resources in the same IP address frequently connecting to the external network server.
[0028] The network status detection method provided in the embodiment of the present application is described in detail below through specific examples.
[0029] Figure 1 A schematic diagram of an exemplary flow chart of a network status detection method provided in an embodiment of the present application is shown.
[0030] refer to Figure 1 A network status detection method provided in an embodiment of the present application specifically includes the following steps:
[0031] S102: In response to determining that the current resource is started, sending a User Datagram Protocol broadcast message.
[0032] S104: In response to receiving a response message from other resources for the user datagram protocol broadcast message, determining whether the response message can carry the current network status.
[0033] S106: In response to determining that the response message carries the current network status, obtaining the current network status according to the response message, and determining a first network status detection time corresponding to the other resources according to the response message.
[0034] S108: Determine a target resource corresponding to the shortest first network status detection time.
[0035] S110: Control the current resource to monitor the target resource to obtain a real-time network status.
[0036] In some embodiments, the present application may be directed to multiple different resources in a device, such as software or cloud files, etc., or may be directed to multiple different resources in multiple different devices in a local area network. When any resource needs to detect the current network status, the resource can be started. When it is determined that the current resource is started, the current resource and the second network status detection time corresponding to the current resource can be initialized, wherein the second network status detection time is the time taken for the current resource to detect the network status from the beginning to the completion of the network status detection. Because the network status detection has not been completed when the current resource is started, the first network status detection time corresponding to the current resource can be initialized, for example, the first network status detection time corresponding to the current resource can be set to infinity MAX INT. And when the current resource is started, the time point when the current resource is started can be recorded, that is, the startup time corresponding to the current resource. Network bandwidth, when the current resource wants to detect the network status, it can first request the network status from other resources in the intranet. When any of the resources has requested the network status, the current resource can try to obtain the current network status through the resource. For example, in a local area network, resource A1 in device A is the current resource. To detect the network status, resource A1 can send a loopback UDP broadcast message (also known as a User Datagram Protocol broadcast message) to the local area network, and then wait for responses from other resources in the local area network.
[0037] Furthermore, when a response message is received from other resources to a user datagram protocol broadcast message, that is, when a response is received to a user datagram protocol broadcast message from any other resource in the local area network, it can be determined whether the current network status can be obtained based on the response message fed back by the other resource. For example, it is determined whether the response message fed back by the other resource carries the current network status. If it does, the current network status can be obtained based on the response message. Furthermore, after the current resource sends a user datagram protocol broadcast message, in order to save as much time as possible in the network status detection process and ensure the efficiency of the network status detection, a receiving period for receiving the response message can be set, for example, 1s, that is, within 1s after sending the user datagram protocol broadcast message, it is determined whether a response message from other resources is received.
[0038] In some embodiments, when a resource has acquired the network status, the resource will feedback the user datagram protocol broadcast message when detecting the user datagram protocol broadcast message sent by other resources, that is, send a reply message. Because the resource has acquired the network status, the reply message carries the current network status, such as whether the current network is connectable or not. Therefore, it can be understood that, in general, when the current resource can receive the reply message sent by other resources, the current network status can be obtained from the reply message. At the same time, there are also cases of information transmission failure, resulting in the reply message sent by other resources not carrying the current network status, then the current resource cannot obtain the current network status according to the reply message, and the current resource can detect the current network status by itself.
[0039] In some embodiments, if no response message is received from any resource for the user datagram protocol broadcast message within a preset time (i.e., 1 second), it proves that no resource in the device or local area network where the current resource is located has requested the current network status, so the current resource can detect the current network status by itself. Specifically, a network status detection request can be sent to the external network, and when the current network status feedback from the external network is received, the current network status can be determined.
[0040] Furthermore, when the current resource obtains the current network state, in order for other resources to obtain the current network state through the current resource when performing network state detection, a broadcast information indicating the current network state can be generated, which can carry the time taken by the current resource to perform network state detection, that is, the second network state detection time. For example, the second network state detection time corresponding to the current resource can be determined by taking the absolute value of the difference between the request time corresponding to the sending of the network state detection request to the external network and the feedback time corresponding to the current network state fed back by the external network.
[0041] Furthermore, the second identity information corresponding to the current resource, the second network status detection time, and the second start time of the current resource recorded at the initial moment can be determined and placed in the broadcast information, and broadcasted so that other resources can obtain the broadcast information when performing network status detection. In other words, for other resources performing network status detection, the broadcast message broadcasted by the current resource is equivalent to the response message received by other resources.
[0042] In some embodiments, the response message may include the first network status detection time corresponding to other resources, that is, the detection time spent by other resources when performing network status detection. After receiving a response message from other resources within a preset time, and determining that the current network status can be obtained according to the response message sent by other resources, the first network status detection time corresponding to other resources can be determined according to the response message, and the priority of the detection queue can be determined according to the network status detection time. Specifically, the target resource corresponding to the shortest second network status detection time can be determined. Since the first network status detection time can be set to infinity, it must be greater than any second network status detection time. Therefore, it is determined that the target resource corresponding to the shortest second network status detection time has a higher priority in the detection queue than the current resource.
[0043] It should be noted that when the current resource can receive a response message sent by other resources within the preset time, the second network status detection time corresponding to the current resource is the initialized infinite value, so the first network status detection time will be less than the second network status detection time, and the priority of other resources is higher than the current resource. When there are multiple other resources that feedback response messages, the target resource corresponding to the smallest network status detection time has the highest priority, so the current resource can be controlled to monitor the target resource with the highest priority, and then obtain real-time network status information through the target resource in the subsequent process.
[0044] In some embodiments, for the judgment of priority, when there are multiple other resources that send a response message to the current resource, when determining at least two of the smallest first network status detection times, the priority can be determined by the start time corresponding to the other resources with the same first network status detection time. Specifically, for example, if there are two other resources with the same smallest first network status detection time, it can be determined whether the first start time of one of the other resources is earlier than the first start time of the other other resource, and it is determined that the priority of the target resource corresponding to the earliest first start time is higher than that of the other resources, and the current resource can be controlled to monitor the target resource with the highest priority, and then the real-time network status information can be obtained through the target resource in the subsequent process.
[0045] It is understandable that when there are multiple other resources that feedback response messages, there are at least two shortest first network status detection times, and both are less than the second network status detection time, then the other resource with the earliest start time is determined as the target resource with the highest priority. It should be noted that, according to the needs of the actual application scenario, the other resource with the latest start time can also be determined as the target resource with the highest priority.
[0046] In some embodiments, the response message may also include first identity information corresponding to other resources, wherein the first identity information may be used to indicate the process ID corresponding to the other resources. The process ID is allocated by the system. For example, if the first resource allocated by the system is resource A, the identity information corresponding to resource A, that is, the process ID, is 1. Taking the example that the earlier the startup time, the higher the priority, when it is determined that there are at least two earliest first startup times, the resource corresponding to the smallest first identity information can be determined as the target resource, that is, the process ID corresponding to the smallest other resource is determined, and the resource is used as the target resource. Determining that the priority of the target resource with the smallest first identity information is higher than that of other resources can control the current resource to monitor the target resource with the highest priority, and then obtain real-time network status information through the target resource in the subsequent process.
[0047] It is understandable that when there are multiple other resources, there are at least two earliest first start times, then the other resource with the smallest process ID can be determined as the target resource with the highest priority. It should be noted that according to the needs of the actual application scenario, the other resource with the largest process ID can also be determined as the target resource with the highest priority.
[0048] In some embodiments, when the application scenario is a plurality of different resources running in a plurality of different devices in a local area network, the response message may also include the first network address information corresponding to other resources, wherein the first network address information is used to indicate the network address corresponding to other devices running other resources. Among them, the network address corresponding to any device in the local area network is uniquely allocated by the TCP / IP protocol. Taking the case that the smaller the process ID, the higher the priority of the corresponding resource, when it is determined that there are at least two smallest process IDs, the resource with the smallest byte value at the target position in the first network address information can be determined, and the resource is used as the target resource. For example, the resource with the smallest last byte in the first network address information is determined, wherein the last byte in the network address information can be used to indicate the size of the host number. The resource is determined to be the target resource, and the priority of the target resource is higher than that of other resources. The current resource can be controlled to monitor the target resource with the highest priority, and then the real-time network status information is obtained through the target resource in the subsequent process. It can be understood that when there are multiple other resources, when there are at least two smallest process IDs, the other resource with the smallest byte at the target position in the network address information can be determined as the target resource with the highest priority. It should be noted that, according to the requirements of actual application scenarios, other resources with the largest bytes at the target location in the network address information may also be determined as the target resource with the highest priority.
[0049] In some embodiments, if the current resource completes sending a network detection request to the external network and has obtained the current network status, and receives a response message sent by other resources, it can be determined whether there is a first network status detection time that is less than the second network status detection time. And when it is determined that the shortest first network status detection time is the same as the second network status detection time, the second startup time corresponding to the current resource can be determined, that is, the time point when the current resource is started. Taking the example that the earlier the startup time, the higher the corresponding resource priority, it can be determined whether there is a first startup time that is less than the second startup time. If the earliest first startup time is the same as the second startup time, further, the second identity information corresponding to the current resource can be determined, and the second identity information is used to indicate the process ID corresponding to the current resource. Taking the example that the smaller the process ID, the higher the priority of the corresponding resource, it is determined whether there is a first identity information with a value less than the second identity information. If the first identity information with the smallest value is the same as the second identity information, it can be further determined that the second network address information corresponding to the current resource, wherein the second network address information is used to indicate the network address corresponding to the current device running the current resource. Taking the example that the smaller the byte at the target position in the network address information, the higher the priority of the corresponding resource, determine whether there is a byte at the target position in the first network address information that is smaller than the byte at the target position in the second network address information. If there is a byte at the target position in the first network address information that is smaller than the byte at the target position in the second network address information, for example, the last byte in one of the first network address information is smaller than the last byte in the second network address information, and the last byte in the first network address information is the smallest, then the resource corresponding to the first network address information is determined as the target resource, and the current resource can be controlled to monitor the target resource, thereby obtaining the real-time network status.
[0050] It can be understood that if there is no byte at the target position in the first network address information that is smaller than the byte at the target position in the second network address information, that is, the last byte in all the first network address information is greater than or equal to the last byte in the second network address information, then the current resource may not monitor any other resource. When the current resource wants to obtain the current network status, it can send a network detection request to the external network, and then obtain the real-time network status through the information fed back by the external network.
[0051] From the above description, it can be seen that the network status detection method, device, electronic device and storage medium provided by the present application can send a user datagram protocol broadcast message to the network when determining that the current resource is started; when receiving a response message from other resources for the user datagram protocol broadcast message, it can be determined whether the response message carries the current network status. If it is determined that the response message carries the current network status, the current network status can be obtained according to the response message, and the first network status detection time corresponding to other resources can be determined according to the response message, that is, the time spent by other resources for detecting the current network status; further, the target resource corresponding to the shortest first network status detection time can be determined, and then the current resource can be controlled to monitor the target resource, and then the real-time network status can be obtained through the target resource. It avoids that each resource sends a request to the external network to obtain the real-time network status by itself when it needs to detect the network status, and it also avoids excessive use of the server network bandwidth. When there is a resource in the internal network that can obtain the network status, the remaining resources can obtain the current network status by monitoring it, saving network bandwidth, and also preventing the problem of external network server denial of access due to multiple resources in the same IP address frequently connecting to the external network server.
[0052] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.
[0053] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0054] Figure 2 A schematic diagram of an exemplary structure of a network status detection device provided in an embodiment of the present application is shown.
[0055] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a network status detection device.
[0056] refer to Figure 2, the network status detection device, the device comprises: a sending module, a first determining module, a second determining module, a third determining module and a control module; wherein,
[0057] a sending module, configured to send a user datagram protocol broadcast message in response to determining that the current resource is started;
[0058] A first determination module is configured to determine, in response to receiving a response message from other resources for the user datagram protocol broadcast message, whether the response message carries the acquisition of the current network status;
[0059] A second determining module is configured to, in response to determining that the response message carries the current network state, obtain the current network state according to the response message, and determine the first network state detection time corresponding to the other resources according to the response message;
[0060] A third determination module is configured to determine a target resource corresponding to the shortest first network status detection time;
[0061] The control module is configured to control the current resource to monitor the target resource to obtain a real-time network status.
[0062] In a possible implementation, the device further includes: a broadcast module;
[0063] The broadcast module is configured to:
[0064] In response to not receiving a response message from any resource to the user datagram protocol broadcast message within a preset time, sending a network status detection request to an external network;
[0065] In response to receiving the current network state fed back by the external network, determining a second network state detection time corresponding to the current resource according to a request time corresponding to sending a network state detection request to the external network and a feedback time corresponding to the current network state fed back by the external network, and generating broadcast information carrying the current network state;
[0066] The second network status detection time is placed in the broadcast information, and the broadcast information is broadcast.
[0067] In a possible implementation, the control module is further configured to:
[0068] determining whether there is a first network status detection time that is less than the second network status detection time;
[0069] In response to the existence of a first network status detection time that is shorter than the second network status detection time, a target resource corresponding to the shortest first network status detection time is determined, and the current resource is controlled to monitor the target resource to obtain a real-time network status.
[0070] In a possible implementation, the response message includes: a first start time corresponding to the other resource;
[0071] The control module is further configured to:
[0072] In response to the existence of at least two shortest first network status detection times, a target resource corresponding to the earliest first startup time is determined, and the current resource is controlled to monitor the target resource to obtain a real-time network status.
[0073] In a possible implementation, the response message further includes: first identity information corresponding to the other resource, where the first identity information is used to indicate a process ID corresponding to the other resource;
[0074] The control module is further configured to:
[0075] In response to the existence of at least two earliest first start times, a target resource corresponding to the first identity information with the smallest value is determined, and the current resource is controlled to monitor the target resource to obtain a real-time network status.
[0076] In a possible implementation, the response message further includes: first network address information corresponding to the other resource, where the first network address information is used to indicate a network address corresponding to another device running the other resource;
[0077] The control module is further configured to:
[0078] In response to the existence of at least two first identity information with the smallest values, a target resource with the smallest byte at the target position in the first network address information is determined, and the current resource is controlled to monitor the target resource to obtain a real-time network status.
[0079] In a possible implementation, the response message includes: a first start time corresponding to the other resource;
[0080] The control module is further configured to:
[0081] In response to the shortest first network status detection time being the same as the second network status detection time, determining a second startup time corresponding to the current resource;
[0082] determining whether there is a first start-up time that is less than the second start-up time;
[0083] In response to the earliest first startup time being the same as the second startup time, determining the second identity information corresponding to the current resource; wherein the second identity information is used to indicate the process ID corresponding to the current resource;
[0084] Determine whether there is first identity information with a value smaller than the second identity information;
[0085] In response to the first identity information with the smallest value being the same as the second identity information, determining the second network address information corresponding to the current resource; wherein the second network address information is used to indicate the network address corresponding to the current device running the current resource;
[0086] determining whether there is a byte at the target location in the first network address information that is smaller than the byte at the target location in the second network address information;
[0087] In response to the existence of a byte at the target position in the first network address information that is smaller than the byte at the target position in the second network address information, a target resource with the smallest byte at the target position in the first network address information is determined, and the current resource is controlled to monitor the target resource to obtain real-time network status.
[0088] For the convenience of describing the above device, the functions are divided into various modules and described separately. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple resources and / or hardware.
[0089] The device of the above embodiment is used to implement the corresponding network status detection method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0090] Figure 3 A schematic diagram of an exemplary structure of an electronic device provided in an embodiment of the present application is shown.
[0091] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the network status detection method described in any of the above embodiments is implemented. Figure 3 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 310, a memory 320, an input / output interface 330, a communication interface 340, and a bus 350. The processor 310, the memory 320, the input / output interface 330, and the communication interface 340 are connected to each other in communication within the device through the bus 350.
[0092] The processor 310 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0093] The memory 320 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 320 can store operating systems and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through resources or firmware, the relevant program codes are stored in the memory 320 and are called and executed by the processor 310.
[0094] The input / output interface 330 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0095] The communication interface 340 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0096] The bus 350 comprises a pathway that transmits information between the various components of the device (eg, the processor 310 , the memory 320 , the input / output interface 330 , and the communication interface 340 ).
[0097] It should be noted that, although the above device only shows the processor 310, the memory 320, the input / output interface 330, the communication interface 340 and the bus 350, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0098] The electronic device of the above embodiment is used to implement the corresponding network status detection method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0099] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the network status detection method described in any of the above embodiments.
[0100] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0101] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the network status detection method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0102] A person skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0103] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power / ground connections to the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device may be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application are to be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). Where specific details (e.g., circuits) are set forth to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or with changes in these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0104] Although the present application has been described in conjunction with specific embodiments of the present application, many alternatives, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the discussed embodiments.
[0105] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.
Claims
1. A network status detection method, characterized in that: The method comprises: In response to determining that the current resource is activated, sending a user datagram protocol broadcast message; In response to receiving a response message from other resources for the user datagram protocol broadcast message, determining whether the response message carries a current network state; In response to determining that the response message carries the current network state, acquiring the current network state according to the response message, and determining a first network state detection time corresponding to the other resources according to the response message; Determining a target resource corresponding to the shortest first network status detection time; The current resource is controlled to monitor the target resource to obtain a real-time network status.
2. The method according to claim 1, characterized in that After sending the user datagram protocol broadcast message, the method further includes: In response to not receiving a response message from any resource to the user datagram protocol broadcast message within a preset time, sending a network status detection request to an external network; In response to receiving the current network state fed back by the external network, determining a second network state detection time corresponding to the current resource according to a request time corresponding to sending a network state detection request to the external network and a feedback time corresponding to the current network state fed back by the external network, and generating broadcast information carrying the current network state; The second network status detection time is placed in the broadcast information, and the broadcast information is broadcast.
3. The method according to claim 2, characterized in that After determining the second network status detection time corresponding to the current resource according to the request time corresponding to sending the network status detection request to the external network and the feedback time corresponding to the current network status fed back by the external network, the method further includes: determining whether there is a first network status detection time that is less than the second network status detection time; In response to the existence of a first network status detection time that is shorter than the second network status detection time, a target resource corresponding to the shortest first network status detection time is determined, and the current resource is controlled to monitor the target resource to obtain a real-time network status.
4. The method according to claim 3, characterized in that The response message includes: a first start time corresponding to the other resource; After the first network status detection time that is shorter than the second network status detection time exists, the method further includes: In response to the existence of at least two shortest first network status detection times, a target resource corresponding to the earliest first startup time is determined, and the current resource is controlled to monitor the target resource to obtain a real-time network status.
5. The method according to claim 4, characterized in that The response message further includes: first identity information corresponding to the other resource, where the first identity information is used to indicate a process ID corresponding to the other resource; In response to the existence of at least two shortest first network status detection times, the method further includes: In response to the existence of at least two earliest first start times, a target resource corresponding to the first identity information with the smallest value is determined, and the current resource is controlled to monitor the target resource to obtain a real-time network status.
6. The method according to claim 5, characterized in that The response message further includes: first network address information corresponding to the other resource, where the first network address information is used to indicate a network address corresponding to another device running the other resource; In response to the existence of at least two earliest first start times, the method further includes: In response to the existence of at least two first identity information with the smallest values, a target resource with the smallest byte at the target position in the first network address information is determined, and the current resource is controlled to monitor the target resource to obtain a real-time network status.
7. The method according to claim 3, characterized in that The response message includes: a first start time corresponding to the other resource; After determining whether there is a first network status detection time that is less than the second network status detection time, the method further includes: In response to the shortest first network status detection time being the same as the second network status detection time, determining a second startup time corresponding to the current resource; determining whether there is a first start-up time that is less than the second start-up time; In response to the earliest first startup time being the same as the second startup time, determining the second identity information corresponding to the current resource; wherein the second identity information is used to indicate the process ID corresponding to the current resource; Determine whether there is first identity information with a value smaller than the second identity information; In response to the first identity information with the smallest value being the same as the second identity information, determining the second network address information corresponding to the current resource; wherein the second network address information is used to indicate the network address corresponding to the current device running the current resource; determining whether there is a byte at the target location in the first network address information that is smaller than the byte at the target location in the second network address information; In response to the existence of a byte at the target position in the first network address information that is smaller than the byte at the target position in the second network address information, a target resource with the smallest byte at the target position in the first network address information is determined, and the current resource is controlled to monitor the target resource to obtain real-time network status.
8. A network status detection device, characterized in that: The device comprises: a sending module, configured to send a user datagram protocol broadcast message in response to determining that the current resource is started; A first determination module is configured to determine, in response to receiving a response message from other resources for the user datagram protocol broadcast message, whether the response message carries the acquisition of the current network status; A second determining module is configured to, in response to determining that the response message carries the current network state, obtain the current network state according to the response message, and determine the first network state detection time corresponding to the other resources according to the response message; A third determination module is configured to determine a target resource corresponding to the shortest first network status detection time; The control module is configured to control the current resource to monitor the target resource to obtain a real-time network status.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to implement the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Network equipment connection method, equipment and system
CN105337814A
Network-state management service
CN106464532A