802.1w RSTP

RSTP(Rapid Spanning Tree Protocol)
IEEE 802.1w , 於2001年提出
ps:
RSTP includes features equivalent to Cisco PortFast, UplinkFast, and BackboneFast for faster network reconvergence.

convergence much faster
1. 收斂速度最快可到1sec
2. 在Blocking state port不須用2倍的Forward Delay時間即可直接變成Forward state
ex:
1. edge port可以直接进入forward state and no delay
2. 當root port為Blocking status,且new root port所接之designated port為Forwarding status,則new root port 可立即成為Forwarding status
3. non-edge port的designated port,可與neighbor bridge進行PA handshake而快速成為Forwarding status

RSTP對STP的改進 
1
STP收斂主要依赖port status
RSTP收斂主要依赖port type
2
STP port state改變,需依賴timer超時
RSTP port state改變,是主動協商
3(待確認) 
STP中的non-root bridge只能relay的hello bpdu
RSTP中的non-root bridge會主動發hello bpdu 

RSTP相容性
RPVST+(Rapid PVST+)
 by using RSTP as the underlying mechanism for the Cisco-proprietary PVST+
MST(Multiple Spanning Tree)
 RSTP also is used as part of the IEEE 802.1s MST operation.
 RSTP operates consistently in each, but replicating RSTP as multiple instances requires different approaches.

………………………………………………………………

root bridge
The root bridge in a network using RSTP is elected just as with 802.1D(by the lowest Bridge ID) 

RSTP port roles
After all switches agree on the identity of the root, the following port roles are determined:
Root port(This is identical to 802.1D)
 保持forward state
Alternate port
 A port that has an alternative path to the root, different from the path the root port takes.
 This path is less desirable than that of the root port.
ex:
an access-layer switch with two uplink ports; one becomes the root port, and the other is an alternate port.
Designated port (This is identical to 802.1D)
 保持forward state
Backup port
 備援的designated port
 A port that provides a redundant (but less desirable) connection to a segment where another switch port(deesignated port) already connects.

RSTP port states
1. After the role is determined, each port can be given a state that determines what it does with incoming data.
2. RSTP defines port states only according to what the port does with incoming frames.
(Naturally, if incoming frames are ignored or dropped, so are outgoing frames.)
Any port role can have any of these port states:
Discarding(=Disabled, Blocking,Listening states)
 1.Incoming frames simply are dropped;
 2.no MAC addresses are learned.
Learning(暫時性學習)
 1. Incoming frames are dropped,
 2. but MAC addresses are learned.
Forwarding(只要6秒即可進入此狀態)
 1. Incoming frames are forwarded
 2. according to MAC addresses that have been (and are being) learned
ps:
discarding state combines the 802.1D Disabled, Blocking,Listening states because all three did not effectively forward anything.
ps:
The Listening state is not needed because RSTP quickly can negotiate a state change without listening for BPDUs first.

……………………………………………………

BPDU
1. RSTP uses the 802.1D BPDU format for backward compatibility.
2. The sending switch port identifies itself by its RSTP role and state
3. RSTP BPDU is ver2 ,802.1D BPDUs is ver0

some previously unused bits in the Message Type field are used.
stp:flags(1byte):
 00000000:topology change(有架構變更旗標)
 10000000:topology change ack(架構變更回覆旗)
rstp:flags(1byte):
 00000000:同stp
 00000001為Proposal message
 00000[00]0:為port role如下
  [00] unknown
  [01] alternate/backup port
  [10] root port
  [11] designate port
 00010000:為Learning state
 00100000:為forwarding state
 01000000:為agreement message
 10000000:同stp

BPDU運作
BPDUs are sent out every switch port at Hello Time intervals, regardless of whether BPDUs are received from the root.
ps:
any switch anywhere in the network can play an active role in maintaining the topology 

BPDU遺失
When 3 BPDUs(3 Hello intervals) are missed in a row (default 6sec)
 1. neighbor switch is presumed to be down,
 2. all information related to the port leading to the neighbor immediately is aged out.
ps:
the Max Age timer interval (default 20 seconds) for 802.1D,才能更新BPDU

不同版本BPDU處理
RSTP can coexist with switches still using 802.1D
Each port attempts to operate according to the STP BPDU that is received.
ps:
802.1D STP無法辨識RSTP的BPDU
ex:
when an 802.1D BPDU is received on a port, that port begins to operate according to the 802.1D rules.

改變STP時的運作
each port has a measure that locks the protocol in use, in case BPDUs from both 802.1D and RSTP are received within a short time frame.
This can occur if the switches in a network are being migrated from one STP type to another. Instead of flapping or toggling the STP type during a migration, the switch holds the protocol type for the duration of a migration delay timer.
After this timer expires, the port is free to change protocols if needed.

………………………………………

RSTP Convergency
When a switch first joins the topology (perhaps it was just powered up) or has detected a failure in the existing topology, RSTP requires it to base its forwarding decisions on the type of port
ps:
RSTP透過port type可快速收斂不依賴timer,但STP要快速收斂只能依賴timer
ps:
RSTP takes a different approach when a switch needs to decide how to participate in the tree topology.


