The stp cost command sets the path cost of a port in a spanning tree.
The undo stp cost command restores the default path cost.
By default, the path cost of a port in a spanning tree is the path cost corresponding to the port rate.
STP/RSTP/MSTP: stp [ process process-id ] [ instance instance-id ] cost cost
VBST: stp [ vlan { vlan-id1 [ to vlan-id2 ] } &<1-10> ] cost cost
STP/RSTP/MSTP: undo stp [ process process-id ] [ instance instance-id ] cost
VBST: undo stp [ vlan { vlan-id1 [ to vlan-id2 ] } &<1-10> ] cost
Parameter | Description | Value |
---|---|---|
process process-id |
Indicates the ID of an MSTP process. If process process-id is not specified, the status and statistics of an MSTP process with the ID 0 will be displayed. |
The value is a decimal integer ranging from 1 to 31. |
instance instance-id |
Specifies the number of a spanning tree instance. If instance instance-id is not specified, it indicates the path cost of an interface in CIST. |
The value is an integer ranging from 0 to 4094. Value 0 refers to CIST. NOTE:
instance-id ranges from 0 to 4094. Each process supports a maximum of 65 instances. |
cost |
Specifies the path cost of an interface. |
According to different calculation standards, the value ranges are as follows:
|
vlan vlan-id1 [ to vlan-id2 ] |
Specifies one or more VLANs in which the port path cost is set.
In the stp cost command, you can specify a maximum of 10 VLAN ranges. NOTE:
VLANs can be specified only when VBST is running. |
The value is an integer that ranges from 1 to 4094. |
Ethernet interface view, GE interface view, XGE interface view, MultiGE interface view, 40GE interface view, 100GE interface view, Eth-Trunk interface view, port group view, 25GE interface view
Usage Scenario
The path cost of a port is an important basis for calculating a spanning tree. Path costs determine root port selection. In a spanning tree, the port with the lowest path cost to the root bridge is selected as a root port.
If different path costs are set for a port on an MSTP device in different spanning tree instances, traffic of different VLANs will be forwarded along different physical links and VLAN-based load balancing can be carried out.
Link Rate |
Recommended Value Default, Value |
Recommended Value Range |
Value Range |
---|---|---|---|
10 Mbit/s |
2000 |
200-20000 |
1-200,000 |
100 Mbit/s |
200 |
20-2000 |
1-200,000 |
1 Gbit/s |
20 |
2-200 |
1-200,000 |
10 Gbit/s |
2 |
2-20 |
1-200,000 |
Over 10 Gbit/s |
1 |
1-2 |
1-200,000 |
Prerequisites
A path cost calculation standard has been set using the stp pathcost-standard command.
Precautions
If the path cost of a port, the spanning tree where the port resides needs to be recalculated.
If the stp pathcost-standard command is used to change the path cost calculation standard, the path cost set using the stp cost command for a port will be restored to the default value.
<HUAWEI> system-view
[HUAWEI] interface gigabitethernet 0/0/1
[HUAWEI-GigabitEthernet0/0/1] stp instance 2 cost 200
<HUAWEI> system-view
[HUAWEI] interface gigabitethernet 0/0/1
[HUAWEI-GigabitEthernet0/0/1] stp vlan 10 cost 300