WO2016004646A1 - Method, system and apparatus for acquiring topological connection relationship between devices - Google Patents

Method, system and apparatus for acquiring topological connection relationship between devices Download PDF

Info

Publication number
WO2016004646A1
WO2016004646A1 PCT/CN2014/082622 CN2014082622W WO2016004646A1 WO 2016004646 A1 WO2016004646 A1 WO 2016004646A1 CN 2014082622 W CN2014082622 W CN 2014082622W WO 2016004646 A1 WO2016004646 A1 WO 2016004646A1
Authority
WO
WIPO (PCT)
Prior art keywords
port
switch
mac
mac address
switch group
Prior art date
Application number
PCT/CN2014/082622
Other languages
French (fr)
Chinese (zh)
Inventor
袁志亚
吕志勇
李志强
Original Assignee
北京东土科技股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京东土科技股份有限公司 filed Critical 北京东土科技股份有限公司
Publication of WO2016004646A1 publication Critical patent/WO2016004646A1/en

Links

Definitions

  • TECHNICAL FIELD The present invention relates to the field of industrial Ethernet technologies, and in particular, to a method, system, and apparatus for acquiring a topology connection relationship between devices.
  • a topology discovery algorithm based on a ⁇ - ⁇ or a Bridge-MIB is generally used to determine a port MAC address of a switch, thereby determining a topology relationship diagram, and the currently available software may be, for example, a WUG (what is up god) )software.
  • FIG. 1 is a schematic diagram of determining a topology connection relationship of a switch in a prior art.
  • a PC searches for a switch 1 (S1), a switch 2 (S2), and a switch 3 (S3) through ping, and the S1 can learn the bridge MAC of the S2 and the S3.
  • S2 can learn the bridge MAC of S3, but S2 can't learn the bridge MAC of S1, and S3 can't learn the bridge MAC of S1 and S2. Therefore, the method will not be able to complete the determination of the topology connection relationship between the switches or devices.
  • the existing Link Layer Discovery Protocol (LLDP) only means that the network device only sends its own information to the directly connected device.
  • LLDP Link Layer Discovery Protocol
  • the present invention has been made in order to provide a method, system and apparatus for obtaining a topology connection relationship between devices that overcomes the above problems or at least partially solves the above problems.
  • An embodiment of the present invention provides a method for acquiring a topology connection relationship between devices, where the method includes:
  • the first switch sends a MAC notification message through each of its own LINK UP ports, where the source address and the destination address of the MAC notification are the MAC address of each port or the bridge MAC of the first switch. ;
  • the first switch determines, for each LINK UP port of the port, whether the number of the second switches included in the associated switch group corresponding to the port is 2; When the number is 2, according to the port that the second switch included in the associated switch group learns the MAC address of the port, the port is determined to be directly connected to the port on which the second switch learns the MAC address of the port. ;
  • the number is not 2, for each second switch included in the associated switch group, determine that the second switch learns the port of the port MAC address of the port, and determines the association of the port that should learn the MAC address of the port.
  • the number of switches remaining in the associated switch group is 2; when the number is 2, the port is determined to be The second switch learns that the port of the MAC address of the port is directly connected. Otherwise, it is determined that the number of the second switches directly connected to the port is more than one, or the port that the second switch learns the MAC address of the port is not directly connected.
  • each of the second switches in the associated switch group corresponding to the port of the first switch learns the port of the MAC address of the port of the first switch, and corresponds to When the number of the remaining switches in the associated switch group is not 2, the method further includes:
  • each second switch learns the port of the MAC address of the port of the first switch, and determines that the port itself and the second switch in the intersection learn the port of the MAC address of the port directly Connected, and the remaining switches in the intersection are connected by a shared link.
  • the first switch sends a MAC notification by using each LINK UP port of the switch.
  • the first switch sends a MAC notification message through each of its LINK UP ports according to a set period; or
  • the MAC notification is sent through each of its own LINK UP ports.
  • the first switch sends a MAC notification through each of its own LINK UP ports, in order to prevent the occurrence of a storm.
  • the first switch sends a MAC notification message through each of its own LINK UP ports, and the second switch that receives the MAC notification message determines whether it learns the MAC address in the MAC notification message.
  • the second switch When the second switch learns the MAC address, the second switch stops forwarding the MAC notification, otherwise, the second switch learns the MAC address and forwards the MAC notification.
  • the computing itself and each second switch in the networking learn the associated switch group corresponding to the port of the first switch port MAC or the bridge MAC
  • And information about non-associative switch groups includes: The first switch determines that the second switch is located in the associated switch group of the port according to the bridge MAC address and the port MAC of each second switch that is returned to the topology, and collects the packets carried in the packet through the topology collection.
  • the bridge MAC and the port MAC of the second switch and the MAC address learned by the second switch calculate information about the associated switch group and the non-associated switch group corresponding to the port of the first switch port MAC or the bridge MAC.
  • An embodiment of the present invention provides an apparatus for acquiring a topology connection relationship between devices, where the apparatus includes:
  • a sending module configured to send, by using each of its LINK UP ports, a MAC notification message, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge of the first switch MAC;
  • An acquiring module configured to collect, according to the second switch, a packet to the returned topology, obtain a bridge MAC address and a port MAC of the second switch, and learn a MAC address of the second switch, and calculate each second switch in the network and the network.
  • the associated switch group corresponding to the port of the first switch port MAC or the bridge MAC, and the information of the non-associated switch group;
  • the topology relationship determining module is configured to determine the associated switch group corresponding to the port for each LINK UP port of the port Whether the number of the second switches included in the switch is 2; when the number is 2, the port corresponding to the MAC address of the port is learned by the second switch included in the associated switch group, and the port and the second switch are determined.
  • the port that learns the MAC address of the port is directly connected; when the number is not 2, for each second switch included in the associated switch group, determining that the second switch learns the port of the MAC address of the port, and determining Exclude the end of the associated switch group of the port that should learn the MAC address of the port After each second switch in the corresponding non-associated switch group, the number of remaining switches in the associated switch group is 2; when the number is 2, it is determined that the port and the second switch learn the MAC of the port by itself. The port of the address is directly connected. Otherwise, it is determined that the number of the second switches directly connected to the port is more than one, or that the second switch learns that the port of the port is not directly connected.
  • the topology relationship determining module is further configured to: when determining that the second switch in the associated switch group corresponding to the port is learned by the second switch When the number of the ports of the port MAC address of the switch and the number of the remaining switches in the corresponding associated switch group are not 2, it is determined that each of the second switches learns the remaining switch group corresponding to the port of the port MAC address of the port.
  • each second switch learns the port of the port MAC address of the first switch, determines that the port of the first switch and each second switch in the intersection learns the port of the port
  • the ports of the MAC address are directly connected, and the remaining switches in the intersection are connected by a shared link.
  • the sending module is specifically configured to send a MAC notification message through each LINK UP port of the switch according to a set period; or, When it is turned on, or receives a link up or receives a link down message, it sends a MAC notification message through each of its own LINK UP ports.
  • the acquiring module is specifically used to accurately determine the connection topology relationship between the switches.
  • the second switch is located in the associated switch group of the port, and the bridge of the second switch carried in the packet is collected by the topology, according to the bridge MAC address and the port MAC of each second switch that collects the packet.
  • the MAC and the port MAC and the MAC address learned by the second switch calculate information about the associated switch group and the non-associated switch group corresponding to the port of the first switch port MAC or the bridge MAC.
  • An embodiment of the present invention provides a system for acquiring a topology relationship between devices, where the system includes the foregoing apparatus, and at least one second switch that returns a topology collection message to the apparatus.
  • the second switch is further configured to determine whether the MAC address in the MAC notification message is learned by the second switch when receiving the MAC notification message; When the MAC address is described, the MAC notification message is stopped. Otherwise, the MAC notification message is forwarded.
  • the embodiment of the invention provides a method, a system and a device for acquiring a topology connection relationship between devices.
  • the first switch sends a MAC address of the MAC address of the port by using the LINK UP port of the first switch.
  • Notifying the ⁇ ⁇ to determine the information of the associated switch group and the non-associated switch group corresponding to each port of each second switch in the network and the network, for each port, the corresponding switch group included in the corresponding switch group
  • the number of the two switches is 2, it is determined that the port of the first switch is directly connected to the port of the associated switch group that learns the MAC address of the port, and the second switch included in the corresponding associated switch group.
  • each switch sends a MAC notification message through each LINK UP port of the switch, and determines the connection relationship between the switch ports according to the information of each switch in the associated switch group and the non-associated switch group. The determination of the topology connection relationship between devices is realized.
  • FIG. 1 is a schematic diagram of determining a topology connection relationship of a switch in the prior art
  • FIG. 2 is a process diagram of acquiring a topology connection relationship between devices according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of topology connection between switches according to an embodiment of the present disclosure
  • FIG. 4 is a detailed process diagram of acquiring a topology connection relationship between devices according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of topology connection between switches according to an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of an apparatus for acquiring a topology connection relationship between devices according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a system for acquiring a topology relationship between devices according to an embodiment of the present invention.
  • the embodiments of the present invention provide a method, system, and apparatus for acquiring a topology connection relationship between devices in order to determine a topology connection relationship between devices.
  • FIG. 2 is a process diagram of acquiring a topology connection relationship between devices according to an embodiment of the present invention, where the process includes the following steps:
  • the first switch sends a MAC notification message through each LINK UP port of the MAC address, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge MAC address of the first switch. .
  • each switch in the network sends a MAC notification message through each LINK UP port of the network, and the source address and the destination address of the MAC notification packet are both the MAC address of the port or the The bridge MAC of the first switch. After such notification message is received by other switches, it will not be processed by the CPU, but can be learned.
  • the MAC notification message may be sent according to a set time period or sent in other manners.
  • S202 Acquire, according to the topology collection packet returned by the second switch, the bridge MAC address and the port MAC of the second switch, and the MAC address learned by the second switch, and calculate the first switch of each second switch in the self and the network. Information about the associated switch group corresponding to the port MAC or bridge MAC port, and the non-associated switch group.
  • the associated switch group corresponding to the port is determined.
  • the switch that returns the topology collection packet through a certain port is used as the corresponding port.
  • Associate switches in the switch group For example, if a second switch returns a topology collection packet through port 1 of the first switch, it can be determined that the second switch is located in the associated switch group corresponding to the port 1, and each switch itself is also located in each of the switches.
  • the information in the non-associated switch group can be determined according to the information of each second switch included in the configured topology collection area and the information of each switch in the associated switch.
  • the first switch in order to obtain the topology relationship, the first switch needs to know the information of the switches included in the associated switch group and the non-associated switch group of other switches, so if other switches have acquired each of their own When the information about the associated switch group and the non-associated switch group corresponding to the LINK UP port is returned to the first switch, the information about the associated switch group and the non-associated switch group corresponding to each port is returned to the first switch. If the other switch does not currently obtain the associated switch group and non-associated switch group corresponding to each port thereof. The information is forwarded to the first switch through the information of the associated switch group and the non-associated switch group corresponding to each port, and finally ensures that each switch has its own association with each port of the other switch. Information about switch groups and non-associative switch groups.
  • the first switch determines, for each LINK UP port of the port, whether the number of the second switches included in the associated switch group corresponding to the port is 2. If the determination result is yes, go to step S204; otherwise, go to step S205. .
  • the first switch determines which port of each switch is directly connected to each port, the first switch determines the number of switches included in the associated switch group corresponding to the port.
  • the associated switch group corresponding to the port contains only two switches, the first switch is directly connected to the switch, and the ports between the two switch ports are determined according to the ports that learn the MAC address of the peer. relationship.
  • step S205 For each second switch included in the associated switch group, determine that the second switch learns the port of the port MAC address of the port, and determines that the associated switch group corresponding to the port that learns the MAC address of the port is excluded. After the second switch of the non-associated switch group corresponding to the port, the number of the remaining switches in the associated switch group is 2, and if the determination result is yes, the process proceeds to step S206; otherwise, the process proceeds to step S207.
  • S206 Determine that the port of the port is directly connected to the port that the second switch learns the MAC address of the port.
  • S207 Determine that the number of the second switches directly connected to the port is not more than one or is not directly connected to the port of the port that is learned by the second switch.
  • the switch of the first switch directly connected to the port is determined by combining the information of the non-associated switch group corresponding to the port of the first switch.
  • each switch sends a MAC notification message through each LINK UP port of the switch, and determines the connection relationship between the switch ports according to the information of each switch in the associated switch group and the non-associated switch group. The determination of the topology connection relationship between devices is realized.
  • each switch periodically sends a MAC notification message to each switch through each LINK UP port of its own, and sets the source address and destination address of the MAC notification address to the MAC address of the port. address.
  • the switch receiving the message will not send the MAC notification message to the CPU when processing the MAC notification message, but the MAC address in the MAC notification message can be learned by the port of the switch. .
  • the computing switch itself learns the associated switch group corresponding to the MAC address of the first switch port or the port of the bridge MAC in the second switch of the network.
  • information about non-associative switch groups includes:
  • the first switch is configured according to a bridge MAC address and a port MAC address of each second switch that returns a topology response message. Determining that the second switch is located in the associated switch group of the port, and collecting the bridge MAC and port MAC of the second switch carried in the packet and the MAC address learned by the second switch, and calculating that each second switch learns Information about the associated switch group and the non-associated switch group corresponding to the port of the first switch port MAC or the bridge MAC.
  • the first switch sends a MAC notification through each LINK UP port of the user in the embodiment of the present invention.
  • the first switch sends a MAC notification message through each of its own LINK UP ports, and the second switch that receives the MAC notification message determines whether it learns the MAC address in the MAC notification message.
  • the second switch When the second switch learns the MAC address, the second switch stops forwarding the MAC notification, otherwise, the second switch learns the MAC address and forwards the MAC notification.
  • the second switch when the second switch has learned the MAC address in the MAC notification packet, the second switch will stop forwarding the MAC notification packet according to the bridge forwarding principle, and will not generate other MAC addresses in the network. Impact, preventing network storms while reducing network bandwidth usage.
  • the first switch sends a MAC notification by using each LINK UP port of the switch.
  • the first switch sends a MAC notification message through each of its LINK UP ports according to a set period; or
  • the MAC notification is sent through each of its own LINK UP ports.
  • the sending period of the MAC notification message may be determined according to the aging time of the MAC address, so as to prevent the MAC address from aging, and the correct topology connection cannot be obtained in time. 1/3, or 1/2 of the aging time of the MAC address.
  • the network Each of the first switches sends a MAC notification through each of its own LINK UP ports.
  • the MAC address is sent by the MAC notification, and the bridge MAC of each switch and the MAC address of each port are obtained through the ifPhys Address of the snmp, and all the MAC addresses learned by the switch are obtained one by one through the dotldTpFdbPort and the dot IdTpFdb Status node. And its corresponding port and learning state.
  • FIG. 3 is a schematic diagram of a topology connection structure between switches according to an embodiment of the present invention.
  • each switch has its own IP address, and the IP of each device of switch 1 (S1) to switch 7 (S7) The addresses are respectively 192.168.0. ⁇ 192.168.0.7.
  • S5, Sl, S2, S3 and S6 are sequentially connected, and S2 is sequentially connected with S4 and S7.
  • Each switch in Figure 3 sends a MAC notification message through each of its own LINK UP ports, according to each The second switch returns a topology collection packet to each port, obtains a bridge MAC address and a port MAC of the second switch, and learns a MAC address of the second switch, and calculates each second switch in the self and the network to learn the first Information about the associated switch group corresponding to the port of the switch port MAC or bridge MAC, and the non-associated switch group.
  • S1 determines that the associated switch group includes six switches for the associated switch group corresponding to port 1.
  • the switches included in the associated switch group are respectively Sl, S2, S3, S4, S6, S7, SI arbitrarily select a non-self switch in the associated switch group, or select a non-self switch with the smallest IP address to judge.
  • the IP address of S2 in the associated switch group is the smallest except S1, and S1 first determines whether its port 1 is connected to S2.
  • S1 finds that the port whose S2 learns its MAC address is port 2, and the non-associated switch group corresponding to S1 port 1 includes S5. After S5 is removed from the associated switch group corresponding to S2 port 2, the associated switch corresponding to S2 port 2 The switches S1 and S2 remain in the group. Therefore, it can be seen that S1 is connected to S2, and port 1 of the specific S1 is directly connected to port 2 of S2. Here, S1 has found a switch that is directly connected to its port 1, so it does not continue to judge other switches in the associated switching group corresponding to its port 1.
  • S1 judges its own port 2, because port 2 corresponds to only two switches in the associated switch group.
  • the two switches are S1 and S2 respectively, so it can be determined that S1 and S5 are directly connected.
  • S5 learns that the port of S1's MAC address is port 1, so port 2 of S1 is directly connected to port 5 of S5.
  • S2 determines, for the associated switch group corresponding to port 1, that the number of switches included in the corresponding associated switch group is not 2, for the associated switch.
  • any switch other than itself in the group judges, for example, for the switch S6, S6 learns that the port of the S2 MAC address is its port 2, and the associated switch group corresponding to S6 (S1, S2, S3, S4, S5, S6, S7) removes the switch in the non-associated switch group (S1, S4, S5, S7) corresponding to port 1 of S2, and the remaining switches are S2, S3, and S6, that is, the number of remaining switches is not 2, so It can be seen that port 1 of S2 is not directly connected to port 2 of S6. It is necessary to continue to judge other switches in the associated switch group corresponding to port 1 of S2.
  • the associated switch group corresponding to port 1 of S2 also includes switch S3.
  • S3 learns that the port of S2's MAC address is port 2, and the associated switch group corresponding to S3 port 2 (S1, S2, S3, S4, S5, S7) After removing the switches in the non-associated switch groups (S1, S4, S5, and S7) corresponding to port 1 of S2, the remaining switches are S2 and S3, and the number of remaining switches is 2. Therefore, it can be seen that port 1 of S2 is The port 2 of S3 is directly connected.
  • Each switch adopts the above method as the first switch, and the first switch judges each LINK UP port of its own, and determines the connection relationship between each port and other switch ports.
  • each of the second switches in the associated switch group corresponding to the port of the first switch learns the port of the MAC address of the port of the first switch, and corresponds to When the number of the remaining switches in the associated switch group is not 2, the method further includes:
  • each second switch learns the port of the MAC address of the port of the first switch, and determines that the port itself and the second switch in the intersection learn the port of the MAC address of the port directly Connected, and the remaining switches in the intersection are connected by a shared link.
  • FIG. 4 is a detailed process diagram of acquiring a topology connection relationship between devices according to an embodiment of the present invention, where the process includes the following steps:
  • the first switch sends a MAC notification message through each LINK UP port of the MAC address, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge MAC address of the first switch. .
  • S402 Obtain, according to the topology collection packet returned by the second switch to each port, the bridge MAC address and the port MAC of the second switch, and the MAC address learned by the second switch, and calculate each second switch in the network and the network. Information about the associated switch group corresponding to the port of the first switch port MAC or bridge MAC, and the non-associated switch group.
  • the first switch determines, for each LINK UP port of the port, whether the number of the second switches included in the associated switch group corresponding to the port is 2. If the determination result is yes, proceed to step S404; otherwise, proceed to step S405. .
  • S404 According to the port that the second switch included in the associated switch group learns the MAC address of the port, determine that the port is directly connected to the port on which the second switch learns the MAC address of the port.
  • S405 For each second switch included in the associated switch group, determine that the second switch learns the port of the port MAC address of the port, and determines that the associated switch group corresponding to the port that learns the MAC address of the port is excluded. After the second switch of the non-associated switch group corresponding to the port, the number of remaining switches in the associated switch group is 2, and if the determination result is yes, go to step S406; otherwise, go to step S407.
  • S406 Determine that the port of the port is directly connected to the port that the second switch learns to be the MAC address of the port.
  • S408 Determine, by each of the second switches, the intersection of the remaining switches in the associated switch group corresponding to the port of the port whose MAC address is the port.
  • each second switch learns the port of the MAC address of the port of the first switch, and determines that the port and the second switch of the intersection learn the MAC address of the port.
  • the ports are directly connected, and the remaining switches in the intersection are connected by a shared link.
  • each switch in the associated switch group corresponding to the port cannot meet the non-association of the corresponding port.
  • the number of switches in the switch group is 2. Therefore, you need to determine the intersection of the switches in the associated switch group after removing the switches in the non-associated switch group corresponding to the port. At least two switches are included in the intersection. , the port is connected to the at least two switches.
  • FIG. 5 is a schematic diagram of a topology connection structure between switches according to an embodiment of the present invention.
  • a plurality of switches are connected to a switch through a hub, specifically, S5, Sl, and S2.
  • S3 and S6 are sequentially connected
  • SI is connected to S8 and S91 through a hub
  • S91 is connected to S92
  • S2 is sequentially connected to S4 and S7.
  • Each switch in FIG. 5 sends a MAC notification packet through each LINK UP port of its own, and obtains a bridge MAC and a port MAC of the second switch according to the topology collection packet returned by each second switch to each port.
  • the second switch learns the MAC address, and calculates information about the associated switch group corresponding to each port of the first switch port MAC or the bridge MAC and the non-associated switch group by each second switch in the network and the network.
  • S4 1 S4, S7 Sl, S2, S3, S5, S6, S8,
  • S1 determines that the associated switch group includes six switches for the associated switch group corresponding to port 1.
  • the switches included in the associated switch group are respectively S1. , S2, S3, S4, S6, S7, SI arbitrarily select a non-self switch in the associated switch group, or select a non-owner switch with the smallest IP address to judge.
  • the IP address of S2 in the associated switch group is the smallest except S1, and S1 first determines whether its port 1 is connected to S2.
  • the SI finds that the port whose S2 learns its MAC address is port 2, and the non-associated switch group corresponding to SI port 1 includes S5.
  • S1 judges its own port 2, because port 2 corresponds to only two switches in the associated switch group.
  • the two switches are S1 and S2 respectively, so it can be determined that S1 and S5 are directly connected.
  • S5 learns that the port of S1's MAC address is port 1, so port 2 of S1 is directly connected to port 5 of S5.
  • the associated switch group corresponding to port 3 includes switches S1, S8, S91, and S92.
  • the number of switches in the corresponding associated switch group is not 2, and S1 first searches for S8.
  • the port of the MAC address is port 4, and the unassociated switch group corresponding to SI port 3 is removed from the associated switch group (S1, S2, S3, S4, S5, S6, S7, S8, S91, S92) corresponding to S8 port 4 ( For the switches in S2, S3, S4, S5, S6, and S7), the remaining switches are Sl, S8, S91, and S92, and the remaining switches are not 2. Therefore, you need to continue to find other switches in the associated switch group corresponding to port 3.
  • S1 finds that the port on which S91 learns its MAC address is port 4, and removes the non-corresponding to SI port 3 in the associated switch group (S1, S2, S3, S4, S5, S6, S7, S8, S91) corresponding to port S91.
  • the remaining switches are Sl, S8, and S91, and the remaining switches are not 2. Therefore, you need to continue to find other switches in the associated switch group corresponding to port 3.
  • S1 finds that the port on which S92 learns its MAC address is port 4, and the associated switch group corresponding to port S92 (S1)
  • Each switch in the associated switch group corresponding to port 3 of S1 learns the port of its own MAC address. After the corresponding associated switch group removes the non-associated switch group corresponding to port 3 of S1, the number of remaining switches is not 2, in order to determine the connection relationship between the port 3 of S1 and other switches, in the embodiment of the present invention, the port corresponding to the port 1 of the S1 is removed from the associated switch group corresponding to the port whose MAC address is learned by each corresponding switch. After the non-associated switch group, the intersection of the remaining switches determines the switch connected to port 3 of the S1.
  • the S3 learns the S1, and the remaining switches are S1, S8, and S91.
  • S92 in the associated switch group in which the S91 of the associated switch group learns the MAC address of the S1, the remaining switches are the Sl, S8, and S91, and the associated switch group is removed from the unassociated switch group corresponding to the port 3 of the S1;
  • the S92 learns the associated switch group corresponding to port 4 of the MAC address of S1, and removes the non-associated switch corresponding to port 3 of S1.
  • the remaining switches in the group are SI, S8, S91, and S92, and their intersections are S1, S8, and S91. Therefore, it can be determined that SI is directly connected to S8 and S91 respectively.
  • Port 3 of the specific S1 is directly connected to port 4 of S8, and directly Connect to port 4 of S91, and connect Sl, S8, and S91 through a shared link.
  • S8 as the first switch determines the second switch connected to each port of the first switch, and S8 determines that the associated switch group includes nine switches for the associated switch group corresponding to the port 4, and the switches included in the associated switch group are respectively Sl, S2, S3, S4, S6, S7, S8, S91, S92, S8 arbitrarily select a non-self switch in the associated switch group, that is, arbitrarily select a second switch, or select the non-IP with the smallest IP address. Its own switch makes judgments.
  • the IP address of S1 is the smallest in the associated switch group, and S8 first determines whether its port 4 is connected to S1.
  • S8 finds that the port on which S1 learns its MAC address is port 3, and the unassociated switch group corresponding to port S8 is empty.
  • the associated switch group corresponding to port 3 of S1 includes Sl, S8, S91, and S92.
  • S8 finds that the port whose S2 learns its MAC address is port 2, and the associated switch group corresponding to port 2 of S2 includes S1, S2, S5, S8, S91, and S92. After the empty set is removed in the associated switch group, the remaining The switch is the same as the switch included in the associated switch group corresponding to port 2 of S2, or is S1, S2, S5, S8, S91, and S92. Based on the same method, S3 learns the associated switch group corresponding to port 2 of its MAC address.
  • the remaining switches are Sl, S2, S3, S4, S5, S7, S8, S91, S92;
  • S4 learns the MAC address of the associated switch group corresponding to port 4, after removing the empty set, the remaining switches S1, S2, S3, S4, S5, S6, S8, S91, S9;
  • S5 learns that the MAC address of the associated switch group corresponding to port 1 removes the empty set, and the remaining switches are Sl, S2, S3,
  • S5 learns that the associated switch group corresponding to port 2 of its MAC address is removed from the associated set, and the remaining switches are Sl, S2, S3, S4, S5, S6, S7, S8, S91, and S92; S7 learns that after removing the empty set from the associated switch group corresponding to port 2 of its MAC address, the remaining switches are Sl, S2, S3, and S4.
  • S91 learns that the associated switch group corresponding to port 4 of its MAC address is removed from the associated set, and the remaining switches are Sl, S2, S3, S4, S5, S6, S7, S8, S91; S92 learns that the associated switch group corresponding to port 4 of its MAC address is removed from the associated set, and the remaining switches are S1, S2, S3, S4, S5, S6, S7, S8, S91, S92;
  • Each switch in the associated switch group corresponding to port 4 of S8 learns the port of its own MAC address. After the corresponding associated switch group removes the non-associated switch group corresponding to port 4 of S8, the number of remaining switches is not 2. After the non-associated switch group corresponding to port 4 of S8 is removed from the associated switch group corresponding to the port whose MAC address is learned by each switch, the intersection of the remaining switches is S1, S8, and S91. S8 is directly connected to S1 and S91. According to the port where the three devices learn the MAC address of the other party, the port 4 of S8 is directly connected to S1. Port 3 is directly connected to port 4 of S91, and S8, SI and S91 are connected by a shared link.
  • FIG. 6 is a schematic structural diagram of an apparatus for acquiring a topology connection relationship between devices according to an embodiment of the present invention, where the apparatus includes:
  • the sending module 61 is configured to send, by using each of its LINK UP ports, a MAC notification message, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge of the first switch.
  • the obtaining module 62 is configured to obtain, according to the topology collection packet returned by the second switch, the bridge MAC address and port MAC of the second switch, and the MAC address learned by the second switch, and calculate each second in the network and the second switch.
  • the switch learns the associated switch group corresponding to the port of the first switch port MAC or the bridge MAC, and the information of the non-associated switch group; the topology relationship determining module 63 is configured to determine, for each LINK UP port of the switch port, corresponding to the port Whether the number of the second switches included in the associated switch group is 2; when the number is 2, the port corresponding to the MAC address of the port is learned by the second switch included in the associated switch group, and the port is determined by the port The second switch learns that the port of the MAC address of the port is directly connected; when the number is not 2, for the associated switch group Each of the included second switches determines that the second switch learns the port of the port MAC address of the port, and determines the non-associated switch corresponding to the port in the associated switch group of the port that should learn the port of the MAC address of the port.
  • the number of switches remaining in the associated switch group is 2; when the number is 2, it is determined that the port itself is directly connected to the port on which the second switch learns the MAC address of the port. Otherwise, it is determined that the number of second switches directly connected to the port is not only i, or is indirectly connected to the port on which the second switch learns the MAC address of the port.
  • the topology relationship determining module 63 is further configured to: when determining that the second switch in the associated switch group corresponding to the port is learned by the second switch When the number of ports of the port MAC address of the first switch and the number of remaining switches in the corresponding associated switch group are not 2, it is determined that each of the second switches learns the associated switch group corresponding to the port of the port MAC address of the port.
  • each second switch learns the port of the port MAC address of the first switch, determines that the port itself and each second switch in the intersection learns itself
  • the port of the port MAC address is directly connected, and the remaining switches in the intersection are connected by a shared link.
  • the sending module 61 is specifically configured to send a MAC notification message through each LINK UP port of the switch according to a set period; or When it is turned on, or receives a link up or receives a link down message, it sends a MAC notification message through each of its own LINK UP ports.
  • the obtaining module 62 is specifically configured to determine, according to the bridge MAC and the port MAC of each second switch that returns the topology collection message. Second switch bit In the associated switch group of the port, the second switch learns the first switch port MAC by calculating the bridge MAC address and port MAC of the second switch carried in the packet and the MAC address learned by the second switch. Or the information of the associated switch group and the non-associated switch group corresponding to the port of the bridge MAC.
  • FIG. 7 is a schematic structural diagram of a system for acquiring a topology relationship between devices, where the system includes the foregoing device 71, and at least one second switch 72 that returns topology collection packets to the device.
  • the second switch 72 is further configured to determine whether the MAC address in the MAC notification packet is learned by the second switch 72. When the MAC address is used, the forwarding of the MAC notification message is stopped, otherwise, the MAC notification message is forwarded.
  • the embodiment of the invention provides a method, a system and a device for acquiring a topology connection relationship between devices.
  • the first switch sends a MAC address of the MAC address of the port by using the LINK UP port of the first switch.
  • Notifying the ⁇ ⁇ to determine the information of the associated switch group and the non-associated switch group corresponding to each port of each second switch in the network and the network, for each port, the corresponding switch group included in the corresponding switch group
  • the number of the two switches is 2, it is determined that the port of the first switch is directly connected to the port of the associated switch group that learns the MAC address of the port, and the second switch included in the corresponding associated switch group.
  • each switch sends a MAC notification message through each LINK UP port of the switch, and determines the connection relationship between the switch ports according to the information of each switch in the associated switch group and the non-associated switch group. The determination of the topology connection relationship between devices is realized.
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed may be employed. Or combine all the processes or units of the device.
  • Each feature disclosed in the specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) can be used in practice to implement an apparatus and system for acquiring a topology connection relationship between devices, a terminal device and a system according to an embodiment of the present invention. Some or all of the features of some or all of the components.
  • the invention can also be embodied as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein. Such a program implementing the present invention may be stored on a computer readable shield or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
  • any reference signs placed between parentheses shall not be construed as a limitation.
  • the word “comprising” does not exclude the presence of elements or steps that are not listed in the claims.
  • the word “a” or “an” preceding a component does not exclude the presence of a plurality of such elements.
  • the invention can be implemented by means of hardware comprising thousands of different elements and by means of a suitably programmed computer. In the unit claims enumerating the thousands of devices, thousands of these devices may be embodied by the same hardware item.
  • the use of the words first, second, and third does not indicate any order. These words can be interpreted as names.

