|
Result:
|
We can repair the failure as follows:
|
|
|
Answer:
|
|
if ( RootID timer expires ) { /* =============================== Reset to the initial state =============================== */ RootID = myID; Distance = 0; for ( each port P ) { status[P] = D; } } if ( state[P] time expires ) { state[P] = D; } |
|
|
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; } Reset all time out timers; } /* =========================================== 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; } Reset all time out timers; } /* =========================================== 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 Reset time out for status[p]; // Refresh blocked port } /* ================================================== Time out counter maintenance Node is one of the last nodes in odd cycle: Send control message to your neighbor to keep port blocked =================================================== */ if ( status[p] == R ) { /* ========================================== My old rootID and distance value received AGAIN on my Root port !!!! **** must be maintenance time **** ========================================== */ for ( all ports q ≠ incoming port p ) { send (bridge.ID, bridge.rootID, bridge.distance) on port q; } } } /* =========================================== 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 Reset time out for status[p]; // Refresh block port status } } else { // Do nothing, ignore a worse configuration } |
Effect:
|
|
the LAN is re-connected to the network !!!