Method and apparatus for generating network topology information, and storage medium

By obtaining device attribute information and determining network addresses using subnet masks, combined with media access control and address resolution protocol tables, the problem of low efficiency in generating topology information when switches are connected to non-switches is solved, and more efficient determination of network topology connection relationships is achieved.

CN116566832BActive Publication Date: 2026-04-24ZHEJIANG DAHUA TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ZHEJIANG DAHUA TECH CO LTD
Filing Date
2023-05-09
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

In existing technologies, switches cannot perceive the connection relationship when connecting to non-switches, resulting in low efficiency in generating network topology information.

Method used

By obtaining the device's attribute information, the network address of the network segment where the device is located is determined using the subnet mask, and the topological connection relationship between devices is determined based on the network address, including using the Media Access Control address mapping table, the Address Resolution Protocol mapping table, and the interface mapping table to determine the connection relationship between devices.

Benefits of technology

It enables a simple and comprehensive determination of network topology connections, improving the efficiency of network topology information generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116566832B_ABST
    Figure CN116566832B_ABST
Patent Text Reader

Abstract

The application discloses a network topology information generation method and device and a storage medium. The method comprises the following steps: obtaining attribute information of a device, wherein the attribute information is used for representing the network attribute of the device; determining the network address of each device in the network segment where the device is located based on the subnet mask of the device in the attribute information; and determining the topology connection relationship between each device based on the network address of each device. The application solves the technical problem of low network topology information generation efficiency in the related art.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network topology technology, and more specifically, to a method, apparatus, and storage medium for generating network topology information. Background Technology

[0002] Currently, when determining network topology connections, the connection relationships between switches are mainly calculated through the link layer connections in the switches. Furthermore, the switches must have the Link Layer Discovery Protocol (LLDP) enabled. When a switch is connected to a non-switch, it cannot perceive the connection relationship, making it difficult to generate network topology information.

[0003] There is currently no effective solution to the technical problem of low efficiency in generating network topology information. Summary of the Invention

[0004] This invention provides a method, apparatus, and storage medium for generating network topology information, so as to at least solve the technical problem of poor efficiency in generating network topology information in related technologies.

[0005] According to one aspect of the present invention, a method for generating network topology information is provided. The method includes: obtaining attribute information of devices, wherein the attribute information is used to represent the network attributes of the devices; determining the network addresses of each device in the network segment where the device is located based on the subnet mask of the device in the attribute information; and determining the topological connection relationship between the devices based on the network addresses of each device.

[0006] According to another aspect of the present invention, a network topology information generation apparatus is also provided. The apparatus includes: an acquisition unit for acquiring attribute information of devices, wherein the attribute information is used to represent the network attributes of the devices; a first determination unit for determining the network addresses of each device in the network segment where the device is located based on the subnet mask of the device in the attribute information; and a second determination unit for determining the topological connection relationship between the devices based on the network addresses of each device.

[0007] According to another aspect of the present invention, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to execute the network topology information generation method of the present invention.

[0008] According to another aspect of the present invention, a processor is also provided. The processor is used to run a program, wherein the program executes the network topology information generation method of the present invention during runtime.

[0009] In this embodiment of the invention, device attribute information is obtained, wherein the attribute information represents the network attributes of the device; based on the subnet mask of the device in the attribute information, the network addresses of each device in the network segment where the device is located are determined; based on the network addresses of each device, the topological connection relationship between each device is determined. That is, in this embodiment of the invention, the network addresses of each device in the network segment where the device is located can be determined based on the subnet mask in the device attribute information. After determining the network addresses of each device included in the network segment, the network topological connection relationship of each device in the network segment can be determined based on the network addresses. This determination method is relatively simple and can determine the topological connection relationship between each device in the network segment. The determined network topological connection relationship is relatively comprehensive, achieving the technical effect of improving the generation efficiency of network topology information, thereby solving the technical problem of low generation efficiency of network topology information in related technologies. Attached Figure Description

[0010] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:

[0011] Figure 1 This is a flowchart of a method for generating network topology information according to an embodiment of the present invention;

[0012] Figure 2 This is a flowchart of a method for generating network topology information according to an embodiment of the present invention;

