When Spanning-Tree (STP) solves a loop in a network of switches, it follows a series of parameters to determine the best path to the Root Bridge, this "path" will be identified on each switch By the Root Port ...
These criteria are, in decreasing
order of priority:
- The "Root Path Cost": the sum of the interfaces costs by which the BPDU enters.
- The Bridge ID of the next switch.
- The Port-ID of the neighbor switch.
The Root path cost can be influenced
by modifying the cost of the interfaces by which the BPDUs enter.
The Bridge ID itself can be
manipulated by adjusting the STP priority. This is usually done to ensure that
a specific switch is elected as the Root-Bridge. It is therefore difficult to
modify it in order to influence the choice of the RP (root-port).
It may happen that two-links lead to
the Root Bridge with the same cost, and that the neighbor's Bridge ID is
identical (two parallel links between the same two switches), this is where the
Port-ID comes in. As with everything else in STP, the smaller Port-ID will be
the best.
In reality the port ID consists of
two elements ...
- The priority of the port encoded on 8 bits (0-255)
- The identifier of the port coded on 8 bits, depending on the material therefore not modifiable.
In general, this detail is
simplified by saying that at equal cost and equal neighbor bridge-id, the
switch chooses the smallest interface (by alphanumeric classification) ... e.g.
fastEthernet0 / 0 is smaller than fastEthernet0 / 1 ... but in reality, Each of
its ports has an identification number associated with it (which moreover
reflects the simplified logic described above).
Although the principle seems simple,
its understanding may be tricky. Indeed, the modification of the cost of an
interface has an effect on the local switch ... because it is added to the
Root-Path-Cost present in the BPDU ... by cons ... The priority of the port as
for it has an indirect effect. The switch will select the interface by which it
receives the lowest Port-ID ... which implies that the information is given by
the neighbor switch.
Let's see this in practice ...
Topology
used for Spanning-Tree Protocol(STP): Port cost vs Port priority
STP Topology |
SWITCH-B and SWITCH-C are connected
by their respective interfaces Fa0 / 1, Fa0 / 2, FA0 / 9 and Fa0 / 10. The Fa0
/ 1 and Fa0 / 2 interfaces are configured as a static Etherchannel, the same
for Fa0 / 9 and Fa0 / 10.
In this way, we have two switches
linked by two parallel Etherchannel, equal cost etc.
Analysis
of the basic topology
SWITCH-B # show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID
Priority 32769
Address
000e.84fd.c440
This
bridge is the root
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge
ID Priority 32769 (priority 32768 sys-id-ext 1)
Address
000e.84fd.c440
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging
Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- --------
---------- ----------------------
Po1 Desg FWD 12 128.65 P2p
Po2 Desg FWD 12 128.66 P2p
SWITCH-B #
Currently SWITCH-B is the
root-bridge. The two Etherchannels (Po1 and Po2) are therefore DP (Designated
Port) and are in a forwarding state. It is therefore on SWITCH-C side that
there will be a port blocking.
SWITCH-C # show
spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID
Priority 32769
Address
000e.84fd.c440
Cost 12
Port 65
(Port-channel1)
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge
ID Priority 32769 (priority 32768 sys-id-ext 1)
Address
000f.28a2.d740
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging
Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- --------
---------- ----------------------
Po1 Root FWD 12 128.65 P2p
Po2 Altn BLK 12 128.66 P2p
SWITCH-C #
It is noted here that Po2 is
blocking (Altn BLK). Why ? ... Po1 and Po2 have the same Root Path Cost, so the
switch tries to break them with the BID of the neighbor ... except it is the
same ... it then has the Port-ID of the neighbor ... Po1 on SWITCH-B has a
Value of 128.65, compared with 128.66 for Po2, when SWITCH-C receives the BPDU
from Po1 of SWITCH-B it considers it as better and Po1 then becomes the RP.
Modify
the RP by acting on the cost
Probably the simplest method, just
modify the interface cost by which between the BPDU. For example here one can
reduce the cost of Po2 on SWITCH-C. This will decrease the Root Path Cost by
this link and will define it as RP.
SWITCH-C (config) #interface port-channel 2
SWITCH-C (config-if) # spanning-tree
Let's check ...
SWITCH-C # show
spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID
Priority 32769
Address
000e.84fd.c440
Cost 11
Port 66
(Port-channel2)
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge
ID Priority 32769 (priority 32768 sys-id-ext 1)
Address
000f.28a2.d740
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging
Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- --------
---------- ----------------------
Po1 Altn BLK 12 128.65 P2p
Po2 Root FWD 11 128.66 P2p
SWITCH-C #
The result corresponds to our
expectations, Po2 now has a cost of 11 and is therefore the best path to the
root, and thus elected RP ... Po1 thus becomes the port blocking.
Simple ... effective ... but ...
modifying the cost of an interface has an impact on the topology as a whole. If
several switches are cascaded, changing the cost on an interface impacts all
the downstream switches.
So we can proceed otherwise ...
Modify
the RP by acting on the Port-ID
Here it is more delicate. It will be
necessary to modify the priority of the port by which the received BPDU is
sent. So to favor Po2 on SWITCH-C, it will be necessary to reduce the priority
value of PO2 (smaller = better) on SWITCH-B ...
Note: In a "show
spanning-tree", the "Prio.Nbr" column indicates the value that
the switch will write to the BPDU when it issues it via this interface.
First we put the default cost on
SWITCH-C .... (SWITC-C Po1 becomes again the RP and Po2 becomes blocker again).
SWITCH-C (config) #interface port-channel 2
SWITCH-C (config-if) #no spanning-tree vlan 1
cost 11
Then switch to SWITCH-B and set a
lower port priority value for Po2 so that SWITCH-C prefers the BPDUs emitted by
this interface ...
SWITCH-B (config) #interface port-channel 2
SWITCH-B (config-if) # spanning-tree vlan 1
port-priority 112
Note that the priority value (128 by
default) must be an increment of X ... where X depends on the switch, IOS etc
... for example on the c2950 I use for the example, increments of 16 (128-16 =
112).
First check the result on SWITCH-B
...
SWITCH-B # show spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID
Priority 32769
Address
000e.84fd.c440
This
bridge is the root
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge
ID Priority 32769 (priority 32768 sys-id-ext 1)
Address
000e.84fd.c440
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging
Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- --------
---------- ----------------------
Po1 Desg FWD 12 128.65 P2p
Po2 Desg FWD 12 112.66 P2p
SWITCH-B #
We see here that the priority of Po2
has been adjusted ... but it must not be forgotten that this has no local
effect, it is the value indicated in the BPDU when it is transmitted by this
interface.
Let's see on SWITCH-C ...
SWITCH-C # show
spanning-tree vlan 1
VLAN0001
Spanning tree enabled protocol ieee
Root ID
Priority 32769
Address
000e.84fd.c440
Cost 12
Port 66
(Port-channel2)
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge
ID Priority 32769 (priority 32768 sys-id-ext 1)
Address
000f.28a2.d740
Hello
Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging
Time 300
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- --------
---------- ----------------------
Po1 Altn BLK 12 128.65 P2p
Po2 Root FWD 12 128.66 P2p
SWITCH-C #
The Po2 interface has become the RP
without changing its cost. On the other hand we do not see here the change of
priority ... again this command only displays the value of the local interface
... to see the value received in the BPDU it is necessary to scrape further ...
SWITCH-C # show
spanning-tree vlan 1 detail
VLAN0001 is executing the ieee compatible
Spanning Tree protocol
Bridge
Identifier has priority 32768, sysid 1, address 000f.28a2.d740
Configured hello time 2, max age 20, forward
delay 15
Current
root has priority 32769, address 000e.84fd.c440
Root
port is 66 (Port-channel2), cost of root path is 12
Topology change not flagged, detected flag not
set
Number
of topology changes 8 last change occurred 00:14:48
From
Port-channel1
Times:
hold 1, topology change 35, notification 2
Hello
2, max age 20, forward delay 15
Timers:
hello 0, topology change 0, notification 0, aging 300
Port 65 (Port-channel1) of VLAN0001 is
blocking
Port
path cost 12, Port priority 128, Port Identifier 128.65.
Designated root has priority 32769, address
000e.84fd.c440
Designated
bridge has priority 32769, address 000e.84fd.c440
Designated
port id is 128.65, designated path cost 0
Timers:
message age 1, forward delay 0, hold 0
Number
of transitions to forwarding state: 4
Link
type is point-to-point by default
BPDU:
fe 4, received 2207
Port 66 (Port-channel2) of VLAN0001 is
forwarding
Port
path cost 12, Port priority 128, Port Identifier 128.66.
Designated root has priority 32769, address
000e.84fd.c440
Designated bridge has priority 32769, address
000e.84fd.c440
Designated
port id is 112.66, designated path cost 0
Timers:
message age 1, forward delay 0, hold 0
Number
of transitions to forwarding state: 4
Link
type is point-to-point by default
BPDU:
sent 4, received 2202
SWITCH-C #
This command displays the STP detail
for the VLAN1, and more specifically the information received in the BPDUs for
the different interfaces concerned (PO & and Po2 in this case).
We see here that Po2 (port 66)
received a BPDU with a port-id of 112.66 (112 is the priority, 66 is the port
number on SWITCH-B).
What
is it for?
One can imagine various applications
of this method, but one of the most frequent is to perform a load balancing
between two redundant trunks. A trunk is defined with a higher priority for one
set of VLANs and the other for the remaining VLANs. This has the effect of not
leaving an unused trunk and keeping redundancy in case of failure without
impacting the topology beyond the link concerned.
0 comments:
Post a Comment