Abstract

The present application provides a method, system and apparatus for acquiring the topological connection relationship between devices, which realize determination of the topological relationship between switches. In the method, a first switch sends, through each LINK UP port of the first switch, a MAC notification packet having a destination address and a source address being a MAC address of the port or a bridge MAC of the first switch; and it is determined, according to the number of second switches comprised in an associated switch group corresponding to each port, whether the port of the first switch is connected to ports, learning the MAC address of the port of the first switch, of the second switches in the associated switch group. In embodiments of the present application, each switch sends a MAC notification packet through each LINK UP port of the switch, and the connection relationship between the ports of the switches is determined according to the information of each switch in an associated switch group and a non-associated switch group, and therefore determination of the topological connection relationship between devices is achieved.

Description

一种获取设备间拓朴连接关系的方法、 系统及装置 本申请要求在 2014年 7月 09日提交中国专利局、 申请号为 201410325994.4、 发明名称为一种获 取设备间拓朴连接关系的方法、 系统及装置的中国专利申请的优先权, 其全部内容通过引用结合 在本申请中。 技术领域 本发明涉及工业以太网技术领域, 尤其涉及一种获取设备间拓朴连接关系的方法、 系统 及装置。 背景技术 现有技术中一般通过基于 ΜΙΒ-Π或 Bridge-MIB的拓朴发现算法,确定交换机的端口 MAC 地址, 从而确定拓朴关系图, 目前可以釆用的软件例如可以是 WUG ( whats up god )软件。  Method, system and device for obtaining topology connection relationship between devices, the application is submitted to the Chinese Patent Office on July 09, 2014, and the application number is 201410325994.4, and the invention name is a method for obtaining a topological connection relationship between devices, The priority of the Chinese patent application for the system and the device, the entire contents of which are incorporated herein by reference. TECHNICAL FIELD The present invention relates to the field of industrial Ethernet technologies, and in particular, to a method, system, and apparatus for acquiring a topology connection relationship between devices. BACKGROUND In the prior art, a topology discovery algorithm based on a ΜΙΒ-Π or a Bridge-MIB is generally used to determine a port MAC address of a switch, thereby determining a topology relationship diagram, and the currently available software may be, for example, a WUG (what is up god) )software.
图 1为现有技术中确定交换机拓朴连接关系的示意图, PC通过 ping来寻找交换机 1( S1 )、 交换机 2( S2 )和交换机 3 ( S3 ), S1能学习到 S2和 S3的桥 MAC, S2能学习到 S3的桥 MAC, 但 S2学习不到 S 1的桥 MAC, S3学习不到 S1和 S2的桥 MAC。 因此该方法将无法完成交换 机或设备间拓朴连接关系的确定。 现有的链路层发现协议( LLDP )仅仅是网络设备仅仅将自 身的信息发给直连设备, 其它非直连设备还是无法获得该网络设备信息, 同样无法完成交换 机或设备间的拓朴连接关系的确定。 发明内容 鉴于上述问题, 提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题 的一种获取设备间拓朴连接关系的方法、 系统及装置。  FIG. 1 is a schematic diagram of determining a topology connection relationship of a switch in a prior art. A PC searches for a switch 1 (S1), a switch 2 (S2), and a switch 3 (S3) through ping, and the S1 can learn the bridge MAC of the S2 and the S3. S2 can learn the bridge MAC of S3, but S2 can't learn the bridge MAC of S1, and S3 can't learn the bridge MAC of S1 and S2. Therefore, the method will not be able to complete the determination of the topology connection relationship between the switches or devices. The existing Link Layer Discovery Protocol (LLDP) only means that the network device only sends its own information to the directly connected device. Other non-directly connected devices still cannot obtain the information of the network device, and the switch or the topology connection between the devices cannot be completed. The determination of the relationship. SUMMARY OF THE INVENTION In view of the above, the present invention has been made in order to provide a method, system and apparatus for obtaining a topology connection relationship between devices that overcomes the above problems or at least partially solves the above problems.
本发明实施例提供了一种获取设备间拓朴连接关系的方法, 该方法包括:  An embodiment of the present invention provides a method for acquiring a topology connection relationship between devices, where the method includes:
第一交换机通过自身的每个 LINK UP端口发送 MAC通知 4艮文, 其中, 所述 MAC通知 •ί艮文的源地址和目的地址为每个端口的 MAC地址或者所述第一交换机的桥 MAC;  The first switch sends a MAC notification message through each of its own LINK UP ports, where the source address and the destination address of the MAC notification are the MAC address of each port or the bridge MAC of the first switch. ;
根据第二交换机返回的拓朴收集报文,获取第二交换机的桥 MAC和端口 MAC以及第二 交换机学习的 MAC地址, 并计算自身及组网中每台第二交换机学习到第一交换机端口 MAC 或者桥 MAC的端口对应的关联交换机组, 及非关联交换机组的信息;  Obtaining, according to the topology collection packet returned by the second switch, the bridge MAC address and the port MAC of the second switch, and the MAC address learned by the second switch, and calculating the MAC address of the first switch port by each second switch in the self and the network. Or the associated switch group corresponding to the port of the bridge MAC, and the information of the non-associated switch group;
第一交换机针对自身的每个 LINK UP端口,判断该端口对应的关联交换机组中包含的第 二交换机的数量是否为 2; 当数量为 2时, 根据该关联交换机组中包含的第二交换机学习到自身该端口的 MAC地 址的端口, 确定自身的该端口与该第二交换机学习到自身该端口的 MAC地址的端口直接连 接; The first switch determines, for each LINK UP port of the port, whether the number of the second switches included in the associated switch group corresponding to the port is 2; When the number is 2, according to the port that the second switch included in the associated switch group learns the MAC address of the port, the port is determined to be directly connected to the port on which the second switch learns the MAC address of the port. ;
当数量不为 2时, 针对该关联交换机组中包含的每台第二交换机, 确定该第二交换机学 习到自身该端口 MAC地址的端口,判断对应该学习到自身该端口 MAC地址的端口的关联交 换机组中排除第一交换机该端口对应的非关联交换机组中的每台第二交换机后, 该关联交换 机组中剩余的交换机数量是否为 2; 当数量为 2时, 确定自身的该端口与该第二交换机学习 到自身该端口 MAC地址的端口直接连接, 否则, 确定与该端口直接连接的第二交换机的数 量不止 1台或者与该第二交换机学习到自身该端口 MAC地址的端口非直接连接。  When the number is not 2, for each second switch included in the associated switch group, determine that the second switch learns the port of the port MAC address of the port, and determines the association of the port that should learn the MAC address of the port. After the second switch in the unassociated switch group corresponding to the port of the first switch is excluded from the switch group, the number of switches remaining in the associated switch group is 2; when the number is 2, the port is determined to be The second switch learns that the port of the MAC address of the port is directly connected. Otherwise, it is determined that the number of the second switches directly connected to the port is more than one, or the port that the second switch learns the MAC address of the port is not directly connected. .
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 当第一交换机该端口对 应的关联交换机组中每台第二交换机学习到该第一交换机该端口 MAC地址的端口、 对应的 关联交换机组中剩余的交换机的数量都不为 2时, 所述方法还包括:  In order to accurately determine the connection topology relationship between the switches, in the embodiment of the present invention, each of the second switches in the associated switch group corresponding to the port of the first switch learns the port of the MAC address of the port of the first switch, and corresponds to When the number of the remaining switches in the associated switch group is not 2, the method further includes:
确定所述每台第二交换机学习到自身该端口 MAC地址的端口对应的关联交换机组中剩 余的交换机的交集;  Determining, by each of the second switches, an intersection of the remaining switches in the associated switch group corresponding to the port of the MAC address of the port;
根据该剩余的交换机的交集中每台第二交换机学习到该第一交换机该端口 MAC地址的 端口, 确定自身的该端口与该交集中每台第二交换机学习到自身该端口 MAC地址的端口直 接连接, 且该交集中的剩余交换机之间通过共享链路连接。  According to the port of the remaining switch, each second switch learns the port of the MAC address of the port of the first switch, and determines that the port itself and the second switch in the intersection learn the port of the MAC address of the port directly Connected, and the remaining switches in the intersection are connected by a shared link.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述第一交换机通过自 身的每个 LINK UP端口发送 MAC通知 4艮文包括:  In order to accurately determine the connection topology relationship between the switches, in the embodiment of the present invention, the first switch sends a MAC notification by using each LINK UP port of the switch.
所述第一交换机按照设定的周期, 通过自身的每个 LINK UP端口发送 MAC通知报文; 或,  The first switch sends a MAC notification message through each of its LINK UP ports according to a set period; or
当所述第一交换机被开启时、 或接收到 link up或接收到 link down消息时, 通过自身的 每个 LINK UP端口发送 MAC通知 4艮文。  When the first switch is turned on, or receives a link up or receives a link down message, the MAC notification is sent through each of its own LINK UP ports.
为了防止风暴的发生, 减少带宽资源的浪费, 在本发明实施例中, 所述第一交换机通过 自身的每个 LINK UP端口发送 MAC通知 4艮文包括:  In the embodiment of the present invention, the first switch sends a MAC notification through each of its own LINK UP ports, in order to prevent the occurrence of a storm.
所述第一交换机通过自身的每个 LINK UP端口发送 MAC通知报文, 接收到该 MAC通 知报文的第二交换机判断自身是否学习到所述 MAC通知报文中的 MAC地址;  The first switch sends a MAC notification message through each of its own LINK UP ports, and the second switch that receives the MAC notification message determines whether it learns the MAC address in the MAC notification message.
当第二交换机学习到所述 MAC地址时, 第二交换机停止转发该 MAC通知 ·ί艮文, 否则, 第二交换机学习该 MAC地址并转发该 MAC通知 4艮文。  When the second switch learns the MAC address, the second switch stops forwarding the MAC notification, otherwise, the second switch learns the MAC address and forwards the MAC notification.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述计算自身及组网中 每台第二交换机学习到第一交换机端口 MAC或者桥 MAC的端口对应的关联交换机组,及非 关联交换机组的信息包括: 所述第一交换机根据返回拓朴收集 4艮文的每台第二交换机的桥 MAC和端口 MAC, 确定 该第二交换机位于该端口的关联交换机组中, 并通过拓朴收集报文中携带的第二交换机的桥 MAC和端口 MAC以及第二交换机学习的 MAC地址, 计算每个第二交换机学习到第一交换 机端口 MAC或者桥 MAC的端口对应的关联交换机组及非关联交换机组的信息。 In order to accurately determine the connection topology between the switches, in the embodiment of the present invention, the computing itself and each second switch in the networking learn the associated switch group corresponding to the port of the first switch port MAC or the bridge MAC, And information about non-associative switch groups includes: The first switch determines that the second switch is located in the associated switch group of the port according to the bridge MAC address and the port MAC of each second switch that is returned to the topology, and collects the packets carried in the packet through the topology collection. The bridge MAC and the port MAC of the second switch and the MAC address learned by the second switch calculate information about the associated switch group and the non-associated switch group corresponding to the port of the first switch port MAC or the bridge MAC.
本发明实施例提供了一种获取设备间拓朴连接关系的装置, 所述装置包括:  An embodiment of the present invention provides an apparatus for acquiring a topology connection relationship between devices, where the apparatus includes:
发送模块, 用于通过自身的每个 LINK UP端口发送 MAC通知 4艮文, 其中, 所述 MAC 通知 4艮文的源地址和目的地址为每个端口的 MAC地址或者所述第一交换机的桥 MAC;  a sending module, configured to send, by using each of its LINK UP ports, a MAC notification message, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge of the first switch MAC;
获取模块, 用于根据第二交换机向返回的拓朴收集报文, 获取第二交换机的桥 MAC和 端口 MAC以及第二交换机学习的 MAC地址,并计算自身及组网中每台第二交换机学习到第 一交换机端口 MAC或者桥 MAC的端口对应的关联交换机组 , 及非关联交换机组的信息; 拓朴关系确定模块, 用于针对自身的每个 LINK UP端口, 判断该端口对应的关联交换机 组中包含的第二交换机的数量是否为 2; 当数量为 2时, 根据该关联交换机组中包含的第二 交换机学习到自身该端口的 MAC地址的端口, 确定自身的该端口与该第二交换机学习到自 身该端口的 MAC地址的端口直接连接; 当数量不为 2时, 针对该关联交换机组中包含的每 台第二交换机, 确定该第二交换机学习到自身该端口 MAC地址的端口, 判断对应该学习到 自身该端口 MAC地址的端口的关联交换机组中排除自身的该端口对应的非关联交换机组中 的每台第二交换机后, 该关联交换机组中剩余的交换机数量是否为 2; 当数量为 2时, 确定 自身的该端口与该第二交换机学习到自身该端口 MAC地址的端口直接连接, 否则, 确定与 该端口直接连接的该第二交换机数量不止 1 台, 或者与第二交换机学习到自身该端口 MAC 地址的端口非直接连接。  An acquiring module, configured to collect, according to the second switch, a packet to the returned topology, obtain a bridge MAC address and a port MAC of the second switch, and learn a MAC address of the second switch, and calculate each second switch in the network and the network. The associated switch group corresponding to the port of the first switch port MAC or the bridge MAC, and the information of the non-associated switch group; the topology relationship determining module is configured to determine the associated switch group corresponding to the port for each LINK UP port of the port Whether the number of the second switches included in the switch is 2; when the number is 2, the port corresponding to the MAC address of the port is learned by the second switch included in the associated switch group, and the port and the second switch are determined. The port that learns the MAC address of the port is directly connected; when the number is not 2, for each second switch included in the associated switch group, determining that the second switch learns the port of the MAC address of the port, and determining Exclude the end of the associated switch group of the port that should learn the MAC address of the port After each second switch in the corresponding non-associated switch group, the number of remaining switches in the associated switch group is 2; when the number is 2, it is determined that the port and the second switch learn the MAC of the port by itself. The port of the address is directly connected. Otherwise, it is determined that the number of the second switches directly connected to the port is more than one, or that the second switch learns that the port of the port is not directly connected.
为了准确的确定交换机间的连接拓朴关系,在本发明实施例中, 所述拓朴关系确定模块, 还用于当确定自身该端口对应的关联交换机组中每台第二交换机学习到该第一交换机该端口 MAC地址的端口、对应的关联交换机组中剩余的交换机的数量都不为 2时, 确定所述每台第 二交换机学习到自身该端口 MAC地址的端口对应的关联交换机组中剩余的交换机的交集; 根据该剩余的交换机的交集中每台第二交换机学习到该第一交换机该端口 MAC地址的端口, 确定自身的该端口与该交集中每台第二交换机学习到自身该端口 MAC地址的端口直接连接, 且该交集中的剩余交换机之间通过共享链路连接。  In order to accurately determine the connection topology between the switches, in the embodiment of the present invention, the topology relationship determining module is further configured to: when determining that the second switch in the associated switch group corresponding to the port is learned by the second switch When the number of the ports of the port MAC address of the switch and the number of the remaining switches in the corresponding associated switch group are not 2, it is determined that each of the second switches learns the remaining switch group corresponding to the port of the port MAC address of the port. The intersection of the switches; according to the intersection of the remaining switches, each second switch learns the port of the port MAC address of the first switch, determines that the port of the first switch and each second switch in the intersection learns the port of the port The ports of the MAC address are directly connected, and the remaining switches in the intersection are connected by a shared link.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述发送模块, 具体用 于按照设定的周期, 通过自身的每个 LINK UP端口发送 MAC通知报文; 或, 当自身被开启 时、 或接收到 link up或接收到 link down消息时, 通过自身的每个 LINK UP端口发送 MAC 通知艮文。  In the embodiment of the present invention, the sending module is specifically configured to send a MAC notification message through each LINK UP port of the switch according to a set period; or, When it is turned on, or receives a link up or receives a link down message, it sends a MAC notification message through each of its own LINK UP ports.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述获取模块, 具体用 于根据返回拓朴收集报文的每台第二交换机的桥 MAC和端口 MAC, 确定该第二交换机位于 该端口的关联交换机组中, 并通过拓朴收集报文中携带的第二交换机的桥 MAC和端口 MAC 以及第二交换机学习的 MAC地址,计算每个第二交换机学习到第一交换机端口 MAC或者桥 MAC的端口对应的关联交换机组及非关联交换机组的信息。 In the embodiment of the present invention, the acquiring module is specifically used to accurately determine the connection topology relationship between the switches. The second switch is located in the associated switch group of the port, and the bridge of the second switch carried in the packet is collected by the topology, according to the bridge MAC address and the port MAC of each second switch that collects the packet. The MAC and the port MAC and the MAC address learned by the second switch calculate information about the associated switch group and the non-associated switch group corresponding to the port of the first switch port MAC or the bridge MAC.
本发明实施例提供了一种获取设备间拓朴关系的系统, 所述系统包括上述装置, 及向所 述装置返回拓朴收集报文的至少一台第二交换机。  An embodiment of the present invention provides a system for acquiring a topology relationship between devices, where the system includes the foregoing apparatus, and at least one second switch that returns a topology collection message to the apparatus.
为了防止风暴的发生, 减少带宽资源的浪费, 所述第二交换机, 还用于接收到该 MAC 通知报文时, 判断自身是否学习到所述 MAC通知报文中的 MAC地址; 当学习到所述 MAC 地址时, 停止转发该 MAC通知艮文, 否则, 转发该 MAC通知艮文。  In order to prevent the occurrence of a storm and reduce the waste of bandwidth resources, the second switch is further configured to determine whether the MAC address in the MAC notification message is learned by the second switch when receiving the MAC notification message; When the MAC address is described, the MAC notification message is stopped. Otherwise, the MAC notification message is forwarded.
本发明实施例提供了一种获取设备间拓朴连接关系的方法、 系统及装置, 该方法中第一 交换机通过自身的每个 LINK UP端口发送目的地址和源地址都为该端口 MAC地址的 MAC 通知 ·ί艮文, 从而确定自身及组网中每台第二交换机的每个端口对应的关联交换机组和非关联 交换机组的信息,针对每个端口当其对应的关联交换机组中包含的第二交换机的数量为 2时, 则确定第一交换机的该端口与该关联交换机组中第二交换机学习到自身该端口 MAC地址的 端口直接连接, 当其对应的关联交换机组中包含的第二交换机的数量不为 2时, 根据该关联 交换机组中去除第一交换机该端口对应的非关联交换机组后剩余的交换机数量是否为 2 , 根 据该数量是否为 2, 确定该第一交换机的该端口是否与该剩余的交换机直接连接。 由于在本 发明实施例中每台交换机通过自身的每个 LINK UP端口发送 MAC通知报文, 并根据关联交 换机组及非关联交换机组中每台交换机的信息, 确定交换机端口间的连接关系, 从而实现了 设备间拓朴连接关系的确定。  The embodiment of the invention provides a method, a system and a device for acquiring a topology connection relationship between devices. In the method, the first switch sends a MAC address of the MAC address of the port by using the LINK UP port of the first switch. Notifying the · 艮 ,, to determine the information of the associated switch group and the non-associated switch group corresponding to each port of each second switch in the network and the network, for each port, the corresponding switch group included in the corresponding switch group When the number of the two switches is 2, it is determined that the port of the first switch is directly connected to the port of the associated switch group that learns the MAC address of the port, and the second switch included in the corresponding associated switch group. If the number of switches is not 2, according to whether the number of switches remaining in the associated switch group after removing the non-associated switch group corresponding to the port of the first switch is 2, according to whether the number is 2, determining whether the port of the first switch is Directly connected to the remaining switches. In the embodiment of the present invention, each switch sends a MAC notification message through each LINK UP port of the switch, and determines the connection relationship between the switch ports according to the information of each switch in the associated switch group and the non-associated switch group. The determination of the topology connection relationship between devices is realized.
上述说明仅是本发明技术方案的概述, 为了能够更清楚了解本发明的技术手段, 而可依 照说明书的内容予以实施, 并且为了让本发明的上述和其它目的、 特征和优点能够更明显易 懂, 以下特举本发明的具体实施方式。 附图说明 图 1为现有技术中确定交换机拓朴连接关系的示意图;  The above description is only an overview of the technical solutions of the present invention, and the technical means of the present invention can be more clearly understood, and can be implemented in accordance with the contents of the specification, and the above and other objects, features and advantages of the present invention can be more clearly understood. Specific embodiments of the invention are set forth below. BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a schematic diagram of determining a topology connection relationship of a switch in the prior art;
图 2为本发明实施例提供的一种获取设备间拓朴连接关系的过程图;  2 is a process diagram of acquiring a topology connection relationship between devices according to an embodiment of the present invention;
图 3为本发明实施例提供的一种交换机间的拓朴连接结构示意图;  FIG. 3 is a schematic structural diagram of topology connection between switches according to an embodiment of the present disclosure;
图 4为本发明实施例提供的一种获取设备间拓朴连接关系的详细过程图;  FIG. 4 is a detailed process diagram of acquiring a topology connection relationship between devices according to an embodiment of the present invention;
图 5为本发明实施例提供的一种交换机间的拓朴连接结构示意图;  FIG. 5 is a schematic structural diagram of topology connection between switches according to an embodiment of the present disclosure;
图 6为本发明实施例提供了一种获取设备间拓朴连接关系的装置结构示意图。  FIG. 6 is a schematic structural diagram of an apparatus for acquiring a topology connection relationship between devices according to an embodiment of the present invention.
图 7本发明实施例提供了一种获取设备间拓朴关系的系统结构示意图。 具体实施方式 为了确定设备间的拓朴连接关系, 本发明实施例提供了一种获取设备间拓朴连接关系的 方法、 系统及装置。 FIG. 7 is a schematic structural diagram of a system for acquiring a topology relationship between devices according to an embodiment of the present invention. The embodiments of the present invention provide a method, system, and apparatus for acquiring a topology connection relationship between devices in order to determine a topology connection relationship between devices.
下面将参照附图更详细地描述本公开的示例性实施例。 虽然附图中显示了本公开的示例 性实施例, 然而应当理解, 可以以各种形式实现本公开而不应被这里阐述的实施例所限制。 相反, 提供这些实施例是为了能够更透彻地理解本公开, 并且能够将本公开的范围完整的传 达给本领域的技术人员。  Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the embodiments of the present invention have been shown in the drawings, it is understood that Rather, these embodiments are provided so that this disclosure will be more fully understood, and the scope of the disclosure can be fully disclosed to those skilled in the art.
下面结合说明附图, 对本发明实施例进行说明。  The embodiments of the present invention will be described below with reference to the accompanying drawings.
图 2为本发明实施例提供的一种获取设备间拓朴连接关系的过程图, 该过程包括以下步 骤:  FIG. 2 is a process diagram of acquiring a topology connection relationship between devices according to an embodiment of the present invention, where the process includes the following steps:
S201 : 第一交换机通过自身的每个 LINK UP端口发送 MAC通知报文,其中, 所述 MAC 通知 4艮文的源地址和目的地址为每个端口的 MAC地址或者所述第一交换机的桥 MAC。  S201: The first switch sends a MAC notification message through each LINK UP port of the MAC address, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge MAC address of the first switch. .
在本发明实施例中, 组网中的每台交换机都会通过自身的每个 LINK UP端口发送 MAC 通知报文,该 MAC通知报文的源地址和目的地址都是该端口的 MAC地址或者所述第一交换 机的桥 MAC。 这样的通知报文被其他的交换机接收到后, 不会上 CPU处理, 但是能被学习 到。  In the embodiment of the present invention, each switch in the network sends a MAC notification message through each LINK UP port of the network, and the source address and the destination address of the MAC notification packet are both the MAC address of the port or the The bridge MAC of the first switch. After such notification message is received by other switches, it will not be processed by the CPU, but can be learned.
该 MAC通知报文可以是按照设定的时间周期发送的, 或者按照其他的方式发送的。 The MAC notification message may be sent according to a set time period or sent in other manners.
S202:根据第二交换机返回的拓朴收集报文,获取第二交换机的桥 MAC和端口 MAC以 及第二交换机学习的 MAC地址, 并计算自身及组网中每台第二交换机学习到第一交换机端 口 MAC或者桥 MAC的端口对应的关联交换机组 , 及非关联交换机组的信息。 S202: Acquire, according to the topology collection packet returned by the second switch, the bridge MAC address and the port MAC of the second switch, and the MAC address learned by the second switch, and calculate the first switch of each second switch in the self and the network. Information about the associated switch group corresponding to the port MAC or bridge MAC port, and the non-associated switch group.
根据向每个端口返回拓朴收集报文的第二交换机, 确定该端口对应的关联交换机组, 在 本发明实施例中将通过某一端口返回拓朴收集报文的交换机, 作为该端口对应的关联交换机 组中的交换机。 例如某一第二交换机通过第一交换机的端口 1返回了拓朴收集报文, 即可确 定该第二交换机位于该端口 1对应的关联交换机组中, 另外每台交换机的自身也位于其每个 端口对应的关联交换机组中。 根据配置的拓朴收集范围内包含的每个第二交换机的信息, 以 及关联交换机中每台交换机的信息, 即可确定非关联交换机组中的信息。  According to the second switch that returns the topology collection packet to each port, the associated switch group corresponding to the port is determined. In the embodiment of the present invention, the switch that returns the topology collection packet through a certain port is used as the corresponding port. Associate switches in the switch group. For example, if a second switch returns a topology collection packet through port 1 of the first switch, it can be determined that the second switch is located in the associated switch group corresponding to the port 1, and each switch itself is also located in each of the switches. The associated switch group corresponding to the port. The information in the non-associated switch group can be determined according to the information of each second switch included in the configured topology collection area and the information of each switch in the associated switch.
另外, 在本发明实施例中为了实现拓朴关系的获取, 第一交换机需要获知其他交换机的 关联交换机组及非关联交换机组中包含的交换机的信息, 因此如果其他交换机已经获取了自 身的每个 LINK UP端口对应的关联交换机组及非关联交换机组的信息,在向第一交换机返回 拓朴收集信息时, 将自身每个端口对应的关联交换机组及非关联交换机组的信息返回第一交 换机, 如果当前该其他交换机还未获取其每个端口对应的关联交换机组及非关联交换机组的 信息, 后续通过其他 ·ί艮文将其每个端口对应的关联交换机组及非关联交换机组的信息告知第 一交换机, 最后保证每台交换机中都保存有自身及其他交换机每个端口对应的关联交换机组 及非关联交换机组的信息。 In addition, in the embodiment of the present invention, in order to obtain the topology relationship, the first switch needs to know the information of the switches included in the associated switch group and the non-associated switch group of other switches, so if other switches have acquired each of their own When the information about the associated switch group and the non-associated switch group corresponding to the LINK UP port is returned to the first switch, the information about the associated switch group and the non-associated switch group corresponding to each port is returned to the first switch. If the other switch does not currently obtain the associated switch group and non-associated switch group corresponding to each port thereof. The information is forwarded to the first switch through the information of the associated switch group and the non-associated switch group corresponding to each port, and finally ensures that each switch has its own association with each port of the other switch. Information about switch groups and non-associative switch groups.
S203: 第一交换机针对自身的每个 LINK UP端口, 判断该端口对应的关联交换机组中包 含的第二交换机的数量是否为 2, 当判断结果为是时, 进行步骤 S204, 否则, 进行步骤 S205。  S203: The first switch determines, for each LINK UP port of the port, whether the number of the second switches included in the associated switch group corresponding to the port is 2. If the determination result is yes, go to step S204; otherwise, go to step S205. .
S204: 根据该关联交换机组中包含的第二交换机学习到自身该端口的 MAC地址的端口, 确定自身的该端口与该第二交换机学习到自身该端口的 MAC地址的端口直接连接。  S204: According to the port that the second switch included in the associated switch group learns the MAC address of the port, determine that the port is directly connected to the port on which the second switch learns the MAC address of the port.
第一交换机在确定自身每个端口与哪台交换机的哪个端口直接连接时, 针对该端口对应 的关联交换机组中包含的交换机的数量进行判断。 当该端口对应的关联交换机组中只包含 2 台交换机时, 说明该第一交换机与该台交换机直接连接, 根据其互相学习到对端的 MAC地 址的端口, 确定该两台交换机端口之间的连接关系。  When the first switch determines which port of each switch is directly connected to each port, the first switch determines the number of switches included in the associated switch group corresponding to the port. When the associated switch group corresponding to the port contains only two switches, the first switch is directly connected to the switch, and the ports between the two switch ports are determined according to the ports that learn the MAC address of the peer. relationship.
S205: 针对该关联交换机组中包含的每台第二交换机, 确定该第二交换机学习到自身该 端口 MAC地址的端口,判断对应该学习到自身该端口 MAC地址的端口的关联交换机组中排 除第一交换机该端口对应的非关联交换机组中的每台第二交换机后 , 该关联交换机组中剩余 的交换机数量是否为 2, 当判断结果为是时, 进行步骤 S206, 否则, 进行步骤 S207。  S205: For each second switch included in the associated switch group, determine that the second switch learns the port of the port MAC address of the port, and determines that the associated switch group corresponding to the port that learns the MAC address of the port is excluded. After the second switch of the non-associated switch group corresponding to the port, the number of the remaining switches in the associated switch group is 2, and if the determination result is yes, the process proceeds to step S206; otherwise, the process proceeds to step S207.
S206: 确定自身的该端口与该第二交换机学习到自身该端口 MAC地址的端口直接连接。 S206: Determine that the port of the port is directly connected to the port that the second switch learns the MAC address of the port.
S207: 确定与该端口直接连接的第二交换机的数量不止 1台或者与该第二交换机学习到 的自身该端口 MAC地址的端口非直接连接。 S207: Determine that the number of the second switches directly connected to the port is not more than one or is not directly connected to the port of the port that is learned by the second switch.
当第一交换机该端口对应的关联交换机组中包含的交换机的数量不为 2时, 即包括至少 两台交换机时, 为了确定与第一交换机的该端口直连的交换机, 在本发明实施例中还要结合 第一交换机该端口对应的非关联交换机组的信息,确定该第一交换机的该端口直连的交换机。  In the embodiment of the present invention, when the number of switches included in the associated switch group corresponding to the port of the first switch is not 2, that is, when at least two switches are included, in order to determine the switch directly connected to the port of the first switch, The switch of the first switch directly connected to the port is determined by combining the information of the non-associated switch group corresponding to the port of the first switch.
由于在本发明实施例中每台交换机通过自身的每个 LINK UP端口发送 MAC通知报文, 并根据关联交换机组及非关联交换机组中每台交换机的信息,确定交换机端口间的连接关系, 从而实现了设备间拓朴连接关系的确定。  In the embodiment of the present invention, each switch sends a MAC notification message through each LINK UP port of the switch, and determines the connection relationship between the switch ports according to the information of each switch in the associated switch group and the non-associated switch group. The determination of the topology connection relationship between devices is realized.
在本发明实施例中每台交换机定期通过自身的每个 LINK UP 端口向其他交换机发送 MAC通知 4艮文, 并将该 MAC通知 ·ί艮文的源地址和目的地址都设置为该端口的 MAC地址。 接收到 4艮文的交换机在处理该 MAC通知 4艮文时,不会将该 MAC通知 4艮文发送到 CPU处理, 但是该 MAC通知报文中的 MAC地址可以被该交换机的该端口学习到。  In the embodiment of the present invention, each switch periodically sends a MAC notification message to each switch through each LINK UP port of its own, and sets the source address and destination address of the MAC notification address to the MAC address of the port. address. The switch receiving the message will not send the MAC notification message to the CPU when processing the MAC notification message, but the MAC address in the MAC notification message can be learned by the port of the switch. .
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述计算自身及组网中 每台第二交换机学习到第一交换机端口 MAC地址或者桥 MAC的端口对应的关联交换机组, 及非关联交换机组的信息包括:  In an embodiment of the present invention, the computing switch itself learns the associated switch group corresponding to the MAC address of the first switch port or the port of the bridge MAC in the second switch of the network. , and information about non-associative switch groups includes:
所述第一交换机根据返回拓朴响应报文的每台第二交换机的桥 MAC和端口 MAC地址, 确定该第二交换机位于该端口的关联交换机组中, 并通过拓朴收集报文中携带的第二交换机 的桥 MAC和端口 MAC以及第二交换机学习的 MAC地址, 计算每个第二交换机学习到第一 交换机端口 MAC或者桥 MAC的端口对应的关联交换机组及非关联交换机组的信息。 The first switch is configured according to a bridge MAC address and a port MAC address of each second switch that returns a topology response message. Determining that the second switch is located in the associated switch group of the port, and collecting the bridge MAC and port MAC of the second switch carried in the packet and the MAC address learned by the second switch, and calculating that each second switch learns Information about the associated switch group and the non-associated switch group corresponding to the port of the first switch port MAC or the bridge MAC.
为了防止风暴, 减少网络带宽资源的占用, 在本发明实施例中, 所述第一交换机通过自 身的每个 LINK UP端口发送 MAC通知 4艮文包括:  In the embodiment of the present invention, the first switch sends a MAC notification through each LINK UP port of the user in the embodiment of the present invention.
所述第一交换机通过自身的每个 LINK UP端口发送 MAC通知报文, 接收到该 MAC通 知报文的第二交换机判断自身是否学习到所述 MAC通知报文中的 MAC地址;  The first switch sends a MAC notification message through each of its own LINK UP ports, and the second switch that receives the MAC notification message determines whether it learns the MAC address in the MAC notification message.
当第二交换机学习到所述 MAC地址时, 第二交换机停止转发该 MAC通知 ·ί艮文, 否则, 第二交换机学习该 MAC地址并转发该 MAC通知 4艮文。  When the second switch learns the MAC address, the second switch stops forwarding the MAC notification, otherwise, the second switch learns the MAC address and forwards the MAC notification.
在本发明实施例中, 当第二交换机已经学习到 MAC通知报文中的 MAC地址时, 根据 bridge转发原理,该第二交换机将停止转发该 MAC通知报文, 不会对网络中其他设备产生影 响, 防止了网络风暴, 同时减少了网络带宽的占用。  In the embodiment of the present invention, when the second switch has learned the MAC address in the MAC notification packet, the second switch will stop forwarding the MAC notification packet according to the bridge forwarding principle, and will not generate other MAC addresses in the network. Impact, preventing network storms while reducing network bandwidth usage.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述第一交换机通过自 身的每个 LINK UP端口发送 MAC通知 4艮文包括:  In order to accurately determine the connection topology relationship between the switches, in the embodiment of the present invention, the first switch sends a MAC notification by using each LINK UP port of the switch.
所述第一交换机按照设定的周期, 通过自身的每个 LINK UP端口发送 MAC通知报文; 或,  The first switch sends a MAC notification message through each of its LINK UP ports according to a set period; or
当所述第一交换机被开启时、 或接收到 link up或接收到 link down消息时, 通过自身的 每个 LINK UP端口发送 MAC通知 4艮文。  When the first switch is turned on, or receives a link up or receives a link down message, the MAC notification is sent through each of its own LINK UP ports.
具体的,在本发明实施例中 MAC通知 4艮文的发送周期可以根据 MAC地址的老化时间来 确定, 以防止 MAC地址老化后无法及时获取正确的拓朴连接, 例如可以为 MAC地址老化时 间的 1/3 , 或者可以为 MAC地址老化时间的 1/2。  Specifically, in the embodiment of the present invention, the sending period of the MAC notification message may be determined according to the aging time of the MAC address, so as to prevent the MAC address from aging, and the correct topology connection cannot be obtained in time. 1/3, or 1/2 of the aging time of the MAC address.
另外, 当交换机刚被启动时, 或者端口刚刚 up发送 link up报文时, 再或者当环路切换 删除 MAC地址放 link down消息时, 为了及时快速的获取设备间的拓朴连接关系, 网络中的 每个第一交换机通过自身的每个 LINK UP端口发送 MAC通知 4艮文。  In addition, when the switch is just started, or when the port just sends up the link up message, or when the loop switch deletes the MAC address and puts the link down message, in order to quickly and quickly obtain the topology connection relationship between the devices, the network Each of the first switches sends a MAC notification through each of its own LINK UP ports.
本发明实施例中通过发送 MAC通知 4艮文, 并通过 snmp的 ifPhys Address获取每台交换 机的桥 MAC及每个端口的 MAC地址,通过 dotldTpFdbPort和 dot IdTpFdb Status节点逐条获 取交换机学习到的所有 MAC地址及其对应的 port和学习状态。  In the embodiment of the present invention, the MAC address is sent by the MAC notification, and the bridge MAC of each switch and the MAC address of each port are obtained through the ifPhys Address of the snmp, and all the MAC addresses learned by the switch are obtained one by one through the dotldTpFdbPort and the dot IdTpFdb Status node. And its corresponding port and learning state.
下面结合一个具体的实施例, 对本发明的上述实施过程进行说明。  The above-described implementation process of the present invention will be described below in conjunction with a specific embodiment.
图 3为本发明实施例提供的一种交换机间的拓朴连接结构示意图, 在图 3中每台交换机 都有自身的 IP 地址, 交换机 1 ( S1 ) 〜交换机 7 ( S7 ) 每台设备的 IP 地址分别为 192.168.0. 〜 192.168.0.7, 在图 3中 S5、 Sl、 S2、 S3和 S6依次连接, 并且 S2与 S4和 S7依 次连接。 图 3中的每台交换机通过自身的每个 LINK UP端口发送 MAC通知报文, 根据每台 第二交换机向每个端口返回的拓朴收集报文,获取第二交换机的桥 MAC和端口 MAC以及第 二交换机学习的 MAC地址, 并计算自身及组网中的每台第二交换机学习到第一交换机端口 MAC或者桥 MAC的端口对应的关联交换机组 , 及非关联交换机组的信息。 FIG. 3 is a schematic diagram of a topology connection structure between switches according to an embodiment of the present invention. In FIG. 3, each switch has its own IP address, and the IP of each device of switch 1 (S1) to switch 7 (S7) The addresses are respectively 192.168.0.~ 192.168.0.7. In Fig. 3, S5, Sl, S2, S3 and S6 are sequentially connected, and S2 is sequentially connected with S4 and S7. Each switch in Figure 3 sends a MAC notification message through each of its own LINK UP ports, according to each The second switch returns a topology collection packet to each port, obtains a bridge MAC address and a port MAC of the second switch, and learns a MAC address of the second switch, and calculates each second switch in the self and the network to learn the first Information about the associated switch group corresponding to the port of the switch port MAC or bridge MAC, and the non-associated switch group.
计算的每台交换机的每个端口对应的关联交换机组及非关联交换机组的信息如下表:  The information about the associated switch group and non-associative switch group corresponding to each port of each switch is as follows:
Figure imgf000010_0001
Figure imgf000010_0001
SI作为第一交换机在确定其每个端口直接连接的第二交换机时, S1针对端口 1对应的关 联交换机组, 判断其关联交换机组中包含 6台交换机, 该关联交换机组中包含的交换机分别 为 Sl、 S2、 S3、 S4、 S6、 S7, SI在该关联交换机组中任意选择一台非自身的交换机, 或者 选择 IP地址最小的非自身的交换机进行判断。 在本发明实施例中在该关联交换机组中 S2的 IP地址除 S1以外最小, S1首先判断其端口 1是否与 S2连接。 When the SI is used as the first switch to determine the second switch directly connected to each port, S1 determines that the associated switch group includes six switches for the associated switch group corresponding to port 1. The switches included in the associated switch group are respectively Sl, S2, S3, S4, S6, S7, SI arbitrarily select a non-self switch in the associated switch group, or select a non-self switch with the smallest IP address to judge. In the embodiment of the present invention, the IP address of S2 in the associated switch group is the smallest except S1, and S1 first determines whether its port 1 is connected to S2.
S1查找 S2学习到其 MAC地址的端口为端口 2, S1端口 1对应的非关联交换机组中包 含有 S5 , 在 S2端口 2对应的关联交换机组中去除 S5后, 该 S2端口 2对应的关联交换机组 中剩余交换机 S1和 S2, 因此可知, S1与 S2连接, 具体的 S1的端口 1与 S2的端口 2直接 连接。在此 S1已经找到了与其端口 1直连的交换机, 因此不再针对其端口 1对应的关联交换 机组中的其他交换机继续进行判断。  S1 finds that the port whose S2 learns its MAC address is port 2, and the non-associated switch group corresponding to S1 port 1 includes S5. After S5 is removed from the associated switch group corresponding to S2 port 2, the associated switch corresponding to S2 port 2 The switches S1 and S2 remain in the group. Therefore, it can be seen that S1 is connected to S2, and port 1 of the specific S1 is directly connected to port 2 of S2. Here, S1 has found a switch that is directly connected to its port 1, so it does not continue to judge other switches in the associated switching group corresponding to its port 1.
之后, S 1针对自身的端口 2进行判断, 因为端口 2此时对应的关联交换机组中只包含两 台交换机, 该两台交换机分别为 S1和 S2, 因此可以确定 S1和 S5直连, 具体的 S5学习到 S1的 MAC地址的端口是端口 1 , 因此 S1的端口 2与 S5的端口 5直接连接。 S2作为第一交换机在确定其每个端口连接的第二交换机时, S2针对其端口 1对应的关联 交换机组, 判断其对应的关联交换机组中包含的交换机的数量不为 2, 针对该关联交换机组 中的任意除自身之外的交换机进行判断, 例如针对交换机 S6, S6学习到 S2的 MAC地址的 端口为其端口 2, 在 S6对应的关联交换机组( Sl、 S2、 S3、 S4、 S5、 S6、 S7 ) 中去除 S2的 端口 1对应的非关联交换机组( Sl、 S4、 S5、 S7 ) 中交换机, 剩余的交换机为 S2、 S3和 S6, 即其剩余的交换机的数量不为 2, 因此可知 S2的端口 1与 S6的端口 2非直接连接。 需要继 续针对 S2的端口 1对应的关联交换机组中的其他交换机进行判断。 S2的端口 1对应的关联 交换机组中还包括交换机 S3 , S3学习到 S2的 MAC地址的端口为端口 2, 将 S3端口 2对应 的关联交换机组( Sl、 S2、 S3、 S4、 S5、 S7 )中去除 S2的端口 1对应的非关联交换机组( Sl、 S4、 S5、 S7 ) 中的交换机后, 剩余交换机为 S2和 S3 , 其剩余的交换机的数量为 2, 因此可 知, S2的端口 1与 S3的端口 2之间直接连接。 After that, S1 judges its own port 2, because port 2 corresponds to only two switches in the associated switch group. The two switches are S1 and S2 respectively, so it can be determined that S1 and S5 are directly connected. S5 learns that the port of S1's MAC address is port 1, so port 2 of S1 is directly connected to port 5 of S5. When S2 is used as the first switch to determine the second switch to which each port is connected, S2 determines, for the associated switch group corresponding to port 1, that the number of switches included in the corresponding associated switch group is not 2, for the associated switch. Any switch other than itself in the group judges, for example, for the switch S6, S6 learns that the port of the S2 MAC address is its port 2, and the associated switch group corresponding to S6 (S1, S2, S3, S4, S5, S6, S7) removes the switch in the non-associated switch group (S1, S4, S5, S7) corresponding to port 1 of S2, and the remaining switches are S2, S3, and S6, that is, the number of remaining switches is not 2, so It can be seen that port 1 of S2 is not directly connected to port 2 of S6. It is necessary to continue to judge other switches in the associated switch group corresponding to port 1 of S2. The associated switch group corresponding to port 1 of S2 also includes switch S3. S3 learns that the port of S2's MAC address is port 2, and the associated switch group corresponding to S3 port 2 (S1, S2, S3, S4, S5, S7) After removing the switches in the non-associated switch groups (S1, S4, S5, and S7) corresponding to port 1 of S2, the remaining switches are S2 and S3, and the number of remaining switches is 2. Therefore, it can be seen that port 1 of S2 is The port 2 of S3 is directly connected.
依次釆用上述方法每台交换机将自身作为第一交换机, 该第一交换机针对自身的每个 LINK UP端口进行判断, 判断自身每个端口与其他交换机端口之间的连接关系。  Each switch adopts the above method as the first switch, and the first switch judges each LINK UP port of its own, and determines the connection relationship between each port and other switch ports.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 当第一交换机该端口对 应的关联交换机组中每台第二交换机学习到该第一交换机该端口 MAC地址的端口、 对应的 关联交换机组中剩余的交换机的数量都不为 2时, 所述方法还包括:  In order to accurately determine the connection topology relationship between the switches, in the embodiment of the present invention, each of the second switches in the associated switch group corresponding to the port of the first switch learns the port of the MAC address of the port of the first switch, and corresponds to When the number of the remaining switches in the associated switch group is not 2, the method further includes:
确定所述每台第二交换机学习到自身该端口 MAC地址的端口对应的关联交换机组中剩 余的交换机的交集;  Determining, by each of the second switches, an intersection of the remaining switches in the associated switch group corresponding to the port of the MAC address of the port;
根据该剩余的交换机的交集中每台第二交换机学习到该第一交换机该端口 MAC地址的 端口, 确定自身的该端口与该交集中每台第二交换机学习到自身该端口 MAC地址的端口直 接连接, 且该交集中的剩余交换机之间通过共享链路连接。  According to the port of the remaining switch, each second switch learns the port of the MAC address of the port of the first switch, and determines that the port itself and the second switch in the intersection learn the port of the MAC address of the port directly Connected, and the remaining switches in the intersection are connected by a shared link.
图 4为本发明实施例提供的一种获取设备间拓朴连接关系的详细过程图, 该过程包括以 下步骤:  FIG. 4 is a detailed process diagram of acquiring a topology connection relationship between devices according to an embodiment of the present invention, where the process includes the following steps:
S401 : 第一交换机通过自身的每个 LINK UP端口发送 MAC通知报文,其中, 所述 MAC 通知 4艮文的源地址和目的地址为每个端口的 MAC地址或者所述第一交换机的桥 MAC。  S401: The first switch sends a MAC notification message through each LINK UP port of the MAC address, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge MAC address of the first switch. .
S402: 根据第二交换机向每个端口返回的拓朴收集报文, 获取第二交换机的桥 MAC和 端口 MAC以及第二交换机学习的 MAC地址,并计算自身及组网中每台第二交换机学习到第 一交换机端口 MAC或者桥 MAC的端口对应的关联交换机组 , 及非关联交换机组的信息。  S402: Obtain, according to the topology collection packet returned by the second switch to each port, the bridge MAC address and the port MAC of the second switch, and the MAC address learned by the second switch, and calculate each second switch in the network and the network. Information about the associated switch group corresponding to the port of the first switch port MAC or bridge MAC, and the non-associated switch group.
S403 : 第一交换机针对自身的每个 LINK UP端口, 判断该端口对应的关联交换机组中包 含的第二交换机的数量是否为 2, 当判断结果为是时, 进行步骤 S404, 否则, 进行步骤 S405。  S403: The first switch determines, for each LINK UP port of the port, whether the number of the second switches included in the associated switch group corresponding to the port is 2. If the determination result is yes, proceed to step S404; otherwise, proceed to step S405. .
S404: 根据该关联交换机组中包含的第二交换机学习到自身该端口的 MAC地址的端口, 确定自身的该端口与该第二交换机学习到自身该端口的 MAC地址的端口直接连接。 S405: 针对该关联交换机组中包含的每台第二交换机, 确定该第二交换机学习到自身该 端口 MAC地址的端口,判断对应该学习到自身该端口 MAC地址的端口的关联交换机组中排 除第一交换机该端口对应的非关联交换机组中的每台第二交换机后 , 该关联交换机组中剩余 的交换机数量是否为 2, 当判断结果为是时, 进行步骤 S406, 否则, 进行步骤 S407。 S404: According to the port that the second switch included in the associated switch group learns the MAC address of the port, determine that the port is directly connected to the port on which the second switch learns the MAC address of the port. S405: For each second switch included in the associated switch group, determine that the second switch learns the port of the port MAC address of the port, and determines that the associated switch group corresponding to the port that learns the MAC address of the port is excluded. After the second switch of the non-associated switch group corresponding to the port, the number of remaining switches in the associated switch group is 2, and if the determination result is yes, go to step S406; otherwise, go to step S407.
S406: 确定自身的该端口与该第二交换机学习到自身该端口 MAC地址的端口直接连接。 S406: Determine that the port of the port is directly connected to the port that the second switch learns to be the MAC address of the port.
S407: 第一交换机该端口对应的关联交换机组中每台第二交换机学习到该第一交换机该 端口 MAC地址的端口、 对应的关联交换机组中剩余的交换机的数量都不为 2。 S407: The number of ports in the associated switch group corresponding to the port of the first switch that learns the port MAC address of the first switch and the number of remaining switches in the corresponding associated switch group are not 2.
S408: 确定所述每台第二交换机学习到自身该端口 MAC地址的端口对应的关联交换机 组中剩余的交换机的交集。  S408: Determine, by each of the second switches, the intersection of the remaining switches in the associated switch group corresponding to the port of the port whose MAC address is the port.
S409: 根据该剩余的交换机的交集中每台第二交换机学习到该第一交换机该端口 MAC 地址的端口, 确定自身的该端口与该交集中每台第二交换机学习到自身该端口 MAC地址的 端口直接连接, 且该交集中的剩余交换机之间通过共享链路连接。  S409: According to the intersection of the remaining switches, each second switch learns the port of the MAC address of the port of the first switch, and determines that the port and the second switch of the intersection learn the MAC address of the port. The ports are directly connected, and the remaining switches in the intersection are connected by a shared link.
当网络中存在共享链路时, 可能存在交换机的一个端口下面直连的设备有多台, 遍历该 端口对应的所有的关联交换机组中的每台交换机, 都无法满足去除该端口对应的非关联交换 机组中的交换机后数量为 2的情况, 因此此时需要确定去除该端口对应的非关联交换机组中 的交换机后其关联交换机组中剩余的交换机的交集, 在该交集中包含至少两台交换机, 该端 口与该至少两台交换机连接。  When there is a shared link in the network, there may be multiple devices directly connected to one port of the switch. Each switch in the associated switch group corresponding to the port cannot meet the non-association of the corresponding port. The number of switches in the switch group is 2. Therefore, you need to determine the intersection of the switches in the associated switch group after removing the switches in the non-associated switch group corresponding to the port. At least two switches are included in the intersection. , the port is connected to the at least two switches.
下面结合一个具体的实施例, 对本发明进行详细说明。  The invention will now be described in detail in connection with a specific embodiment.
图 5为本发明实施例提供的一种交换机间的拓朴连接结构示意图, 在图 5中存在多台交 换机通过集线器(hub )连接到一台交换机的情形, 具体的, S5、 Sl、 S2、 S3和 S6依次连接, SI通过集线器分别与 S8、 S91连接, 并且 S91连接 S92, S2与 S4和 S7依次连接。 图 5中 的每台交换机通过自身的每个 LINK UP端口发送 MAC通知报文, 根据每台第二交换机向每 个端口返回的拓朴收集报文,获取第二交换机的桥 MAC和端口 MAC以及第二交换机学习的 MAC地址,并计算自身及组网中的每台第二交换机学习到第一交换机端口 MAC或者桥 MAC 的每个端口对应的关联交换机组, 及非关联交换机组的信息。  FIG. 5 is a schematic diagram of a topology connection structure between switches according to an embodiment of the present invention. In FIG. 5, a plurality of switches are connected to a switch through a hub, specifically, S5, Sl, and S2. S3 and S6 are sequentially connected, SI is connected to S8 and S91 through a hub, and S91 is connected to S92, and S2 is sequentially connected to S4 and S7. Each switch in FIG. 5 sends a MAC notification packet through each LINK UP port of its own, and obtains a bridge MAC and a port MAC of the second switch according to the topology collection packet returned by each second switch to each port. The second switch learns the MAC address, and calculates information about the associated switch group corresponding to each port of the first switch port MAC or the bridge MAC and the non-associated switch group by each second switch in the network and the network.
计算的每台交换机的每个端口对应的关联交换机组及非关联交换机组的信息如下表:  The information about the associated switch group and non-associative switch group corresponding to each port of each switch is as follows:
 Mountain