[0013] Figure 3 This is a flowchart of the traversal method according to an embodiment of the present invention;

[0014] Figure 4 This is a schematic diagram of a network topology information generation device according to an embodiment of the present invention. Detailed Implementation

[0015] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0016] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0017] Example 1

[0018] According to an embodiment of the present invention, an embodiment of a method for generating network topology information is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0019] Figure 1 This is a flowchart of a method for generating network topology information according to an embodiment of the present invention, such as... Figure 1 As shown, the method may include the following steps:

[0020] Step S101: Obtain the device's attribute information, wherein the attribute information is used to represent the device's network attribute information.

[0021] In the technical solution provided by step S101 of the present invention, the attribute information of the device can be obtained. The device can be a server in the network. The attribute information of the device includes the network protocol address (Internet Protocol, abbreviated as IP), the subnet mask of the device, and the Simple Network Management Protocol (SNMP) information of the device. The attribute information of the device is used to represent the network attributes of the device.

[0022] In this embodiment, the device can receive the device's IP address, subnet mask, and SNMP information input by the user. After receiving the user's input, the user's input can be determined as the device's attribute information.

[0023] Step S102: Based on the subnet mask of the device in the attribute information, determine the network address of each device in the network segment where the device is located.

[0024] In the technical solution provided by step S102 of the present invention, as can be seen from the description of step S101, the attribute information of the device includes a subnet mask, which is also called a network mask, address mask, or subnet mask. Based on the subnet mask, the network segment where the device is located can be determined. After determining the network segment where the device is located, the network address of each device in the network segment can be determined based on the network segment where the device is located.

[0025] Optionally, after determining the device's attribute information, the network address of each device in the network segment where the device is located can be calculated based on the IP address, subnet mask, and SNMP information in the device's attribute information. The network address can be the IP address of each device in the network segment.

[0026] Step S103: Determine the topological connection relationship between each device based on the network address of each device.

[0027] In the technical solution provided in step S103 of the present invention, since the network address of a device can be its IP address, after determining the network addresses of each device in the network segment, the Media Access Control (MAC) address corresponding to each device can be determined in the Media Access Control Address Mapping Table based on the network addresses of each device. The Media Access Control Address Mapping Table stores the mapping relationship between IP addresses and MAC addresses. After determining the MAC address of the device, the IP address corresponding to each determined MAC address can be further searched in the Address Resolution Protocol (ARP) Mapping Table, which stores the mapping relationship between MAC addresses and IP addresses. After determining the IP address of the device, the device interface corresponding to each IP address can be searched in the Interface Mapping Table, which stores the mapping relationship between IP addresses and device interfaces. Finally, the topological connection relationship between the devices can be determined based on the determined information.

[0028] In this embodiment, after determining the MAC addresses corresponding to each device from the Media Access Control (MAC) address mapping table, the determined MAC addresses can be summarized to obtain a MAC address list, which can be represented as MACList. Then, for each MAC address in the MAC address list, the corresponding IP address is searched in the Address Resolution Protocol (ARP) mapping table, and the found IP addresses are summarized to obtain an IP address list, which can be represented as ARPList. Next, for each IP address in the IP address list, the corresponding device interface is searched in the interface mapping table, and the determined device interfaces are summarized to obtain a device interface list. This process of iterating through IfTableList determines whether the MAC address is a switch MAC address.

[0029] After determining the MAC address list, IP address list, and interface list, each list can be traversed to query the connection relationships between devices. After querying the device connection relationships, the network topology connection relationships between devices can be further determined.

[0030] In steps S101 to S103 above, device attribute information is obtained, wherein the attribute information is used to represent the network attributes of the device; based on the subnet mask of the device in the attribute information, the network addresses of each device in the network segment where the device is located are determined; based on the network addresses of each device, the topological connection relationship between each device is determined. That is to say, in this embodiment of the invention, the network addresses of each device in the network segment where the device is located can be determined based on the subnet mask in the device attribute information. After determining the network addresses of each device included in the network segment, the connection relationship of each device can be found in the mapping relationship table based on the network addresses. Then, based on the determined connection relationship, network topology information is generated. This determination method is relatively simple and can determine the topological connection relationship between each device in the network segment. The determined network topology connection relationship is relatively comprehensive, which achieves the technical effect of improving the generation efficiency of network topology information, thereby solving the technical problem of low generation efficiency of network topology information in related technologies.

