Skip to main content
. 2019 May 31;19(11):2489. doi: 10.3390/s19112489
Algorithm 1: Collaborative detection mechanism.
Require nodes start;
Require cont = 0;
for all Nodei do
Require set positionRingNodei;
Require Calculate Energyi;
Require Calculate ReTxi;
Require Calculate CsmaRetriesi;
Require send HELLO packet with metrics information;
  if Algorithm == Extended Mechanism then
   Collector node sends broadcast to receive information of all nodes;
   Collector node sets metric values for each nodei;
   Collector node compares each value per metric for each positionRing;
   while positionRingNodei == positionRingNodex do
    if Energyi != [Energyxmin,Energyxmax] then
     cont++;
    end if
    if ReTxi != [ReTxxmin,ReTxxmax] then
     cont++;
    end if
    if CsmaRetriesi != [CsmaRetriesxmin,CsmaRetriesxmax] then
     cont++;
    end if
   end while
  end if
  if Algorithm == Connected Mechanism then
   for all Nodex neighbor of Nodei do
    if Energyi != [Energyxmin,Energyxmax] then
     cont++;
    end if
    if ReTxi != [ReTxxmin,ReTxxmax] then
     cont++;
    end if
    if CsmaRetriesi != [CsmaRetriesxmin,CsmaRetriesxmax] then
     cont++;
    end if
   end for
  end if
  IF cont>=2 then
    Nodei sends a control packet to every Nodex;
    Nodex deletes Nodei from its routing table;
  end if
end for