In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
A local area network is usually formed by the interconnection of multiple switches. in order to avoid broadcast storms, we need to ensure that there are no path loops in the network, that is, all links should form a tree without loops. STP (spanning Tree Protocol) on the switch achieves this function. In this chapter, we will first learn some basic concepts about the STP protocol, and how the STP protocol can achieve a dynamic spanning tree by blocking and opening redundant links. Finally, we will introduce RSTP (Rapid spanning Tree Protocol) and MSTP (multiple spanning Tree Protocol), and how to configure the spanning tree on the switch.
Background of STP production
The influence of path Loop
In a switched network, the bridge does not make any changes to the Ethernet data frame, nor does it record how many bridges have passed through the frame. If there is a loop in the network Xiao Hong, the frame may continue to cycle and multiply in the loop, causing the network bandwidth to be occupied by a large number of repeated frames, resulting in network congestion.
The image above is an example of data frame loops and multiplications caused by loops.
At first, it is assumed that PCA has not sent any frames, so there is no address record for PCA in the address tables of bridge SWA, SWB, and SWC.
When PCA sends a frame, the first three bridges receive the frame, record the address of the PCA on physical segment A, and forward the frame to physical segment B.
The bridge SWA will forward the frame to physical segment B, so that SWB and SWC will receive the frame again, because SWA is transparent to SWB and SWC, as if the frame was sent by PCA on physical segment B, so SWB and SWC record PCA on physical segment B and forward the new frame to physical segment A.
By the same token, SWB sends the initial frame to physical segment B, and both SWA and SWC receive the frame. SWC believes that PCA is still on physical segment B, and SWA finds that PCA has been transferred to physical segment B, and then both SWA and SWC forward the new frame to physical segment A. If this goes on, the frame will continue to loop in the loop, and to make matters worse, each successful frame transmission will result in two new frames in the network.
The role of STP
Although transparent bridge has this hidden danger, its application is quite attractive, because the role of transparent bridge in loop-free network is beyond reproach. So does it mean that we can't build a network with loops? This is obviously not appropriate, because the existence of the loop can still ensure the connectivity of the network after a link of the topology is disconnected.
For this reason, we find a good algorithm, which prunes a loop bridging network into a loop-free tree topology by blocking redundant links, which not only solves the loop problem, but also restores network connectivity by activating blocked redundant links when an active (active) link is disconnected.
The figure above shows an example of a bridged network that applies a spanning tree, where the bridge identified by the character ROOT is the root of the spanning tree, the solid line is the active link, that is, the branches of the spanning tree, and the dotted line is the blocked redundant link, which is activated only when the active link is down.
STP spanning Tree Protocol
STP (Spanning Tree Protocol, spanning Tree Protocol) is a protocol established according to the 802.1D standard developed by the IEEE Association to eliminate physical loops in the data link layer in the local area network. The devices running the protocol discover the loops in the network by exchanging information with each other, and selectively block some ports, and finally trim the loop network structure into a tree network structure without loops, so as to prevent the continuous growth and infinite circulation of messages in the loop network, and avoid the decline of message processing capacity caused by the repeated reception of the same messages.
STP contains two meanings. In the narrow sense, STP refers to the STP protocol defined in IEEE 802.1D, and in the broad sense, STP refers to the STP protocol defined by IEEE 802.1D and various improved spanning tree protocols based on it, such as RSTP and MSTP.
The protocol message adopted by STP is BPDU (Bridge Protocol Data Unit, bridge protocol data unit), and BPDU contains enough information to complete the calculation of spanning tree.
BPDU is divided into two categories in the STP protocol:
Configure BPDU (Configuration BPDU): messages used to perform spanning tree calculations and maintain spanning tree topologies.
TCN BPDU (Topology Change Notification BPDU): a message used to notify relevant devices of the occurrence of a network topology when the topology changes.
Configure the generation and delivery of BPDU
The BPDU message for the configuration of STP protocol carries the following important information:
Root Bridge ID (RootID)
It consists of the priority and MAC address of the root bridge. By comparing the BPDU double root bridge ID,STP, we finally decide who is the root bridge.
Root path cost (RootPathCost)
The path cost to the root bridge. In the root port election, the port with the least cost is elected as the root port: in the designated bridge election, the bridge north with the lowest cost is elected as the designated bridge.
Specify bridge ID (DesignatedBridgeID)
When the root port is elected, the smallest port of the connected bridge ID is elected as the root port. When the designated bridge is elected, the bridge with the smallest bridge ID is elected as the designated bridge.
Designated port ID (DesignatedPortID)
When the root port is elected, the port with the smallest ID is elected as the root port.
Each port of each device will initially generate a configuration message with itself as the root bridge, with a root path cost of 0, specify the bridge ID as its own device ID, and specify the port as the local port. Each device sends its own configuration information and receives configuration messages from other devices. By comparing these configuration messages, the switch performs spanning tree calculation, elects the root bridge, and determines the port role.
After the network converges, the root bridge will generate and send out the configuration BPDU according to a certain time interval, and other devices forward the configuration BPDU to ensure the stability of the topology.
The election of Root Bridge
The tree-shaped network structure must have tree roots, so STP introduced the concept of Root Bridge.
Each device in the network has its own bridge ID, and the bridge ID consists of two parts: priority (BridgePriority) and bridge MAC address (BridgeMacAddress). Because the bridge MAC address is unique in the network, it is guaranteed that the bridge ID is also unique in the network. In the bridge ID comparison, first compare the priority, the lower priority value is the better; in the case of equal priority, then use the MAC address to compare, the smaller MAC address is the better.
At the beginning of the network, all the STP devices in the network thought of themselves as the "root bridge". The bridge ID is compared between devices by configuring BPDU, and the device with the smallest bridge ID in the network is selected as the root bridge. The root bridge generates and sends the configuration BPDU at a certain time interval, and other devices forward the configuration BPDU to ensure the stability of the topology.
In the figure above, because the bridge ID of SWA is the smallest, all SWA are elected as the root bridge.
Determination of port role
The function of STP is to prune a bridge network with loops to a tree topology without loops by blocking redundant links. It does this by putting some ports on the loop into a blocking state and not allowing data frames to pass through. Here is the process of determining which ports are in a blocking state:
All ports on the root bridge are designated ports (Designated Port)
Select the port with the lowest root path cost (RootPathCost) as the root port (RootPort) for each non-root bridge, and the path from that port to the root bridge is the best path from this bridge to the root bridge.
Select the bridge with the lowest root path cost for each physical segment as the designated bridge (Designated Bridge). The designated port from the bridge to the physical segment is used as the designated port, which is responsible for forwarding data on the physical segment.
A port that is neither a designated port nor a root port is placed in a blocking state.
Root path cost
Root path cost (RootPathCost) is a parameter used in spanning Tree Protocol to determine the distance to the root. It is the algebraic sum of all link costs (Cost) on the path to the root.
When a non-root bridge elects a root port, the root path cost of each port is compared first, and the port with the lowest cost is elected as the root port. When the physical segment elects a designated bridge, the root path cost of each bridge is also compared first. The north of the bridge with the lowest cost is elected as the designated bridge.
Typically, the cost of the link is inversely proportional to the physical bandwidth. The greater the bandwidth, the stronger the capacity of the link, and the lower the path cost.
IEEE802.1D and 802.1t define the Ethernet link (port) cost under different rates and working modes, while H3C optimizes the numerical definition of cost according to the actual network operation status, and establishes a private standard. The common definitions of the above three standards are shown in the table. For other details, please refer to the relevant standard documents and equipment manuals.
The H3C switch defaults to the link cost defined by private standards. The link cost of the switch port can be set manually to affect the routing of spanning tree.
Determine the port role through the bridge ID
Spanning Tree Protocol determines the port role based on the port ID when it is the same as the path cost and the designated bridge ID.
If multiple ports on the non-root bridge go through the same upstream to the root and the root path cost is the same, the protocol compares the port ID of the upstream bridge to which the port is connected, and the port with the smallest ID is elected as the root port.
Port ID consists of two parts: Port index number and port priority. When making a comparison, we first compare the port priority, which is smaller than the port priority; when the priority is the same, compare the port index number, which is smaller than the port priority.
In the figure above, two ports on SWB are connected to SWA. The root path cost of these two ports is the same, and so is the upstream designated bridge ID. According to the upstream designated port ID, the protocol determines that the connected designated port ID is so small that the port is the root port.
In general, the port index number cannot be changed, and the user can influence the routing of the spanning tree by setting the port priority.
Port statu
In fact, in 802.1D protocols, ports have five states:
Disabled: indicates that the port is in an invalid state and does not receive or send any messages. This state can be caused by the physical state of the port (for example, there is no up in the physical layer of the port), or the manager shuts down the port manually.
Blocking: ports in this state cannot participate in forwarding datagrams, but can receive configuration messages and hand them over to CPU for processing. However, configuration messages cannot be sent, and address learning is not performed.
Listening: ports in this state do not participate in data forwarding or address learning, but can receive and send configuration messages.
Learing: ports in this state do not participate in data forwarding, but start address learning and can receive, process, and send configuration messages.
Forwarding: once the port enters this state, it can forward any data, as well as address learning and the receiving, processing, and sending of configuration messages.
Among the above five states, Listening and Learing are unstable intermediate states.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.