交换 关联交换机组 非关联交换机组  Exchange associated switch group non-associative switch group
机 V Machine V
S1 1 Sl、 S2、 S3、 S4、 S6、 S7 S5、 S8、 S91、 S92  S1 1 Sl, S2, S3, S4, S6, S7 S5, S8, S91, S92
2 Sl、 S5 S2、 S3、 S4、 S6、 S7、 S8、  2 Sl, S5 S2, S3, S4, S6, S7, S8,
S91、 S92  S91, S92
3 Sl、 S8、 S91、 S92 S2、 S3、 S4、 S5、 S6、 S7 S2 1 S2、 S3、 S6 Sl、 S4、 S5、 S7、 S8、 S91、 3 Sl, S8, S91, S92 S2, S3, S4, S5, S6, S7 S2 1 S2, S3, S6 Sl, S4, S5, S7, S8, S91,
S92  S92
2 Sl、 S2、 S5、 S8、 S91、 S92 S3、 S4、 S6、 S7  2 Sl, S2, S5, S8, S91, S92 S3, S4, S6, S7
3 S2、 S4、 S7 Sl、 S3、 S5、 S6、 S8、 S91、  3 S2, S4, S7 Sl, S3, S5, S6, S8, S91,
S92  S92
S3 1 S3、 S6 Sl、 S2、 S4、 S5、 S7、 S8、  S3 1 S3, S6 Sl, S2, S4, S5, S7, S8,
S91、 S92  S91, S92
2 Sl、 S2、 S3、 S4、 S5、 S7、 S8、 S6  2 Sl, S2, S3, S4, S5, S7, S8, S6
S91、 S92  S91, S92
S4 1 S4、 S7 Sl、 S2、 S3、 S5、 S6、 S8、  S4 1 S4, S7 Sl, S2, S3, S5, S6, S8,
S91、 S92  S91, S92
4 Sl、 S2、 S3、 S4、 S5、 S6、 S8、 S7  4 Sl, S2, S3, S4, S5, S6, S8, S7
S91、 S92  S91, S92
S5 1 Sl、 S2、 S3、 S4、 S5、 S6、 S7、  S5 1 Sl, S2, S3, S4, S5, S6, S7,
S8、 S91、 S92  S8, S91, S92
S6 2 Sl、 S2、 S3、 S4、 S5、 S6、 S7、  S6 2 Sl, S2, S3, S4, S5, S6, S7,
S8、 S91、 S92  S8, S91, S92
S7 2 Sl、 S2、 S3、 S4、 S5、 S6、 S7、  S7 2 Sl, S2, S3, S4, S5, S6, S7,
S8、 S91、 S92  S8, S91, S92
S8 4 Sl、 S2、 S3、 S4、 S5、 S6、 S7、  S8 4 Sl, S2, S3, S4, S5, S6, S7,
S8、 S91、 S92  S8, S91, S92
S91 3 S91、 S92 Sl、 S2、 S3、 S4、 S5、 S6、  S91 3 S91, S92 Sl, S2, S3, S4, S5, S6,
S7、 S8  S7, S8
4 Sl、 S2、 S3、 S4、 S5、 S6、 S7、 S92  4 Sl, S2, S3, S4, S5, S6, S7, S92
S8、 S91  S8, S91
S92 4 Sl、 S2、 S3、 S4、 S5、 S6、 S7、  S92 4 Sl, S2, S3, S4, S5, S6, S7,
S8、 S91、 S92  S8, S91, S92
SI作为第一交换机在确定其每个端口连接的第二交换机时, S1针对端口 1对应的关联交 换机组,判断其关联交换机组中包含 6台交换机,该关联交换机组中包含的交换机分别为 Sl、 S2、 S3、 S4、 S6、 S7, SI 在该关联交换机组中任意选择一台非自身的交换机, 或者选择 IP 地址最小的非自身的交换机进行判断。 在本发明实施例中在该关联交换机组中 S2的 IP地址 除 S1以外最小, S1首先判断其端口 1是否与 S2连接。 SI查找 S2学习到其 MAC地址的端口为端口 2, SI端口 1对应的非关联交换机组中包 含有 S5 , 在 S2端口 2对应的关联交换机组中去除 S5后, 该 S2端口 2对应的关联交换机组 中剩余交换机 S1和 S2, 因此可知, S1与 S2连接, 具体的 S1的端口 1与 S2的端口 2直接 连接。在此 S1已经找到了与其端口 1直连的交换机, 因此不再针对其端口 1对应的关联交换 机组中的其他交换机继续进行判断。 When the SI is used as the first switch to determine the second switch connected to each port, S1 determines that the associated switch group includes six switches for the associated switch group corresponding to port 1. The switches included in the associated switch group are respectively S1. , S2, S3, S4, S6, S7, SI arbitrarily select a non-self switch in the associated switch group, or select a non-owner switch with the smallest IP address to judge. In the embodiment of the present invention, the IP address of S2 in the associated switch group is the smallest except S1, and S1 first determines whether its port 1 is connected to S2. The SI finds that the port whose S2 learns its MAC address is port 2, and the non-associated switch group corresponding to SI port 1 includes S5. After S5 is removed from the associated switch group corresponding to S2 port 2, the associated switch corresponding to S2 port 2 The switches S1 and S2 remain in the group. Therefore, it can be seen that S1 is connected to S2, and port 1 of the specific S1 is directly connected to port 2 of S2. Here, S1 has found a switch that is directly connected to its port 1, so it does not continue to judge other switches in the associated switch group corresponding to its port 1.
之后, S 1针对自身的端口 2进行判断, 因为端口 2此时对应的关联交换机组中只包含两 台交换机, 该两台交换机分别为 S1和 S2, 因此可以确定 S1和 S5直连, 具体的 S5学习到 S1的 MAC地址的端口是端口 1 , 因此 S1的端口 2与 S5的端口 5直接连接。  After that, S1 judges its own port 2, because port 2 corresponds to only two switches in the associated switch group. The two switches are S1 and S2 respectively, so it can be determined that S1 and S5 are directly connected. S5 learns that the port of S1's MAC address is port 1, so port 2 of S1 is directly connected to port 5 of S5.
然后, S1针对自身的端口 3进行判断, 端口 3对应的关联交换机组中包含交换机 Sl、 S8、 S91和 S92, 其对应的关联交换机组中的交换机数量不为 2, S1 首先查找 S8学习到其 MAC地址的端口为端口 4, 在 S8端口 4对应的关联交换机组( Sl、 S2、 S3、 S4、 S5、 S6、 S7、 S8、 S91、 S92 ) 中去除 SI端口 3对应的非关联交换机组( S2、 S3、 S4、 S5、 S6、 S7 ) 中的交换机, 剩余的交换机为 Sl、 S8、 S91、 S92, 剩余的交换机不为 2。 因此需要继续查找 该端口 3对应的关联交换机组中的其他交换机。  Then, S1 determines for its own port 3. The associated switch group corresponding to port 3 includes switches S1, S8, S91, and S92. The number of switches in the corresponding associated switch group is not 2, and S1 first searches for S8. The port of the MAC address is port 4, and the unassociated switch group corresponding to SI port 3 is removed from the associated switch group (S1, S2, S3, S4, S5, S6, S7, S8, S91, S92) corresponding to S8 port 4 ( For the switches in S2, S3, S4, S5, S6, and S7), the remaining switches are Sl, S8, S91, and S92, and the remaining switches are not 2. Therefore, you need to continue to find other switches in the associated switch group corresponding to port 3.
S1查找 S91学习到其 MAC地址的端口为端口 4,在 S91端口 4对应的关联交换机组( Sl、 S2、 S3、 S4、 S5、 S6、 S7、 S8、 S91 ) 中去除 SI端口 3对应的非关联交换机组( S2、 S3、 S4、 S5、 S6、 S7 ) 中的交换机, 剩余的交换机为 Sl、 S8、 S91 , 剩余的交换机不为 2。 因此 需要继续查找该端口 3对应的关联交换机组中的其他交换机。  S1 finds that the port on which S91 learns its MAC address is port 4, and removes the non-corresponding to SI port 3 in the associated switch group (S1, S2, S3, S4, S5, S6, S7, S8, S91) corresponding to port S91. For the switches in the associated switch group (S2, S3, S4, S5, S6, and S7), the remaining switches are Sl, S8, and S91, and the remaining switches are not 2. Therefore, you need to continue to find other switches in the associated switch group corresponding to port 3.
S1查找 S92学习到其 MAC地址的端口为端口 4,在 S92端口 4对应的关联交换机组( S1、 S1 finds that the port on which S92 learns its MAC address is port 4, and the associated switch group corresponding to port S92 (S1)
52、 S3、 S4、 S5、 S6、 S7、 S8、 S91、 S92 ) 中去除 SI端口 3对应的非关联交换机组( S2、52, S3, S4, S5, S6, S7, S8, S91, S92) remove the non-associated switch group corresponding to SI port 3 (S2)
53、 S4、 S5、 S6、 S7 ) 中的交换机, 剩余的交换机为 Sl、 S8、 S91、 S92, 剩余的交换机不 为 2。 In the switch in S4, S5, S6, and S7), the remaining switches are Sl, S8, S91, and S92, and the remaining switches are not 2.
S1的端口 3对应的关联交换机组中的每台交换机学习到自身 MAC地址的端口, 其对应 的关联交换机组中去除 S1的端口 3对应的非关联交换机组后,剩余的交换机的数量都不为 2, 为了确定出 S1的端口 3与其他交换机的连接关系,在本发明实施例中根据其对应的每台交换 机学习到其 MAC地址的端口对应的关联交换机组中去除 S 1的端口 3对应的非关联交换机组 后, 剩余的交换机的交集, 确定该 S1的端口 3连接的交换机。  Each switch in the associated switch group corresponding to port 3 of S1 learns the port of its own MAC address. After the corresponding associated switch group removes the non-associated switch group corresponding to port 3 of S1, the number of remaining switches is not 2, in order to determine the connection relationship between the port 3 of S1 and other switches, in the embodiment of the present invention, the port corresponding to the port 1 of the S1 is removed from the associated switch group corresponding to the port whose MAC address is learned by each corresponding switch. After the non-associated switch group, the intersection of the remaining switches determines the switch connected to port 3 of the S1.
该 S1的端口 3对应的关联交换机组中 S8学习到 S1的 MAC地址的端口 4对应的关联交 换机组中, 去除 S1的端口 3对应的非关联交换机组后剩余的交换机为 Sl、 S8、 S91、 S92; 其关联交换机组中 S91学习到 S1的 MAC地址的端口 4对应的关联交换机组中, 去除 S1的 端口 3对应的非关联交换机组后剩余的交换机为 Sl、 S8、 S91 ; 其关联交换机组中 S92学习 到 S1的 MAC地址的端口 4对应的关联交换机组中, 去除 S1的端口 3对应的非关联交换机 组后剩余的交换机为 SI、 S8、 S91、 S92, 其交集为 Sl、 S8、 S91 , 因此可以确定 SI与 S8、 S91分别直接连接,具体的 S1的端口 3直接连接 S8的端口 4,并直接连接 S91的端口 4, Sl、 S8、 S91之间通过共享链路连接。 In the associated switch group corresponding to the port 4 of the S1 MAC address of the S3, the S3 learns the S1, and the remaining switches are S1, S8, and S91. S92; in the associated switch group in which the S91 of the associated switch group learns the MAC address of the S1, the remaining switches are the Sl, S8, and S91, and the associated switch group is removed from the unassociated switch group corresponding to the port 3 of the S1; The S92 learns the associated switch group corresponding to port 4 of the MAC address of S1, and removes the non-associated switch corresponding to port 3 of S1. The remaining switches in the group are SI, S8, S91, and S92, and their intersections are S1, S8, and S91. Therefore, it can be determined that SI is directly connected to S8 and S91 respectively. Port 3 of the specific S1 is directly connected to port 4 of S8, and directly Connect to port 4 of S91, and connect Sl, S8, and S91 through a shared link.
S8作为第一交换机在确定自身其每个端口连接的第二交换机时, S8针对端口 4对应的关 联交换机组, 判断其关联交换机组中包含 9台交换机, 该关联交换机组中包含的交换机分别 为 Sl、 S2、 S3、 S4、 S6、 S7、 S8、 S91、 S92, S8在该关联交换机组中任意选择一台非自身 的交换机, 即任意选择一台第二交换机, 或者选择 IP地址最小的非自身的交换机进行判断。 在本发明实施例中在该关联交换机组中 S1的 IP地址最小, S8首先判断其端口 4是否与 S1 连接。  S8 as the first switch determines the second switch connected to each port of the first switch, and S8 determines that the associated switch group includes nine switches for the associated switch group corresponding to the port 4, and the switches included in the associated switch group are respectively Sl, S2, S3, S4, S6, S7, S8, S91, S92, S8 arbitrarily select a non-self switch in the associated switch group, that is, arbitrarily select a second switch, or select the non-IP with the smallest IP address. Its own switch makes judgments. In the embodiment of the present invention, the IP address of S1 is the smallest in the associated switch group, and S8 first determines whether its port 4 is connected to S1.
S8查找 S1学习到其 MAC地址的端口为端口 3 , S8端口 4对应的非关联交换机组为空, S1的端口 3对应的关联交换机组中包括 Sl、 S8、 S91、 S92,  S8 finds that the port on which S1 learns its MAC address is port 3, and the unassociated switch group corresponding to port S8 is empty. The associated switch group corresponding to port 3 of S1 includes Sl, S8, S91, and S92.
在 S 1端口 3对应的关联交换机组中去除空集后, 该 S 1端口 3对应的关联交换机组中剩 余交换机 Sl、 S8、 S91、 S92, 剩余的交换机不为 2。 继续判断与其他交换机之间的连接关系 After the empty set is removed from the associated switch group corresponding to S1 port 3, the remaining switches S1, S8, S91, and S92 in the associated switch group corresponding to S1 port 3, and the remaining switches are not 2. Continue to judge the connection relationship with other switches
S8查找 S2学习到其 MAC地址的端口为端口 2, S2的端口 2对应的关联交换机组中包 括 Sl、 S2、 S5、 S8、 S91、 S92, 在该关联交换机组中去除空集后, 剩余的交换机与 S2的端 口 2对应的关联交换机组中包括的交换机相同, 还是 Sl、 S2、 S5、 S8、 S91、 S92; 基于同样 的方法, S3学习到其 MAC地址的端口 2对应的关联交换机组中去除空集后, 剩余的交换机 为 Sl、 S2、 S3、 S4、 S5、 S7、 S8、 S91、 S92; S4学习到其 MAC地址的端口 4对应的关联 交换机组中去除空集后, 剩余的交换机为 Sl、 S2、 S3、 S4、 S5、 S6、 S8、 S91、 S92; S5学 习到其 MAC地址的端口 1对应的关联交换机组中去除空集后, 剩余的交换机为 Sl、 S2、 S3、S8 finds that the port whose S2 learns its MAC address is port 2, and the associated switch group corresponding to port 2 of S2 includes S1, S2, S5, S8, S91, and S92. After the empty set is removed in the associated switch group, the remaining The switch is the same as the switch included in the associated switch group corresponding to port 2 of S2, or is S1, S2, S5, S8, S91, and S92. Based on the same method, S3 learns the associated switch group corresponding to port 2 of its MAC address. After the empty set is removed, the remaining switches are Sl, S2, S3, S4, S5, S7, S8, S91, S92; S4 learns the MAC address of the associated switch group corresponding to port 4, after removing the empty set, the remaining switches S1, S2, S3, S4, S5, S6, S8, S91, S9; S5 learns that the MAC address of the associated switch group corresponding to port 1 removes the empty set, and the remaining switches are Sl, S2, S3,
54、 S5、 S6、 S7、 S8、 S91、 S92; S6学习到其 MAC地址的端口 2对应的关联交换机组中去 除空集后, 剩余的交换机为 Sl、 S2、 S3、 S4、 S5、 S6、 S7、 S8、 S91、 S92; S7 学习到其 MAC地址的端口 2对应的关联交换机组中去除空集后, 剩余的交换机为 Sl、 S2、 S3、 S4、54. S5, S6, S7, S8, S91, S92; S6 learns that the associated switch group corresponding to port 2 of its MAC address is removed from the associated set, and the remaining switches are Sl, S2, S3, S4, S5, S6, S7, S8, S91, and S92; S7 learns that after removing the empty set from the associated switch group corresponding to port 2 of its MAC address, the remaining switches are Sl, S2, S3, and S4.
55、 S6、 S7、 S8、 S91、 S92; S91学习到其 MAC地址的端口 4对应的关联交换机组中去除 空集后, 剩余的交换机为 Sl、 S2、 S3、 S4、 S5、 S6、 S7、 S8、 S91 ; S92学习到其 MAC地 址的端口 4对应的关联交换机组中去除空集后, 剩余的交换机为 Sl、 S2、 S3、 S4、 S5、 S6、 S7、 S8、 S91、 S92; 55, S6, S7, S8, S91, S92; S91 learns that the associated switch group corresponding to port 4 of its MAC address is removed from the associated set, and the remaining switches are Sl, S2, S3, S4, S5, S6, S7, S8, S91; S92 learns that the associated switch group corresponding to port 4 of its MAC address is removed from the associated set, and the remaining switches are S1, S2, S3, S4, S5, S6, S7, S8, S91, S92;
S8的端口 4对应的关联交换机组中的每台交换机学习到自身 MAC地址的端口, 其对应 的关联交换机组中去除 S8的端口 4对应的非关联交换机组后,剩余的交换机的数量都不为 2, 根据其对应的每台交换机学习到其 MAC地址的端口对应的关联交换机组中去除 S8的端口 4 对应的非关联交换机组后, 剩余的交换机的交集为 Sl、 S8、 S91 , 因此可知, S8与 S1和 S91 直接连接, 具体的根据三台设备学习到对方 MAC地址的端口可知, S8的端口 4直接连接 S1 的端口 3并直接连接 S91的端口 4, S8、 SI和 S91之间通过共享链路连接。 Each switch in the associated switch group corresponding to port 4 of S8 learns the port of its own MAC address. After the corresponding associated switch group removes the non-associated switch group corresponding to port 4 of S8, the number of remaining switches is not 2. After the non-associated switch group corresponding to port 4 of S8 is removed from the associated switch group corresponding to the port whose MAC address is learned by each switch, the intersection of the remaining switches is S1, S8, and S91. S8 is directly connected to S1 and S91. According to the port where the three devices learn the MAC address of the other party, the port 4 of S8 is directly connected to S1. Port 3 is directly connected to port 4 of S91, and S8, SI and S91 are connected by a shared link.
釆用上述方式依次可以确定每个交换机的拓朴连接关系。  In this way, the topology connection relationship of each switch can be determined in turn.
图 6为本发明实施例提供了一种获取设备间拓朴连接关系的装置结构示意图, 所述装置 包括:  FIG. 6 is a schematic structural diagram of an apparatus for acquiring a topology connection relationship between devices according to an embodiment of the present invention, where the apparatus includes:
发送模块 61 ,用于通过自身的每个 LINK UP端口发送 MAC通知报文,其中,所述 MAC 通知 4艮文的源地址和目的地址为每个端口的 MAC地址或者所述第一交换机的桥 MAC; 获取模块 62 , 用于根据第二交换机返回的拓朴收集报文, 获取第二交换机的桥 MAC和 端口 MAC以及第二交换机学习的 MAC地址,并计算自身及组网中每台第二交换机学习到第 一交换机端口 MAC或者桥 MAC的端口对应的关联交换机组 , 及非关联交换机组的信息; 拓朴关系确定模块 63 , 用于针对自身的每个 LINK UP端口, 判断该端口对应的关联交 换机组中包含的第二交换机的数量是否为 2; 当数量为 2时, 根据该关联交换机组中包含的 第二交换机学习到自身该端口的 MAC地址的端口, 确定自身的该端口与该第二交换机学习 到自身该端口的 MAC地址的端口直接连接; 当数量不为 2时, 针对该关联交换机组中包含 的每台第二交换机, 确定该第二交换机学习到自身该端口 MAC地址的端口, 判断对应该学 习到自身该端口 MAC地址的端口的关联交换机组中排除自身的该端口对应的非关联交换机 组中的每台第二交换机后, 该关联交换机组中剩余的交换机数量是否为 2; 当数量为 2时, 确定自身的该端口与该第二交换机学习到自身该端口 MAC地址的端口直接连接, 否则, 确 定与该端口直接连接的第二交换机数量不止 i 台,或者与第二交换机学习到自身该端口 MAC 地址的端口非直接连接。  The sending module 61 is configured to send, by using each of its LINK UP ports, a MAC notification message, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge of the first switch. The obtaining module 62 is configured to obtain, according to the topology collection packet returned by the second switch, the bridge MAC address and port MAC of the second switch, and the MAC address learned by the second switch, and calculate each second in the network and the second switch. The switch learns the associated switch group corresponding to the port of the first switch port MAC or the bridge MAC, and the information of the non-associated switch group; the topology relationship determining module 63 is configured to determine, for each LINK UP port of the switch port, corresponding to the port Whether the number of the second switches included in the associated switch group is 2; when the number is 2, the port corresponding to the MAC address of the port is learned by the second switch included in the associated switch group, and the port is determined by the port The second switch learns that the port of the MAC address of the port is directly connected; when the number is not 2, for the associated switch group Each of the included second switches determines that the second switch learns the port of the port MAC address of the port, and determines the non-associated switch corresponding to the port in the associated switch group of the port that should learn the port of the MAC address of the port. After each second switch in the group, the number of switches remaining in the associated switch group is 2; when the number is 2, it is determined that the port itself is directly connected to the port on which the second switch learns the MAC address of the port. Otherwise, it is determined that the number of second switches directly connected to the port is not only i, or is indirectly connected to the port on which the second switch learns the MAC address of the port.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述拓朴关系确定模块 63 , 还用于当确定自身该端口对应的关联交换机组中每台第二交换机学习到该第一交换机该 端口 MAC地址的端口、 对应的关联交换机组中剩余的交换机的数量都不为 2时, 确定所述 每台第二交换机学习到自身该端口 MAC地址的端口对应的关联交换机组中剩余的交换机的 交集; 根据该剩余的交换机的交集中每台第二交换机学习到该第一交换机该端口 MAC地址 的端口, 确定自身的该端口与该交集中每台第二交换机学习到自身该端口 MAC地址的端口 直接连接, 且该交集中的剩余交换机之间通过共享链路连接。  In order to accurately determine the connection topology relationship between the switches, in the embodiment of the present invention, the topology relationship determining module 63 is further configured to: when determining that the second switch in the associated switch group corresponding to the port is learned by the second switch When the number of ports of the port MAC address of the first switch and the number of remaining switches in the corresponding associated switch group are not 2, it is determined that each of the second switches learns the associated switch group corresponding to the port of the port MAC address of the port. The intersection of the remaining switches; according to the intersection of the remaining switches, each second switch learns the port of the port MAC address of the first switch, determines that the port itself and each second switch in the intersection learns itself The port of the port MAC address is directly connected, and the remaining switches in the intersection are connected by a shared link.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述发送模块 61 , 具体 用于按照设定的周期, 通过自身的每个 LINK UP端口发送 MAC通知报文; 或, 当自身被开 启时、或接收到 link up或接收到 link down消息时,通过自身的每个 LINK UP端口发送 MAC 通知艮文。  In the embodiment of the present invention, the sending module 61 is specifically configured to send a MAC notification message through each LINK UP port of the switch according to a set period; or When it is turned on, or receives a link up or receives a link down message, it sends a MAC notification message through each of its own LINK UP ports.
为了准确的确定交换机间的连接拓朴关系, 在本发明实施例中, 所述获取模块 62, 具体 用于根据返回拓朴收集报文的每台第二交换机的桥 MAC和端口 MAC, 确定该第二交换机位 于该端口的关联交换机组中, 并通过拓朴收集报文中携带的第二交换机的桥 MAC 和端口 MAC以及第二交换机学习的 MAC地址, 计算每个第二交换机学习到第一交换机端口 MAC 或者桥 MAC的端口对应的关联交换机组及非关联交换机组的信息。 In order to accurately determine the connection topology relationship between the switches, in the embodiment of the present invention, the obtaining module 62 is specifically configured to determine, according to the bridge MAC and the port MAC of each second switch that returns the topology collection message. Second switch bit In the associated switch group of the port, the second switch learns the first switch port MAC by calculating the bridge MAC address and port MAC of the second switch carried in the packet and the MAC address learned by the second switch. Or the information of the associated switch group and the non-associated switch group corresponding to the port of the bridge MAC.
图 7本发明实施例提供了一种获取设备间拓朴关系的系统结构示意图, 所述系统包括上 述装置 71 , 及向所述装置返回拓朴收集报文的至少一台第二交换机 72。  FIG. 7 is a schematic structural diagram of a system for acquiring a topology relationship between devices, where the system includes the foregoing device 71, and at least one second switch 72 that returns topology collection packets to the device.
为了防止风暴的发生, 减少带宽资源的浪费,所述第二交换机 72,还用于接收到该 MAC 通知报文时, 判断自身是否学习到所述 MAC通知报文中的 MAC地址; 当学习到所述 MAC 地址时, 停止转发该 MAC通知艮文, 否则, 转发该 MAC通知艮文。  In order to prevent the occurrence of a storm and reduce the waste of bandwidth resources, the second switch 72 is further configured to determine whether the MAC address in the MAC notification packet is learned by the second switch 72. When the MAC address is used, the forwarding of the MAC notification message is stopped, otherwise, the MAC notification message is forwarded.
本发明实施例提供了一种获取设备间拓朴连接关系的方法、 系统及装置, 该方法中第一 交换机通过自身的每个 LINK UP端口发送目的地址和源地址都为该端口 MAC地址的 MAC 通知 ·ί艮文, 从而确定自身及组网中每台第二交换机的每个端口对应的关联交换机组和非关联 交换机组的信息,针对每个端口当其对应的关联交换机组中包含的第二交换机的数量为 2时, 则确定第一交换机的该端口与该关联交换机组中第二交换机学习到自身该端口 MAC地址的 端口直接连接, 当其对应的关联交换机组中包含的第二交换机的数量不为 1时, 根据该关联 交换机组中去除第一交换机该端口对应的非关联交换机组后剩余的交换机数量是否为 2 , 根 据该数量是否为 2, 确定该第一交换机的该端口是否与该剩余的交换机直接连接。 由于在本 发明实施例中每台交换机通过自身的每个 LINK UP端口发送 MAC通知报文, 并根据关联交 换机组及非关联交换机组中每台交换机的信息, 确定交换机端口间的连接关系, 从而实现了 设备间拓朴连接关系的确定。  The embodiment of the invention provides a method, a system and a device for acquiring a topology connection relationship between devices. In the method, the first switch sends a MAC address of the MAC address of the port by using the LINK UP port of the first switch. Notifying the · 艮 ,, to determine the information of the associated switch group and the non-associated switch group corresponding to each port of each second switch in the network and the network, for each port, the corresponding switch group included in the corresponding switch group When the number of the two switches is 2, it is determined that the port of the first switch is directly connected to the port of the associated switch group that learns the MAC address of the port, and the second switch included in the corresponding associated switch group. If the number of switches remaining in the associated switch group after removing the non-associated switch group corresponding to the port of the first switch is 2, according to whether the number is 2, determine whether the port of the first switch is Directly connected to the remaining switches. In the embodiment of the present invention, each switch sends a MAC notification message through each LINK UP port of the switch, and determines the connection relationship between the switch ports according to the information of each switch in the associated switch group and the non-associated switch group. The determination of the topology connection relationship between devices is realized.
在此提供的算法和显示不与任何特定计算机、 虚拟系统或者其它设备固有相关。 各种通 用系统也可以与基于在此的示教一起使用。 根据上面的描述, 构造这类系统所要求的结构是 显而易见的。 此外, 本发明也不针对任何特定编程语言。 应当明白, 可以利用各种编程语言 实现在此描述的本发明的内容, 并且上面对特定语言所做的描述是为了披露本发明的最佳实 施方式。  The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used with the teaching based on the teachings herein. According to the above description, the structure required to construct such a system is obvious. Moreover, the invention is not directed to any particular programming language. It is to be understood that the present invention may be embodied in a variety of programming language, and the description of the specific language has been described above in order to disclose the preferred embodiments of the invention.
在此处所提供的说明书中, 说明了大量具体细节。 然而, 能够理解, 本发明的实施例可 以在没有这些具体细节的情况下实践。 在一些实例中, 并未详细示出公知的方法、 结构和技 术, 以便不模糊对本说明书的理解。  Numerous specific details are set forth in the description provided herein. However, it is understood that the embodiments of the invention may be practiced without these specific details. In some instances, well known methods, structures, and techniques have not been shown in detail so as not to obscure the description.
类似地, 应当理解, 为了精筒本公开并帮助理解各个发明方面中的一个或多个, 在上面 对本发明的示例性实施例的描述中, 本发明的各个特征有时被一起分组到单个实施例、 图、 或者对其的描述中。 然而, 并不应将该公开的方法解释成反映如下意图: 即所要求保护的本 发明要求比在每个权利要求中所明确记载的特征更多的特征。 更确切地说, 如下面的权利要 求书所反映的那样, 发明方面在于少于前面公开的单个实施例的所有特征。 因此, 遵循具体 实施方式的权利要求书由此明确地并入该具体实施方式, 其中每个权利要求本身都作为本发 明的单独实施例。 Similarly, it is to be understood that in the above description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment. , diagram, or description of it. However, the method disclosed is not to be interpreted as reflecting the intention that the claimed invention requires more features than those recited in the claims. Rather, as the following claims reflect, inventive aspects reside in less than all features of the single embodiments disclosed herein. Therefore, follow the specifics The claims of the embodiments are hereby expressly incorporated into the specific embodiments, and each of the claims as a separate embodiment of the invention.
本领域那些技术人员可以理解, 可以对实施例中的设备中的模块进行自适应性地改变并 且把它们设置在与该实施例不同的一个或多个设备中。 可以把实施例中的模块或单元或组件 组合成一个模块或单元或组件, 以及此外可以把它们分成多个子模块或子单元或子组件。 除 了这样的特征和 /或过程或者单元中的至少一些是相互排斥之外, 可以釆用任何组合对本说明 书 (包括伴随的权利要求、 摘要和附图) 中公开的所有特征以及如此公开的任何方法或者设 备的所有过程或单元进行组合。 除非另外明确陈述, 本说明书 (包括伴随的权利要求、 摘要 和附图) 中公开的每个特征可以由提供相同、 等同或相似目的的替代特征来代替。  Those skilled in the art will appreciate that the modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components. In addition to such features and/or at least some of the processes or units being mutually exclusive, any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed may be employed. Or combine all the processes or units of the device. Each feature disclosed in the specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
此外, 本领域的技术人员能够理解, 尽管在此所述的一些实施例包括其它实施例中所包 括的某些特征而不是其它特征, 但是不同实施例的特征的组合意味着处于本发明的范围之内 并且形成不同的实施例。 例如, 在下面的权利要求书中, 所要求保护的实施例的任意之一都 可以以任意的组合方式来使用。  In addition, those skilled in the art will appreciate that, although some embodiments described herein include certain features that are not included in other embodiments, and other features, combinations of features of different embodiments are intended to be within the scope of the present invention. Different embodiments are formed and formed. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
本发明的各个部件实施例可以以硬件实现, 或者以在一个或者多个处理器上运行的软件 模块实现, 或者以它们的组合实现。 本领域的技术人员应当理解, 可以在实践中使用微处理 器或者数字信号处理器 (DSP ) 来实现根据本发明实施例的通过获取设备间拓朴连接关系的 装置及系统, 终端设备及系统中的一些或者全部部件的一些或者全部功能。 本发明还可以实 现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序 (例如, 计算机程序 和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介盾上, 或者可以具有 一个或者多个信号的形式。 这样的信号可以从因特网网站上下载得到, 或者在载体信号上提 供, 或者以任何其他形式提供。  The various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) can be used in practice to implement an apparatus and system for acquiring a topology connection relationship between devices, a terminal device and a system according to an embodiment of the present invention. Some or all of the features of some or all of the components. The invention can also be embodied as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein. Such a program implementing the present invention may be stored on a computer readable shield or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制, 并且本领域技术 人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。 在权利要求中, 不应将位 于括号之间的任何参考符号构造成对权利要求的限制。 单词 "包含" 不排除存在未列在权利 要求中的元件或步骤。 位于元件之前的单词 "一" 或 "一个" 不排除存在多个这样的元件。 本发明可以借助于包括有若千不同元件的硬件以及借助于适当编程的计算机来实现。 在列举 了若千装置的单元权利要求中, 这些装置中的若千个可以是通过同一个硬件项来具体体现。 单词第一、 第二、 以及第三等的使用不表示任何顺序。 可将这些单词解释为名称。  It is to be noted that the above-described embodiments are illustrative of the present invention and are not intended to limit the scope of the invention, and those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as a limitation. The word "comprising" does not exclude the presence of elements or steps that are not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising thousands of different elements and by means of a suitably programmed computer. In the unit claims enumerating the thousands of devices, thousands of these devices may be embodied by the same hardware item. The use of the words first, second, and third does not indicate any order. These words can be interpreted as names.
显然, 本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范 围。 这样, 倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内, 则 本发明也意图包含这些改动和变型在内。  It is apparent that those skilled in the art can make various modifications and variations to the invention without departing from the spirit and scope of the invention. Thus, it is intended that the present invention cover the modifications and the modifications

