CN108847999B - Equipment network connectivity detection method, device, terminal equipment and storage medium - Google Patents
Equipment network connectivity detection method, device, terminal equipment and storage medium Download PDFInfo
- Publication number
- CN108847999B CN108847999B CN201810375932.2A CN201810375932A CN108847999B CN 108847999 B CN108847999 B CN 108847999B CN 201810375932 A CN201810375932 A CN 201810375932A CN 108847999 B CN108847999 B CN 108847999B
- Authority
- CN
- China
- Prior art keywords
- network node
- detected
- target network
- equipment
- detection
- 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.)
- Active
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L43/00—Arrangements for monitoring or testing data switching networks
- H04L43/08—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
- H04L43/0805—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability
- H04L43/0811—Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters by checking availability by checking connectivity
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/09—Mapping addresses
- H04L61/10—Mapping addresses of different types
- H04L61/103—Mapping addresses of different types across network layers, e.g. resolution of network layer into physical layer addresses or address resolution protocol [ARP]
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Environmental & Geological Engineering (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a method for detecting the network connectivity of equipment, which comprises the following steps: when the detection time is up, judging whether the equipment to be detected and the target network node are in the same network segment; when the equipment to be detected and a target network node are in the same network segment, judging whether the IP address of the target network node changes compared with the last detection moment; when the IP address is not changed, judging whether the network between the equipment to be detected and the target network node is communicated at the last detection moment; when the network at the last detection moment is connected, judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment; and when the equipment to be detected receives the data message, judging that the network at the current detection moment is connected. The invention can detect the network connectivity of the equipment, reduce the sending frequency and the quantity of the broadcast messages and improve the network utilization rate.
Description
Technical Field
The present invention relates to the field of computer network communication technologies, and in particular, to a method and an apparatus for detecting device network connectivity, a terminal device, and a storage medium.
Background
With the rapid development of computer network communication technology, the difficulty of managing each node device of the network is increased. The network connectivity is an important factor for ensuring the normal operation of the network in the network management, and by detecting the connectivity among the network node devices, the network performance parameters of the links among the nodes can be obtained, the working state of the links can be known as soon as possible according to the data, the connectivity fault among the network devices can be accurately positioned, and the method has important significance for the management and maintenance of the network.
Currently, connectivity between a network device and a target network node is typically detected through a PING detection mechanism and an APR detection mechanism. However, at present, some network devices forbid PING, or a target network node may not respond to the ICMP Echo Reply message due to antivirus protection, firewall rules, and other reasons, so that the real network connectivity between the network device and the target network node cannot be determined by using a PING detection mechanism; the APR detection mechanism adopts a mechanism of broadcasting and sending messages, so that one device can generate more broadcast messages when performing an ARP request, and if a plurality of network devices in the same network segment perform network connectivity detection by adopting the ARP detection mechanism, the total ARP broadcast messages are more, and network resources are occupied to a certain extent.
Disclosure of Invention
Embodiments of the present invention provide a method and an apparatus for detecting device network connectivity, a terminal device, and a storage medium, which can reduce the frequency and the number of sending broadcast messages, reduce the occupation of network resources, and improve the network utilization.
An embodiment of the present invention provides a method for detecting device network connectivity, where the method for detecting device network connectivity includes:
when the detection time is up, judging whether the equipment to be detected and the target network node are in the same network segment;
when the equipment to be detected and a target network node are in the same network segment, judging whether the IP address of the target network node changes compared with the last detection moment;
when the IP address of the target network node is not changed, judging whether the network between the equipment to be detected and the target network node is communicated at the last detection moment;
when the network between the equipment to be detected and the target network node is communicated at the last detection moment, judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment;
when the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment, judging that the network between the equipment to be detected and the target network node is connected at the current detection moment;
and when the IP address of the target network node changes, or the network between the equipment to be detected and the target network node is not communicated at the last detection moment, or the equipment to be detected does not receive the data message of the target network node between the last detection moment and the current detection moment, executing an ARP detection mechanism to detect the connectivity between the equipment to be detected and the target network node.
Compared with the prior art, the method for detecting the network connectivity of the equipment determines whether the network between the equipment to be detected and the target network node is connected or not by detecting whether the equipment to be detected receives the data message of the target network node between the last detection time and the current detection time when the equipment and the target network node are in the same network segment and the IP address of the target network node is not changed and the detection result of the last detection time is network connection, and determines that the network between the equipment to be detected and the target network node is connected if the equipment to be detected receives the data message of the target network node between the last detection time and the current detection time, so that ARP (address resolution protocol) is not required to be broadcast and sent to detect the connectivity between the equipment to be detected and the target network node when each detection time arrives and the equipment to be detected and the target network node are in the same network segment, the frequency and the number of the broadcast messages are greatly reduced, the occupation of network resources is reduced, and the network utilization rate is improved.
Further, when the network between the device to be detected and the target network node is connected at the previous detection time, it is determined whether the device to be detected receives the data packet of the target network node between the previous detection time and the current detection time, specifically: when the network between the equipment to be detected and the target network node is communicated at the last detection moment and the current detection moment does not reach the preset ARP detection period, judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment;
the method further comprises the following steps: and when the current detection moment reaches the ARP detection period, executing an ARP detection mechanism to detect the connectivity between the equipment to be detected and the target network node.
By setting the ARP detection period, ARP detection is periodically executed, the IP address and the MAC address of the target network node are timely updated, and the situation that when the corresponding relation between the IP address and the MAC address of the target network node changes, the original MAC address is still adopted to judge whether the equipment to be detected receives the data message of the target network node between the last detection time and the current detection time to judge the connectivity of the network, so that the detection result is inaccurate is prevented.
Further, the executing the ARP detection mechanism to detect the network connectivity between the device to be detected and the target network node includes:
the method comprises the steps that an ARP request message is sent to a two-layer network broadcast, and if the equipment to be detected receives an ARP response message of a target network node, network communication between the equipment to be detected and the target network node is judged; if the equipment to be detected does not receive the ARP response message of the target network node, judging that the network between the equipment to be detected and the target network node is not communicated; the ARP request message comprises an IP address and an MAC address of equipment and an IP address and an MAC address of a target network node, and the ARP response message comprises the IP address and the MAC address of the target network node.
Further, the method further comprises:
clearing the first count value when an ARP detection mechanism is executed each time the network between the equipment to be detected and the target network node is detected to be connected, and recording the number of data messages which are received by the equipment to be detected and are matched with the MAC address of the target network node from 0 through the second count value;
the step of judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment specifically comprises the following steps:
comparing the first count value with the second count value at the current moment;
and if the first count value and the second count value at the current detection moment are different, judging that the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment, and assigning the second count value to the first count value, otherwise, judging that the equipment to be detected does not receive the data message of the target network node between the last detection moment and the current detection moment.
Further, the step of judging whether the device to be detected and the target network node are in the same network segment comprises the following steps:
acquiring an IP address of a target network node;
acquiring an IP address and a subnet mask of equipment to be detected;
respectively performing AND operation on the IP address of the target network node, the IP address of the equipment to be detected and the subnet mask;
if the operation result is the same as the operation result, judging that the equipment to be detected and the target network node are in the same network segment; and if the result obtained by the operation is different, judging that the equipment to be detected and the target network node are in different network segments.
Further, when the device to be detected and the target network node are in different network segments, a PING detection mechanism is executed to detect the network connectivity between the device to be detected and the target network node.
Further, the executing the PING detection mechanism to detect the network connectivity between the device to be detected and the target network node includes:
sending an ICMP response request message to a target network node, and if the equipment to be detected receives the ICMP response message of the target network node, judging the network communication between the equipment to be detected and the target network node; and if the equipment to be detected does not receive the ICMP echo reply message of the target network node, judging that the network between the equipment to be detected and the target network node is not connected.
Another embodiment of the present invention correspondingly provides an apparatus for detecting device network connectivity, where the apparatus for detecting device network connectivity includes:
the judging module is used for judging whether the equipment to be detected and the target network node are in the same network segment or not when the detection time arrives;
the address identification module is used for judging whether the IP address of the target network node changes compared with the last detection moment when the equipment to be detected and the target network node are in the same network segment;
the network communication identification module is used for judging whether the network between the equipment to be detected and the target network node is communicated at the last detection moment when the IP address of the target network node is not changed;
the data message detection module is used for detecting whether the equipment to be detected receives the data message of the target network node between the last detection time and the current detection time when the network between the equipment to be detected and the target network node is connected at the last detection time;
the network communication judging module is used for judging that the network between the equipment to be detected and the target network node is communicated at the current detection moment when the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment;
and the ARP detection module is used for executing an ARP detection mechanism to detect the connectivity between the equipment to be detected and the target network node when the IP address of the target network node changes, the network between the equipment to be detected and the target network node is not communicated at the last detection moment, or the equipment to be detected does not receive the data message of the target network node between the last detection moment and the current detection moment.
Compared with the prior art, the device network connectivity detection device provided by the invention has the advantages that when the device and the target network node are in the same network segment and the IP address of the target network node is not changed, and the detection result of the last detection moment is network connection, whether the data message of the target network node is received by the device to be detected between the last detection moment and the current detection moment is detected through the data message detection module, so that whether the network between the device to be detected and the target network node is connected is judged, if the data message of the target network node is received by the device to be detected between the last detection moment and the current detection moment, the network between the device to be detected and the target network node is judged to be connected, and therefore, ARP request messages do not need to be broadcast to be sent to detect when the device to be detected and the target network node are in the same network segment at each detection moment, and the device to be detected and the target The communication between the two devices greatly reduces the sending frequency and the quantity of the broadcast messages, reduces the occupation of network resources and improves the network utilization rate.
Another embodiment of the present invention further provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, the network connectivity detection method of the device according to the above embodiment of the present invention is implemented.
Another embodiment of the present invention further provides a storage medium, where the storage medium includes a stored computer program, where when the computer program runs, a device where the storage medium is located is controlled to execute the method for detecting device network connectivity according to the above embodiment of the present invention.
Drawings
Fig. 1 is a schematic flowchart of a method for detecting device network connectivity according to a first embodiment of the present invention.
Fig. 2 is a schematic structural diagram of an apparatus network connectivity detecting device according to a third embodiment of the present invention.
Fig. 3 is a schematic structural diagram of a data packet detection module according to a third embodiment of the present invention.
Fig. 4 is a schematic structural diagram of an apparatus network connectivity detecting device according to a fourth embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, it is a schematic flow chart of a method for detecting device network connectivity according to a first embodiment of the present invention, including:
s101, when the detection time is up, whether the equipment to be detected and the target network node are in the same network segment is judged.
In this embodiment, a periodic detection time is preset, and when the set detection time arrives, the IP address and the subnet mask of the device to be detected are obtained, and the IP address of the target network node is obtained; then respectively performing AND operation on the IP address of the equipment to be detected and the IP address of the target network node and the subnet mask; if the operation result is the same as the operation result, judging that the equipment to be detected and the target network node are in the same network segment; and if the result obtained by the operation is different, judging that the equipment to be detected and the target network node are in different network segments.
S102, when the equipment to be detected and the target network node are in different network segments, a PING detection mechanism is executed to detect the network connectivity between the equipment to be detected and the target network node.
Specifically, equipment to be detected sends an ICMP response request message to a target network node, and if the equipment to be detected receives the ICMP response message of the target network node, network communication between the equipment to be detected and the target network node is judged; and if the equipment to be detected does not receive the ICMP echo reply message of the target network node, judging that the network between the equipment to be detected and the target network node is not connected.
S103, when the device to be detected and the target network node are in the same network segment, judging whether the IP address of the target network node changes compared with the last detection moment.
In this embodiment, the previous detection time is a time separated from the current detection time by a set period.
And S104, judging whether the network between the equipment to be detected and the target network node is connected at the last detection moment.
S105, when the network between the equipment to be detected and the target network node is connected at the last detection moment, judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment.
It should be noted that, in this embodiment, when the IP address of the target network node changes, or the network between the device to be detected and the target network node is not connected at the previous detection time, or the device to be detected does not receive the data packet of the target network node between the previous detection time and the current detection time, an ARP detection mechanism is executed to detect the connectivity between the device to be detected and the target network node.
In this embodiment, an ARP detection mechanism is executed to detect connectivity between a device to be detected and a target network node, which specifically includes: the method comprises the steps that an ARP request message is sent to a two-layer network broadcast by a device to be detected, and if the device to be detected receives an ARP response message of a target network node, network communication between the device to be detected and the target network node is judged; and if the equipment to be detected does not receive the ARP response message of the target network node, judging that the network between the equipment to be detected and the target network node is not communicated.
The ARP request message comprises an IP address and an MAC address of equipment and an IP address and an MAC address of a target network node, and the ARP response message comprises the IP address and the MAC address of the target network node. When an ARP detection mechanism is executed to detect that the network between the equipment to be detected and the target network node is communicated, the MAC address of the target network node can be obtained.
In this embodiment, each time the ARP detection mechanism is executed to detect that the network between the device to be detected and the target network node is connected, the first count value is cleared, and the number of data packets received by the device to be detected and matched with the MAC address of the target network node is recorded from 0 through the second count value.
Specifically, each time the ARP detection mechanism is executed to detect that the network between the device to be detected and the target network node is connected, the first count value is cleared, the initial value of the second count value is set to zero, the MAC address of the target network node is acquired and the data packet received by the device to be detected is continuously detected, and when the MAC address in the data packet received by the device to be detected matches the MAC address of the target network node, the second count value is incremented by 1.
The step of judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment specifically comprises the following steps:
comparing the first count value with the second count value at the current moment;
and if the first count value and the second count value at the current detection moment are different, judging that the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment, assigning the second count value to the first count value, and otherwise, judging that the equipment to be detected does not receive the data message of the target network node between the last detection moment and the current detection moment.
S106, when the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment, judging that the network between the equipment to be detected and the target network node is connected at the current detection moment.
It should be noted that, in this embodiment, when the device to be detected does not receive the data packet of the target network node between the last detection time and the current detection time, an ARP detection mechanism is executed to detect the network connectivity between the device to be detected and the target network node.
In this embodiment, when the last detection time is that the network between the device to be detected and the target network node is detected to be connected through the ARP detection mechanism, the first count value at the current time is 0; and when the last detection moment is that the network between the equipment to be detected and the target network node is judged to be connected by comparing the difference between the first count value and the second count value, the first count value at the current moment is the second count value at the last detection moment.
In this embodiment, when it is detected that the network between the device to be detected and the target network node is connected, the next detection time is waited to arrive, so as to continue to execute the above steps to detect the network connectivity between the device to be detected and the target network node.
Compared with the prior art, the embodiment of the invention detects the network connectivity between the equipment to be detected and the target network node in a passive detection mode, and specifically comprises the following steps: when the equipment to be detected and a target network node are in the same network segment, the IP address of the target network node is not changed, and the detection result at the last detection moment is network communication, whether the network between the equipment to be detected and the target network node is communicated is judged by detecting whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment, and if the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment, the network between the equipment to be detected and the target network node is communicated. Therefore, the ARP request message does not need to be broadcast and sent to detect the connectivity between the equipment to be detected and the target network node when the equipment to be detected and the target network node reach each detection moment and are in the same network segment, the sending frequency and the quantity of the broadcast messages are greatly reduced, the occupation of network resources is reduced, and the network utilization rate is improved.
A second embodiment of the present invention provides a method for detecting device network connectivity, where the difference between this embodiment and the first embodiment is:
in this embodiment, an ARP detection period is set, when the device to be detected and the target network node are in the same network segment and the IP address of the target network node is not changed, it is detected whether the ARP detection period arrives, and if the ARP detection period arrives, an ARP detection mechanism is directly executed to detect the network connectivity between the device to be detected and the target network node.
The method for detecting the network connectivity of the equipment according to the embodiment of the invention periodically executes ARP detection by setting an ARP detection period, updates the IP address and the MAC address of the target network node in time, and prevents the equipment to be detected from judging whether to receive the data message of the target network node between the last detection time and the current detection time by using the original MAC address to judge the network connectivity when the corresponding relation between the IP address and the MAC address of the target network node changes, thereby causing inaccurate detection result.
Referring to fig. 2, a device network connectivity detection apparatus 200 according to a third embodiment of the present invention is provided, where the device network connectivity detection apparatus 200 includes:
the judging module 201 is configured to, when the detection time arrives, judge whether the device to be detected and the target network node are in the same network segment;
the address identification module 202 is configured to, when the device to be detected and a target network node are in the same network segment, determine whether an IP address of the target network node changes compared with a last detection time;
the network connectivity identification module 203 is configured to, when the IP address of the target network node does not change, determine whether a network between the device to be detected and the target network node is connected at the last detection time;
a data packet detection module 204, configured to detect, when a network between the device to be detected and the target network node is connected at a previous detection time, whether the device to be detected receives a data packet of the target network node between the previous detection time and a current detection time;
a network connectivity determining module 205, configured to determine that a network between the device to be detected and a target network node is connectivity at a current detection time when the device to be detected receives a data packet of the target network node between a last detection time and the current detection time;
and the ARP detection module 206 is configured to execute an ARP detection mechanism to detect connectivity between the device to be detected and the target network node when the IP address of the target network node changes, or the network between the device to be detected and the target network node is not connected at the previous detection time, or the device to be detected does not receive the data packet of the target network node between the previous detection time and the current detection time.
And the PING detection module 207 is used for executing a PING detection mechanism to detect the network connectivity between the equipment to be detected and the target network node when the equipment to be detected and the target network node are in different network segments.
In this embodiment, the ARP detection module 206 is further configured to execute an ARP detection mechanism to detect connectivity between the device to be detected and the target network node when the device to be detected does not receive the data packet of the target network node between the previous detection time and the current detection time.
Referring to fig. 3, for the data packet detection module 204 of this embodiment, the data packet detection module 204 includes:
the address identification counting module 2041 is configured to, after the ARP detection mechanism is executed each time and it is detected that the network between the device to be detected and the target network node is connected, zero-clear the first count value, and record the number of data packets received by the device to be detected and matching the MAC address of the target network node from 0 through the second count value.
A count value comparison module 2042, configured to compare a first count value and a second count value at a current detection time when a network between the device to be detected and the target network node is connected at a previous detection time;
the data packet determining module 2043 is configured to determine, when the first count value at the current detection time is different from the second count value, that the device to be detected receives the data packet of the target network node between the previous detection time and the current detection time, and assign the second count value to the first count value; otherwise, the device to be detected does not receive the data message of the target network node between the last detection moment and the current detection moment.
Compared with the prior art, the embodiment of the invention detects the network connectivity between the equipment to be detected and the target network node in a passive detection mode, and specifically comprises the following steps: when the equipment to be detected and the target network node are in the same network segment, the IP address of the target network node is not changed, and the detection result at the previous detection moment is network communication, detecting whether the equipment to be detected receives the data message of the target network node between the previous detection moment and the current detection moment through the data message detection module 204 to determine whether the network between the equipment to be detected and the target network node is connected, and if the equipment to be detected receives the data message of the target network node between the previous detection moment and the current detection moment, determining that the network between the equipment to be detected and the target network node is connected. Therefore, the ARP request message does not need to be broadcast and sent to detect the connectivity between the equipment to be detected and the target network node when the equipment to be detected and the target network node reach each detection moment and are in the same network segment, the sending frequency and the quantity of the broadcast messages are greatly reduced, the occupation of network resources is reduced, and the network utilization rate is improved.
As shown in fig. 4, a device network connectivity detection apparatus 200 'according to a fourth embodiment of the present invention is different from the third embodiment in that the device network connectivity detection apparatus 200' further includes:
and the ARP period detection module 208' is configured to detect whether the ARP detection period is reached when the device to be detected and the target network node are in the same network segment and the IP address of the target network node is not changed.
And an ARP enforcement module 209' configured to, when the ARP detection period arrives, execute an ARP detection mechanism to detect connectivity between the device to be detected and the target network node.
The device network connectivity detection apparatus 200' according to the embodiment of the present invention updates the IP address and the MAC address of the target network node in time by periodically executing the ARP detection mechanism, so as to prevent the original MAC address from being used to determine whether the device to be detected receives the data packet of the target network node between the previous detection time and the current detection time to determine the network connectivity when the correspondence between the IP address and the MAC address of the target network node changes, which may result in inaccurate detection results.
A fifth embodiment of the present invention provides a terminal device, which includes a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, the processor implements the device network connectivity detection method according to the above-described embodiment of the present invention.
A sixth embodiment of the present invention provides a storage medium, where the storage medium includes a stored computer program, and when the computer program runs, a device where the storage medium is located is controlled to execute the method for detecting device network connectivity according to the foregoing embodiment of the present invention.
Illustratively, in the fifth and sixth embodiments, the computer program may be divided into one or more modules/units, which are stored in the memory and executed by the processor, to accomplish the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program in the terminal.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may be any conventional processor or the like, which is the control center of the terminal and connects the various parts of the overall terminal using various interfaces and lines.
The memory may be used for storing the computer programs and/or modules, and the processor may implement various functions of the terminal device by executing or executing the computer programs and/or modules stored in the memory and calling data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the cellular phone, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
Wherein the terminal-integrated module/unit, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in a computer-readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like.
It should be noted that the above-described device embodiments are merely illustrative, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. In addition, in the drawings of the embodiment of the apparatus provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, and may be specifically implemented as one or more communication buses or signal lines. One of ordinary skill in the art can understand and implement it without inventive effort.
While the foregoing is directed to the preferred embodiment of the present invention, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention.
Claims (10)
1. A method for device network connectivity detection, the method comprising:
when the detection time is up, judging whether the equipment to be detected and the target network node are in the same network segment;
when the equipment to be detected and a target network node are in the same network segment, judging whether the IP address of the target network node changes compared with the last detection moment;
when the IP address of the target network node is not changed, judging whether the network between the equipment to be detected and the target network node is communicated at the last detection moment;
when the network between the equipment to be detected and the target network node is communicated at the last detection moment, judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment;
when the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment, judging that the network between the equipment to be detected and the target network node is connected at the current detection moment;
and when the IP address of the target network node changes, or the network between the equipment to be detected and the target network node is not communicated at the last detection moment, or the equipment to be detected does not receive the data message of the target network node between the last detection moment and the current detection moment, executing an ARP detection mechanism to detect the connectivity between the equipment to be detected and the target network node.
2. The method for detecting device network connectivity according to claim 1, wherein when the network between the device to be detected and the target network node is connected at the previous detection time, the method for determining whether the device to be detected receives the data packet of the target network node between the previous detection time and the current detection time specifically comprises: when the network between the equipment to be detected and the target network node is communicated at the last detection moment and the current detection moment does not reach the preset ARP detection period, judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment;
the method further comprises the following steps: and when the current detection moment reaches the ARP detection period, executing an ARP detection mechanism to detect the connectivity between the equipment to be detected and the target network node.
3. The device network connectivity detection method according to any one of claims 1 or 2, wherein the performing the ARP detection mechanism to detect the network connectivity between the device to be detected and the target network node comprises:
the method comprises the steps that an ARP request message is sent to a two-layer network broadcast, and if the equipment to be detected receives an ARP response message of a target network node, network communication between the equipment to be detected and the target network node is judged; if the equipment to be detected does not receive the ARP response message of the target network node, judging that the network between the equipment to be detected and the target network node is not communicated; the ARP request message comprises an IP address and an MAC address of equipment and an IP address and an MAC address of a target network node, and the ARP response message comprises the IP address and the MAC address of the target network node.
4. The device network connectivity detection method according to claim 1 or 2, characterized in that the method further comprises:
clearing the first count value when an ARP detection mechanism is executed each time the network between the equipment to be detected and the target network node is detected to be connected, and recording the number of data messages which are received by the equipment to be detected and are matched with the MAC address of the target network node from 0 through the second count value;
the step of judging whether the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment specifically comprises the following steps:
comparing the first count value with the second count value at the current moment;
and if the first count value and the second count value at the current detection moment are different, judging that the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment, and assigning the second count value to the first count value, otherwise, judging that the equipment to be detected does not receive the data message of the target network node between the last detection moment and the current detection moment.
5. The method for detecting the network connectivity of the equipment according to claim 1, wherein the step of judging whether the equipment to be detected and the target network node are in the same network segment comprises the following steps:
acquiring an IP address of a target network node;
acquiring an IP address and a subnet mask of equipment to be detected;
respectively performing AND operation on the IP address of the target network node, the IP address of the equipment to be detected and the subnet mask;
if the operation result is the same as the operation result, judging that the equipment to be detected and the target network node are in the same network segment; and if the result obtained by the operation is different, judging that the equipment to be detected and the target network node are in different network segments.
6. The device network connectivity detection method according to claim 1, wherein when the device to be detected and the target network node are in different network segments, a PING detection mechanism is performed to detect the network connectivity between the device to be detected and the target network node.
7. The device network connectivity detection method of claim 6, wherein the performing a PING detection mechanism to detect network connectivity between the device to be detected and the target network node comprises:
sending an ICMP response request message to a target network node, and if the equipment to be detected receives the ICMP response message of the target network node, judging the network communication between the equipment to be detected and the target network node; and if the equipment to be detected does not receive the ICMP echo reply message of the target network node, judging that the network between the equipment to be detected and the target network node is not connected.
8. An apparatus for detecting device network connectivity, comprising:
the judging module is used for judging whether the equipment to be detected and the target network node are in the same network segment or not when the detection time arrives;
the address identification module is used for judging whether the IP address of the target network node changes compared with the last detection moment when the equipment to be detected and the target network node are in the same network segment;
the network communication identification module is used for judging whether the network between the equipment to be detected and the target network node is communicated at the last detection moment when the IP address of the target network node is not changed;
the data message detection module is used for detecting whether the equipment to be detected receives the data message of the target network node between the last detection time and the current detection time when the network between the equipment to be detected and the target network node is connected at the last detection time;
the network communication judging module is used for judging that the network between the equipment to be detected and the target network node is communicated at the current detection moment when the equipment to be detected receives the data message of the target network node between the last detection moment and the current detection moment;
and the ARP detection module is used for executing an ARP detection mechanism to detect the connectivity between the equipment to be detected and the target network node when the IP address of the target network node changes, the network between the equipment to be detected and the target network node is not communicated at the last detection moment, or the equipment to be detected does not receive the data message of the target network node between the last detection moment and the current detection moment.
9. A terminal device comprising a processor, a memory and a computer program stored in the memory and configured to be executed by the processor, the processor implementing the device network connectivity detection method according to any one of claims 1 to 7 when executing the computer program.
10. A storage medium comprising a stored computer program, wherein the computer program controls a device in which the storage medium is located to perform the method for detecting network connectivity of a device according to any one of claims 1 to 7 when the computer program runs.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810375932.2A CN108847999B (en) | 2018-04-24 | 2018-04-24 | Equipment network connectivity detection method, device, terminal equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810375932.2A CN108847999B (en) | 2018-04-24 | 2018-04-24 | Equipment network connectivity detection method, device, terminal equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108847999A CN108847999A (en) | 2018-11-20 |
CN108847999B true CN108847999B (en) | 2020-06-16 |
Family
ID=64212128
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810375932.2A Active CN108847999B (en) | 2018-04-24 | 2018-04-24 | Equipment network connectivity detection method, device, terminal equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108847999B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109756390B (en) * | 2018-12-06 | 2020-12-01 | 网易(杭州)网络有限公司 | Method and device for automatically testing connectivity of network accelerator |
CN111917608B (en) * | 2020-08-07 | 2022-01-04 | 深圳市友华软件科技有限公司 | Method and device for judging Internet connectivity based on Linux system equipment |
CN115834436B (en) * | 2022-11-24 | 2024-05-03 | 中国联合网络通信集团有限公司 | Network connectivity detection method, device and storage medium |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101110848B (en) * | 2006-07-20 | 2011-05-04 | 华为技术有限公司 | Method for detecting channel trouble |
CN101741513A (en) * | 2009-12-15 | 2010-06-16 | 中兴通讯股份有限公司 | Method and system for detecting connectivity |
CN103684897A (en) * | 2012-09-11 | 2014-03-26 | 北京百度网讯科技有限公司 | Method, system and device for detecting network connectivity in client |
EP2949104A4 (en) * | 2013-01-23 | 2016-02-10 | Ericsson Telefon Ab L M | Methods and arrangements for checking connectivity and detecting connectivity failure |
CN104683188A (en) * | 2015-03-23 | 2015-06-03 | 太仓市同维电子有限公司 | Method for quickly detecting communication of IP channel of household router |
-
2018
- 2018-04-24 CN CN201810375932.2A patent/CN108847999B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN108847999A (en) | 2018-11-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11671402B2 (en) | Service resource scheduling method and apparatus | |
CN108847999B (en) | Equipment network connectivity detection method, device, terminal equipment and storage medium | |
CN111182659B (en) | Mode switching method and mode switching device of Mesh equipment and Mesh equipment | |
EP3076709A1 (en) | Zigbee network-based data transmission method, apparatus, and system | |
CN111464358B (en) | Message reporting method and device | |
CN106921578B (en) | Method and device for generating forwarding table item | |
CN104717107A (en) | Method, device and system for detecting network device | |
CN108429739B (en) | Method, system and terminal equipment for identifying honeypots | |
CN113285918B (en) | ACL filtering table item establishing method and device for network attack | |
CN111884875A (en) | Offline device determination method and device | |
CN113473576A (en) | Roaming networking processing method and device, mobile terminal and readable storage medium | |
CN110087226B (en) | Flow statistical method and device, storage medium and electronic device | |
CN107465621B (en) | Router discovery method, SDN controller, router and network system | |
CN114786241B (en) | Network selection method, related device, network equipment and storage medium | |
CN111431772A (en) | Network delay measuring method, system, readable storage medium and terminal equipment | |
CN111131484A (en) | Node mounting method, device, network node and storage medium | |
CN108834130B (en) | Identification distribution method, device, terminal and computer readable storage medium | |
CN108156247B (en) | Data communication method, device, system, terminal and readable storage medium | |
CN107547676B (en) | Address processing method and device | |
CN110830984B (en) | Method, device, equipment and storage medium for routing QoS acceleration request message | |
CN114978600B (en) | Abnormal flow processing method, system, equipment and storage medium | |
CN114567589B (en) | Identification method and device for route report | |
US20150109958A1 (en) | Transmission path control device | |
CN114584496A (en) | Device discovery method, device, client and storage medium | |
CN109661005B (en) | Load sharing adjustment method and device of local access controller |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right | ||
TR01 | Transfer of patent right |
Effective date of registration: 20220613 Address after: Floor 12-17, unit 1, building 2, No. 466, Xinyu Road, high tech Zone, Chengdu, Sichuan 610000 Patentee after: Chengdu Lianzhou International Technology Co.,Ltd. Address before: 518000 the 1st and 3rd floors of the south section of building 24 and the 1st-4th floor of the north section of building 28, Shennan Road Science and Technology Park, Nanshan District, Shenzhen City, Guangdong Province Patentee before: TP-LINK TECHNOLOGIES Co.,Ltd. |