[0031] The method described in this embodiment will be further described below.

[0032] As an optional implementation, step S103, determining the topological connection relationship between each device based on the network address of each device, includes: obtaining a media access control address mapping table for each device based on the network address of each device, wherein the media access control address mapping table includes the mapping relationship between media access control addresses and device ports; generating a media access control address list based on the obtained media access control address mapping table; and determining the topological connection relationship between each device based on the media access control address list.

[0033] In this embodiment, since the media access control address mapping table includes the mapping relationship between IP addresses and MAC addresses, and the network address of a device can be an IP address, after determining the network address of each device, the media access control address mapping table of each device can be obtained based on the IP address of each device. The media access control address mapping table includes the mapping relationship between MAC addresses and device ports. It should be noted that if the device type is a switch, the device's media access control address mapping table can be obtained based on the device's IP address; if the device type is not a switch, the device's media access control address mapping table cannot be obtained based on the device type.

[0034] After obtaining the media access control address mapping table for the devices, the obtained media access control address mapping table can be summarized to generate a media access control address list, which can be represented as MACList. This media access control address list can include the mapping relationship between the MAC addresses of each switch device and the device ports. Then, based on this media access control address list, the correspondence between the device MAC addresses and device ports can be determined. If a device MAC address corresponds to a device interface, and that MAC address is the MAC address of another switch device, then it can be confirmed that the switch device is connected to the other switch device, and this connection relationship can be determined as the network topology connection relationship of the device.

[0035] As an optional implementation, a media access control address list is generated based on the obtained media access control address mapping table, including: in response to obtaining the media access control address mapping table of the device, determining that the device type of the device is a switch; based on the devices of the device type of switch, generating a set of devices to be traversed, and summarizing the media access control addresses in the obtained media access control address mapping table to obtain a media access control address list.

[0036] In this embodiment, taking any device as an example, when obtaining the media access control address mapping table of the device based on the device's IP address, if the media access control address mapping table of the device is obtained, the device type of the device can be determined as a switch; conversely, if the media access control address mapping table of the device is not obtained, the device type of the device can be determined as a non-switch. According to this method, the device type of each device can be determined. After determining the device type of each device, the devices with the device type of switch can be summarized to obtain a set of devices to be traversed. The set of devices to be traversed can be represented as SwitchList. The set of devices to be traversed includes the identification information of each switch device. The identification information can be the device name, the device's IP address, or the device's MAC address, without specific restrictions here.

[0037] As an optional implementation, determining the topological connection relationship between various devices based on the media access control address list includes: determining the media access control address of the device to be traversed in the set of devices to be traversed from the media access control address list, wherein the device to be traversed is a device in the set of devices to be traversed that has not been traversed; determining the mapping relationship between the media access control address and the port of the device to be traversed based on the media access control address mapping relationship table corresponding to the media access control address of the device to be traversed; and determining the topological connection relationship of the device to be traversed based on the mapping relationship.

[0038] In this embodiment, after determining the set of devices to be traversed and the media access control address list, each device in the set of devices to be traversed can be traversed. Each device to be traversed is a switch device, and each device in the set has not been traversed before. Taking one device as an example, the MAC address of the device to be traversed can be checked in the media access control address list to see if it corresponds to a device interface. If the MAC address of the device to be traversed corresponds to a device interface, and that MAC address is the MAC address of another switch device, then it can be confirmed that the device to be traversed is connected to another switch device, and this connection relationship can be determined as the network topology connection relationship of the device to be traversed.

[0039] Optionally, when traversing each device in the set of devices to be traversed, the traversed device can be marked after each traversal to avoid repeated traversal and missed traversal, and to ensure that each device in the set of devices to be traversed can be traversed.

[0040] As an optional implementation, after generating the media access control address list, the method further includes: based on each media access control address in the media access control address list, searching for the network address corresponding to each media access control address in the address resolution protocol mapping table; and summarizing the queried network addresses to obtain a network address list.

