() Initialization: (Algorithm executed at every node initially) |
Set NS = “Not Integrated” |
Create a Token object |
Set TS = true |
Parent = null |
Broadcast Beacon (UID) periodically |
() When change in neighborhood is detected: [9] |
(i) On receiving Beacon Message from node A for the first time: |
Add node to list of neighbors |
Mark the edge to as 0 |
(ii) When no Beacon Message was received from node for more than ms: ( ms/450 ms/900 ms) |
Remove node from the list of neighbors |
If the neighbor list becomes empty |
Set NS = “Not Integrated” |
Create Token |
Set TS = true |
Else if this node belongs to the sub-tree that has no token |
Create Token |
Set TS = true |
() A node that possesses the token and Initiates the construction process: |
Call BCAnyToken |
() Procedure BCAnyToken: |
Broadcast “Any Token (UID, dir, speed)?” Message |
Wait for ms to collect replies. |
If no reply is received |
If NS = “Integrated” |
Call CirculateToken |
Else |
Wait for change in its neighborhood |
Call BCAnyToken |
Else |
For each reply received on edge , label that edge as 1 |
Find the node , which has the highest node degree among the newly joined nodes |
Send “Delete Token” message to all nodes other than from which reply is received |
Delete Token |
Set TS = flase |
Send “Token Deleted” Message to node |
Set NS = “Integrated” |
() On receiving “Any Token” Message from node : |
If TS = true |
Send Reply (UID, degree, dir, speed) to |
Wait for reply from node |
Set NS to “Integrated” |
If “Delete Token” message is received |
Delete the Token of it |
Set TS = false |
Else if “Token Deleted” Message is received |
Call BCAnyToken |
() Procedure CirculateToken: |
Find the next child C in the tree that has not yet traversed |
If all children were traversed |
Reset all its children as not traversed |
If its parent is not null |
Pass on the token to its parent |
Set TS = false |
Else |
If any change occurred in its proximity |
Call BCAnyToken |
Else |
Call CirculateToken |
Else |
Pass on the token to C |
Set TS = false |
Mark C as traversed |
(7) Upon receiving the token from node |
Set TS = true |
Set parent as |
If any change occurred in its proximity |
Call BCAnyToken |
Else |
Call CirculateToken |