Skip to main content
. 2019 Sep 20;19(19):4072. doi: 10.3390/s19194072
Algorithm 3 Pseudocode for an exceptional case handling process at an intermediate node i
  • 1:

    n ← number of paths        ▹ number of paths calculated by Algorithm 1

  • 2:

    pi ← original packet to construct the number of paths at node i

  • 3:

    p ← modified packet to handle the exception

  • 4:

    pj ← received packet from the neighbor node j

  • 5:

    h ← number of overhearings (default = 0)

  • 6:

  • 7:

    StartTimer(T) ▹ when this timer expires, the timer of all neighbors is considered to have expired

  • 8:

    whileT.expired() == FALSE do     ▹ overhearing the transmission of the neighbors

  • 9:

        if Receive(pj) == TRUE then   ▹ when receiving the packet pj from the neighbor nodes

  • 10:

            h = h + 1

  • 11:

            if h=n then                  ▹ a sufficient paths are constructed

  • 12:

               Exit()                  ▹ quit the exception handling process

  • 13:

            end if

  • 14:

        end if

  • 15:

    end while

  • 16:

  • 17:

    ifh = 0 then                         ▹ no paths were constructed

  • 18:

        Send(pi)

  • 19:

    end if

  • 20:

    ifh < n then  ▹ Some paths were constructed and the number of paths is insufficient by nh.

  • 21:

        p.SetNumberofPaths(nh)    ▹ set the number of paths, nh, to construct n paths

  • 22:

        Send (p)          ▹ modified packet is retransmitted

  • 23:

    end if