|
|
Algorithm 1 ABIDE Algorithm. |
|
| message formats: Forward(message type, sender, parent, list), Backward(message type, sender, destination, cycleID) |
| initially: id is the unique node identifier; visited←false; cycleID←null; parent←null; backwardCount←childCount←0; cycleIDset←ancestors←∅ |
| sink node multicasts Forward(forward type,sink,null,null) to neighbors |
| upon a node receives a message |
| if msg.type = Forward then call ReceiveForward(msg) |
| else if msg.type = Backward then call ReceiveBackward(msg) end if
|
| end upon
|
| procedure ReceiveForward(Message msg) |
| if visited = false then
|
| visited←true; parent←msg.sender; ancestors←msg.ancestors; ancestors.append(parent) |
| multicast Forward(forward type,id,parent,ancestors); start BackwardTimer |
| else
|
| if msg.parent = id then childCount←childCount+1 |
| else cycleIDset.add(ancestors⋏msg.ancestors); mark the link to msg.sender as non-bridge |
| end if
|
| end if
|
| end procedure
|
| upon BackwardTimer expires |
| if childCount = 0 and id≠sink then call SendBackward() end if
|
| end upon
|
| procedure SendBackward() |
| if cycleIDset is empty then
|
| mark the link to parent as bridge; send Backward(backward_type,id,parent,null) to parent |
| else
|
| mark the link to parent as non-bridge; cycleID ←front(ancestors,cycleIDset) |
| send Backward(backward type,id,parent,cycleID) to parent |
| end if
|
| end procedure
|
| procedure ReceiveBackward(Message msg) |
| backwardCount←backwardCount+1 |
| if msg.cycleID = null then mark the link to msg.sender as bridge |
| else
|
| mark the link to msg.sender as non-bridge |
| if msg.cycleID≠id then cycleIDset.add(msg.cycleID) end if
|
| end if
|
| if backwardCount = childCount then call sendBackward() end if
|
| end procedure
|
|