Absrtact: Spanning tree algorithms and protocols are the basis for automatically generating network topologies. This paper expounds the content of spanning tree algorithm and protocol, and gives the realization process in Ethernet switch. It is proved by practice that the square tip has a good effect on the analytic optimal topological structure of the network.
The Ethernet switch must have routing capabilities on the second layer, the MAC layer. At present, the commonly used MAC layer routing is the standard published by IEEE802.1 organization: Routing based on spanning tree algorithm. After the switch in the LAN executes the spanning tree algorithm, a spanning tree dynamic topology is formed, which causes no loops between any two workstations in the LAN to prevent the resulting LAN broadcast storm, and the spanning tree algorithm is also responsible for monitoring the changes of the physical topology. A new spanning tree can be created after the topology changes. For example, when a switch is broken or a piece of data is broken, the topology of the spanning tree is reconfigured by providing a certain degree of fault tolerance. The switch maintains and updates the MAC routing table according to the state information of the dynamic topological structure of the generating tree, and finally realizes the route of Mac layer.
First, Ethernet switch in the MAC layer architecture
The function of Ethernet switch at MAC layer is to realize the interconnection of LAN. According to the IEEE802.1D protocol, the architecture working at the MAC level must include the following: (1) a MAC forwarding entity for connecting the Switch ports, (2) at least two ports, and (3) A high-level protocol entity, which includes a switch protocol entity. As shown in Figure 1.
Figure I
The MAC forwarding entity mainly realizes the internal communication between different ports of the switch. The entity stores the working state of each port and maintains a filtered database. A MAC Address table is stored in the database to achieve the MAC layer routing. When a data frame is transmitted from the underlying service process of a port, the Mac entity first determines the working state of the destination port, and if the destination port is not blocked, the MAC forwarding entity forwards the frame from the destination port according to the corresponding relationship of the MAC address table. At the same time, the MAC forwarding entity can also filter, record MAC address and other operations.
The function of the switch port is to receive or transmit data from the LAN to which it is connected. The state of the port is defined by the spanning tree algorithm, including forwarding, learning, listening, blocking, and forbidding states.
The High-level Protocol entity is located at the LLC level and is primarily used to compute and configure the topology of the LAN. The Spanning Tree protocol algorithm described below is run within the protocol entity to implement the MAC layer routing. When the spanning tree algorithm is run, the top-level protocol entity can directly invoke the services provided by the MAC forwarding entity and can read or change the information maintained in the MAC entity database, such as reading or changing the status information of a port from the Mac entity.
When running the spanning tree algorithm, the switch's top-level protocol entity uses a unified group address 01-80-c2-00-00-00 as the destination MAC address, which is called the BPDU (Bridge Protocol data Unit). The BPDU carries with it the information about implementing the spanning tree algorithm. When implementing the spanning tree algorithm, the BPDU is received from the port, which is passed to the switch protocol entity by the service process of the LLC layer. After the spanning tree algorithm is executed, the protocol entity of the switch updates the status information of the port according to the result of the algorithm and updates the filtering database to determine the working state (blocking or forwarding, etc.) of the switch port to establish the spanning tree topology.
Two, spanning Tree protocol
1. Introduction to Spanning Tree protocol
The spanning tree protocol is based on the following points: (1) There is a unique group address (01-80-c2-00-00-00) that identifies all the switches on a specific LAN. This group address can be identified by all switches (2) Each switch has a unique identity (Brideg Identifier) and (3) each switch has a unique port identifier (port Identifier). Managing the configuration of the spanning tree also requires a relative priority for each switch, co-ordination a relative priority on each port of each switch, and co-ordination a path for each port co-ordination.
A switch with the highest priority is called the root switch. Each switch port has a root path cost, and the root path cost is the sum of the path costs for each hop segment that the switch passes through to the root switch. The lowest port in a switch where the root path is spent is called the root port, and if multiple ports have the same root-path cost, the highest priority port is the root port.
Each LAN has a switch called a designated switch, which belongs to the least expensive switch for the root path in the LAN. The port that connects the LAN to the selection switch is the selection port of the LAN (designated port). If you select more than two ports in the switch to connect to this LAN, the port with the highest priority is selected as the selection port. The topology structure is shown in Figure 2.
Because switch A has the highest priority (lowest bridge identification), is selected as the root switch, so switch A is LAN A and LAN B's selector switch; assuming that switch B's root path costs 6 and switch C's root path costs 4, switch C is selected as the LAN C selector switch, or LAN The message between C and switch A is forwarded through switch C instead of Switch B. The link between LAN C and Switch B is a redundant link.
2, BPDU code
BPDU packets are sent periodically between switches to exchange spanning tree configuration information to enable timely response to network topology, cost, or priority changes. BPDU is divided into two types, BPDU packages that contain configuration information, called Configuration BPDU (Configuration BPDU), are sent a topology change notification BPDU (topology change NOTIFICATION BPDU) when the network topology changes are detected. Configure the BPDU encoding as shown in Figure 3.
The topology change notification BPDU code is shown in Figure 4.
For configuration Bpdu, bytes other than 35 bytes are ignored, and bytes other than 4 bytes are ignored for topology change notification BPDU.
3. Elements of the decision necessary to form a spanning tree
(1) Determine the root switch
A, at the beginning of all switches are considered to be the root switch;
b, the switch sends configuration BPDU to the LAN broadcast connected to it, and its root_id is the same as the bridge_id value;
C, when the switch receives the configuration BPDU from another switch, if it finds that the value of the root_id field in the received configuration BPDU is greater than the value of the root_id parameter in the switch, the frame is discarded, otherwise the root_id, root path cost of the switch is updated root_path_ The value of the parameter such as the cost, the switch will continue to broadcast the send configuration BPDU with the new value.
(2) Determine the root port
The lowest port in a switch where the root path is spent is called the root port.
If multiple ports have the same minimum root path cost, the port with the highest priority is the root port. If two or more ports have the same minimum root-path cost and highest priority, the port with the lowest number of ports is the default root port.
(3) Determine the selection of the LAN switch
A, at the beginning, all switches consider themselves to be the selection switch for the LAN.
b, when the switch receives a BPDU from another switch (in the same LAN) that is spent on a lower root path, the switch no longer claims to be the selector switch. If two or more switches have the same root path cost in one LAN, the switch with the highest priority is selected first. In a LAN, only the selection switch can receive and forward frames, and all ports on the other switch are placed in a blocked state.
C, if the switch is picked up at a certain point in time. The configuration BPDU that is sent by other switches on the LAN because of competing to select the switch will send a response configuration BPDU to redefine the selection switch.
(4) Decide to select the port
The port that is connected to the LAN in the selection switch of the LAN is the selection port. If you select a switch with two or more ports connected to the LAN, the port with the lowest identification is the selection port.
In addition to the root port and the selection port, the other ports are placed in a blocking state. Thus, the topology of a spanning tree is determined when the root switch, the root port of the switch, and the selection switch and selection port for each LAN are determined.
4. Topology change
Topology information is propagated over the network with a time limit, which is included in each configuration BPDU, which is the message time limit. Each switch stores protocol information from the LAN selection port and monitors the time that the information is stored. In a normally stable state, the root switch sends configuration messages on a regular basis to ensure that the topology information does not timeout. If the root switch fails, the protocol information in the other switches times out, and the new topology is quickly propagated across the network.
When a switch detects a topology change, it sends a topology change notification to the selector switch in the direction of the root switch, and periodically sends a topology change notification to the BPDU at the time interval of the topology change notification timer BPDU until a confirmation topology change message from the selected switch is received (this confirmation signal is in the configuration BPDU That is, the topology change flag position), at the same time select the switch to repeat the above process, continue to the root switch direction of the switch to send a topology change notification BPDU. In this way, notifications of topology changes are eventually uploaded to the root switch. The root switch receives such a notification, or itself changes the topology, it will send a configuration BPDU for a period of time, in the configuration BPDU the topology change flag bit is placed. All switches will receive one or more configuration messages, and use the value of forwarding delay parameters to age the filtered addresses in the database. All switches will redefine the root switch, the root port of the switch, and the selection switch and selection port for each LAN, so that the topology of the spanning tree is decided again.
The tree-spanning algorithm based on the above principles and methods is normal and can resolve the optimal network topology. When an administrator makes a port invalid or a link is disconnected, the algorithm can reconfigure the topology of the spanning tree in time to respond to network topology changes.