Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Spanning Tree Protocol
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Protocol operation== {{multiple image | width = 300 | image1 = Spanning tree protocol at work 5.svg | alt1 = | caption1 = [[Network bridge|Bridges]] with Spanning Tree Protocol implementation in a local area network (LAN). One bridge is the STP ''root bridge''. All bridge ports that connect a link between two bridges are either a ''root port'' (RP), a ''designated port'' (DP), or a ''blocked port'' (BP). | image2 = Spanning tree protocol at work 6.svg | alt2 = After link failure the spanning tree algorithm computes and spans new least-cost tree. | caption2 = After link failure the spanning tree algorithm computes and spans new least-cost tree. }} The need for the Spanning Tree Protocol (STP) arose because [[Network switch|switches]] in [[local area networks]] (LANs) are often interconnected using redundant links to improve resilience should one connection fail.<ref name="Angelescu"/>{{rp|386}} However, this connection configuration creates a [[switching loop]] resulting in [[broadcast radiation]]s and [[MAC table]] instability.<ref name="Angelescu"/>{{rp|388}} If redundant links are used to connect switches, then switching loops need to be avoided.<ref name="Angelescu"/>{{rp|385}} To avoid the problems associated with redundant links in a switched LAN, STP is implemented on switches to monitor the network topology. Every link between switches, and in particular redundant links, are catalogued. The spanning-tree algorithm then blocks forwarding on redundant links by setting up one preferred link between switches in the LAN. This preferred link is used for all Ethernet frames unless it fails, in which case a non-preferred redundant link is enabled. When implemented in a network, STP designates one layer-2 switch as ''root bridge''. All switches then select their best connection towards the root bridge for forwarding and block other redundant links. All switches constantly communicate with their neighbors in the LAN using {{section link||Bridge_protocol_data_units}} (BPDUs).<ref name="Angelescu"/>{{rp|388}} Provided there is more than one link between two switches, the STP root bridge calculates the cost of each path based on bandwidth. STP will select the path with the lowest cost, that is the highest bandwidth, as the preferred link. STP will enable this preferred link as the only path to be used for Ethernet frames between the two switches, and disable all other possible links by designating the switch ports that connect the preferred path as ''root port''.<ref name="Angelescu">{{Cite book |title=CCNA Certification All-In-One For Dummies |author=Silviu Angelescu |publisher=John Wiley & Sons |year=2010 |isbn=9780470635926}}</ref>{{rp|393}} After STP enabled switches in a LAN have elected the root bridge, all non-root bridges assign one of their ports as root port. This is either the port that connects the switch to the root bridge, or if there are several paths, the port with the preferred path as calculated by the root bridge. Because not all switches are directly connected to the root bridge they communicate amongst each other using STP BPDUs. Each switch adds the cost of its own path to the cost received from the neighboring switches to determine the total cost of a given path to the root bridge. Once the cost of all possible paths to the root bridge have been added up, each switch assigns a port as root port which connects to the path with the lowest cost, or highest bandwidth, that will eventually lead to the root bridge.<ref name="Angelescu"/>{{rp|394}} === Path cost === {| class="wikitable floatright" style="text-align: right" |+Path cost for different port speed and STP variation |- ! Data rate<br />(link bandwidth) ! Original STP cost<br />(802.1D-1998) ! RSTP/MSTP cost<br />(recommended value)<ref name="802.1Q"/>{{rp|503}} |- | {{nowrap|4 Mbit/s}} | 250 | 5,000,000 |- | {{nowrap|10 Mbit/s}} | 100 | 2,000,000 |- | {{nowrap|16 Mbit/s}} | 62 | 1,250,000 |- | {{nowrap|100 Mbit/s}} | 19 | 200,000 |- | {{nowrap|1 Gbit/s}} | 4 | 20,000 |- | {{nowrap|2 Gbit/s}} | 3 | 10,000 |- | {{nowrap|10 Gbit/s}} | 2 | 2,000 |- | {{nowrap|100 Gbit/s}} | N/A | 200 |- | {{nowrap|1 Tbit/s}} | N/A | 20 |} The STP path cost default was originally calculated by the formula {{math|{{sfrac|1 Gbit/s|bandwidth}}}}. When faster speeds became available, the default values were adjusted as otherwise speeds above {{nowrap|1 Gbit/s}} would have been indistinguishable by STP. Its successor RSTP uses a similar formula with a larger numerator: {{math|{{sfrac|20 Tbit/s|bandwidth}}}}. These formulas lead to the sample values in the table.<ref name="802.1D-2004">{{cite web |url=http://standards.ieee.org/getieee802/download/802.1D-2004.pdf |archive-url=https://web.archive.org/web/20051210051119/http://standards.ieee.org/getieee802/download/802.1D-2004.pdf |url-status=dead |archive-date=December 10, 2005 |title=802.1D IEEE Standard for Local and Metropolitan Area Networks. Media Access Control (MAC) Bridges |year=2004 |publisher=[[IEEE]] |access-date=19 April 2012}}</ref>{{rp|154}} === Port states === All switch ports in the LAN where STP is enabled are categorized.<ref name="Angelescu"/>{{rp|388}} ; Blocking: A port that would cause a switching loop if it were active. To prevent the use of looped paths, no user data is sent or received over a blocking port. BPDU data is still received in blocking state. A blocked port may go into forwarding mode if the other links in use fail and the spanning tree algorithm determines the port may transition to the forwarding state. ; Listening: The switch processes BPDUs and awaits possible new information that would cause it to return to the blocking state. It does not populate the [[MAC table]] and it does not forward frames. ; Learning: While the port does not yet forward frames, it does learn source addresses from frames received and adds them to the MAC table. ; Forwarding: A port in normal operation receiving and forwarding frames. The port monitors incoming BPDUs that would indicate it should return to the blocking state to prevent a loop. ; Disabled: A network administrator has manually disabled the switch port. When a device is first attached to a switch port, it will not immediately start to forward data. It will instead go through a number of states while it processes BPDUs and determines the topology of the network. The port attached to a host such as a computer, printer or [[Server (computing)|server]] always goes into the forwarding state, albeit after a delay of about 30 seconds while it goes through the listening and learning states. The time spent in the listening and learning states is determined by a value known as the forward delay (default 15 seconds and set by the root bridge). If another switch is connected, the port may remain in blocking mode if it is determined that it would cause a loop in the network. Topology change notification (TCN) BPDUs are used to inform other switches of port changes. TCNs are injected into the network by a non-root switch and propagated to the root. Upon receipt of the TCN, the root switch will set the topology change flag in its normal BPDUs. This flag is propagated to all other switches and instructs them to rapidly age out their forwarding table entries.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)