CN113472882A - Network state switching method and device, client device and storage medium - Google Patents
Network state switching method and device, client device and storage medium Download PDFInfo
- Publication number
- CN113472882A CN113472882A CN202110739447.0A CN202110739447A CN113472882A CN 113472882 A CN113472882 A CN 113472882A CN 202110739447 A CN202110739447 A CN 202110739447A CN 113472882 A CN113472882 A CN 113472882A
- Authority
- CN
- China
- Prior art keywords
- remote server
- service provided
- remote
- icmp
- time
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 50
- 230000004044 response Effects 0.000 claims abstract description 52
- 238000004590 computer program Methods 0.000 claims description 12
- 230000005540 biological transmission Effects 0.000 claims description 8
- 238000001514 detection method Methods 0.000 claims description 4
- 238000005516 engineering process Methods 0.000 abstract description 4
- 238000004891 communication Methods 0.000 description 10
- 238000012545 processing Methods 0.000 description 6
- 238000010586 diagram Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 5
- 230000004048 modification Effects 0.000 description 3
- 238000012986 modification Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 238000012360 testing method Methods 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000010801 machine learning Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001953 sensory effect Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/54—Presence management, e.g. monitoring or registration for receipt of user log-on information, or the connection status of the users
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The disclosure provides a network state switching method, a network state switching device, client equipment and a storage medium, and relates to the technical field of internet, in particular to a network intercommunication technology. The specific implementation scheme is as follows: sending an Internet message control protocol ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message; receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of ICMP response message; detecting the availability of the remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; and if the remote service provided by the remote server is unavailable, switching the network state of the remote server from the online state to the offline state. According to the method and the device, the online state can be automatically switched to the offline state from the online state under the condition that the network condition of the client is poor or the remote service is unavailable, so that the flow loss is effectively avoided, and the waiting time of a user is reduced.
Description
Technical Field
The present disclosure relates to the field of internet technologies, and further relates to a network interworking technology, and in particular, to a network status switching method and apparatus, a client device, and a storage medium.
Background
With the rapid development of communication technology, Wireless networks, especially Wireless Local Area Networks (WLAN) have been widely used in various aspects of life. Because the wireless local area network does not need wiring and has higher transmission speed, the defect of the limited local area network can be well made up. Almost all current intelligent terminals support a hotspot of accessing a Wireless local area network through Wireless Fidelity (WiFi for short) to realize an internet function.
However, due to network congestion or limited network access, when the network is connected, the accessed page may not be opened for a long time, and in such a case, the user needs to perform multiple network access attempts (for example, to try to refresh or access other links) to determine whether the network has a problem, which wastes the user's time.
When the network condition of the client is not good or the remote service is unavailable, if the client continuously sends the online request, request failures such as timeout and the like occur, and traffic loss is caused.
Disclosure of Invention
The disclosure provides a network state switching method, a network state switching device, a client device and a storage medium.
In a first aspect, the present application provides a network status switching method, where the method includes:
sending an Internet message control protocol ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message;
receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of the ICMP response message;
detecting the availability of the remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; wherein the availability of the remote service provided by the remote server comprises: a remote service provided by the remote server is available or the remote service provided by the remote server is unavailable;
and if the remote service provided by the remote server is unavailable, switching the network state of the remote server from the online state to the offline state.
In a second aspect, the present application provides a network status switching apparatus, including: the device comprises a sending module, a receiving module, a detecting module and a switching module; wherein,
the sending module is used for sending an ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message;
the receiving module is configured to receive an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of the ICMP response message;
the detection module is used for detecting the availability of the remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; wherein the availability of the remote service provided by the remote server comprises: a remote service provided by the remote server is available or the remote service provided by the remote server is unavailable;
the switching module is used for switching the network state from the online state to the offline state if the remote service provided by the remote server is unavailable.
In a third aspect, an embodiment of the present application provides a client device, including:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the network state switching method according to any embodiment of the present application.
In a fourth aspect, the present application provides a storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the network state switching method according to any embodiment of the present application.
In a fifth aspect, a computer program product is provided, which when executed by a computer device implements the network state switching method according to any embodiment of the present application.
According to the technical scheme, the technical problem that when the network condition of the client equipment is poor or the remote service is unavailable, if the client continuously sends the online request, the request failure such as overtime occurs, and the traffic loss is caused is solved.
It should be understood that the statements in this section do not necessarily identify key or critical features of the embodiments of the present disclosure, nor do they limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description.
Drawings
The drawings are included to provide a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 is a first flowchart of a network status switching method according to an embodiment of the present application;
fig. 2 is a second flowchart of a network status switching method according to an embodiment of the present application;
fig. 3 is a third flow chart of a network state switching method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a network state switching device according to an embodiment of the present application;
fig. 5 is a block diagram of a client device for implementing a network status switching method according to an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, in which various details of the embodiments of the disclosure are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Example one
Fig. 1 is a flowchart of a network status switching method provided in an embodiment of the present application, where the method may be performed by a network status switching apparatus or a client device, where the apparatus or the client device may be implemented by software and/or hardware, and the apparatus or the client device may be integrated in any intelligent device with a network communication function. As shown in fig. 1, the network state switching method may include the following steps:
s101, sending an ICMP request message to a remote server through a PING command; and recording the transmission time of the ICMP request message.
In this step, the client device may send an ICMP request message to the remote server via a PING command; and recording the transmission time of the ICMP request message. Specifically, ping (packet Internet groper) is an Internet packet explorer, a program for testing the amount of network connection. PPING is a service command working in the application layer of TCP/IP network architecture, and mainly sends ICMP request message to specific destination host to test whether destination station can reach and know its related state.
S102, receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; and recording the receiving time of the ICMP response message.
In this step, the client device may receive an ICMP response message corresponding to the ICMP request message returned by the remote server; and recording the receiving time of the ICMP response message. Under the condition of network interruption, the client device cannot receive the ICMP request message returned by the remote server, and at this time, the client device may set the receiving time of the ICMP response message to a predetermined time, or set the receiving time of the ICMP response message to null.
S103, detecting the availability of the remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; wherein the availability of the remote service provided by the remote server comprises: the remote service provided by the remote server is available or the remote service provided by the remote server is not available.
In this step, the client device may detect the availability of the remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; wherein the availability of the remote service provided by the remote server comprises: the remote service provided by the remote server is available or the remote service provided by the remote server is not available. Specifically, the client device may first calculate a time interval between a reception time of the ICMP response message and a transmission time of the ICMP request message; and taking the time interval as the delay time of the remote server; availability of a remote service provided by the remote server is then detected based on the delay time of the remote server. Further, if the delay time of the remote server is less than a preset duration threshold, the client device may determine that the remote service provided by the remote server is available; if the delay time of the remote server is greater than or equal to the duration threshold, the client device may determine that the remote service provided by the remote server is unavailable.
And S104, if the remote service provided by the remote server is unavailable, switching the network state from the online state to the offline state.
In this step, if the remote service provided by the remote server is not available, the client device may switch its network state from the online state to the offline state. Specifically, the client device can be automatically switched to the ideal state under the condition that the network condition of the client device is not good or the remote service is unavailable, so that the waiting time of a user can be reduced, and the traffic loss is avoided.
The network state switching method provided by the embodiment of the application comprises the steps of firstly sending an ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message; then receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of ICMP response message; then, based on the sending time of the ICMP request message and the receiving time of the ICMP response message, the availability of the remote service provided by the remote server is detected; and if the remote service provided by the remote server is unavailable, switching the network state of the remote server from the online state to the offline state. That is, the present application can automatically switch its network status from an online status to an offline status by detecting the availability of a remote service provided by a remote server. In the prior art, when the network status of the client device is not good or the remote service is unavailable, the user usually accesses a large and stable third-party website at regular time to determine whether the network of the client device is connected or whether the remote service is available. The availability of the remote service provided by the remote server is detected by sending an ICMP request message and receiving an ICMP response message; if the remote service provided by the remote server is unavailable, the technical means for automatically switching the network state of the remote server from the online state to the offline state overcomes the technical problem that the traffic loss is caused by request failure such as overtime and the like if the client continuously sends an online request under the condition that the network state of the client equipment is poor or the remote service is unavailable; moreover, the technical scheme of the embodiment of the application is simple and convenient to implement, convenient to popularize and wide in application range.
Example two
Fig. 2 is a second flowchart of a network status switching method according to an embodiment of the present application. Further optimization and expansion are performed based on the technical scheme, and the method can be combined with the various optional embodiments. As shown in fig. 2, the network status switching method may include the following steps:
s201, sending an ICMP request message to a remote server through a PING command; and recording the transmission time of the ICMP request message.
S202, receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; and recording the receiving time of the ICMP response message.
S203, calculating the time interval between the receiving time of the ICMP response message and the sending time of the ICMP request message; and takes this time interval as the delay time of the remote server.
In this step, the client device may calculate a time interval between the time of receiving the ICMP response message and the time of sending the ICMP request message; and takes this time interval as the delay time of the remote server. Under the condition of network interruption, the client device cannot receive the ICMP request message returned by the remote server, and at this time, the client device may set the receiving time of the ICMP response message to a predetermined time, or set the receiving time of the ICMP response message to null.
S204, detecting the availability of the remote service provided by the remote server according to the delay time of the remote server; wherein the availability of the remote service provided by the remote server comprises: the remote service provided by the remote server is available or the remote service provided by the remote server is not available.
In this step, the client device may detect availability of a remote service provided by the remote server according to the delay time of the remote server; wherein the availability of the remote service provided by the remote server comprises: the remote service provided by the remote server is available or the remote service provided by the remote server is not available. Specifically, if the delay time of the remote server is less than a preset duration threshold, the client device may determine that the remote service provided by the remote server is available; if the delay time of the remote server is greater than or equal to the duration threshold, the client device may determine that the remote service provided by the remote server is unavailable. For example, if the delay time of the remote server is less than 1000ms, the client device may determine that the remote service provided by the remote server is available; if the delay time of the remote server is greater than or equal to 1000ms, the client device may determine that the remote service provided by the remote server is unavailable.
And S205, if the remote service provided by the remote server is unavailable, switching the network state from the online state to the offline state.
The network state switching method provided by the embodiment of the application comprises the steps of firstly sending an ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message; then receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of ICMP response message; then, based on the sending time of the ICMP request message and the receiving time of the ICMP response message, the availability of the remote service provided by the remote server is detected; and if the remote service provided by the remote server is unavailable, switching the network state of the remote server from the online state to the offline state. That is, the present application can automatically switch its network status from an online status to an offline status by detecting the availability of a remote service provided by a remote server. In the prior art, when the network status of the client device is not good or the remote service is unavailable, the user usually accesses a large and stable third-party website at regular time to determine whether the network of the client device is connected or whether the remote service is available. The availability of the remote service provided by the remote server is detected by sending an ICMP request message and receiving an ICMP response message; if the remote service provided by the remote server is unavailable, the technical means for automatically switching the network state of the remote server from the online state to the offline state overcomes the technical problem that the traffic loss is caused by request failure such as overtime and the like if the client continuously sends an online request under the condition that the network state of the client equipment is poor or the remote service is unavailable; moreover, the technical scheme of the embodiment of the application is simple and convenient to implement, convenient to popularize and wide in application range.
EXAMPLE III
Fig. 3 is a third flow chart of a network state switching method according to an embodiment of the present application. Further optimization and expansion are performed based on the technical scheme, and the method can be combined with the various optional embodiments. As shown in fig. 3, the network status switching method may include the following steps:
s301, sending an ICMP request message to a remote server through a PING command; and recording the transmission time of the ICMP request message.
S302, receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; and recording the receiving time of the ICMP response message.
S303, detecting the availability of the remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; wherein the availability of the remote service provided by the remote server comprises: the remote service provided by the remote server is available or the remote service provided by the remote server is not available.
S304, if the remote service provided by the remote server is unavailable, switching the network state from the online state to the offline state; and accumulating the current weak network count value by 1; and if the remote service provided by the remote server is available, clearing the current weak network count value.
In this step, if the remote service provided by the remote server is unavailable, the client device may switch its network state from an online state to an offline state; and accumulating the current weak network count value by 1; the client device may clear the current weak network count value if the remote service provided by the remote server is available. Specifically, if the remote service provided by the remote server is unavailable, which indicates that the client device is in the weak network environment, the current weak network count value may be accumulated by 1 at this time; if the remote service provided by the remote server is available, which indicates that the client device is in a good network environment, the current weak network count value may be cleared at this time.
S305, based on the current weak network count value, adjusting the time interval for executing the operation of sending the ICMP request message to the remote server through the PING command.
In this step, the client device may adjust a time interval for performing an operation of sending an ICMP request message to the remote server via a PING command based on the current weak network count value. Specifically, if the current weak network count value is smaller than a predetermined value, the client device may execute an operation of sending an ICMP request message to the remote server through a PING command according to a first time interval; if the current weak network count value is greater than or equal to the predetermined value, the client device may perform an operation of sending an ICMP request message to the remote server through a PING command according to the second time interval. For example, if the current weak network count value is less than 10, the client device may execute an operation of sending an ICMP request message to the remote server through a PING command every 5 s; if the current weak network count value is greater than or equal to 10, the client device may perform an operation of sending an ICMP request message to the remote server through a PING command every 1 s.
The network state switching method provided by the embodiment of the application comprises the steps of firstly sending an ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message; then receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of ICMP response message; then, based on the sending time of the ICMP request message and the receiving time of the ICMP response message, the availability of the remote service provided by the remote server is detected; and if the remote service provided by the remote server is unavailable, switching the network state of the remote server from the online state to the offline state. That is, the present application can automatically switch its network status from an online status to an offline status by detecting the availability of a remote service provided by a remote server. In the prior art, when the network status of the client device is not good or the remote service is unavailable, the user usually accesses a large and stable third-party website at regular time to determine whether the network of the client device is connected or whether the remote service is available. The availability of the remote service provided by the remote server is detected by sending an ICMP request message and receiving an ICMP response message; if the remote service provided by the remote server is unavailable, the technical means for automatically switching the network state of the remote server from the online state to the offline state overcomes the technical problem that the traffic loss is caused by request failure such as overtime and the like if the client continuously sends an online request under the condition that the network state of the client equipment is poor or the remote service is unavailable; moreover, the technical scheme of the embodiment of the application is simple and convenient to implement, convenient to popularize and wide in application range.
Example four
Fig. 4 is a schematic structural diagram of a network state switching device according to an embodiment of the present application. As shown in fig. 4, the apparatus 400 includes: a sending module 401, a receiving module 402, a detecting module 403 and a switching module 404; wherein,
the sending module 401 is configured to send an internet message control protocol ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message;
the receiving module 402 is configured to receive an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of the ICMP response message;
the detecting module 403 is configured to detect availability of a remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; wherein the availability of the remote service provided by the remote server comprises: a remote service provided by the remote server is available or the remote service provided by the remote server is unavailable;
the switching module 404 is configured to switch the network status from an online status to an offline status if the remote service provided by the remote server is unavailable.
Further, the detecting module 403 is specifically configured to calculate a time interval between the receiving time of the ICMP response message and the sending time of the ICMP request message; and taking the time interval as the delay time of the remote server; detecting availability of a remote service provided by the remote server based on the delay time of the remote server.
Further, the detecting module 403 is specifically configured to determine that the remote service provided by the remote server is available if the delay time of the remote server is less than a preset duration threshold; and if the delay time of the remote server is greater than or equal to the duration threshold, determining that the remote service provided by the remote server is unavailable.
Further, the sending module 401 is further configured to, if the remote service provided by the remote server is available, execute the operation of sending the ICMP request message to the remote server through the PING command according to a first time interval; if the remote service provided by the remote server is unavailable, executing the operation of sending the ICMP request message to the remote server through the PING command according to a second time interval; wherein the first time interval is greater than the second time interval.
Further, the switching module 404 is further configured to clear a pre-stored current weak network count value or accumulate the current weak network count value by 1 according to the availability of the remote service provided by the remote server; and adjusting the time interval for executing the operation of sending the ICMP request message to the remote server through the PING command based on the current weak network count value.
Further, the switching module 404 is specifically configured to clear the current weak network count value if the remote service provided by the remote server is available; and if the remote service provided by the remote server is unavailable, accumulating the current weak network count value by 1.
The network state switching device can execute the method provided by any embodiment of the application, and has the corresponding functional modules and beneficial effects of the execution method. For details of the network state switching method provided in any embodiment of the present application, reference may be made to the technical details not described in detail in this embodiment.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the personal information of the related user all accord with the regulations of related laws and regulations, and do not violate the good customs of the public order.
EXAMPLE five
The present disclosure also provides a client device, a readable storage medium, and a computer program product according to embodiments of the present disclosure.
Fig. 5 illustrates a schematic block diagram of an example client device 500 that can be used to implement embodiments of the present disclosure. Client devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The client device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 5, the apparatus 500 comprises a computing unit 501 which may perform various appropriate actions and processes in accordance with a computer program stored in a Read Only Memory (ROM)502 or a computer program loaded from a storage unit 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The calculation unit 501, the ROM 502, and the RAM 503 are connected to each other by a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
A number of components in the device 500 are connected to the I/O interface 505, including: an input unit 506 such as a keyboard, a mouse, or the like; an output unit 507 such as various types of displays, speakers, and the like; a storage unit 508, such as a magnetic disk, optical disk, or the like; and a communication unit 509 such as a network card, modem, wireless communication transceiver, etc. The communication unit 509 allows the device 500 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunication networks.
The computing unit 501 may be a variety of general-purpose and/or special-purpose processing components having processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The calculation unit 501 performs the respective methods and processes described above, such as the network state switching method. For example, in some embodiments, the network state switching method may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program may be loaded and/or installed onto the device 500 via the ROM 502 and/or the communication unit 509. When the computer program is loaded into the RAM 503 and executed by the computing unit 501, one or more steps of the network state switching method described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the network state switching method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, Field Programmable Gate Arrays (FPGAs), Application Specific Integrated Circuits (ASICs), Application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for implementing the network state switching method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the program codes, when executed by the processor or controller, cause the functions/operations specified in the flowchart and/or block diagram to be performed. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), Wide Area Networks (WANs), and the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server may be a cloud server, a server of a distributed system, or a server with a combined blockchain.
It should be understood that various forms of the flows shown above may be used, with steps reordered, added, or deleted. For example, the steps described in the present disclosure may be executed in parallel, sequentially, or in different orders, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, and the present disclosure is not limited herein.
The above detailed description should not be construed as limiting the scope of the disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.
Claims (15)
1. A network state switching method is applied to client equipment and comprises the following steps:
sending an Internet message control protocol ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message;
receiving an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of the ICMP response message;
detecting the availability of the remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; wherein the availability of the remote service provided by the remote server comprises: a remote service provided by the remote server is available or the remote service provided by the remote server is unavailable;
and if the remote service provided by the remote server is unavailable, switching the network state of the remote server from the online state to the offline state.
2. The method according to claim 1, wherein the detecting availability of the remote service provided by the remote server based on the transmission time of the ICMP request message and the reception time of the ICMP response message comprises:
calculating the time interval between the receiving time of the ICMP response message and the sending time of the ICMP request message; and taking the time interval as the delay time of the remote server;
detecting availability of a remote service provided by the remote server based on the delay time of the remote server.
3. The method of claim 2, wherein said detecting availability of a remote service provided by the remote server based on a delay time of the remote server comprises:
if the delay time of the remote server is less than a preset time threshold, determining that the remote service provided by the remote server is available;
and if the delay time of the remote server is greater than or equal to the duration threshold, determining that the remote service provided by the remote server is unavailable.
4. The method of claim 2, further comprising:
if the remote service provided by the remote server is available, executing the operation of sending the ICMP request message to the remote server through the PING command according to a first time interval;
if the remote service provided by the remote server is unavailable, executing the operation of sending the ICMP request message to the remote server through the PING command according to a second time interval; wherein the first time interval is greater than the second time interval.
5. The method of claim 1, further comprising:
according to the availability of the remote service provided by the remote server, clearing a pre-stored current weak network count value or accumulating the current weak network count value by 1;
and adjusting the time interval for executing the operation of sending the ICMP request message to the remote server through the PING command based on the current weak network count value.
6. The method of claim 5, wherein the clearing a pre-saved current weak network count value or accumulating the current weak network count value by 1 according to the availability of the remote service provided by the remote server comprises:
if the remote service provided by the remote server is available, clearing the current weak network count value;
and if the remote service provided by the remote server is unavailable, accumulating the current weak network count value by 1.
7. A network state switching apparatus, the apparatus comprising: the device comprises a sending module, a receiving module, a detecting module and a switching module; wherein,
the sending module is used for sending an Internet message control protocol ICMP request message to a remote server through a PING command; recording the sending time of the ICMP request message;
the receiving module is configured to receive an ICMP response message corresponding to the ICMP request message returned by the remote server; recording the receiving time of the ICMP response message;
the detection module is used for detecting the availability of the remote service provided by the remote server based on the sending time of the ICMP request message and the receiving time of the ICMP response message; wherein the availability of the remote service provided by the remote server comprises: a remote service provided by the remote server is available or the remote service provided by the remote server is unavailable;
the switching module is used for switching the network state from the online state to the offline state if the remote service provided by the remote server is unavailable.
8. The apparatus according to claim 7, wherein the detection module is specifically configured to calculate a time interval between a reception time of the ICMP response packet and a transmission time of the ICMP request packet; and taking the time interval as the delay time of the remote server; detecting availability of a remote service provided by the remote server based on the delay time of the remote server.
9. The apparatus according to claim 8, wherein the detection module is specifically configured to determine that the remote service provided by the remote server is available if the delay time of the remote server is less than a preset duration threshold; and if the delay time of the remote server is greater than or equal to the duration threshold, determining that the remote service provided by the remote server is unavailable.
10. The apparatus of claim 8, wherein the sending module is further configured to, if a remote service provided by the remote server is available, execute the sending of the ICMP request message to the remote server through the PING command according to the first time interval; if the remote service provided by the remote server is unavailable, executing the operation of sending the ICMP request message to the remote server through the PING command according to a second time interval; wherein the first time interval is greater than the second time interval.
11. The apparatus according to claim 7, wherein the switching module is further configured to clear a pre-stored current weak network count value or add up the current weak network count value by 1 according to availability of a remote service provided by the remote server; and adjusting the time interval for executing the operation of sending the ICMP request message to the remote server through the PING command based on the current weak network count value.
12. The apparatus according to claim 11, wherein the switching module is specifically configured to clear the current weak network count value if the remote service provided by the remote server is available; and if the remote service provided by the remote server is unavailable, accumulating the current weak network count value by 1.
13. A client device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
14. A non-transitory computer readable storage medium having stored thereon computer instructions for causing the computer to perform the method of any one of claims 1-6.
15. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110739447.0A CN113472882A (en) | 2021-06-30 | 2021-06-30 | Network state switching method and device, client device and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110739447.0A CN113472882A (en) | 2021-06-30 | 2021-06-30 | Network state switching method and device, client device and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113472882A true CN113472882A (en) | 2021-10-01 |
Family
ID=77876711
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110739447.0A Pending CN113472882A (en) | 2021-06-30 | 2021-06-30 | Network state switching method and device, client device and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113472882A (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102960029A (en) * | 2011-06-21 | 2013-03-06 | 华为技术有限公司 | Method, device, user equipment and system for repeated access detection and restriction |
CN103428037A (en) * | 2012-05-16 | 2013-12-04 | 华为技术有限公司 | User online detecting method, device and system |
CN105610913A (en) * | 2015-12-22 | 2016-05-25 | 用友网络科技股份有限公司 | Heartbeat keep-alive method and apparatus for long connection in communication network |
CN106161601A (en) * | 2016-06-24 | 2016-11-23 | 广东欧珀移动通信有限公司 | Method and device for data request |
CN108429820A (en) * | 2018-05-23 | 2018-08-21 | 深圳远征技术有限公司 | A kind of communication means of internet of things application layer, system and terminal device |
CN111031598A (en) * | 2020-01-08 | 2020-04-17 | Oppo广东移动通信有限公司 | Network communication control method, device, communication equipment and storage medium |
CN112749009A (en) * | 2020-12-30 | 2021-05-04 | 杭州迪普科技股份有限公司 | Server scheduling method and device |
-
2021
- 2021-06-30 CN CN202110739447.0A patent/CN113472882A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102960029A (en) * | 2011-06-21 | 2013-03-06 | 华为技术有限公司 | Method, device, user equipment and system for repeated access detection and restriction |
CN103428037A (en) * | 2012-05-16 | 2013-12-04 | 华为技术有限公司 | User online detecting method, device and system |
CN105610913A (en) * | 2015-12-22 | 2016-05-25 | 用友网络科技股份有限公司 | Heartbeat keep-alive method and apparatus for long connection in communication network |
CN106161601A (en) * | 2016-06-24 | 2016-11-23 | 广东欧珀移动通信有限公司 | Method and device for data request |
CN108429820A (en) * | 2018-05-23 | 2018-08-21 | 深圳远征技术有限公司 | A kind of communication means of internet of things application layer, system and terminal device |
CN111031598A (en) * | 2020-01-08 | 2020-04-17 | Oppo广东移动通信有限公司 | Network communication control method, device, communication equipment and storage medium |
CN112749009A (en) * | 2020-12-30 | 2021-05-04 | 杭州迪普科技股份有限公司 | Server scheduling method and device |
Non-Patent Citations (1)
Title |
---|
黄圆媛: "《收银员实用技能》", 成都:天地出版社, pages: 142 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113726607B (en) | Network detection method and device, electronic equipment and storage medium | |
CN113778644B (en) | Task processing method, device, equipment and storage medium | |
CN112783731B (en) | Abnormal device detection method, device and storage medium | |
CN113438106B (en) | Content distribution network processing method and device and electronic equipment | |
CN112965823B (en) | Control method and device for call request, electronic equipment and storage medium | |
CN113609027B (en) | ARM cloud server testing method and device, electronic equipment and storage medium | |
CN113918383A (en) | Core board resetting method, device, equipment, storage medium and program product | |
CN113795039A (en) | Operator network switching method, device, equipment and computer readable storage medium | |
CN116016276B (en) | Server health status detection method and device | |
CN115484216A (en) | Message transmission method and device, electronic equipment and automatic driving vehicle | |
CN114070752B (en) | Test method, test device, electronic equipment and computer readable storage medium | |
CN114095394B (en) | Network node fault detection method and device, electronic equipment and storage medium | |
CN113472882A (en) | Network state switching method and device, client device and storage medium | |
CN117880053A (en) | Method, apparatus, device, storage medium and program product for providing alarm | |
CN115514718B (en) | Data interaction method, control layer and equipment based on data transmission system | |
CN114170821B (en) | Signal machine performance detection method and device and traffic signal lamp control system | |
CN115529346A (en) | Service changing method, device, equipment and storage medium | |
CN105163336A (en) | Method and system for optimizing stability of wireless network | |
CN112714420B (en) | Network access method and device of wifi hotspot providing equipment and electronic equipment | |
CN113965514A (en) | Link construction and display method and device and electronic equipment | |
CN113327602A (en) | Method and device for speech recognition, electronic equipment and readable storage medium | |
CN115378795B (en) | Method and device for monitoring network quality of server, electronic equipment and storage medium | |
CN120111091A (en) | Network exception processing method, device, equipment, system, medium and product | |
CN113596129B (en) | Restarting method, restarting device, restarting equipment and restarting storage medium of cloud mobile phone | |
CN116306407B (en) | Verification method, device, equipment and storage medium of Network On Chip (NOC) |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20211001 |
|
RJ01 | Rejection of invention patent application after publication |