A method and system for detecting network topology of target machines in a network range
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-08
- Publication Date
- 2026-08-14
AI Technical Summary
目前场景实例化后会针对一些特殊应用(例如一些服务的端口是否能够连接)判断场景是否初始化完成,但是并不清楚实际启动的场景是否与网络拓扑图配置的一致,整个拓扑网络是否真的能够连通,需要手动对拓扑中靶机进行检测
[0023]有益效果:与现有技术相比,本发明具有如下优点:本发明通过自动分析场景网络拓扑,进行终端、网络、路由的分类检测,能获取到整个网络拓扑链路状态,保证实际启动场景的拓扑与配置一致,有助于网络拓扑验证和网络连通性问题定位,极大地提高了工作效率。本发明通过网络链路自动检测,能够获取并展示整个网络拓扑变化情况。
Smart Images

Figure CN116436790B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method and system for detecting the network topology of target machines in a network range, belonging to the fields of computer software and network security. Background Technology
[0002] When launching a scenario in a network testbed based on a network topology diagram, the network, virtual machine terminals, switches, and routers are instantiated according to the scenario configuration data. Currently, after scenario instantiation, the system checks whether the scenario initialization is complete for some specific applications (such as whether certain service ports are connectable). However, it is unclear whether the actual launched scenario matches the network topology configuration, or whether the entire network topology is truly connected. Manual testing of the target machines in the topology is required. Furthermore, troubleshooting network topology connectivity issues is complex and tedious. Summary of the Invention
[0003] Purpose of the invention: In view of the problems existing in the prior art, the purpose of this invention is to provide a method and system for detecting network topology of target machines in a network range, which can automatically analyze the network scene topology, obtain the network link status, display the network topology change status, and improve detection efficiency.
[0004] Technical solution: To achieve the above-mentioned objectives, the present invention adopts the following technical solution:
[0005] A method for detecting the network topology of target machines in a network range includes the following steps:
[0006] The network test range scenario data is acquired and parsed to obtain the list of virtual machines, network list, and route list to be tested. The list of virtual machines contains all virtual machines in the scenario topology, the list of networks contains all networks in the scenario topology and the virtual machines within those networks, and the list of routes contains two different networks in the scenario topology connected by routers and the virtual machines within those networks.
[0007] Iterate through each virtual machine to be tested in the list of virtual machines. In the network namespace where the virtual machine is located on the network range control node, arping the virtual machine's IP address to obtain the MAC address of the reply packet and comparing it with the MAC address assigned when the virtual machine was created to determine whether the virtual machine configuration is normal.
[0008] Iterate through each network to be detected in the network list, schedule it to the computing node where the virtual machine is located in the network via RPC, access the virtual machine via serial port, ping the network's gateway address on the virtual machine, and determine whether the network configuration is normal based on whether the ping is successful.
[0009] Iterate through each route to be tested in the routing list, schedule it to the compute node where the virtual machine in one of the networks is located via RPC, access the virtual machine via serial port, ping the IP address of another virtual machine in the network from the virtual machine, and determine whether the routing configuration is normal based on whether the ping is successful.
[0010] As a preferred method, when detecting a network or route, a virtual machine is randomly selected from the virtual machines within the network for detection.
[0011] As a preferred method, the MAC address assigned when the virtual machine is created is obtained by querying the virtual machine configuration file through the compute node where the virtual machine is located via RPC scheduling, and obtaining the virtual machine MAC address in the configuration file.
[0012] Furthermore, the method also includes displaying the network link status of the scene topology based on the real-time detection results during the detection process.
[0013] A network topology detection system for target machines in a network range includes:
[0014] The task parsing module is used to acquire network target range scenario data and parse it to obtain a list of virtual machines, a list of networks, and a list of routes to be detected. The list of virtual machines contains all virtual machines in the scenario topology, the list of networks contains all networks in the scenario topology and the virtual machines within those networks, and the list of routes contains two different networks in the scenario topology connected by routers and the virtual machines within those networks.
[0015] The terminal detection module is used to traverse each virtual machine to be detected in the list of virtual machines. Within the network namespace where the virtual machine is located on the network range control node, it arping the virtual machine's IP address, obtaining the MAC address of the reply packet, and comparing it with the MAC address assigned when the virtual machine was created to determine whether the virtual machine configuration is normal.
[0016] The network detection module is used to traverse each network to be detected in the network list, schedule it to the computing node where the virtual machine is located in the network via RPC, access the virtual machine via serial port, ping the network's gateway address on the virtual machine, and determine whether the network configuration is normal based on whether the ping is successful.
[0017] The route detection module is used to traverse each route to be detected in the route list, schedule it to the compute node where the virtual machine in one of the networks is located via RPC, access the virtual machine via serial port, ping the IP address of another virtual machine in the network, and determine whether the route configuration is normal based on whether the ping is successful.
[0018] Preferably, the network detection module or route detection module randomly selects one virtual machine from the virtual machines within the network for detection when detecting the network or route.
[0019] Preferably, the terminal detection module obtains the MAC address assigned when the virtual machine is created by querying the virtual machine configuration file through RPC scheduling of the compute node where the virtual machine is located, and obtaining the virtual machine MAC address in the configuration file.
[0020] Furthermore, the system also includes a result display module, which is used to display the network link status of the scene topology based on the real-time detection results during the detection process.
[0021] A computer system includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded onto the processor, it implements the steps of the network topology detection method for target machines in a network range.
[0022] A computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the network topology detection method for target machines in a network range.
[0023] Beneficial Effects: Compared with existing technologies, this invention has the following advantages: By automatically analyzing the network topology of a scenario and classifying and detecting terminals, networks, and routes, this invention can obtain the status of the entire network topology links, ensuring that the topology and configuration of the actual startup scenario are consistent. This facilitates network topology verification and network connectivity problem localization, greatly improving work efficiency. This invention, through automatic network link detection, can acquire and display the changes in the entire network topology. Attached Figure Description
[0024] Figure 1 This is a general flowchart of an embodiment of the present invention.
[0025] Figure 2 This is a schematic diagram of the network topology in the test range scenario.
[0026] Figure 3 This is a schematic diagram of virtual machine terminal detection in an embodiment of the present invention.
[0027] Figure 4 This is a schematic diagram of network detection in an embodiment of the present invention.
[0028] Figure 5 This is a schematic diagram of route detection in an embodiment of the present invention. Detailed Implementation
[0029] The technical solution of the present invention will now be clearly and completely described in conjunction with the accompanying drawings and specific embodiments.
[0030] like Figure 1As shown in the illustration, this invention discloses a method for detecting the network topology of target machines in a network range scenario. The method mainly includes several steps: task parsing, virtual machine terminal detection, network detection, and route detection. After a scenario is launched through the front end of the range management platform, the platform transmits the scenario launch data to an automatic analysis and detection network link service via an interface. The service analyzes the scenario data, first classifying it into the types requiring terminal detection, network detection, and route detection, and then optimizing the detection process. After parsing the scenario data, a list of virtual machines, a list of networks, and a list of routes to be detected are obtained. The virtual machine list contains all virtual machines in the scenario topology; the network list contains all networks in the scenario topology and the virtual machines within those networks; and the route list contains two different networks connected by routers in the scenario topology and the virtual machines within those networks.
[0031] In specific scenarios, data can be transmitted to the automatic detection service via XML files or database files. During parsing, routers can be tagged as the first type and their network information recorded, network switches as the second type and their virtual machines recorded, and virtual machine terminals as the third type. From the second type of network switches, the virtual machine terminals under their network can be known, as well as the network connection routes. That is, first determine the network, detect the virtual machine terminals under each network, then detect the network of the virtual machines under it, and then detect the routes of different network segments under the routers connected to it.
[0032] In addition, efficiency can be improved by optimizing the detection process. Figure 2 In the scenario shown, VM1 and VM2 are connected to switch S1, while VM2, VM3, and VM4 are connected to switch S2. After detecting VM1 and VM2 using the terminal detection method, network testing only needs to be performed on one of the terminal nodes. The network test on VM1 will yield the same result as VM2. Similarly, network testing on VM3, VM4, and VM5 only requires testing on one of the virtual machines. Routing detection also only requires testing VM1 and VM3 to determine if the routers connected to the two switches are functioning correctly. This significantly improves detection efficiency by reducing the need for extensive network and routing testing on all machines. Because the reporting is real-time, each time network or routing is tested, a virtual machine is randomly selected for testing.
[0033] In all types of network scenarios, except for virtual machines which require real-time monitoring; when a switch connects multiple virtual machines, only one virtual machine needs to be monitored for network connectivity; when two switches are connected via a router, only one virtual machine needs to be monitored for routing. The specific monitoring methods for virtual machine terminals, networks, and routing are explained below.
[0034] 1. Terminal detection method
[0035] When a virtual machine is created, such as when a new network is allocated, a namespace for the corresponding network is created on the network control node (i.e., the OpenStack control node), and the network's DHCP service is configured. This service uses arping to the virtual machine's IP address within the network namespace, and compares the returned MAC address with the MAC address assigned during virtual machine creation to check if the virtual machine's network is functioning correctly. Figure 3 As shown.
[0036] Arping virtual machine IP via namespace:
[0037] ip netns exec qdhcp-f46b1cf0-7d9c-49e3-b8ea-4048ded3566b arping 192.168.1.147
[0039] ARPING 192.168.1.147 from 192.168.1.1 tap75f58168-e4
[0040] Unicast reply from 192.168.1.147 [FA:16:3E:FD:B4:D9] 1.047ms
[0041] Unicast reply from 192.168.1.147 [FA:16:3E:FD:B4:D9] 0.876ms
[0042] The system uses RPC to schedule to the node where the virtual machine resides to query the MAC address in the virtual machine's configuration file. This MAC address is then verified against the one obtained above to determine the result. Example of the network interface section in the configuration file:
[0043] <interface type='bridge'>
[0044] <mac address='fa:16:3e:fd:b4:d9' / >
[0045] <source bridge='qbr9a7743eb-ad'>
[0046] <target dev='tap9a7743eb-ad' / >
[0047] <model type='virtio' / >
[0048] <mtu size='1500' / >
[0049] <alias name='net0' / >
[0050] <address type='pci' domain='0x0000' bus='0x00' slot='0x03'function='0x0'>< / address>
[0051]
[0052] The detection result is obtained by analyzing whether the MAC addresses of the two are the same.
[0053] 2. Network Detection Methods
[0054] like Figure 4 As shown, the service RPC calls to the host where the virtual machine is located, connects to the virtual machine via serial port, and pings the gateway address from the virtual machine. If the ping is successful, it means the network is working; otherwise, it is not.
[0055] 3. Route detection method
[0056] like Figure 5 As shown, connect to the virtual machine via serial port and ping an address that is on a different network segment from the virtual machine.
[0057] When a network testbed creates a virtual machine, it creates a TCP-type console device and points the target to the virtual machine's serial device.
[0058] This is an example of serial port device configuration;
[0059] <console type='tcp'>
[0060] <source mode='bind' host='0.0.0.0' service='15913' tls='no'>
[0061] <protocol type='telnet' / >
[0062] <logfile=' / var / lib / nova / instances / f3279ec8-388d-4ebb-904a-61a320f13ba1 / console.log' append= 'off' / >
[0063] <target type='serial' port='0' / >
[0064] <alias name='serial0' / >
[0065]
[0066] By obtaining the current network link status at intervals and in real time, the results are pushed to the front-end page in a timely manner via WebSocket, and the front-end displays the results.
[0067] Based on the same inventive concept, this invention discloses a network topology detection system for target machines in a network range, comprising: a task parsing module, used to acquire network range scene data and parse it to obtain a list of virtual machines, a network list, and a route list to be detected; a terminal detection module, used to traverse each virtual machine to be detected in the virtual machine list, and within the network namespace where the virtual machine is located on the network range control node, arping the virtual machine's IP address to obtain the MAC address of the reply packet, and comparing it with the MAC address in the configuration file on the computing node where the virtual machine is located to determine whether the virtual machine configuration is normal; a network detection module, used to traverse each network to be detected in the network list, schedule to the computing node where the virtual machine is located in the network via RPC, access the virtual machine via serial port, ping the network's gateway address on the virtual machine, and determine whether the network configuration is normal based on whether the ping is successful; and a route detection module, used to traverse each route to be detected in the route list, schedule to the computing node where the virtual machine is located in one of the networks via RPC, access the virtual machine via serial port, ping the IP address of the virtual machine in another network on the virtual machine, and determine whether the route configuration is normal based on whether the ping is successful.
[0068] Based on the same inventive concept, the present invention discloses a computer system including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is loaded onto the processor, it implements the steps of the network topology detection method for target machines in a network range.
[0069] Based on the same inventive concept, embodiments of the present invention disclose a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the network topology detection method for target machines in a network range.
Claims
1. A method for detecting the network topology of target machines in a network range, characterized in that, Includes the following steps: Acquire network range scenario data, analyze the scenario data, classify the types of terminal detection, network detection, and route detection required, and parse to obtain the list of virtual machines, network list, and route list to be detected. The list of virtual machines contains all virtual machines in the scenario topology, the list of networks contains all networks in the scenario topology and the virtual machines within the networks, and the list of routes contains two different networks in the scenario topology connected by routers and the virtual machines within the networks. For terminal detection, each virtual machine to be detected in the virtual machine list is traversed. In the network namespace where the virtual machine is located on the network range control node, the virtual machine IP address is arping to obtain the MAC address of the reply packet, and compared with the MAC address assigned when the virtual machine was created to determine whether the virtual machine configuration is normal. The MAC address assigned when the virtual machine was created is obtained by querying the virtual machine configuration file through the compute node where the virtual machine is located via RPC scheduling to obtain the virtual machine MAC address in the configuration file. For network detection, each network to be detected in the network list is traversed, and the virtual machine in the network is scheduled to the computing node within the network via RPC. The virtual machine is then connected via serial port, and the network gateway address is pinged from the virtual machine. Whether the ping is successful is used to determine whether the network configuration is normal. For route detection, each route to be detected in the route list is traversed, and the virtual machine in one of the networks is scheduled to the compute node via RPC. The virtual machine is then connected via serial port, and the IP address of another virtual machine in the network is pinged from the virtual machine. Whether the ping is successful is used to determine whether the route configuration is normal.
2. The method for detecting the network topology of target machines in a network range according to claim 1, characterized in that, When testing a network or route, a virtual machine is randomly selected from the virtual machines within the network for testing.
3. The method for detecting the network topology of target machines in a network range according to claim 1, characterized in that, It also includes displaying the network link status of the scene topology based on the real-time detection results during the detection process.
4. A network topology detection system for target machines in a network range, characterized in that, include: The task parsing module is used to acquire network range scenario data, analyze the scenario data, classify the types of terminal detection, network detection, and route detection required, and parse out the list of virtual machines, network list, and route list to be detected. The virtual machine list contains all virtual machines in the scenario topology, the network list contains all networks in the scenario topology and the virtual machines within the networks, and the route list contains two different networks in the scenario topology connected by routers and the virtual machines within the networks. The endpoint detection module is used for endpoint detection. It iterates through each virtual machine to be detected in the virtual machine list, and within the network namespace where the virtual machine is located on the network range control node, it arping the virtual machine's IP address to obtain the MAC address of the reply packet. This MAC address is then compared with the MAC address assigned when the virtual machine was created to determine if the virtual machine configuration is normal. The MAC address assigned when the virtual machine was created is obtained by querying the virtual machine configuration file through the compute node where the virtual machine is located via RPC scheduling. The network detection module is used for network detection. It traverses each network to be detected in the network list, schedules it to the computing node where the virtual machine is located in the network via RPC, connects to the virtual machine via serial port, pings the network's gateway address on the virtual machine, and determines whether the network configuration is normal based on whether the ping is successful. The route detection module is used for route detection. It iterates through each route to be detected in the route list, schedules it to the compute node where the virtual machine in one of the networks is located via RPC, connects to the virtual machine via serial port, and pings the IP address of another virtual machine in the network. The success or failure of the ping determines whether the route configuration is normal.
5. The network topology detection system for target machines in a network range according to claim 4, characterized in that, The network detection module or route detection module randomly selects one virtual machine from the virtual machines within the network for detection when detecting the network or route.
6. The network topology detection system for target machines in a network range according to claim 4, characterized in that, It also includes a results display module, which is used to display the network link status of the scene topology based on the real-time detection results during the detection process.
7. A computer system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is loaded into the processor, it implements the steps of the network topology detection method for target machines in a network range according to any one of claims 1-3.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the network topology detection method for target machines in a network range according to any one of claims 1-3.
Citation Information
Patent Citations
Network detection method and system based on Openstack
CN108683572A
Disk testing method and device, electronic equipment and computer readable storage medium
CN114048075A