Network address detection method and device, electronic equipment and storage medium
By automatically dividing and switching network bits and host bits of network addresses, generating detection addresses and sending detection packets, the problem of testers being difficult to quickly obtain network equipment IP addresses is solved, and efficient and accurate network address detection is achieved, supporting subsequent black box testing.
Patent Information
- Application Number
- CN202411606269.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-03-14
AI Technical Summary
In the prior art, it is difficult for testers to quickly and accurately obtain the IP address of the network device to be tested before conducting black box tests, resulting in low test efficiency and low success rate.
By automatically dividing the network bits and host bits of the network address, automatically switching the values of the network bits and host bits, generating different detection addresses, and building detection packets to send them to the target device to realize automatic detection of the network address of the target device.
It realizes automatic execution of network address detection process with high efficiency and accuracy, can cover the entire network widely, quickly judge and obtain the network address of the test target device, and provides a solid foundation for subsequent black box testing.
Smart Images

Figure CN119629150A_ABST
Abstract
Description
Background Art
[0002] With the development of Internet technology, the performance and security of network equipment have become increasingly important. In order to ensure that network equipment can operate stably in complex environments, testers usually choose to use black box testing to verify the functions, performance, and compatibility of network equipment.
[0003] In related technologies, testers need to use the Internet Protocol (IP) address of the network device to be tested in order to interact with the network device and further detect the network device. However, in some cases, testers may not be able to know the IP address of the network device before conducting black box testing. At this time, testers can only find the IP address of the network device through manual intervention, that is, testers manually set network parameters and repeatedly try different IP addresses until they find the IP address of the network device. However, this method that relies on the experience or even luck of testers is time-consuming, labor-intensive, inefficient, and cannot guarantee a success rate.
[0004] Therefore, there is an urgent need for a new method that can quickly and accurately obtain the IP address of the network device to be tested without relying on manual guessing. Summary of the invention
[0005] Embodiments of the present application provide a network address detection method, device, electronic device, and storage medium to improve the efficiency of network address detection.
[0006] A network address detection method provided in an embodiment of the present application includes:
[0007] In response to the detection address generation instruction, the detection address is obtained based on different division methods of dividing the network address with a fixed number of bits into network bits and host bits, and changes in the values of the network bits and the host bits in any division method;
[0008] Based on the detection address, construct and send a detection packet to the target device;
[0009] Determining that no response packet returned by the target device is received, triggering the detection address generation instruction again;
[0010] When the response packet is received, the response packet is parsed to obtain the target network address of the target device.
[0011] An embodiment of the present application provides a network address detection device, including:
[0012] A response unit, configured to obtain a detection address in response to a detection address generation instruction based on different division methods of dividing a network address with a fixed number of bits into network bits and host bits, and changes in the values of the network bits and the host bits under any division method;
[0013] A construction unit, configured to construct and send a detection packet to the target device based on the detection address;
[0014] A determination unit, configured to determine that no response packet returned by the target device is received, and trigger the detection address generation instruction again;
[0015] The parsing unit is used to parse the response packet when receiving the response packet to obtain the target network address of the target device.
[0016] Optionally, the response unit is specifically used for:
[0017] In response to the detection address generation instruction, the division method of the network bit and the host bit is changed once, and based on the number of bits of the currently divided network bits and the number of bits of the host bits, a first variation range of the value of the network bit and a second variation range of the value of the host bit are determined;
[0018] Transforming the value of the network bit within the first variation range, and transforming the value of the host bit within the second variation range, to obtain a plurality of candidate network bits and a plurality of candidate host bits;
[0019] For each candidate network bit, a candidate network bit is combined with each candidate host bit to obtain multiple detection addresses.
[0020] Optionally, the response unit is specifically used for:
[0021] In response to the detection address generation instruction, a value corresponding to at least one bit in the network address having a fixed number of bits is changed once;
[0022] Based on different division methods of dividing a network address with a fixed number of bits into network bits and host bits, detection addresses in multiple different communication subnet ranges are obtained.
[0023] Optionally, the response unit is further configured to determine different division modes of the network address having a fixed number of bits into network bits and host bits by:
[0024] Based on the respective bit ranges of the network bits and the host bits, the network bits and the host bits of the network address with fixed bits are transformed respectively.
[0025] Optionally, the device further comprises:
[0026] A mapping unit, configured to set the network mode to a bridge mode and disable the network address translation NAT and host-only network functions of the virtual machine if the test initiating device is a virtual machine; or
[0027] Map the USB network card connected to the host machine to the virtual machine, and delete the virtual network card of the virtual machine.
[0028] Optionally, each detection packet includes a request response instruction, a detection address and a source network address of the test initiating device; the detection address and the source network address included in each detection packet have the same communication subnet range as each other;
[0029] The response packet is sent to the test initiating device based on the source network address in a detection packet after the target device receives a detection packet and determines that the detection address in the detection packet is consistent with its own target network address; the response packet includes the target network address of the target device.
[0030] Optionally, the construction unit is specifically used for:
[0031] Based on the detection address, each protocol in the communication protocol set is used to construct and send a detection packet to the target device; the communication protocol set includes at least one of the Internet Control Message Protocol and the Transmission Control Protocol.
[0032] An electronic device provided by an embodiment of the present application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the above-mentioned network address detection methods.
[0033] An embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is executed on an electronic device, the computer program is used to enable the electronic device to execute the steps of any one of the above-mentioned network address detection methods.
[0034] An embodiment of the present application provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of any one of the above-mentioned network address detection methods.
[0035] The beneficial effects of this application are as follows:
[0036] The embodiment of the present application provides a network address detection method, device, electronic device and storage medium. Since the present application can automatically divide the network bit and host bit of the network address, automatically switch the values of the network bit and the host bit, generate different detection addresses based on different division methods and different value changes, automatically send different detection packets containing different detection addresses to the target device, realize automatic detection of the network address of the target device, and once the response packet is received, the target network address of the target device can be obtained. Compared with the prior art that can only rely on manual operation or passive waiting, which is inefficient and prone to errors, the present application can automatically perform the network address detection process with high efficiency and high accuracy, and can widely cover the entire network, quickly determine and obtain the network address of the test target device, and provide a solid foundation for subsequent black box testing.
[0037] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0039] Figure 1 A schematic diagram of an application scenario of a network address detection method provided in an embodiment of the present application;
[0040] Figure 2 An overall flow chart of a network address detection method provided in an embodiment of the present application;
[0041] Figure 3 An overall flow chart of another network address detection method provided in an embodiment of the present application;
[0042] Figure 4 A schematic diagram of the structure of a network address detection device provided in an embodiment of the present application;
[0043] Figure 5 A schematic diagram of a hardware structure of an electronic device provided in an embodiment of the present application;
[0044] Figure 6 A schematic diagram of the hardware structure of another electronic device provided for application of an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.
[0046] The following is an introduction to some concepts involved in the embodiments of the present application.
[0047] Virtual Machine: An independent computing environment created on a host computer through virtualization software that can simulate the hardware of a physical computer to run its own operating system and applications.
[0048] Host machine: A physical computer that runs virtualization software and hosts one or more virtual machines. It is responsible for providing physical resources to the virtual machines, such as the central processing unit (CPU), memory, storage space, etc., as well as managing and scheduling the operation of the virtual machines.
[0049] Network address: An identifier used to uniquely identify a device in a computer network. This application mainly takes the IP address (and mainly IPv4) as an example. The IPv4 address contains 32 address bits, which are divided into host bits and network bits.
[0050] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.
[0051] like Figure 1 As shown, it is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario diagram includes a test initiator 110 and a target device 120. The test initiator 110 and the target device of the address to be detected are directly connected via a network cable. Figure 1 The target device 120 already has a configured network address, such as an IP address, but the IP address is unknown and there is no related user manual.
[0052] In the embodiment of the present application, the test initiating device 110 includes but is not limited to a terminal device (such as a mobile phone, a tablet computer, a laptop computer, a desktop computer, etc.); a client related to network address detection may be installed on the terminal device, and the client may be software (such as a browser, network address detection software, etc.), or a web page, a small program, etc., or a server specifically used for network address detection, which is not specifically limited in the present application. The server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0053] The target device 120 may be a terminal device or a network device (such as a router, a switch, etc.).
[0054] It should be noted that the network address detection method in each embodiment of the present application is mainly executed by the test initiating device 110. Before performing the black box test, it is necessary to detect the network address of the target device 120. The test initiating device 110 responds to the detection address generation instruction, and obtains the detection address based on different division methods of dividing the network address with a fixed number of bits into network bits and host bits, and the changes in the values of the network bits and host bits under any division method, and constructs a detection packet for each detection address, and sends the detection packet to the target device 120; if the response packet returned by the target device 120 is not received, the detection address generation instruction is triggered again; if the response packet is received, the test initiating device 110 parses the response packet to obtain the target network address of the target device 120.
[0055] In an optional implementation, the test initiating device 110 and the target device 120 may communicate with each other via a network cable.
[0056] It should be noted that Figure 1 The figure is only an example. In fact, the number of the test initiating device 110 and the target device 120 is not limited, and is not specifically limited in the embodiments of the present application.
[0057] In addition, the embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation and other scenarios.
[0058] The following describes the network address detection method provided by the exemplary embodiment of the present application in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this regard.
[0059] See also Figure 2 As shown, it is an implementation flow chart of a network address detection method provided in an embodiment of the present application. The specific implementation process of the method is as follows S201-S204:
[0060] S201: In response to a detection address generation instruction, a detection address is obtained based on different division methods of dividing a network address with a fixed number of bits into network bits and host bits, and changes in the values of the network bits and the host bits in any division method.
[0061] The present application is mainly used in application scenarios of network address detection. For example, before conducting a black box test, it is necessary to determine the network address of the target device (the IP address is used as an example below). If the target device has been configured with an IP address but the IP address is unknown, and there is no method to directly obtain the IP address of the target device, in this scenario, the present application proposes a method for detecting the network address of the target device, connecting the target device and the test initiating device through a network cable for communication, and the test initiating device continuously generates a detection address to check the IP address of the target device by sending a detection packet to the target device.
[0062] Before performing address detection, you first need to configure the operating system environment of the test initiator to ensure that the network detection task can be performed automatically. You can use a device with a Linux-like operating system as the test initiator; the ifconfig command in the Linux-like operating system can perform temporary IP configuration, and can flexibly set the IP address and subnet mask of each network segment, which can achieve a high degree of automation of network address detection.
[0063] The Linux operating system may be Ubuntu system, etc., and this application does not make any specific limitation.
[0064] Exemplarily, an automated script may be written using the bash shell in a Linux system to implement automatic changes in the IP address so that subsequent detection tasks can be automatically executed.
[0065] In addition, if there is no device with a Linux operating system, a virtual machine can be used to complete the detection task. In this case, the test initiator is a virtual machine, which is essentially a computing environment simulated by software and attached to a host machine. The host machine is a physical server that carries the virtual machine and provides CPU, memory, storage, and network resources for the virtual machine. At this time, the host machine and the target device are physically connected via a network cable. In order to ensure the stability of the network connection at the hardware level and avoid network interference, the network settings of the virtual machine need to be further adjusted.
[0066] An optional implementation is to set the network mode to bridge mode and turn off the network address translation NAT and host-only network functions of the virtual machine; or, map the USB network card connected to the host machine to the virtual machine and delete the virtual network card of the virtual machine.
[0067] That is, it can be set in the following two ways.
[0068] Method 1: Configure a bridged network card to bridge the physical network cable to the Linux environment in the virtual machine. In addition, the host machine is usually configured with multiple network segments and IP addresses. In order to avoid interference in the detection process, the NAT function and host-only network function of the virtual machine need to be turned off.
[0069] In this mode, the virtual machine appears as an independent device on the network and can be directly connected to the target device based on a physical network cable and communicate with the target device without going through the network settings of the host machine.
[0070] Method 2: If you have a Universal Serial Bus (USB) network card, you can insert the USB network card into the host machine, separate the USB network card from the host system through the virtual machine manager (such as VirtualBox, VMware, etc.), and map it to the operating system environment in the virtual machine. In the virtual machine, use the lsusb command to confirm whether the USB network card has been recognized by the system, and then use the ifconfig or ip link command to view the network interface to ensure that the USB network card has been successfully mapped and is available.
[0071] Delete the default virtual network card of the virtual machine (that is, turn off the NAT function and host-only network function of the virtual machine) to avoid the interference of the configuration of the virtual network card on the detection environment; this method can also realize the direct connection between the virtual machine and the target device, effectively reduce the false alarms caused by the network configuration of the virtual machine, and improve the purity and stability of the test environment. At the same time, it also enables the entire solution to be physicalized as a product, simplifies the deployment process, and enhances the portability of the system.
[0072] After the settings at the operating system level and the hardware level are completed, the test initiator continuously generates detection addresses based on the network allocation strategy in an attempt to find the target network address of the target device.
[0073] There are two main network allocation strategies.
[0074] Strategy 1: Fixed subnet mask but not IP address.
[0075] This method is suitable for scenarios where the subnet range of the target device is large and high-precision detection is required. By setting a large-scale subnet mask and gradually detecting each network address, the network address information of the target device can be accurately obtained. In particular, when the target device uses an irregular network address (such as not using common IP addresses such as 1, 10, 100), it can still be effectively detected.
[0076] Exemplarily, the test initiator changes the way the network bits and host bits are divided once in response to a detection address generation instruction, and determines a first variation range of the numerical value of the network bit and a second variation range of the numerical value of the host bit based on the number of network bits and the number of host bits currently divided; then, the numerical value of the network bit is transformed within the first variation range, and the numerical value of the host bit is transformed within the second variation range to obtain multiple candidate network bits and multiple candidate host bits; finally, for each candidate network bit, one candidate network bit is combined with each candidate host bit to obtain multiple detection addresses.
[0077] An optional implementation is that the division of network bits and host bits is achieved by transforming the network bits and host bits of a network address with fixed bits based on the respective bit ranges of the network bits and host bits. The bit range of the network bits and host bits is [0,32].
[0078] Taking the network address as an IP address as an example, an IPv4 IP address usually contains 32 address bits, such as 11000000.10101000.00000001.00000001. For the convenience of description, it is expressed in decimal as 192.168.1.1. Some of the address bits in the IP address are network bits, and the other part of the address bits are host bits. The division of network bits and host bits is determined by the subnet mask. For example, the subnet mask is 255.255.255.0, which is / 24, which means that the first 24 bits are network bits, that is, the network bit of 192.168.1.1 is 192.168.1, and the host bit is 1. The IP address 192.168.1.1 belongs to the subnet 192.168.1.0 / 24, and there are 254 available host addresses in this subnet (that is, from 192.168.1.1 to 192.168.1.254).
[0079] Therefore, the above method of first determining the division method of network bits and host bits and then changing the values of network bits and host bits is essentially to first determine a subnet mask, that is, first determine the size of a subnet to be detected, and then continuously switch the IP address (that is, change the specific value of each address bit) to obtain multiple detection addresses. If the target device is not within the scope of the detected subnet, there will be no response.
[0080] After the subnet mask is determined, assuming the subnet mask is / 24, when switching the IP address later, you can give priority to switching the value of the host bit, that is, first determine a specific subnet, such as 192.168.1.0 / 24, and detect IP addresses from 192.168.1.1 to 192.168.1.254, 192.168.1.1 to 192.168.1.254 are 254 detection addresses; if none of them are detected, then switch the value of the network bit, that is, change a subnet, such as changing to 192.168.2.0 / 24, and detect IP addresses from 192.168.2.1 to 192.168.2.254, and so on.
[0081] The entire detection process can be accelerated by using multithreading after the IP configuration is completed. For example, 254 IP addresses (detection addresses) from 192.168.1.1 to 192.168.1.254 are configured at one time, and the detection process of these 254 IP addresses is subsequently performed in parallel, such as sending detection packets. The detection process can also be performed serially for each detection address, which is not specifically limited in this application.
[0082] It should be noted that IP addresses in different subnets / segments cannot perform the detection process in parallel.
[0083] Strategy 2: Fixed IP but not subnet mask.
[0084] This method is suitable for the case where the IP range of the target device is small or uncertain. By setting a fixed detection address and gradually adjusting the subnet mask to detect the target network address of the target device, this method has a faster detection speed.
[0085] Exemplarily, the test initiating device responds to the detection address generation instruction by changing the value corresponding to at least one bit in the network address with a fixed number of bits; then, based on different division methods of dividing the network address with a fixed number of bits into network bits and host bits, the detection addresses in multiple different communication subnet ranges are obtained.
[0086] An optional implementation is that the division of network bits and host bits is achieved by transforming the network bits and host bits of a network address with fixed bits based on the respective bit ranges of the network bits and host bits. The bit range of the network bits and host bits is [0,32].
[0087] Strategy 2 is essentially to first determine an IP address, that is, to first determine the value of each address bit of the IP address, and then continuously switch the subnet mask to try to detect the same IP address (detection address) in subnets of different sizes; you can set an IP address that is not usually used, and detect which subnet the IP address is in by gradually modifying the subnet mask.
[0088] That is, "detection addresses in multiple different communication subnet ranges" are essentially the same IP address, and the values of the address bits of each detection address are the same, but the subnet masks are different, that is, the number of network bits and host bits is different.
[0089] Assuming that the IP address is determined to be 192.168.1.1, the subnet mask can be set to / 32, / 31, / 30, ..., / 1, and detection can be performed in sequence. Common subnet masks such as / 24, / 16 and / 8 can also be preferentially detected. This application does not make specific limitations.
[0090] Based on the above two methods, the network address detection task can be automatically executed, which can maintain high efficiency and high accuracy in complex network environments, provide a wide range of detection coverage, and provide a reliable data foundation for subsequent network testing and analysis.
[0091] S202: Based on the detection address, construct and send a detection packet to the target device.
[0092] A corresponding detection packet is constructed for each detection address, and the detection packet contains the source IP address of the test initiator device, the detection address, and the request response instruction.
[0093] In addition, multiple communication protocols can be used to detect the IP address of the target device to avoid detection failure caused by the target device disabling a certain communication protocol, thereby improving the accuracy of IP detection; exemplarily, based on the detection address, each protocol in the communication protocol set is used to construct and send a detection packet to the target device; the communication protocol set includes at least one of the Internet Control Message Protocol and the Transmission Control Protocol, and may also include other communication protocols, which are not specifically limited in this application.
[0094] That is, for each detection address, multiple detection packets can be constructed based on different communication protocols. If it is Internet Control Message Protocol (ICMP), the detection packet can be an echo request packet; if it is Transmission Control Protocol (TCP), the detection packet is a Transmission Control Protocol detection packet. The detection process of different communication protocols corresponding to the same detection address can be executed in parallel or in sequence.
[0095] For example, ICMP first uses the ping command to detect whether the target device responds to the ICMP request; when the ping command detection has no results, the TCP protocol is further used to detect common ports (such as 21, 22, 23, 80, 443, 445, etc.) for detection.
[0096] In addition, this application also supports:
[0097] Address Resolution Protocol (ARP): used to detect the MAC address of the target device and is suitable for LAN environments.
[0098] User Datagram Protocol (UDP): detects whether a specific port of a target device is open, especially for devices that prohibit TCP detection.
[0099] Simple Network Management Protocol: (SNMP) is used to obtain management information of the target device and is usually applicable to network devices.
[0100] ICMP protocol types other than ICMP Echo Request and Echo Reply: used to detect and analyze the network status and behavior of the target device.
[0101] It can be seen that the present application can effectively respond to various common network security protection measures by adopting multiple communication protocols for detection, avoid the situation where detection failure occurs when the target device disables a certain protocol due to network security, and ensure that the target IP address is accurately obtained on devices with different protection levels. Especially when facing network devices with multiple layers of protection, the survival status of the target device can be effectively identified, greatly improving the success rate of detection.
[0102] It should be noted that the detection address contained in each detection packet is the same as the communication subnet range corresponding to the source network address, that is, the subnet mask is the same. Only in this case can the two devices communicate. Therefore, when the detection address changes and the subnet mask of the new detection address is different from the previous detection address, the subnet mask corresponding to the source network address must be changed accordingly to make it consistent with the subnet mask of the new detection address.
[0103] S203: Determine that no response packet returned by the target device is received, and trigger the detection address generation instruction again.
[0104] The response packet is sent to the test initiator device based on the source network address in a detection packet after the target device receives a detection packet and determines that the detection address in the detection packet is consistent with its own target network address; the response packet contains the target network address of the target device.
[0105] If no response packet is received, it means that the target network address of the target device is not hit among all the detection addresses constructed by this detection, then the detection address generation instruction is re-triggered. If the detection address is generated using strategy one in S201, that is, the method of fixing the subnet mask but not the IP, then after the detection address generation instruction is re-triggered, a new subnet mask is replaced, and then the IP address is changed based on the new subnet mask (that is, the specific value of each address bit is changed); if the detection address is generated using strategy two in S201, that is, the method of fixing the IP but not the subnet mask, then after the detection address generation instruction is re-triggered, the value of at least one of the 32-bit address bits is changed to obtain a new IP address, and then the subnet mask is changed based on the new IP address, and then the detection is continued.
[0106] S204: When a response packet is received, the response packet is parsed to obtain a target network address of the target device.
[0107] If a response packet is received, the target network address in the response packet can be obtained by parsing the response packet.
[0108] After receiving the response packet, the test initiator will output information such as the round-trip delay of the detection. If no response packet is received, it will output prompt information such as detection failure. The above output information can be presented in a visual interface to prompt the user. At the same time, it can be equipped with corresponding algorithm logic to determine whether the target network address is detected based on the above output data.
[0109] The method of directly determining whether the target network address is detected by receiving a response packet and the method of determining whether the target network address is detected by outputting data are both feasible. The former requires higher permissions, while the latter requires lower permissions.
[0110] Finally, the detection results can be recorded in a log or database.
[0111] If the detection process encounters an abnormal situation, the resources can be automatically released to end the detection task. There are also corresponding processing mechanisms for possible interference factors such as IP address conflicts and network delays. By dynamically adjusting the detection parameters and communication strategies, interference can be effectively avoided to ensure that the obtained network address is accurate and reliable.
[0112] Optionally, in order to improve the accuracy of detection, when using a detection method (fixed subnet mask but not fixed IP or fixed IP but not fixed subnet mask), after trying all IPs under all subnets, if the target network address (target IP address) of the target device is still not found, you can change to another detection method and perform address detection again.
[0113] In summary, the test initiator device of the present application can automatically change the detection address and subnet range to cover a larger detection range as much as possible, and the whole process does not require human intervention. In order to improve the test efficiency, multi-threading technology can also be used to allow multiple threads to execute multiple detection tasks in parallel, which not only greatly shortens the detection time, but also expands the coverage of the detection. Furthermore, by using a variety of communication protocols (such as ARP, ICMP, TCP, UDP, etc.) to communicate with the target device to verify the survival status of the target device. Different protocols have different characteristics and applicable scenarios. Combined with multi-protocol verification methods, it is possible to more accurately determine whether the target device is online and its specific IP address information.
[0114] Based on the above process, Figure 3 As shown, it is an overall flow chart of another network address detection method provided by an embodiment of the present application, and the server specifically performs the following steps:
[0115] Step 301: Initialize network configuration.
[0116] If the test initiator is a virtual machine, the virtual machine must be configured in advance to achieve a direct connection between the virtual machine and the target device and to avoid interference of the virtual network card configuration on the detection environment.
[0117] Step 302: Obtain the detection protocol and the number of threads.
[0118] Step 303: Generate a detection address and a detection packet.
[0119] Generate detection addresses by setting subnet mask but not IP or setting IP but not subnet mask, taking different communication protocols into consideration.
[0120] Step 304: Send a detection packet to the target device and monitor the response data packet.
[0121] The response data packet is the response packet.
[0122] Step 305: If a response packet is received, the response packet is parsed to obtain the target network address.
[0123] Step 306: Record the detection result to a log / database.
[0124] Step 307: Present the detection results in a visual interface.
[0125] Based on the same inventive concept, the present application embodiment also provides a network address detection device. Figure 4 As shown, it is a schematic diagram of the structure of a network address detection device, which may include:
[0126] A response unit 401 is used to respond to the detection address generation instruction and obtain the detection address based on different division methods of dividing the network address with a fixed number of bits into network bits and host bits, and changes in the values of the network bits and the host bits under any division method;
[0127] A construction unit 402 is used to construct and send a detection packet to a target device based on the detection address;
[0128] A determination unit 403 is used to determine that no response packet returned by the target device is received, and trigger the detection address generation instruction again;
[0129] The parsing unit 404 is used to parse the response packet upon receiving the response packet to obtain the target network address of the target device.
[0130] Optionally, the response unit 401 is specifically used for:
[0131] In response to the detection address generation instruction, the division method of the network bit and the host bit is changed once, and based on the number of bits of the currently divided network bits and the number of bits of the host bits, a first variation range of the value of the network bit and a second variation range of the value of the host bit are determined;
[0132] Transforming the value of the network bit within a first variation range, and transforming the value of the host bit within a second variation range, to obtain a plurality of candidate network bits and a plurality of candidate host bits;
[0133] For each candidate network bit, a candidate network bit is combined with each candidate host bit to obtain multiple detection addresses.
[0134] Optionally, the response unit 401 is specifically used for:
[0135] In response to the detection address generation instruction, a value corresponding to at least one bit in the network address having a fixed number of bits is changed once;
[0136] Based on different division methods of dividing a network address with a fixed number of bits into network bits and host bits, detection addresses in multiple different communication subnet ranges are obtained.
[0137] Optionally, the response unit 401 is further configured to determine different division modes of the network address having a fixed number of bits into network bits and host bits by:
[0138] Based on the respective bit ranges of the network bit and the host bit, the network bit and the host bit of the network address with fixed bits are transformed.
[0139] Optionally, the device further comprises:
[0140] A mapping unit 405 is configured to set the network mode to a bridge mode and disable the network address translation NAT and host-only network functions of the virtual machine if the test initiating device is a virtual machine; or
[0141] Map the USB network card connected to the host machine to the virtual machine and delete the virtual network card of the virtual machine.
[0142] Optionally, each detection packet includes a request response instruction, a detection address, and a source network address of the test initiating device; the detection address and the source network address included in each detection packet have the same communication subnet range as each other;
[0143] The response packet is sent by the target device to the test initiator device based on the source network address in a detection packet after the target device receives a detection packet and determines that the detection address in the detection packet is consistent with its own target network address; the response packet contains the target network address of the target device.
[0144] Optionally, the construction unit 402 is specifically used for:
[0145] Based on the detection address, each protocol in the communication protocol set is used to construct and send a detection packet to the target device; the communication protocol set includes at least one of the Internet Control Message Protocol and the Transmission Control Protocol.
[0146] After introducing the network address detection method and device according to the exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.
[0147] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0148] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. In one embodiment, the electronic device may be a server, such as Figure 1 The test initiator 110 is shown in FIG. In this embodiment, the structure of the electronic device can be as follows: Figure 5 As shown, it includes a memory 501 , a communication module 503 and one or more processors 502 .
[0149] The memory 501 is used to store computer programs executed by the processor 502. The memory 501 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0150] The memory 501 may be a volatile memory, such as a random-access memory (RAM); the memory 501 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 501 may be any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 501 may be a combination of the above memories.
[0151] The processor 502 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 502 is used to implement the above network address detection method when calling the computer program stored in the memory 501 .
[0152] The communication module 503 is used to communicate with other devices.
[0153] The specific connection medium between the memory 501, the communication module 503 and the processor 502 is not limited in the embodiment of the present application. Figure 5 In the embodiment, the memory 501 and the processor 502 are connected via a bus 504. The bus 504 is connected to the processor 502 via a bus 504. Figure 5 The connections between the other components are described with bold lines, which are only for illustrative purposes and are not intended to be limiting. The bus 504 can be divided into an address bus, a data bus, a control bus, etc. For ease of description, Figure 5 The diagram shows that only one thick line is used, but this does not mean that there is only one bus or only one type of bus.
[0154] The memory 501 stores a computer storage medium, and the computer storage medium stores computer executable instructions, and the computer executable instructions are used to implement the network address detection method of the embodiment of the present application. The processor 502 is used to execute the above-mentioned network address detection method, such as Figure 2 shown.
[0155] In another embodiment, the electronic device may also be other electronic devices, such as a terminal device. Figure 1 The test initiator device 110 and the target device 120 shown in the figure may be terminal devices. In this embodiment, the structure of the electronic device may be as follows: Figure 6 As shown, it includes: a communication component 610, a memory 620, a display unit 630, a camera 640, a sensor 650, an audio circuit 660, a Bluetooth module 670, a processor 680 and other components.
[0156] The communication component 610 is used to communicate with the server. In some embodiments, a wireless fidelity (WiFi) module may be included. The WiFi module belongs to a short-range wireless transmission technology. The electronic device can help the user to send and receive information through the WiFi module.
[0157] The memory 620 can be used to store software programs and data. The processor 680 executes various functions and data processing of the test initiator 110 by running the software programs or data stored in the memory 620. The memory 620 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. The memory 620 stores an operating system that enables the test initiator 110 to run. In the present application, the memory 620 can store an operating system and various application programs, and can also store a computer program for executing the network address detection method of the embodiment of the present application.
[0158] The display unit 630 may also be used to display information input by a user or information provided to a user and a graphical user interface (GUI) of various menus of the test initiator 110. Specifically, the display unit 630 may include a display screen 632 disposed on the front of the test initiator 110. The display screen 632 may be configured in the form of a liquid crystal display, a light emitting diode, or the like.
[0159] The display unit 630 can also be used to receive input digital or character information and generate signal input related to user settings and function control of the test initiating device 110. Specifically, the display unit 630 may include a touch screen 631 arranged on the front of the test initiating device 110, which can collect user touch operations on or near it, such as clicking a button, dragging a scroll box, etc.
[0160] The touch screen 631 can be covered on the display screen 632, or the touch screen 631 and the display screen 632 can be integrated to realize the input and output functions of the test initiator 110. The integrated touch screen can be referred to as a touch display screen. In this application, the display unit 630 can display the application and the corresponding operation steps.
[0161] The camera 640 can be used to capture static images, and the user can publish the images taken by the camera 640 through the application. The camera 640 can be one or more. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the processor 680 to convert it into a digital image signal.
[0162] The test initiator 110 may further include at least one sensor 650, such as an acceleration sensor 651, a distance sensor 652, a fingerprint sensor 653, and a temperature sensor 654. The test initiator 110 may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, a light sensor, and a motion sensor.
[0163] The audio circuit 660, the speaker 661, and the microphone 662 can provide an audio interface between the user and the test initiator 110. The audio circuit 660 can transmit the electrical signal converted from the received audio data to the speaker 661, which is converted into a sound signal for output. The test initiator 110 can also be configured with a volume button for adjusting the volume of the sound signal. On the other hand, the microphone 662 converts the collected sound signal into an electrical signal, which is received by the audio circuit 660 and converted into audio data, and then the audio data is output to the communication component 610 to be sent to other devices, or the audio data is output to the memory 620 for further processing.
[0164] The Bluetooth module 670 is used to exchange information with other Bluetooth devices having Bluetooth modules through the Bluetooth protocol. For example, the test initiator 110 can establish a Bluetooth connection with a wearable electronic device (such as a smart watch) that also has a Bluetooth module through the Bluetooth module 670 to exchange data.
[0165] The processor 680 is the control center of the test initiator 110. It uses various interfaces and lines to connect various parts of the entire terminal. It executes various functions of the test initiator 110 and processes data by running or executing software programs stored in the memory 620 and calling data stored in the memory 620. In some embodiments, the processor 680 may include one or more processing units; the processor 680 may also integrate an application processor and a baseband processor, wherein the application processor mainly processes an operating system, a user interface, and an application program, and the baseband processor mainly processes wireless communications. It is understandable that the above-mentioned baseband processor may not be integrated into the processor 680. In the present application, the processor 680 can run an operating system, an application program, a user interface display and a touch response, as well as a network address detection method of an embodiment of the present application. In addition, the processor 680 is coupled to the display unit 630.
[0166] In some possible implementations, various aspects of the network address detection method provided in the present application may also be implemented in the form of a program product, which includes a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to perform the steps of the network address detection method according to various exemplary embodiments of the present application described above in this specification. For example, the electronic device may perform the following steps: Figure 2 Follow the steps shown in .
[0167] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0168] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0169] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0170] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0171] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0172] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A network address detection method, characterized in that: Applied to a test initiating device, the test initiating device is communicatively connected with a target device of a to-be-detected address via a physical network cable; the method comprises: In response to the detection address generation instruction, the detection address is obtained based on different division methods of dividing the network address with a fixed number of bits into network bits and host bits, and changes in the values of the network bits and the host bits in any division method; Based on the detection address, construct and send a detection packet to the target device; Determining that no response packet returned by the target device is received, triggering the detection address generation instruction again; When the response packet is received, the response packet is parsed to obtain the target network address of the target device.
2. The method according to claim 1, characterized in that The step of obtaining the detection address in response to the detection address generation instruction based on different division methods of dividing the network address of a fixed number of bits into network bits and host bits, and changes in the values of the network bits and the host bits in any division method, includes: In response to the detection address generation instruction, the division method of the network bit and the host bit is changed once, and based on the number of bits of the currently divided network bits and the number of bits of the host bits, a first variation range of the value of the network bit and a second variation range of the value of the host bit are determined; Transforming the value of the network bit within the first variation range, and transforming the value of the host bit within the second variation range, to obtain a plurality of candidate network bits and a plurality of candidate host bits; For each candidate network bit, a candidate network bit is combined with each candidate host bit to obtain multiple detection addresses.
3. The method according to claim 1, characterized in that The step of obtaining the detection address in response to the detection address generation instruction based on different division methods of dividing the network address of a fixed number of bits into network bits and host bits, and changes in the values of the network bits and the host bits in any division method, includes: In response to the detection address generation instruction, a value corresponding to at least one bit in the network address having a fixed number of bits is changed once; Based on different division methods of dividing a network address with a fixed number of bits into network bits and host bits, detection addresses in multiple different communication subnet ranges are obtained.
4. The method according to claim 2 or 3, characterized in that The division of a fixed-bit network address into network bits and host bits is determined by the following methods: Based on the respective bit ranges of the network bits and the host bits, the network bits and the host bits of the network address with fixed bits are transformed respectively.
5. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: If the test initiating device is a virtual machine, the network mode is set to bridge mode, and the network address translation NAT and host-only network functions of the virtual machine are turned off; or Map the USB network card connected to the host machine to the virtual machine, and delete the virtual network card of the virtual machine.
6. The method according to any one of claims 1 to 3, characterized in that: Each detection packet includes a request response instruction, a detection address and the source network address of the test initiator; the detection address and the source network address included in each detection packet have the same communication subnet range as the source network address; The response packet is sent to the test initiating device based on the source network address in a detection packet after the target device receives a detection packet and determines that the detection address in the detection packet is consistent with its own target network address; the response packet includes the target network address of the target device.
7. The method according to any one of claims 1 to 3, characterized in that: The constructing and sending a detection packet to the target device based on the detection address includes: Based on the detection address, each protocol in the communication protocol set is used to construct and send a detection packet to the target device; the communication protocol set includes at least one of the Internet Control Message Protocol and the Transmission Control Protocol.
8. A network address detection device, characterized in that: include: A response unit, configured to obtain a detection address in response to a detection address generation instruction based on different division methods of dividing a network address with a fixed number of bits into network bits and host bits, and changes in the values of the network bits and the host bits under any division method; A construction unit, configured to construct and send a detection packet to the target device based on the detection address; A determination unit, configured to determine that no response packet returned by the target device is received, and trigger the detection address generation instruction again; The parsing unit is used to parse the response packet when receiving the response packet to obtain the target network address of the target device.
9. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: It comprises a computer program. When the computer program is run on an electronic device, the computer program is used to make the electronic device execute the steps of any one of the methods of claims 1 to 7.
11. A computer program product, characterized in that The method comprises a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of any one of the methods described in claims 1 to 7.