Using PortFast and Other Commands to Fix Workstation Startup Connectivity Delays
This document addresses initial connectivity delays that occur when workstations that are connected to switches have one of these two issues:
*Unable to log in to a network domain, either Microsoft Windows NT or Novell
*Unable to obtain a DHCP address
The steps in this document are easy to implement and address the most common causes of workstation connectivity delays that you encounter during the workstation initialization/startup phase.
If you have recently migrated from a hub environment to a switch environment, startup connectivity delays can appear because a switch works much differently than a hub. A switch provides connectivity at the data link layer, not at the physical layer. The switch uses a bridging algorithm in order to decide if packets that are received on a port need to be transmitted out other ports. The bridging algorithm is susceptible to physical loops in the network topology. Because of this susceptibility to loops, switches run the protocol STP that causes loops to be eliminated in the topology. When you run STP, all ports that are included in the spanning tree process become active much slower than they otherwise become active as STP detects and blocks loops. A bridged network that has physical loops, without STP, breaks. Despite the time that the process involves, STP is beneficial. STP that runs on Catalyst switches is an industry-standard specification (IEEE 802.1D).
After a port on the switch has linked and joined the bridge group, STP runs on that port. A port that runs STP can be in one of five states:
STP dictates that the port starts out blocking, and then immediately moves through the listening and learning phases. By default, the port spends approximately 15 seconds listening and 15 seconds learning. During the listening state, the switch tries to determine where the port fits in the spanning tree topology. The switch especially wants to know whether this port is part of a physical loop. If the port is part of a loop, the port can be chosen to go into blocking mode. The blocking mode means that the port does not send or receive user data in order to eliminate loops. If the port is not part of a loop, the port proceeds to the learning state, in which the port learns which MAC addresses live off this port. This entire STP initialization process takes about 30 seconds.
If you connect a workstation or a server with a single NIC card or an IP phone to a switch port, the connection cannot create a physical loop. These connections are considered leaf nodes. There is no reason to make the workstation wait 30 seconds while the switch checks for loops if the workstation cannot cause a loop. Cisco added the PortFast or fast-start feature. With this feature, the STP for this port assumes that the port is not part of a loop and immediately moves to the forwarding state and does not go through the blocking, listening, or learning states. This command does not turn STP off. This command makes STP skip a few initial steps (unnecessary steps, in this circumstance) on the selected port.
这篇文档中说到，Cisco added the PortFast or fast-start feature，思科添加了一个portfast功能，跳过listening，learning，直接进入forwarding状态。
interface fastEthernet 0/1
那莫，为什么原有的STP协议中没有把这么方便的一个功能加进去呢？看上面那么大一段Warning就知道了~啊，原来是loops的后果很坏很严重……开启了portfast的端口只能接一个网络设备，也就是说，在开启了portfast得端口上，如果出现了环路，哇，居然可以network cannot recover，不过对于我们这种小型办公网络而言，最多也就是个网速超慢……总之呢，就是开启了portfast的端口，是不能接交换机，路由器，集线器等等设备的，也就是说，只能有一个NIC，一个MAC地址（当然是同时）。
Caution: Never use the PortFast feature on switch ports that connect to other switches, hubs, or routers. These connections can cause physical loops, and spanning tree must go through the full initialization procedure in these situations. A spanning tree loop can bring your network down. If you turn on PortFast for a port that is part of a physical loop, there can be a window of time when packets are continuously forwarded (and can even multiply) in such a way that the network cannot recover.
这篇文档居然还无聊地对端口up时间做了个benchmark（请参考原文中Timing Tests on the Catalyst 2900XL段落），结果是可以把三十秒的时间缩短为一秒……效果还是很明显的，等于是把网线插入电脑就可以上网了，零等待~