Claims

权 利 要 求 Rights request
1、 一种获取设备间拓朴连接关系的方法, 其特征在于, 该方法包括: A method for obtaining a topology connection relationship between devices, the method comprising:
第一交换机通过自身的每个 LINK UP端口发送 MAC通知 4艮文, 其中, 所述 MAC通知 •ί艮文的源地址和目的地址为每个端口的 MAC地址或者所述第一交换机的桥 MAC;  The first switch sends a MAC notification message through each of its own LINK UP ports, where the source address and the destination address of the MAC notification are the MAC address of each port or the bridge MAC of the first switch. ;
根据第二交换机返回的拓朴收集报文,获取第二交换机的桥 MAC和端口 MAC以及第二 交换机学习的 MAC地址, 并计算自身及组网中每台第二交换机学习到第一交换机端口 MAC 或者桥 MAC的端口对应的关联交换机组, 及非关联交换机组的信息;  Obtaining, according to the topology collection packet returned by the second switch, the bridge MAC address and the port MAC of the second switch, and the MAC address learned by the second switch, and calculating the MAC address of the first switch port by each second switch in the self and the network. Or the associated switch group corresponding to the port of the bridge MAC, and the information of the non-associated switch group;
第一交换机针对自身的每个 LINK UP端口,判断该端口对应的关联交换机组中包含的交 换机的数量是否为 2;  The first switch determines, for each LINK UP port of the port, whether the number of switches included in the associated switch group corresponding to the port is 2;
当数量为 2时, 根据该关联交换机组中包含的第二交换机学习到自身该端口的 MAC地 址的端口, 确定自身的该端口与该第二交换机学习到自身该端口的 MAC地址的端口直接连 接;  When the number is 2, according to the port that the second switch included in the associated switch group learns the MAC address of the port, the port is determined to be directly connected to the port on which the second switch learns the MAC address of the port. ;
当数量不为 2时, 针对该关联交换机组中包含的每台第二交换机, 确定该第二交换机学 习到自身该端口 MAC地址的端口,判断对应该学习到自身该端口 MAC地址的端口的关联交 换机组中排除第一交换机该端口对应的非关联交换机组中的每台第二交换机后, 该关联交换 机组中剩余的交换机数量是否为 2; 当数量为 2时, 确定自身的该端口与该第二交换机学习 到自身该端口 MAC地址的端口直接连接, 否则, 确定与该端口直接连接的第二交换机的数 量不止 1台或者与该第二交换机学习到的自身该端口 MAC地址的端口非直接连接。  When the number is not 2, for each second switch included in the associated switch group, determine that the second switch learns the port of the port MAC address of the port, and determines the association of the port that should learn the MAC address of the port. After the second switch in the unassociated switch group corresponding to the port of the first switch is excluded from the switch group, the number of switches remaining in the associated switch group is 2; when the number is 2, the port is determined to be The second switch learns that the port of the MAC address of the port is directly connected. Otherwise, it is determined that the number of the second switches directly connected to the port is more than one, or the port of the port that is learned by the second switch is not directly connection.
2、 如权利要求 1所述的方法, 其特征在于, 当第一交换机该端口对应的关联交换机组中 每台第二交换机学习到该第一交换机该端口 MAC地址的端口、 对应的关联交换机组中剩余 的交换机的数量都不为 2时, 所述方法还包括:  2. The method according to claim 1, wherein each of the second switches in the associated switch group corresponding to the port of the first switch learns the port of the port MAC address of the first switch, and the corresponding associated switch group. When the number of remaining switches is not 2, the method further includes:
确定所述每台第二交换机学习到自身该端口 MAC地址的端口对应的关联交换机组中剩 余的交换机的交集;  Determining, by each of the second switches, an intersection of the remaining switches in the associated switch group corresponding to the port of the MAC address of the port;
根据该剩余的交换机的交集中每台第二交换机学习到该第一交换机该端口 MAC地址的 端口, 确定自身的该端口与该交集中每台第二交换机学习到自身该端口 MAC地址的端口直 接连接, 且该交集中的剩余交换机之间通过共享链路连接。  According to the port of the remaining switch, each second switch learns the port of the MAC address of the port of the first switch, and determines that the port itself and the second switch in the intersection learn the port of the MAC address of the port directly Connected, and the remaining switches in the intersection are connected by a shared link.
3、如权利要求 1或 2所述的方法,其特征在于,所述第一交换机通过自身的每个 LINK UP 端口发送 MAC通知 4艮文包括:  The method according to claim 1 or 2, wherein the first switch sends a MAC notification through each of its own LINK UP ports.
所述第一交换机按照设定的周期, 通过自身的每个 LINK UP端口发送 MAC通知报文; 或, The first switch sends a MAC notification message through each LINK UP port of the first switch according to the set period; or,
当所述第一交换机被开启时、 或接收到 link up或接收到 link down消息时, 通过自身的 每个 LINK UP端口发送 MAC通知 4艮文。  When the first switch is turned on, or receives a link up or receives a link down message, the MAC notification is sent through each of its own LINK UP ports.
4、如权利要求 1或 2所述的方法,其特征在于,所述第一交换机通过自身的每个 LINK UP 端口发送 MAC通知 4艮文包括:  The method according to claim 1 or 2, wherein the first switch sends a MAC notification through each of its own LINK UP ports.
所述第一交换机通过自身的每个 LINK UP端口发送 MAC通知报文, 接收到该 MAC通 知报文的第二交换机判断自身是否学习到所述 MAC通知报文中的 MAC地址;  The first switch sends a MAC notification message through each of its own LINK UP ports, and the second switch that receives the MAC notification message determines whether it learns the MAC address in the MAC notification message.
当第二交换机学习到所述 MAC地址时, 第二交换机停止转发该 MAC通知 ·ί艮文, 否则, 第二交换机学习该 MAC地址并转发该 MAC通知 4艮文。  When the second switch learns the MAC address, the second switch stops forwarding the MAC notification, otherwise, the second switch learns the MAC address and forwards the MAC notification.
5、 如权利要求 1所述的方法, 其特征在于, 所述计算自身及组网中每台第二交换机学习 到第一交换机端口 MAC地址或者桥 MAC的端口对应的关联交换机组 ,及非关联交换机组的 信息包括:  The method according to claim 1, wherein the computing itself and each of the second switches in the network learn the associated switch group corresponding to the first switch port MAC address or the bridge MAC port, and are not associated. The information of the switch group includes:
所述第一交换机根据返回拓朴收集报文的每台第二交换机的桥 MAC和端口 MAC地址, 确定该第二交换机位于该端口的关联交换机组中, 并通过拓朴收集报文中携带的第二交换机 的桥 MAC和端口 MAC以及第二交换机学习的 MAC地址, 计算每个第二交换机学习到第一 交换机端口 MAC或者桥 MAC的端口对应的关联交换机组及非关联交换机组的信息。  The first switch determines, according to the bridge MAC address and the port MAC address of each second switch that returns the topology collection packet, that the second switch is located in the associated switch group of the port, and collects the packet in the topology collection packet. The bridge MAC and the port MAC of the second switch and the MAC address learned by the second switch calculate information about the associated switch group and the non-associated switch group corresponding to the port of the first switch port MAC or the bridge MAC.
6、 一种获取设备间拓朴连接关系的装置, 其特征在于, 所述装置包括:  6. A device for obtaining a topology connection relationship between devices, the device comprising:
发送模块, 用于通过自身的每个 LINK UP端口发送 MAC通知 4艮文, 其中, 所述 MAC 通知 4艮文的源地址和目的地址为每个端口的 MAC地址或者所述第一交换机的桥 MAC;  a sending module, configured to send, by using each of its LINK UP ports, a MAC notification message, where the source address and the destination address of the MAC notification message are the MAC address of each port or the bridge of the first switch MAC;
获取模块, 用于根据第二交换机返回的拓朴收集报文, 获取第二交换机的桥 MAC和端 口 MAC以及第二交换机学习的 MAC地址,并计算自身及组网中每台第二交换机学习到第一 交换机端口 MAC或者桥 MAC的端口对应的关联交换机组 , 及非关联交换机组的信息; 拓朴关系确定模块, 用于针对自身的每个 LINK UP端口, 判断该端口对应的关联交换机 组中包含的第二交换机的数量是否为 2; 当数量为 2时, 根据该关联交换机组中包含的第二 交换机学习到自身该端口的 MAC地址的端口, 确定自身的该端口与该第二交换机学习到自 身该端口的 MAC地址的端口直接连接; 当数量不为 2时, 针对该关联交换机组中包含的每 台第二交换机, 确定该第二交换机学习到自身该端口 MAC地址的端口, 判断对应该学习到 自身该端口 MAC地址的端口的关联交换机组中排除自身的该端口对应的非关联交换机组中 的每台第二交换机后, 该关联交换机组中剩余的交换机数量是否为 2; 当数量为 2时, 确定 自身的该端口与该第二交换机学习到自身该端口 MAC地址的端口直接连接, 否则, 确定与 该端口直接连接的第二交换机数量不止 1台,或者与第二交换机学习到自身该端口 MAC地址 的端口非直接连接。 The obtaining module is configured to obtain, according to the topology collection packet returned by the second switch, the bridge MAC address and the port MAC of the second switch, and the MAC address learned by the second switch, and calculate each second switch in the network and the learning The associated switch group corresponding to the port of the first switch port MAC or the bridge MAC, and the information of the non-associated switch group; the topology relationship determining module is configured to determine, for each LINK UP port of the port, the associated switch group corresponding to the port Whether the number of the second switches included is 2; when the number is 2, the port corresponding to the MAC address of the port is learned by the second switch included in the associated switch group, and the port is determined to learn with the second switch. The port to the MAC address of the port is directly connected; when the number is not 2, for each second switch included in the associated switch group, determining that the second switch learns the port of the port MAC address of the port, and determining the pair You should learn the non-associated traffic corresponding to the port in the associated switch group of the port whose MAC address is the port. After changing each second switch in the group, the number of remaining switches in the associated switch group is 2; when the number is 2, it is determined that the port itself and the second switch learn the port of the port MAC address directly Connect, otherwise, determine that there are more than one second switch directly connected to the port, or learn the MAC address of the port with the second switch. The port is not directly connected.
7、 如权利要求 6所述的装置, 其特征在于, 所述拓朴关系确定模块, 还用于当确定自身 该端口对应的关联交换机组中每台第二交换机学习到该第一交换机该端口 MAC地址的端口、 对应的关联交换机组中剩余的交换机的数量都不为 2时, 确定所述每台第二交换机学习到自 身该端口 MAC地址的端口对应的关联交换机组中剩余的交换机的交集; 根据该剩余的交换 机的交集中每台第二交换机学习到该第一交换机该端口 MAC地址的端口, 确定自身的该端 口与该交集中每台第二交换机学习到自身该端口 MAC地址的端口直接连接 , 且该交集中的 剩余交换机之间通过共享链路连接。  The apparatus according to claim 6, wherein the topology relationship determining module is further configured to: when determining that the second switch in the associated switch group corresponding to the port is learned by the second switch, the port is When the number of the ports of the MAC address and the number of the remaining switches in the corresponding associated switch group are not 2, the intersection of the remaining switches in the associated switch group corresponding to the port on which the second switch learns the MAC address of the port is determined. According to the intersection of the remaining switches, each second switch learns the port of the first switch with the MAC address of the port, and determines the port of the port and the second switch of the intersection to learn the port of the MAC address of the port. Directly connected, and the remaining switches in the intersection are connected by a shared link.
8、 如权利要求 6或 7所述的装置, 其特征在于, 所述发送模块, 具体用于按照设定的周 期,通过自身的每个 LINK UP端口发送 MAC通知报文; 或, 当自身被开启时、或接收到 link up或接收到 link down消息时, 通过自身的每个 LINK UP端口发送 MAC通知报文。  The device according to claim 6 or 7, wherein the sending module is specifically configured to send a MAC notification message through each of its LINK UP ports according to a set period; or, when it is When it is enabled, or receives a link up or receives a link down message, it sends a MAC notification message through each LINK UP port of its own.
9、 如权利要求 6所述的装置, 其特征在于, 所述获取模块, 具体用于根据返回拓朴收集 报文的每台第二交换机的桥 MAC和端口 MAC, 确定该第二交换机位于该端口的关联交换机 组中,并通过拓朴收集报文中携带的第二交换机的桥 MAC和端口 MAC以及第二交换机学习 的 MAC地址, 计算每个第二交换机学习到第一交换机端口 MAC或者桥 MAC的端口对应的 关联交换机组及非关联交换机组的信息。  The device according to claim 6, wherein the acquiring module is configured to determine, according to a bridge MAC and a port MAC of each second switch that returns a topology collection message, that the second switch is located in the The associated switch group of the port collects the bridge MAC address and port MAC of the second switch carried in the packet and the MAC address learned by the second switch, and learns that each second switch learns the first switch port MAC or bridge. Information about the associated switch group and non-associated switch group corresponding to the port of the MAC.
10、 一种获取设备间拓朴关系的系统, 其特征在于, 所述系统包括如权利要求 6~9任一 项所述的装置, 及向所述装置返回拓朴收集报文的至少一台第二交换机。  10. A system for obtaining a topology relationship between devices, the system comprising: the device according to any one of claims 6 to 9, and at least one device that returns a topology collection message to the device The second switch.
11、 如权利要求 10所述的系统, 其特征在于, 所述第二交换机, 还用于接收到该 MAC 通知报文时, 判断自身是否学习到所述 MAC通知报文中的 MAC地址; 当学习到所述 MAC 地址时, 停止转发该 MAC通知艮文, 否则, 转发该 MAC通知艮文。 The system according to claim 10, wherein the second switch is further configured to: when receiving the MAC notification message, determine whether the MAC address in the MAC notification message is learned by itself; When the MAC address is learned, the forwarding of the MAC notification message is stopped, otherwise, the MAC notification message is forwarded.
PCT/CN2014/082622 2014-07-09 2014-07-21 Method, system and apparatus for acquiring topological connection relationship between devices WO2016004646A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410325994.4 2014-07-09
CN201410325994.4A CN104468365B (en) 2014-07-09 2014-07-09 A kind of method, system and device for obtaining equipment room topological connection relation