[0041] In this embodiment, the Media Access Control (MAC) address list includes a mapping relationship between the MAC addresses of each switch device and the device ports. Based on this, the network address corresponding to each MAC address can be looked up in the Address Resolution Protocol (ARP) mapping table according to the MAC address of each switch device in the MAC address list. This network address can be an IP address, and the ARP mapping table stores the mapping relationship between MAC addresses and IP addresses. After determining the network addresses of each switch device, the determined network addresses can be summarized to obtain a network address list, which can be represented as an ARPList.

[0042] As an optional implementation, after obtaining the network address list, the method further includes: querying the device interface corresponding to each network address in the interface mapping table, wherein the interface mapping table contains the mapping relationship between network addresses and device ports; and summarizing the queried device interfaces to obtain an interface list.

[0043] In this embodiment, since the network address list contains the IP addresses of each device, after obtaining the network address list, the corresponding device interface for each IP address can be found in the interface mapping table based on the IP addresses of each device contained in the network address list. The interface mapping table contains the mapping relationship between IP addresses and device interfaces. After determining the device interfaces corresponding to each IP address, the determined device interfaces can be summarized to obtain an interface list, which can be represented as IfTableList.

[0044] As an optional implementation, when the mapping relationship between the media access control address of the device to be traversed and the port of the device to be traversed is one-to-one, the method further includes: querying the media access control address corresponding to the port of the device to be traversed in the interface mapping table; and storing the connection relationship between the port of the device to be traversed and the media access control address of the device when the media access control address is the media access control address of the device type is a switch device.

[0045] In this embodiment, a one-to-one relationship is used to indicate that the media access control address of the device to be traversed corresponds to a device port. Based on this, when the mapping relationship between the media access control address of the device to be traversed and the port of the device to be traversed is a one-to-one relationship, the media access control address corresponding to the port of the device to be traversed can be further queried in the interface mapping relationship table, that is, the MAC address corresponding to the port of the device to be traversed, and it can be determined whether the MAC address is the media access control address of a device whose device type is a switch. If the MAC address is a device whose device type is a switch, it is determined that the device to be traversed is connected to the switch device, and then the connection relationship can be stored.

[0046] Example 2

[0047] The technical solutions of the embodiments of the present invention will be illustrated below with reference to preferred implementation methods.

[0048] In related technologies, when determining network topology connections, the connection relationships between switches are mainly calculated through the link layer connections in the switches. Furthermore, the switches must have the LLDP protocol enabled. When a switch is connected to a non-switch, it cannot perceive the connection relationship, making it difficult to generate network topology information.

[0049] However, in this embodiment of the invention, by obtaining the device's attribute information and then determining the network addresses of each device in the network segment where the device is located based on the device's subnet mask in the device's attribute information, the topological connection relationship between the devices can be determined based on the network addresses of each device. In other words, in this embodiment of the invention, the network addresses of each device in the network segment where the device is located can be determined based on the subnet mask in the device's attribute information. After determining the network addresses of each device included in the network segment, the network topological connection relationship between the devices in the network segment can be determined based on the network addresses. This determination method is relatively simple and can determine the topological connection relationship between the devices in the network segment. The determined network topological connection relationship is relatively comprehensive, achieving the technical effect of improving the generation efficiency of network topology information, thereby solving the technical problem of low generation efficiency of network topology information in related technologies.

[0050] The method for generating network topology information in the embodiments of the present invention will be further described below.

[0051] Figure 2 This is a flowchart of a method for generating network topology information according to an embodiment of the present invention, such as... Figure 2 As shown, the method may include the following steps:

[0052] Step S201: Obtain the IP address and subnet mask of the current server.

[0053] In this embodiment, the system can receive the current server's IP address, subnet mask, and SNMP information input by the user.

[0054] Step S202: Calculate all IP addresses in the current subnet and store them in IPList.

[0055] In this embodiment, after receiving the information input by the user, all IP addresses of the current subnet can be calculated and stored in IPList.

[0056] Step S203: Iterate through each IP address in IPList and query the MAC mapping table.

[0057] In this embodiment, each IP address in the IPList can be traversed, and the MAC mapping table can be queried based on each IP address.

[0058] Step S204: Determine whether the MAC mapping table can be found.

