1. Let NodeID = address (ID) of the node in binary
2. Divide the NodeID into groups of 2 bits each:
NodeID = 11223344556677.....
/* ===============================================================
This distributed algorithm will identify the node
with the largest node ID !!!
================================================================ */
while ( true )
{
x = next 2 bits in NodeID; // x = bits 11 or bits 22, and so on
Transmit a jam signal for (x + 1)*τ sec // τ = end to end delay
Listen on the transmission medium
if ( transmission medium is busy for > τ sec )
{
/* =============================================
Some other node has an x value > my x value
============================================= */
winner = false; // Node will stop competing !!
exit;
}
else ( transmission medium is busy for < τ sec )
{
/* =============================================
Some other node has an x value == my x value
============================================= */
continue; // Try again with next group of bits
}
else // The transmission medium is clear !!!
{
/* =============================================
This node transmits the jam for the longest time !!
I.e.: This node has the highest x value !!!
============================================= */
winner = true; // This node is the winner
exit;
}
}
|