Publications (1)

Publication Number Publication Date
WO2016004646A1 true WO2016004646A1 (en) 2016-01-14

Family

ID=52913761

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/082622 WO2016004646A1 (en) 2014-07-09 2014-07-21 Method, system and apparatus for acquiring topological connection relationship between devices

Country Status (2)

Country Link
CN (1) CN104468365B (en)
WO (1) WO2016004646A1 (en)

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107634842A (en) * 2016-07-18 2018-01-26 阿里巴巴集团控股有限公司 Method for discovering network topology and device
CN109687989B (en) * 2017-10-19 2021-11-23 中兴通讯股份有限公司 Networking topology obtaining method and system
CN108600018B (en) * 2018-04-27 2021-11-30 北京东土军悦科技有限公司 Train topology discovery method and device, train equipment and storage medium
CN109218198B (en) * 2018-10-09 2021-03-26 迈普通信技术股份有限公司 Data interaction method, device, MPLS network system and storage medium
CN109257225B (en) * 2018-10-12 2021-08-10 北京信研汇智信息技术有限公司 Method, device, storage medium and processor for generating network topology
CN109412955B (en) * 2018-12-06 2021-03-16 中盈优创资讯科技有限公司 Method and device for determining link relation between IPRAN network devices
CN111600762B (en) * 2020-06-02 2023-04-07 山东中创软件商用中间件股份有限公司 Network topology structure generation method, device, equipment and medium
CN113765807B (en) * 2020-09-29 2022-12-27 北京京东尚科信息技术有限公司 Method, device, system and medium for network traffic visualization
CN113193994B (en) * 2021-04-22 2023-06-13 大连市共进科技有限公司 Topology discovery method, device, terminal equipment and medium
CN114021972A (en) * 2021-11-04 2022-02-08 哈尔滨工业大学 Industrial robot system equipment asset value evaluation method based on network topology

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101640610A (en) * 2009-09-02 2010-02-03 中兴通讯股份有限公司 Method and system for automatic discovery of Ethernet link
CN101764709A (en) * 2009-12-29 2010-06-30 福建星网锐捷网络有限公司 Network physical topology discovering method and network management server based on SNMP
CN102638408A (en) * 2012-04-27 2012-08-15 华为技术有限公司 Method for sending topology change (TC) message and method and device for refreshing forwarding table
CN102946349A (en) * 2012-02-23 2013-02-27 Ut斯达康通讯有限公司 OSPF (open shortest path first) protocol-based Ethernet E-Line service link discovery method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6917986B2 (en) * 2002-01-07 2005-07-12 Corrigent Systems Ltd. Fast failure protection using redundant network edge ports
CN102694689B (en) * 2012-06-06 2016-02-10 杭州华三通信技术有限公司 A kind of method for discovering network topology and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101640610A (en) * 2009-09-02 2010-02-03 中兴通讯股份有限公司 Method and system for automatic discovery of Ethernet link
CN101764709A (en) * 2009-12-29 2010-06-30 福建星网锐捷网络有限公司 Network physical topology discovering method and network management server based on SNMP
CN102946349A (en) * 2012-02-23 2013-02-27 Ut斯达康通讯有限公司 OSPF (open shortest path first) protocol-based Ethernet E-Line service link discovery method and device
CN102638408A (en) * 2012-04-27 2012-08-15 华为技术有限公司 Method for sending topology change (TC) message and method and device for refreshing forwarding table