[0059] In this embodiment, it can be determined that the MAC mapping table can be queried based on the IP address. If the MAC mapping table can be queried based on the IP address, then the device corresponding to the IP address is determined to be a switch device, and step S205 is executed; otherwise, step S206 is executed.

[0060] Step S205: Store the queried switch devices in the switch device set (SwithList) and save the queried MAC mapping table to the MAC mapping table set (MACList).

[0061] Step S206: Store the non-switch devices in the non-switch device set (NoSwithList).

[0062] Step S207: Query the ARP table and store the results in ARPList; query the interface table and store the results in IfTableList.

[0063] In this embodiment, after determining the MAC mapping table set (MACList), the IP address corresponding to each MAC address in the MAC mapping table set can be queried in the ARP table, and the queried IP address can be stored in the ARPList. Alternatively, the interface table can be queried, and the interfaces queried in the interface table can be stored in the interface list (IfTableList).

[0064] Step S208: Traverse the MAC table, ARPList, and interface table to calculate the end-to-end relationship.

[0065] Step S209: Generate a network topology diagram based on the determined end-to-end relationships.

[0066] In this embodiment, after determining the end-to-end relationship, the determined end-to-segment relationship can be stored and pushed to the server so that the server can draw the network topology connection relationship based on the determined end-to-end relationship.

[0067] Figure 3 This is a flowchart of the traversal method according to an embodiment of the present invention, such as... Figure 3 As shown, this includes the following steps:

[0068] Step S301: Traverse SwitchList and mark the traversed switch devices.

[0069] In this embodiment, SwitchList stores multiple switch devices. Based on this, each switch device in SwitchList can be traversed sequentially. To avoid missing or repeating traversals, after each switch device is traversed, the switch device can be marked. When traversing again, it is not necessary to traverse the marked switch device.

[0070] Step S302: Traverse MACList.

[0071] In this embodiment, after determining the switch device to be traversed, the MACList can be traversed. The MACList stores the mapping relationship between MAC addresses and device ports. Based on this, the MAC address of the device to be traversed can be found in the MACList, and then the number of device ports corresponding to the MAC address can be determined.

[0072] Step S303: Determine whether the device port and MAC address have a one-to-one relationship.

[0073] In this embodiment, if there is a one-to-one relationship between the device port and the MAC address, then step S304 is executed; if there is not a one-to-one relationship between the device port and the MAC address, then step S307 is executed to store the corresponding relationship in the WaitTPList topology relationship.

[0074] Step S304: Iterate through IfTableList to determine if the MAC address is the MAC address of the switch.

[0075] In this embodiment, if there is a one-to-one relationship between the device port and the MAC address, the IfTableList can be further traversed to determine whether the MAC address is the MAC address of the switch. If the MAC address is the MAC address of the switch, step S305 is executed to store the MAC address in the TPList topology relationship. If the MAC address is not the MAC address of the switch, step S306 is executed to determine that the device corresponding to the MAC address has been marked with a connection relationship in the NoSwithList.

[0076] Step S308: Determine if there are any ports on the switch that need to be traversed.

[0077] In this embodiment, it can be further determined whether the switch device currently being traversed still has ports that need to be traversed. If there are still ports that need to be traversed, then continue traversing the next port; otherwise, step S309 is executed.

[0078] Step S309: Determine if there are any more switch devices that need to be traversed.

[0079] In this embodiment, after traversing all the switch devices, it can be determined whether there are any switch devices to be traversed in the set of switch devices. If there are, the next switch device is traversed, that is, the above step S301 is executed.

[0080] Step S310: Update fuzzy links.

[0081] In this embodiment, if there are no switch devices to be traversed in the set of switch devices, the fuzzy connection can be updated, and the intersection of WaitTPList and TPList can be determined as WaitTPList.

[0082] Step S311: Update TPList.

[0083] In this embodiment, after updating the fuzzy connections, TPList can be updated while preserving the physical port relationships.

[0084] Step S312, update TPList.

[0085] In this embodiment, updating TPList can look up the IP address in ARPList for non-switch physical MAC addresses and store the found IP address in TPList.

[0086] Example 3

[0087] According to an embodiment of the present invention, a network topology information generation apparatus is also provided. It should be noted that this network topology information generation apparatus can be used to execute the network topology information generation method in Embodiment 1.

