Skip to main content
. 2018 Mar 19;18(3):907. doi: 10.3390/s18030907
Algorithm 1 Leader Election Algorithm.
  •   1:

    Koptn2×π×20.765

  •   2:

    PoptKoptn

  •   3:

    ThresholdLEACHPopt1Popt×(rmod(1Popt))

  •   4:

    MaxNumberElectionGetMaxNumberOfElections()

  •   5:

    ElectionCounter0

  •   6:

    while “Node without a leader” do

  •   7:

    ThresholdEnergyGetCurrentBatteryPowerLevel()GetFullBatteryPowerLevel()

  •   8:

    ThresholdThresholdLEACH×α+ThresholdEnergy×(1α)

  •   9:

    RandomNumberrandom(0,1)

  • 10:

    ElectionCounterElectionCounter+1

  • 11:

    if RandomNumber<Threshold or ElectionCounter>MaxNumberElection then

  • 12:

      SetNodeAsLeader()

  • 13:

    else

  • 14:

      wait(random(0,1))

  • 15:

    end if

  • 16:

    end while