Spanning Tree : Portfast
Spanning Tree : Portfast
Let's look at the an example to see why the Portfast feature was included to the Spanning Tree protocol. Consider a server that is attached to a switch port that isn't PortFast setup. The switchport goes down and then backs up when the server reboots. The interface enters a forwarding state as part of the Spanning-Tree protocol's standard procedure. The port goes through several phases: the Listening state (15 seconds), the Learning state (15 seconds), and the Forwarding state (15 seconds). Therefore, it takes around 30 seconds for the server to send and receive data across the port.
The switch sees this link flap as a topology change and triggers the Topology Change Notification (TCN) process. It is explained in detail in this lesson. In short, when a topology change is detected, switches lower their MAC table aging timer (5 min) to the MaxAge time (20 sec). However, if a switchport connects only to one end-user device (like a server, computer, printer, etc.), there’s very little risk of a loop. Loops only occur when the device is bridging traffic back into the network, which end-user devices do not do.
What is Portfast?
PortFast is a spanning-tree feature that optimizes the handling of edge ports. Edge ports are ones that connect to end-user devices such as computers, servers, and printers. PortFast is configured per port and provides two significant optimizations when enabled
- When the port becomes up, STP puts it into a Forwarding state right away, skipping the Listening and Learning states.
- When the port status changes, STP does not generate a Topology Change Notifications (TCNs).
Enabling portfast doesn't mean that the port doesn't participate in STP elections, BPDUs are still sent and received on the interface. Whenever an interface receives a BPDU it goes to a non-portfast state and starts the election process, this can create a small window where layer 2 loops can occur.
To avoid this, portfast is only enabled on edge ports(ports that connect end hosts to the network) and is paired with a BPDU guard for security purposes. Although you can also enable this feature on trunking ports, it is suggested that you only use this feature on edge ports to avoid the formation of layer 2 loops.
Advantages:
- Devices connected to this port can access the network without waiting for STP convergence on each VLAN.
- Minimize the amount of time trunk ports waits for the spanning tree to converge.
- This allows the port to immediately transition from disabled to the forwarding state, thus avoiding the 30-second delay for him accessing the network.
- Avoid forming spanning tree loops with other directly connected switches.