Setting the Port Cost
Setting the Port Cost The parameters in this next set are used to enable the network administrator to influence the path that spanning tree chooses when setting the port priority, port cost, and path cost. Cisco does not recommend changing these settings unless it’s absolutely necessary. However, the best way to get a good understanding of how the STP works is by changing the defaults. We do not recommend trying any of this on a production network unless you have permission from the network manager, who understands that you can bring the network down by doing so. By changing the port cost, you can change the port ID, which means it can be a more desirable port to STP. Remember that STP uses the port ID only if there is more than one path to the root bridge and they are of equal cost. Path cost is the sum of the costs between Scaling the Spanning Tree Protocol 511 a switch and the root bridge. The STP calculates the path cost based on the media speed of the links between the switch and the port cost of each port forwarding the frames. In the hands-on lab on the accompanying CD, both links are 100Mbps, so the port ID is important and will be used. To change the path used between a switch and the root bridge, first calculate the current path cost. Then change the port cost of the port you want to use, making sure that you keep in mind the alternate paths if the primary path fails before making any changes to your switch. Remember that ports with a lower port cost are more likely to be chosen; this doesn’t mean they always will be chosen. To change the port cost of a port on a 4000 series switch, use the set spantree portcost command: Terry_4000> (enable) set spantree portcost ? Usage: set spantree portcost <mod_num/port_num> <cost> set spantree portcost <trcrf> <cost> (cost = 1..65535) The parameters to set the cost of a port are the module and port number and the cost you want to configure. The following example shows how to set the port cost on port 1/1 from the default of 19 to 10: Terry_4000> (enable) set spantree portcost 1/1 10 Spantree port 1/1 path cost set to 10. You would verify the change with the show spantree command. However, because both ports are in forwarding mode, the preceding command will not change the switch’s STP parameters. Notice in the following switch output that both ports are forwarding, but the costs of the ports are different:
Port Vlan Port-State Cost Priority Fast-Start --------- ---- ------------- ----- -------- ---------- 1/1 1 forwarding 10 32 disabled 1/2 1 forwarding 19 32 disabled Remember that a root switch will be forwarding on all active ports, so the port IDs are irrelevant to the switch. However, the 2950 must then choose a port to perform blocking on the interface with the lowest cost. To change the port cost on an IOS-based switch, use the spanning-tree cost interface command. The cost value can be any number from 1 to 200000000; however, you cannot make it less than the path cost of both links. What you need to do is to raise the port priority of the port that we don’t want STP to use for forwarding. Notice in the following example that we change the cost of port fa0/24 to 20. This should make the fa0/24 port a more desirable path: Terry_2950#conf t Enter configuration commands, one per line. End with CNTL/Z. 512 Chapter 16 Using Spanning Tree with VLANs Terry_2950(config)#interface fa0/24 Terry_2950(config-if)#spanning-tree ? bpdufilter Don't send or receive BPDUs on this interface bpduguard Don't accept BPDUs on this interface cost Change an interface's spanning tree port path cost guard Change an interface's spanning tree guard mode link-type Specify a link type for spanning tree protocol use port-priority Change an interface's spanning tree port priority portfast Enable an interface to move directly to forwarding on link up stack-port Enable stack port vlan VLAN Switch Spanning Tree Terry_2950(config-if)#spanning-tree cost ? <1-200000000> port path cost Terry_2950(config-if)#spanning-tree cost 20 Terry_2950(config-if)#^Z To verify the port priorities, use the show spanning-tree command: Terry_2950#show spanning-tree
VLAN0001 Spanning tree enabled protocol ieee [Output cut] Interface Port ID Designated Port ID Name Prio.Nbr Cost Sts Cost Bridge ID Prio.Nbr ---------------- -------- --------------- -------------------- -------- Fa0/1 128.1 5 FWD 0 1 00b0.6414.1180 128.1 Fa0/24 128.24 20 BLK 0 1 00b0.6414.1180 128.12 In the preceding switch output, notice that port fa0/1 is forwarding and port fa0/24 is now blocking. In the output, the port path cost is 5 for port fa0/1 and 20 for port fa0/24. This is a pretty simple and straightforward configuration and worked fine, but the network suffered downtime due to convergence, so caution should be used when changing the port costs in a real production network. Also, you need to plan your final topology, because you can cause havoc in a network if the configuration is not thought out carefully. The port costs are propagated in the BPDUs, so a small change on one switch can affect how spanning tree chooses the various ports on a switch a few cable segments away.
You can get a good idea of the delays associated with spanning tree convergence if you try this out for yourself. Immediately after making the changes to the port cost, enter the show spanning-tree command on the 2950 switch. If you keep repeating the command, you will see the switch going through the blocking, listening, and learning modes on the way to forwarding. You can time the process with your watch.
641 times read
|