[0088] Figure 4 This is a schematic diagram of a network topology information generation apparatus according to an embodiment of the present invention. Figure 4 As shown, the network topology information generation device 400 may include: an acquisition unit 401, a first determination unit 402, and a second determination unit 403.

[0089] The acquisition unit 401 is used to acquire the attribute information of the device, wherein the attribute information is used to represent the network attributes of the device;

[0090] The first determining unit 402 is used to determine the network address of each device in the network segment where the device is located based on the subnet mask of the device in the attribute information.

[0091] The second determining unit 403 is used to determine the topological connection relationship between each device based on the network address of each device.

[0092] Optionally, the second determining unit 403 includes: an acquisition module, configured to acquire a media access control address mapping table for each device based on the network address of each device, wherein the media access control address mapping table includes a mapping relationship between media access control addresses and device ports; a generation module, configured to generate a media access control address list based on the acquired media access control address mapping table; and a determining module, configured to determine the topology connection relationship between each device based on the media access control address list.

[0093] Optionally, the generation module includes: a first determining submodule, used to determine that the device type of the device is a switch in response to obtaining the media access control address mapping table of the device; and a generation submodule, used to generate a set of devices to be traversed based on the devices of the device type being switches, and to summarize the obtained media access control address mapping table to obtain a media access control address list.

[0094] Optionally, the determining module includes: a second determining submodule, used to determine the media access control address of the device to be traversed in the set of devices to be traversed from the media access control address list, wherein the device to be traversed is a device in the set of devices to be traversed that has not been traversed; a third determining submodule, used to determine the mapping relationship between the media access control address and the port of the device to be traversed based on the media access control address mapping relationship table corresponding to the media access control address of the device to be traversed; and a fourth determining submodule, used to determine the topology connection relationship of the device to be traversed based on the mapping relationship.

[0095] Optionally, after generating the media access control address, the device 400 further includes: a first lookup unit, configured to look up the network address corresponding to each media access control address in the address resolution protocol mapping table based on each media access control address in the media access control address list; and a first aggregation unit, configured to aggregate the queried network addresses to obtain a network address list.

[0096] Optionally, after obtaining the network address list, the device 400 further includes: a second lookup unit, used to query the device interface corresponding to each network address in the interface mapping table based on each network address in the network address list, wherein the interface mapping table contains the mapping relationship between network addresses and device ports; and a second summarization unit, used to summarize the queried device interfaces to obtain an interface list.

[0097] Optionally, the device is further configured to: query the interface mapping table for the media access control address corresponding to the port of the device to be traversed, in response to the one-to-one mapping relationship between the media access control address of the device to be traversed and the port of the device to be traversed;

[0098] In response to a device whose media access control address is a switch, the connection relationship between the port of the device to be traversed and the media access control address of the device is stored.

[0099] In this embodiment, an acquisition unit is used to acquire device attribute information, wherein the attribute information represents the network attributes of the device; a first determination unit is used to determine the network addresses of each device in the network segment where the device is located based on the subnet mask of the device in the attribute information; and a second determination unit is used to determine the topological connection relationship between each device based on the network addresses of each device. In other words, in this embodiment of the invention, the network addresses of each device in the network segment where the device is located can be determined based on the subnet mask in the device attribute information. After determining the network addresses of each device included in the network segment, the network topological connection relationship of each device in the network segment can be determined based on the network addresses. This determination method is relatively simple and can determine the topological connection relationship between each device in the network segment. The determined network topological connection relationship is relatively comprehensive, achieving the technical effect of improving the generation efficiency of network topology information, thereby solving the technical problem of low generation efficiency of network topology information in related technologies.

[0100] Example 4

[0101] According to an embodiment of the present invention, a computer-readable storage medium is also provided, the storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to execute the method for generating network topology information in Embodiment 1.

[0102] Example 5

[0103] According to an embodiment of the present invention, a processor is also provided for running a program, wherein the program executes the method for generating network topology information in Embodiment 1 during runtime.

[0104] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0105] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0106] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of modules can be a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection between units or modules, and can be electrical or other forms.

[0107] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0108] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0109] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.