Also Published As

Publication number Publication date
CN104468365B (en) 2017-08-08
CN104468365A (en) 2015-03-25

Similar Documents

Publication Publication Date Title
WO2016004646A1 (en) Method, system and apparatus for acquiring topological connection relationship between devices
CN104734964B (en) Message processing method, node and system
CN105594185B (en) Repeat MAC Address detection
US9106443B2 (en) Forwarding table optimization with flow data
EP2432164B1 (en) Node device and communication method
WO2015043327A1 (en) Routing method, device and system
CN109714274B (en) Method for acquiring corresponding relation and routing equipment
WO2015109821A1 (en) Service chain management method, system and device
ES2620082T3 (en) Identification of routes taken through a network of interconnected devices
WO2019042186A1 (en) Network management method and related device
EP3591913A1 (en) Traceroute in virtual extensible local area networks
WO2014187204A1 (en) Ofs in-band communication method and ofs
WO2017025021A1 (en) Method and device for processing flow table
JP2016515339A5 (en)
EP3720075B1 (en) Data transmission method and virtual switch
WO2012103731A1 (en) Method and device for establishing router neighbor
ES2626578T3 (en) Identification of an output port of a device
JP2016517240A5 (en) Server-managed routing system and method
WO2016062165A1 (en) Method and apparatus for implementing operations, administration and maintenance function
WO2013071866A1 (en) Host name transfer method and device
WO2013189414A2 (en) Automatic network topology acquisition method and system, and network query and management system
US20140301182A1 (en) Graceful restart (gr) methods and devices
CN101043462A (en) Method for processing link condition announcement and router
WO2019001260A1 (en) Method and node for determining transmission path
WO2017084642A1 (en) Method for counting bgp community attribute or extended community attribute flow value, and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14897018

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14897018

Country of ref document: EP

Kind code of ref document: A1