CS485 Sylabus

### The Spanning Tree Algorithm and an example

• The IEEE 802.1D Spanning Tree Algorithm

• The (Distributed) Spanning Tree Algorithm in pseudo code:

 ``` Let: msg = control message received p = port on which the message msg was received /* =========================================== Check for better root =========================================== */ if ( msg.rootID < bridge.rootID ) { /* ===================================== Update state variables ===================================== */ bridge.rootID = msg.rootID; bridge.distance = msg.distance + 1; status[p] = R; // This is the root port for ( all ports q ≠ incoming port p ) { status[q] = D; // Other ports are now designated } /* ===================================== Forward new state to neighbors ===================================== */ for ( all ports q ≠ incoming port p ) { send (bridge.ID, bridge.rootID, bridge.distance) on port q; } } /* =========================================== Check for shorter path to root bridge =========================================== */ else if ( msg.rootID == bridge.rootID && msg.distance + 1 < bridge.distance ) { /* ===================================== Update state variables ===================================== */ bridge.rootID = msg.rootID; bridge.distance = msg.distance + 1; status[p] = R; // This is the root port for ( all ports q ≠ incoming port p ) { status[q] = D; // Other ports are now designated } /* ===================================== Forward new state to neighbors ===================================== */ for ( all ports q ≠ incoming port p ) { send (bridge.ID, bridge.rootID, bridge.distance) on port q; } } /* =========================================== Check for farthest node in even cycle =========================================== */ else if ( msg.rootID == bridge.rootID && msg.distance + 1 == bridge.distance ) { if ( status[p] != R ) status[p] = B; // Block the incoming port } /* =========================================== Check for farthest node in odd cycle =========================================== */ else if ( msg.rootID == bridge.rootID && msg.distance == bridge.distance ) { if ( msg.ID < bridge.ID ) status[p] = B; // Block the incoming port } else { // Do nothing, ignore a worse configuration } ```

• Example of the IEEE 802.1D Spanning Tree Algorithm

• Consider the following interconnect LANs:

• Initialization of the IEEE 802.1D Spanning Tree Algorithm (at time of start up):

 Each bridge assume that it is the the root bridge

Result:

• Recall:

• The Root bridge x will periodically transmit the configuration message:

 ``` ( x, x, 0 ) ```

• Start of message exchange:

• Messages that are sent:

• Computations performed by each node:

Explanation:

• Bridge 1 and bridge 3 found a better root bridge 0

 Set incoming port to root Set other ports to designated

• Bridge 2 found a better root bridge 1

 Set incoming port to root Set other ports to designated

• State after the computations:

• Next, bridges that computed a better configuration will forward a configuration message on its designated port:

• Messages that are sent:

• Computations performed by each node:

Explanation:

• Bridge 1 detects an odd cycle

 However, since the ID (=3) in the message is larger than the bridge (= 1), bridge 1 will do nothing

• Bridge 3 also detects an odd cycle

 Because, since the ID = 1 in the message is smaller than the bridge (3), bridge 3 will change the incoming port to blocked

• Bridge 2 found a better root bridge 1

 Set incoming port to root Set other ports to designated

• State after the computations:

• Again, bridges that computed a better configuration will forward a configuration message on its designated port:

• Messages that are sent:

• No computations are performed....

DONE !!!

• Final configuration:

Observed that:

• Because port#2 of Bridge 3 is blocked:

 The loop in the physical newtork is broken

• The learning algorithm of the switches (see: click here ), the forwarding database (table) will now be constructed correctly...

 Recall that the learning technique failed because of loops.....

(The learning bridge technique will work again)