[0110] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for generating network topology information, characterized in that, include: Obtain the attribute information of the device, wherein the attribute information is used to represent the network attributes of the device; Based on the subnet mask of the device described in the attribute information, determine the network address of each device in the network segment where the device is located; Based on the network addresses of each device, the topological connection relationship between the devices is determined; The process of determining the topological connection relationship between the devices based on their network addresses includes: obtaining a media access control (MAC) address mapping table for each device based on its network address. By summarizing the MAC address mapping table of each device, a media access control address list is obtained; For switch devices that have not been traversed, perform the following traversal operation to obtain the topology connection relationship of the switch devices: The MAC address of the untraversed switch device and the number of device ports corresponding to the MAC address are found in the media access control address list, wherein the media access control address list includes the mapping relationship between the MAC addresses and device ports of all switch devices; When there is a one-to-one relationship between the device port and the MAC address, the interface list is traversed to determine whether the MAC address corresponding to the device port is the MAC address of the switch. The interface list is obtained by summarizing the device ports corresponding to the network addresses of all switch devices recorded in the interface mapping table. All switch devices are the switch devices recorded in the Media Access Control address list. The network addresses of all switch devices are obtained by querying the Address Resolution Protocol mapping table using the MAC address of each switch device. The interface mapping table includes the mapping relationship between network addresses and device ports. If the MAC address is the MAC address of the switch, the MAC address is stored in the TPList topology relationship to obtain the topology connection relationship of the switch device.

2. The method according to claim 1, characterized in that, The method further includes: In response to obtaining the media access control address mapping table of the device, the device type of the device is determined to be a switch; Based on the devices of the device type being switches, a set of devices to be traversed is generated, and the obtained media access control address mapping table is summarized to obtain the media access control address list.

3. The method according to claim 1, characterized in that, After obtaining the list of media access control addresses, the method further includes: Based on each of the media access control addresses in the media access control address list, the network address corresponding to each of the media access control addresses is found in the address resolution protocol mapping table. The retrieved network addresses are then aggregated to obtain a list of network addresses.

4. The method according to claim 1, characterized in that, When the device port and the MAC address have a one-to-one relationship, the method further includes: Query the media access control address corresponding to the port of the device to be traversed in the interface mapping table; In response to the fact that the media access control address is the media access control address of a device whose device type is a switch, the connection relationship between the port of the device to be traversed and the media access control address of the device is stored.

5. A device for generating network topology information, characterized in that, include: An acquisition unit is used to acquire attribute information of a device, wherein the attribute information is used to represent the network attributes of the device; The first determining unit is used to determine the network address of each device in the network segment where the device is located based on the subnet mask of the device in the attribute information; The second determining unit is used to determine the topological connection relationship between the devices based on the network addresses of the devices. The device is further configured to determine the topological connection relationship between the devices based on their network addresses in the following manner: obtaining a Media Access Control (MAC) address mapping table for each device based on its network address; summarizing the MAC address mapping tables to obtain a Media Access Control (MAC) address list; and performing the following traversal operation on untraversed switch devices to obtain their topological connection relationship: searching the MAC address of the untraversed switch device and the number of device ports corresponding to the MAC address in the MAC address list, wherein the MAC address list includes the mapping relationship between the MAC addresses and device ports of all switch devices; and searching the mapping relationship between the device ports and the MAC addresses... When the address has a one-to-one relationship, the interface list is traversed to determine whether the MAC address corresponding to the device port is the MAC address of the switch. The interface list is obtained by summarizing the device ports corresponding to the network addresses of all switch devices recorded in the interface mapping table. All switch devices are those recorded in the Media Access Control address list. The network addresses of all switch devices are obtained by querying the Address Resolution Protocol (ARP) mapping table using the MAC addresses of each switch device. The interface mapping table includes the mapping relationship between network addresses and device ports. If the MAC address is the MAC address of the switch, the MAC address is stored in the TPList topology relationship to obtain the topology connection relationship of the switch devices.

6. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein when the program is run by a processor, it controls the device in which the storage medium is located to perform the method of any one of claims 1 to 4.

Citation Information

Patent Citations

  • Method for obtaining physical layer link network topology based on address forwarding mechanism

    CN101610178A

  • Network topology determination method and computer readable storage medium

    CN108900318A

  • Topology method for network physical arrangement

    CN1921419A