Port Types
Every switch port can be considered one of the following types:
Edge port:可快速轉移,不會收到任何bpdu,也就是接到hub或pc
nonedge port:在這裡指全雙工的switch間連線
 Root port
 Point-to-point port:可快速轉移


Edge port
1.A port at the “edge” of the network, where only a single host connects.
ps:this has been identified by enabling the STP PortFast feature. RSTP keeps the PortFast concept for familiarity.
2.the port cannot form a loop as it connects to one host, so it can be placed immediately in the Forwarding state.
ps:
if a BPDU ever is received on an edge port
 1.the port immediately loses its edge port status
 2.topology change be triggered(a nonedge port transitions to the Forwarding state) 
Root port
1. The port that has the best cost to the root of the STP instance.
2. Only one root port can be selected and active at any time, although alternative paths to the root can exist through other ports.
3. If alternative paths are detected, those ports are as alternative root ports and immediately can be placed in the Forwarding state when the existing root port fails.
Point-to-point port(designated port)
1. Any port that connects to another switch and becomes a designated port.
2. A quick handshake with the neighboring switch, rather than a timer expiration, decides the port state.
3. BPDUs are exchanged back and forth in the form of a proposal and an agreement.
4. One switch proposes that its port becomes a designated port; if the other switch agrees, it replies with an agreement message.

Point-to-point ports的產生方式
automatically be determined by the duplex mode in use
Full-duplex ports
 1 point to point port(p2p)
 because only two switches can be present on the link.
 2.STP convergence can occur quickly over a p2p link through RSTP handshake messages
Half-duplex ports
 1 not point-to-point ports/shared port.
 because a shared medium with possibly more than two switches present.
 2.the traditional 802.1D style convergence must be used. This results in a slower response


RSTP收斂原理
propagation of handshakes over point-to-point links
step1
When a switch needs to make an STP decision,a handshake is made with the nearest neighbor.
step2
When that is successful, the handshake sequence is moved to the next switch and the next, as an ever-expanding wave moving toward the network’s edges.


Synchronization concept
To participate in RSTP convergence, a switch must decide the state of each of its ports.
1. Nonedge ports begin in the Discarding state.
2. After BPDUs(PA handshake) are exchanged between the switch and its neighbor, the Root Bridge can be identified.
3. If a port receives a superior BPDU from a neighbor, that port becomes the root port

PA handshake
For each nonedge port, the switch exchanges a proposal-agreement handshake(a configuration BPDU) to decide the state of each end of the link
ps:當non-edge port從blocking成為forwarding狀態,才會運作PA handshake

Synchronization process
Each switch assumes that its port should become the designated port for the segment, and a proposal message is sent to the neighbor suggesting this.
步驟如下
1
switch(DP)傳送Proposal message(BPDU flag 00000001)到neighbor switch(root port)
ps:switch all Nonedge ports begin in the Discarding state.
2
neighbor switch做以下事
All nonedge ports immediately are moved into the Discarding (blocking) state
neighbor switch(root port)傳回agreement message(BPDU flag 01000000)給switch(DP)
3
switch的designated port和neighbor switch的root port進入Forwarding state,可開始forwarding
4
若neighbor switch還有尚未做PA交握之switch,則neighbor switch做為步驟1中的switch
ps:
This creates a moving “wave” of synchronizing switches, which quickly can decide to start forwarding on their links only if their neighbors agree
ps:
the entire convergence process happens quickly, at the speed of BPDU transmission,without the use of any timers

接收agreement message異常時
Suppose that the neighboring switch does not understand RSTP or has a problem replying.
The sending switch then must become overly cautious and must begin playing by the 802.1D rules – the port must be moved through the legacy Listening and Learning states (using the Forward Delay timer) before moving to the Forwarding state.

TC(topology change)
RSTP detects a topology change only when a nonedge port transitions to the Forwarding state.
topology changes are detected only so that bridging tables can be updated and corrected as hosts appear first on a failed port and then on a different functioning port.

TC的處理
a switch must propagate news of the change to other switches in the network so that they can correct their bridging tables, too.
This process is similar to the convergence and synchronization mechanism;
TC messages propagate through the network in an ever-expanding wave

TC的步驟
1.
The switch send BPDUs(with their TC bit set) out all the nonedge designated ports
This is done until the TC timer expires, after 2 intervals of the Hello time
用途:This notifies neighboring switches of the new link and the topology change.
2.
The swich all MAC addresses associated with the nonedge designated ports are flushed from the CAM table.
用途:This forces the addresses to be relearned after the change, in case hosts now
appear on a different link
3.
All neighboring switches that receive the TC messages,做以下兩件事
 3.1 flush the MAC-addr learned on all ports except the one that received the TC message
 3.2 成為step1中的switch , send TC messages out their nonedge designated ports, and so on.