Disclosure of Invention
The embodiment of the application provides a port state processing method and network equipment, which are used for effectively avoiding that data sent to root bridge equipment by non-root bridge equipment through a link is blocked on a port corresponding to the link in the root bridge equipment when the link is recovered due to failure, so that the loss of a data packet is effectively reduced.
In order to solve the above problem, an embodiment of the present application provides the following technical solutions:
in a first aspect, an embodiment of the present application provides a port state processing method, where the method is applied in an STP network including a non-root bridge device and a first root bridge device, and the method includes: the method comprises the steps that a non-root bridge device determines a root port of the non-root bridge device in an STP network and determines the physical state of a link where the root port is located, when the physical state of the link where the root port is located is changed from failure (down) to recovery (up), the non-root bridge device sends an STP message to a first root bridge device connected with the link, and after the first root bridge device receives the STP message, the first root bridge device sets the STP state of a port corresponding to the link on the first root bridge device to be in a forwarding (forward) state according to the received STP message. Therefore, in the embodiment of the application, when the non-root bridge device senses that the link where the root port is located has failed to recover, the non-root bridge device actively sends the STP message, so that the root bridge device where the failed link is located releases the port corresponding to the failed link after receiving the STP message, that is, the port is released only when the port is determined to be the edge port without waiting for detection, thereby effectively avoiding that data sent to the root bridge device by the non-root bridge device through the failed recovered link is blocked on the port corresponding to the link in the root bridge device when the link fails to recover, and effectively reducing the loss of data packets.
In a possible design, the non-root bridge device sends the STP message to the first root bridge device, which means that the non-root bridge device sends at least one STP message to the first root bridge device within a preset time length through the root port. In practical application, the preset duration may be configured according to actual conditions, so long as the first root bridge device releases the blocking state of the port corresponding to the failure recovery link on the first root bridge device as soon as possible. Illustratively, the predetermined duration is less than the time required for the non-root bridge device to pass the edge port detection. Meanwhile, in the embodiment of the application, the non-root bridge device sends at least one, namely one or more STP messages to the first root bridge device, so that the first root bridge device can be effectively ensured to receive the STP messages sent by the non-root bridge device, and the implementation of the scheme is effectively improved.
In one possible design, the non-root bridge device sends at least one STP packet to the first root bridge device through the root port within a preset time period, including: and the non-root bridge equipment transmits at least two STP messages to the root bridge equipment through the root port within a preset time length according to a preset transmission interval. In the embodiment of the application, when the non-root bridge device sends a plurality of STP messages to the first root bridge device within the preset time, the STP messages can be sent at reasonable sending intervals, so that the non-root bridge device can be prevented from sending the STP messages to the first root bridge device at a certain time point in a centralized manner, and the sending burden of the non-root bridge device is reduced.
In one possible design, the root port is a logical port composed of a plurality of physical ports, where the plurality of physical ports connect a plurality of root bridge devices through a plurality of links of a cross-device link aggregation group, respectively. Before the non-root bridge device sends the STP message to the first root bridge device, the method further includes: and the non-root bridge equipment determines one of the links as a target transmission link according to a Hash (HASH) algorithm, and transmits the STP message to the first bridge equipment through the determined target transmission link. In this embodiment, before the non-root bridge device sends an STP packet to the first bridge device, the non-root bridge device first determines one of the links as a target sending link according to the hash algorithm, and then sends the STP packet to the first bridge device through the target sending link. It may be advantageous to load balance the links across the device link aggregation group.
In one possible design, the STP network further includes a second root bridge device, where the first root bridge device and the second root bridge device are paired root bridge devices, the target transmission link includes any link between a root port and a member port of a cross-device link aggregation group on the second root bridge device, and the non-root bridge device transmits the STP packet to the first root bridge device through the target transmission link, including: and the non-root bridge equipment transmits the STP message to the second root bridge equipment through the target transmission link, so that the STP message is synchronized to the first root bridge equipment after the STP message received by the second root bridge equipment. In this embodiment, when the non-root bridge device determines that the target transmission link is a link between the second root bridge device and the root port according to the hash algorithm, the non-root bridge device may send the STP packet to the second root bridge device, and then, by using a synchronization mechanism between the first root bridge device and the second root bridge device, the second root bridge device synchronizes the STP packet received from the non-root bridge device to the first root bridge device.
In one possible design, the non-root bridge device determines the target transmission link according to a hash algorithm, including: the non-root bridge device determines a destination Media Access Control (MAC) address and a source MAC address of the STP message, and then obtains the target transmission link according to the determined destination MAC address and the source MAC address and a Hash algorithm. In the embodiment of the application, the non-root bridge device determines the target transmission link through a hash algorithm, specifically, performs hash calculation according to the destination MAC address and the source MAC address of the STP packet to be transmitted, so as to improve the implementability of the scheme.
In one possible design, the target transmit link includes a link between a root port and a member port of a cross-device link aggregation group on a first root bridge device. That is, the target transmission link determined by the non-root bridge device according to the hash algorithm may be any link between the root port and the member port of the first root bridge device.
In a possible design, when a non-root bridge device determines a root port of a non-root bridge device in an STP network, the non-root bridge device first determines path costs from each port of the non-root bridge device to a first root bridge device in the STP network, and the non-root bridge device selects a port with the smallest path cost from the path costs from each port to the first root bridge device as the root port of the non-root bridge device.
In a second aspect, an embodiment of the present application provides a port state processing method, which is applied to an STP network including a non-root bridge device and a root bridge device, and the method includes: the method comprises the steps that root bridge equipment receives an STP message sent by non-root bridge equipment, wherein the STP message is the STP message sent by the non-root bridge equipment when the physical state of a link where a root port is located is determined to be changed from fault (down) to recovery (up), and the root bridge equipment is the root bridge equipment connected with the link; after the root bridge device receives the STP message sent by the non-root bridge device, the root bridge device sets the STP state of a port corresponding to the link on the root bridge device to be a forwarding (forward) state according to the received STP message. Therefore, in the embodiment of the application, when the non-root bridge device senses that the link where the root port is located has failed to recover, the non-root bridge device actively sends the STP message, so that the root bridge device where the failed link is located releases the port corresponding to the failed link after receiving the STP message, that is, the port is released only when the port is determined to be the edge port without waiting for detection, thereby effectively avoiding that data sent to the root bridge device by the non-root bridge device through the failed recovered link is blocked on the port corresponding to the link in the root bridge device when the link fails to recover, and effectively reducing the loss of data packets.
In a possible design, the setting, by the root bridge device, an STP state of a port corresponding to the link on the root bridge device to a forward state according to the STP message specifically includes: the root bridge device carries out STP protocol calculation according to the STP message, determines that the bridge priority of the first root bridge device is higher than that of the non-root bridge device, thereby determining that the port is an edge port, and sets the STP state of the port to a forward state after determining that the port is the edge port.
In a third aspect, an embodiment of the present application further provides a network device, which is applied in an STP network, where the STP network includes the network device and a first root bridge device, the network device is a non-root bridge device, and the non-root bridge device includes: the processing module is used for determining a root port of non-root bridge equipment in the STP network; the method comprises the steps of determining the physical state of a link where a root port is located; and the sending module is used for sending the STP message to the first root bridge device when the physical state of the link where the root port is located is changed from the fault down to the recovery up, so that after the first root bridge device receives the STP message, the STP state of the port corresponding to the link on the first root bridge device is set to be a forwarding (forward) state according to the STP message.
In a third aspect of the present application, a component module of the non-root bridge device may further perform steps described in the foregoing first aspect and various possible implementations, for details, see the foregoing description of the first aspect and various possible implementations, and details are not described herein again.
In a fourth aspect, an embodiment of the present application further provides a network device, which is applied in an STP network, where the network device is a root bridge device in the STP network, and the STP network includes the root bridge device and a non-root bridge device, and includes: the system comprises a receiving module, a transmitting module and a processing module, wherein the receiving module is used for receiving an STP message sent by non-root bridge equipment when determining that the physical state of a link where a root port of the non-root bridge equipment is located is changed from fault (down) to (up), and the root bridge equipment is the root bridge equipment connected with the link; and the processing module is used for setting the STP state of a port corresponding to the link on the root bridge equipment into a forwarding (forward) state according to the STP message after the receiving module receives the STP message.
In a fourth aspect of the present application, the constituent modules of the root bridge device may further perform the steps described in the foregoing second aspect and various possible implementations, for details, see the foregoing description of the second aspect and various possible implementations, and are not further described here in detail.
In a fifth aspect, an embodiment of the present application further provides a network device, where the network device has a function of implementing a behavior of a non-root bridge device in the foregoing method, and the function may be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-described functions. In a possible design, the structure of the non-root bridge device includes a communication port, where the communication port is configured to support forwarding of data between the non-root bridge device and the root bridge device, and send or receive information, instructions, or messages related to the above method, which are sent by the root bridge device, to the root bridge device. The non-root bridge device may further comprise a memory and a processor, the processor being configured to support the non-root bridge device to perform the respective functions of the above-described method; the memory is used for storing necessary programs and contents of instructions, forwarded messages and the like of the non-root bridge equipment.
In a sixth aspect, an embodiment of the present application further provides another network device, where the network device has a function of implementing a behavior of a root bridge device in the above method design. The above functions may be implemented by hardware, or may be implemented by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-described functions. The modules may be software and/or hardware.
In one possible design, the structure of the root bridge device includes a communication port, and the communication port is configured to support forwarding of information between the root bridge device and the non-root bridge device, and to send or receive information, instructions, or messages related to the above method, which is sent by the non-root bridge device, to the non-root bridge device. The root bridge device may further include a memory and a processor, the processor is configured to support the root bridge device to perform the corresponding functions of the above method, and the memory is configured to store necessary programs and contents, instructions, forwarded messages, and the like of the root bridge device.
In a seventh aspect, the present application provides a computer-readable storage medium having stored therein instructions, which when executed on a computer, cause the computer to perform the method of the above-described aspects.
It can be seen from the foregoing technical solutions that the embodiments of the present application provide a port state processing method, which is applied to an STP network including a non-root bridge device and a root bridge device. In the method, a non-root bridge device determines a root port of the non-root bridge device in a current STP network, monitors a physical state of a link where the root port is located, and when the non-root bridge device monitors that the physical state of the link where the root port is located is changed from a fault (down) to a recovery (up), the non-root bridge device sends an STP message to the root bridge device, so that after the root bridge device receives the STP message, the STP state of a port corresponding to the link on the root bridge device is set to be a forwarding (forward) state according to the received STP message, wherein the first root bridge device is the root bridge device connected with the link where the root port is located. Therefore, in the embodiment of the application, when the non-root bridge device senses that the link where the root port is located has failed to recover, the non-root bridge device releases the port corresponding to the failed link in a mode of actively sending the STP message after receiving the STP message, that is, the non-root bridge device releases the port without waiting for the detection to determine that the port is the edge port, so that data sent to the root bridge device by the non-root bridge device through the link can be effectively prevented from being blocked on the port corresponding to the link in the root bridge device when the link fails to recover, and the loss of data packets can be effectively reduced.
Detailed Description
The application provides a port state processing method and is applied to an STP network comprising non-root bridge equipment and root bridge equipment, so that data sent to the root bridge equipment by the non-root bridge equipment through a link can be effectively reduced when the link is recovered from a fault, and the data is blocked on a port corresponding to the link in the root bridge equipment, thereby effectively reducing data packet loss.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. It is to be understood that the described embodiments are merely exemplary of some, and not all, of the present application. All other embodiments that can be derived from the embodiments given herein by a person of ordinary skill in the art are intended to be within the scope of the present disclosure.
It should be noted that the terms "first," "second," "third," "fourth," and the like (if any) in the description and claims of this application and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," and any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
The following describes examples of the present application.
First, a system framework applied to the port state processing method provided in the embodiment of the present application is explained, the embodiment of the present application may be applied to an ethernet network configured with an STP protocol, for example, the embodiment of the present application may be applied to a cross-device link aggregation group using an STP protocol. For ease of understanding, the following description will be made of the STP network applied in the embodiments of the present application.
The primary member port roles defined in STP networks include: a designated port and a root port. The designated port is a member port of a network device for forwarding Bridge Protocol Data Unit (BPDU) to the connected network segments, and each network segment has only one designated port. In general, each member port of the root bridge device is a designated port. In the non-root bridge equipment, the data or the message is sent to the member port with the optimal path of the root bridge equipment, at most only one root port is arranged on the non-root bridge equipment running the STP protocol, and the root port does not send the STP message to the root bridge equipment.
Fig. 2 is a schematic diagram of a system architecture applied to a port state processing method according to an embodiment of the present application, where the system architecture includes a root bridge device, a non-root bridge device, and a server, where the root bridge device and the non-root bridge device may be network devices such as a switch, and are not limited herein. In this embodiment of the present application, a non-root bridge device determines a root port of the non-root bridge device in an STP network, and monitors a physical state of a link where the root port is located, and when the physical state of the link where the root port of the non-root bridge device is located changes from a failure (down) to a restoration (up), the non-root bridge device sends an STP message to the root bridge device connected to the link where the root port is located, so that after the root bridge device receives the STP message, the root bridge device sets the STP state of a port corresponding to the failure restoration link to a forwarding (forwarded) state according to the STP message. The following provides a detailed description of examples of the present application.
As shown in fig. 3, an embodiment of the present application provides a port state processing method, which is applied to an STP network including a non-root bridge device and a first root bridge device, and includes:
101. and the non-root bridge equipment determines a root port of the non-root bridge equipment in the STP network.
In an embodiment of the present application, a non-root bridge device forming an STP network may determine a root port of the non-root bridge device in the STP network. It should be noted that when the current STP network converges, the root bridge device and the non-root bridge device in the current STP network are in a stable state, that is, the STP network selects which network device in the STP network is the root bridge device and which network device is the root bridge device according to the STP protocol. The non-root bridge device described in the embodiment of the present application refers to any one non-root bridge device in the STP network.
In some embodiments of the present application, determining, by a non-root bridge device, a root port on the non-root bridge device in an STP network includes:
the non-root bridge device determines the path cost from each port of the non-root bridge device to the first root bridge device in the STP network;
and the non-root bridge equipment selects a port with the minimum path cost from the path costs from each port of the non-root bridge equipment to the first root bridge equipment as a root port of the non-root bridge equipment, wherein the first root bridge equipment is the root bridge equipment in the current STP network.
As can be seen from the above description, in the STP network, the determination process of the root port on the non-root bridge device is to select a port with an optimal path to the first root bridge device among different ports on all non-root bridge devices, and determine the port with the optimal path to the root bridge device according to the minimum path cost from the port on the non-root bridge device to the root bridge device.
102. And the non-root bridge equipment determines the physical state of the link where the root port is located.
And when the non-root bridge equipment determines the root port, monitoring the physical state of the link where the root port is located in real time.
In an STP network, a non-root bridge device may monitor the physical state of links connecting a root port with a root bridge device in the STP network.
103. And when the physical state of the link where the root port is located is changed from a fault (down) to a fault (up), the non-root bridge equipment sends an STP message to first root bridge equipment, wherein the first root bridge equipment is the root bridge equipment connected with the link.
In this embodiment of the present application, when a non-root bridge device determines that a physical state of a link where a root port is located is changed from a fault (down) to (up), the non-root bridge device sends an STP message to a first root bridge device connected to the link.
It can be understood that the physical state of the link where the root port is located is in a down state, which means that the link where the root port is located cannot transmit data or messages, and is in a failure state, and specifically, the failure state may be caused by various reasons.
For example, a port corresponding to a link where a root port is located on the first root bridge device fails; or a link between the first root bridge device and the root port is damaged, and the like, so that data cannot be normally transmitted; or a root port on the non-root bridge device fails, or a combination of any of the above 3 cases may cause a physical state of a link where the root port is located to fail.
In some examples of the present application, the sending, by the non-root bridge device, an STP packet to the first root bridge device includes:
and the non-root bridge equipment sends at least one STP message to the first root bridge equipment within a preset time length through the root port.
Illustratively, when the physical state of the link where the root port is located is changed from a failure (down) to a restoration (up), the non-root bridge device sends one or more STP messages to the first root bridge device within 1s through the root port, it should be noted that, in practical applications, the preset time duration may be configured according to practical situations, as long as the first root bridge device releases the blocking (block) state of the port corresponding to the failure restoration link on the first root bridge device as soon as possible. Illustratively, the preset duration is less than the time required for the root bridge device to perform the edge port detection.
As can be seen from the foregoing description, when a link failure is recovered, when a port corresponding to the link on the first bridge device is in a blocking state, the port needs to be opened after a detection time of an edge port as long as several seconds, and therefore, in this application example, when the physical state of the link where the root port is located is changed from a failure (down) to (up), the non-root bridge device sends an STP packet to the first bridge device within a preset time duration, so that the first bridge device can receive the STP packet as soon as possible, thereby releasing the port connected to the failure recovery link on the first bridge device, and converting the STP state of the port into a forwarding (forward) state.
Based on the foregoing embodiment, in some examples of the present application, the sending, by the non-root bridge device through the root port, at least one STP packet to the first root bridge device within a preset time includes:
and the non-root bridge equipment transmits at least two STP messages to the root bridge equipment through the root port within a preset time according to a preset transmission interval.
Illustratively, when the physical state of the link where the root port is located changes from failure (down) to recovery (up), the non-root bridge device continuously transmits 3 STP messages through the root port, and the transmission interval of each STP message is 50 milliseconds. That is, in the embodiment of the present application, a transmission interval when the non-root bridge device transmits a plurality of STP messages through the root port within a preset time period is further defined, so that a transmission load when the non-root bridge device transmits STP messages can be reduced.
In some embodiments of the present application, when the root port is a logical port formed by a plurality of physical ports, the plurality of physical ports are respectively connected to a plurality of root bridge devices through a plurality of links, and the plurality of links form a cross-device link aggregation group m-lag, before the non-root bridge device sends an STP packet to the first root bridge device, the method further includes:
the non-root bridge equipment determines a target sending link according to a Hash algorithm, wherein the target sending link is a link corresponding to one physical port in the plurality of physical ports;
the non-root bridge device sends the STP message to the first root bridge device, and the method comprises the following steps:
and the non-root bridge equipment transmits the STP message to the first root bridge equipment through the target transmission link.
When a plurality of links corresponding to the plurality of physical ports form an m-lag, the target sending link includes a link between the root port and a member port of the m-lag on the first root bridge device.
In some examples of the application, when the STP network performs networking for an m-lag in a cross-device link aggregation group, the STP network further includes a second root bridge device, the first root bridge device and the second root bridge device are paired root bridge devices, the target transmission link may also be a link between the root port and a member port of the m-lag on the second root bridge device, and the non-root bridge device transmits the STP packet to the first root bridge device through the target transmission link, specifically, the non-root bridge device transmits the STP packet to the second root bridge device through the target transmission link, so that the STP packet is synchronized to the first root bridge device after the STP packet is received by the second root bridge device.
It should be noted that, in the cross-device link aggregation group, after the paired root bridge devices can successfully pair with each other, the synchronization mechanism between the root bridge devices realizes information synchronization, so that the second root bridge device can synchronize the STP message received from the non-root bridge device to the first root bridge device.
In some embodiments of the present application, the determining, by the non-root bridge device, a target transmission link according to a hash algorithm includes:
the non-root bridge equipment determines a destination MAC address and a source MAC address of the STP message;
and the non-root bridge equipment determines the target transmission link through the Hash algorithm according to the destination MAC address and the source MAC address of the STP message.
Taking an STP network as an example of networking a cross-device link aggregation group, when the cross-device link aggregation group adopts an STP protocol, a first root bridge device and a second root bridge device are paired root bridge devices, the first root bridge device and the second root bridge device are virtualized to form an STP root bridge device, and information such as a state between the two root bridge devices is synchronized between the first root bridge device and the second root bridge device according to a preset synchronization mechanism. In the cross-device link aggregation group, when the non-root bridge device sends an STP packet to an upstream device, the routing is performed through a HASH (HASH) algorithm, and finally the STP packet is sent through an aggregation link port, that is, a root port, so the following two sending situations occur:
the first situation is that when the non-root bridge device monitors that the physical state of the link where the root port is located is changed from failure (down) to recovery (up), the non-root bridge device determines the link between the non-root bridge device and the first root bridge device as a target transmission link after selecting a route according to a hash algorithm, and then directly transmits the STP message to the first root bridge device through the target transmission link.
The second situation is that when the non-root bridge device monitors that the physical state of the link where the root port is located is changed from failure (down) to recovery (up), the non-root bridge device determines the link between the non-root bridge device and the second bridge device as a target transmission link after routing according to a hash algorithm, then transmits the STP message to the second bridge device through the target transmission link, and the second bridge device synchronizes the STP message received from the non-root bridge device to the first bridge device according to a synchronization mechanism provided by a cross-device link aggregation group.
104. The first root bridge device receives the STP message sent by the non-root bridge device.
The first root bridge device may receive an STP message sent by the non-root bridge device to the first root bridge device when the non-root bridge device monitors that the physical state of the link where the root port is located is changed from failure (down) to recovery (up).
105. And after receiving the STP message, the first root bridge device sets the STP state of a port corresponding to the link on the first root bridge device to be a forwarding (forward) state according to the STP message.
In some examples of the present application, the first root bridge device performs STP protocol calculation according to the STP packet, and determines that a bridge priority of the first root bridge device is higher than a bridge priority of the non-root bridge device, thereby determining that a port corresponding to the link is an assigned port; and when the port is determined to be the designated port, setting the STP state of the port to be a forwarding (forward) state.
For convenience of understanding, the following description will be made with reference to a scenario drawing, taking a cross-device link aggregation group using an STP protocol as a networking scenario, where the scenario drawing is as follows:
referring to fig. 4, a schematic view of an application scenario of a port state processing method according to an embodiment of the present application is shown, in which the application scenario includes a root bridge device, a non-root bridge device and a server, two physical links of the non-root bridge device SW3, which are connected with the root bridge device SW1 and the root bridge device SW2, form a cross-device link aggregation group m-lag1, two physical links of the non-root bridge device SW4, which are connected with the root bridge device SW1 and the root bridge device SW2, form a cross-device link aggregation group m-lag2, the m-lag 1-1 and the m-lag1-2 ports are member ports of the m-lag1, the m-lag 2-1 and the m-lag 2-2 ports are member ports of the m-lag2, two physical ports of the non-root bridge device SW3, which belong to the m-lag1, form one logical port, and two physical ports of the non-root bridge device SW4, which belong to the m-lag2, form another logical port. When the link between the member port m-lag 1-1 of the root bridge device SW1 and the root port of the non-root bridge device SW3 recovers after a failure, the m-lag 1-1 port is in a blocked (block) state. As shown in fig. 5, when the non-root bridge device SW3 senses that a link between the m-lag 1-1 port of the root bridge device SW1 and the root port of the non-root bridge device SW3 is failed, the non-root bridge device SW3 sends an STP message to the upstream root bridge device, and since the non-root bridge device SW3 sends the STP message to the upstream root bridge device in the cross-device link aggregation group according to a hash algorithm, there are two sending cases.
One case is where the non-root bridge device SW3 sends an STP message to the root bridge device SW1 over a physical link with the root bridge device SW 1. The other is that the non-root bridge device SW3 sends the STP message to the root bridge device SW2 through the physical link between the non-root bridge device SW3 and the root bridge device SW2, and finally the root bridge device SW2 synchronizes the STP message sent by the non-root bridge device SW3 to the root bridge device SW1 according to the synchronization mechanism provided by the cross-device link aggregation group. Referring to fig. 6, after receiving the STP message, the root bridge device SW1 calculates the m-lag 1-1 port as the designated port according to the STP protocol performed on the STP message, thereby setting the STP state of the m-lag 1-1 port as a forwarding (forward) state. Under the cross-device link aggregation networking, for the typical fault recovery scene, the fault recovery performance can be improved, the port state recovery time can be reduced, the data packet loss can be effectively reduced, and the link fault recovery performance under the scene can be optimized.
In summary, in the embodiment of the present application, when the non-root bridge device senses that the link where the root port is located has failed and recovers, the non-root bridge device releases the port corresponding to the failed link after receiving the STP message by actively sending the STP message, so that data sent to the root bridge device through the failed recovery link during the detection time of the edge port when the link fails and recovers can be effectively reduced and blocked on the port corresponding to the failed recovery link in the root bridge device, thereby effectively reducing the loss of data packets.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are exemplary embodiments and that the acts and modules referred to are not necessarily required by the application.
In order to better implement the solution described in the above embodiments of the present application, the following also provides the relevant means for implementing the above solution.
Referring to fig. 7, a schematic structural diagram of a network device provided in an embodiment of the present application is shown, where the network device may be used as a non-root bridge device when used in an STP network, where the STP network includes the non-root bridge device and a first root bridge device, and the non-root bridge device may include: aprocessing module 101 and a sendingmodule 102, wherein,
aprocessing module 101, configured to determine a root port of a non-root bridge device in the STP network;
theprocessing module 101 is further configured to determine a physical state of a link where the root port is located;
a sendingmodule 102, configured to send an STP packet to the first root bridge device when the physical state of the link where the root port is located changes from a failure (down) to a restoration (up), so that after the first root bridge device receives the STP packet, the first root bridge device sets, according to the STP packet, an STP state of a port on the first root bridge device corresponding to the link to a forwarding (forward) state, where the first root bridge device is a root bridge device connected to the link.
In some examples of the present application, the sendingmodule 102 is configured to send an STP packet to the first root bridge device, and includes:
the sendingmodule 102 is configured to send at least one STP packet to the first root bridge device within a preset time duration through the root port.
In some embodiments of the present application, the sendingmodule 102 is configured to send at least one STP packet to the first root bridge device within a preset time duration, where the sending module is configured to:
the sendingmodule 102 is configured to send, through the root port, at least two STP messages to the root bridge device according to a preset sending interval within the preset time duration.
In some embodiments of the present application, the root port is a logical port formed by a plurality of physical ports, the plurality of physical ports are respectively connected to a plurality of root bridge devices through a plurality of links, the plurality of links form a cross-device link aggregation group, and theprocessing module 101 is further configured to:
determining a target sending link through a Hash algorithm, wherein the target sending link is one of the links;
the sendingmodule 102 is configured to send an STP packet to the first root bridge device, and includes:
the sendingmodule 102 is configured to send the STP packet to the first root bridge device through the target sending link determined by theprocessing module 101.
In some embodiments of the present application, the target transmit link comprises a link between the root port and a member port of the cross-device link aggregation group on the first root bridge device.
In some embodiments of the present application, the STP network further includes a second root bridge device, the first root bridge device and the second root bridge device are paired root bridge devices, the target transmission link includes a link between the root port and a member port of the cross-device link aggregation group on the second root bridge device, and the sendingmodule 102 is configured to send an STP packet to the first root bridge device, and includes:
the sendingmodule 102 is configured to send the STP packet to the second root bridge device through the target sending link, so that the STP packet is synchronized to the first root bridge device after the STP packet is received by the second root bridge device.
In some embodiments of the present application, theprocessing module 101 is configured to determine a target transmission link according to a hash algorithm, and includes:
theprocessing module 101 is configured to determine a destination physical address MAC and a source MAC address of the STP packet, and obtain the target transmission link through the hash algorithm according to the destination MAC address and the source MAC address of the STP packet.
In some embodiments of the present application, theprocessing module 101 is configured to determine a root port of the non-root bridge device, and includes:
theprocessing module 101 is configured to determine path costs from each port of the non-root bridge device to the first root bridge device in the STP network, and select a port with the smallest path cost from the path costs from each port of the non-root bridge device to the first root bridge device as a root port of the non-root bridge device.
With reference to fig. 8, another network device structure schematic diagram provided in the embodiment of the present application is described below, where the network device may be used as a root bridge device when applied to an STP network, where the STP network includes the root bridge device and a non-root bridge device, and the root bridge device may include: a receivingmodule 201 and aprocessing module 202, wherein,
areceiving module 201, configured to receive an STP message sent by the non-root bridge device, where the STP message is sent by the non-root bridge device when it is determined that a physical state of a link where a root port of the non-root bridge device is located changes from a fault (down) to a recovery (up), and the root bridge device is a root bridge device connected to the link;
and theprocessing module 202 is configured to set, after thereceiving module 101 receives the STP packet, an STP state of a port corresponding to the link on the root bridge device to a forwarding (forwarded) state according to the STP packet.
In some embodiments of the present application, theprocessing module 202 is configured to set an STP state of a port corresponding to the link on the root bridge device to a forwarding (forward) state, including:
theprocessing module 202 is configured to perform STP protocol calculation according to the STP packet, and determine that a bridge priority of the root bridge device is higher than a bridge priority of the non-root bridge device, thereby determining that the port is an assigned port; and setting the STP state of the port to be a forwarding (forward) state.
It should be noted that, for the information interaction, execution process, and other contents between the modules/units of the apparatus, since the same concept is based on the method embodiment in the embodiment of the present application, the technical effect brought by the method embodiment is the same as that of the method embodiment of the present application, and specific contents may refer to the description in the foregoing method embodiment of the present application, and are not described herein again.
The embodiment of the present application further provides a computer storage medium, where the computer storage medium stores a program, and the program, when executed by a computer, can implement some or all of the steps described in the above method embodiments.
Referring to fig. 9, a schematic structural diagram of another network device provided in an embodiment of the present application, where the network device may be used as a non-root bridge device when used in an STP network, and the network device includes:
acommunication port 301, aprocessor 302 and a memory 303 (wherein, the number of theprocessors 302 in the network device may be one or more, and one processor is taken as an example in fig. 9). In some embodiments of the present application, thecommunication port 301, theprocessor 302 and thememory 303 may be connected by a bus or other means, which is not limited herein, and fig. 9 illustrates an example of connection by a bus.
Memory 303 may include both read-only memory and random access memory and provides instructions and data toprocessor 302. A portion of thememory 303 may also include a non-volatile random access memory (NVRAM). Thememory 303 stores an operating system and operating instructions, executable modules or data structures, or a subset or an expanded set thereof, wherein the operating instructions may include various operating instructions for performing various operations. The operating system may include various system programs for implementing various basic services and for handling hardware-based tasks.
Processor 302 controls the operation of the network device, andprocessor 302 may also be referred to as a Central Processing Unit (CPU). In a particular application, the various components of the network device are coupled together by a bus system that may include a power bus, a control bus, a status signal bus, etc., in addition to a data bus. For clarity of illustration, the various buses are referred to in the figures as a bus system.
The method disclosed in the embodiments of the present application may be applied to theprocessor 302, or implemented by theprocessor 302. Theprocessor 302 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in theprocessor 302. Theprocessor 302 may be a general-purpose processor, a Digital Signal Processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in thememory 303, and theprocessor 302 reads the information in thememory 303 and completes the steps of the method in combination with the hardware thereof.
Thecommunication port 301 may be used to receive or transmit information and generate signals or messages related to the related settings and function control of the network device, so as to perform initialization, message forwarding, and other processing of the non-root bridge device.
In this embodiment, theprocessor 302 is configured to execute the port state processing method executed by the non-root bridge device side when the network device is used as a non-root bridge device.
Referring to fig. 10, a schematic structural diagram of another network device provided in an embodiment of the present application is described next, where the network device may be used as a root bridge device when used in an STP network, and the network device includes:
acommunication port 401, aprocessor 402 and a memory 403 (wherein, the number of theprocessors 402 in the network device may be one or more, and one processor is taken as an example in fig. 10). In some embodiments of the present application, thecommunication port 401, theprocessor 402 and thememory 403 may be connected by a bus or in other manners, which is not limited herein, and fig. 10 illustrates an example of connection by a bus.Memory 403 may include both read-only memory and random-access memory, and provides instructions and data toprocessor 402. A portion of thememory 403 may also include NVRAM. Thememory 403 stores an operating system and operating instructions, executable modules or data structures, or a subset or an expanded set thereof, wherein the operating instructions may include various operating instructions for performing various operations. The operating system may include various system programs for implementing various basic services and for handling hardware-based tasks.
Processor 402 controls the operation of the network device, andprocessor 402 may also be referred to as a CPU. In a particular application, the various components of the network device are coupled together by a bus system that may include a power bus, a control bus, a status signal bus, etc., in addition to a data bus. For clarity of illustration, the various buses are referred to in the figures as a bus system.
The method disclosed in the embodiments of the present application may be applied to theprocessor 402 or implemented by theprocessor 402. Theprocessor 402 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware or instructions in the form of software in theprocessor 402. Theprocessor 402 described above may be a general purpose processor, a DSP, an ASIC, an FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in thememory 403, and theprocessor 402 reads the information in thememory 403 and performs the steps of the method in combination with the hardware.
In this embodiment, theprocessor 402 is configured to execute the port state processing method executed by the root bridge device side when the network device is used as the root bridge device.
It should be noted that the above-described embodiments of the apparatus are merely schematic, where the units described as separate parts may or may not be physically separate, and the parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. In addition, in the drawings of the embodiments of the apparatus provided in the present application, the connection relationship between the modules indicates that there is a communication connection therebetween, and may be implemented as one or more communication buses or signal lines.
In the several embodiments provided in this application, it should be understood that the disclosed system, module and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.