| Algorithm 1. Pseudocode of the node discovery process. |
|
Input: N nodes are randomly deployed in a given area Output: Several masters are elected to own the neighbors’ information Init: Start discovery timer T1 |
|
while (T1 > 0) Nodes Start timer T2 and randomly act as advertisers or scanners if (T2 > 0) if (Random_op = advertiser) Advertising its own ID and the number of neighbors else Scanning channels 37, 38, and 39 to update neighbor list end if else Switch roles and repeat the above advertising and scanning process if any two nodes exchange information with each other Compare their neighbor lists if the node has the most neighbors, it becomes a master and resets timer T2 else the node becomes a slave end if end if end if end while |