Skip to main content
. 2020 Jul 26;20(15):4158. doi: 10.3390/s20154158
Algorithm 1: Cross-layer optimization for low-power and lossy networks using iCPLA
  1. while the device is on do

  2. set maximum retry limit

  3. set maximum backoff stages

  4. setCWmin = 0, CWmax = 31

  5. set current reward = 0, ΔQ (s, a) = 0, Q(s, a) = 0

  6. BE = MIN (n_collisions, CSMA_MAX_BE)

  7. measure CW using BE in (6)

  8. calculate Pcoll using CW in (7)

  9. calculate Pcoll¯ using (8)

  10. counter ++

  11. if (counter = 5), then

  12.   counter = 1

  13.   Pcoll = Pcoll(current)

  14. end if

  15. Pcoll(Ni)=Avg(Pcoll¯, Pcoll(current))

  16. if(Pcoll(current)<Pcoll¯), then

  17.  reward = positive

  18. else

  19. reward = negative

  20. update reward table for r (s, a)

  21. update Q-values table according to (2)

  22. pick a random value to explore and exploit

  23. if (exploit), then

  24. find minaQ(s,a) IP address

  25. else (explore)

  26. if (node = root node), then

  27.   root rank = 1

  28. end if

  29. if (parent = null), then

  30.   rank = max path cost

  31. end if

  32. if (parent != null), then

  33.   Rank(cj)=Rank(pi)+rankincrease

  34.   rankincrease = (Pcoll(Ni)

  35. end if

  36. if(Rank(pi) =0, then

  37.   rank = base rank (128)

  38. end if

  39. return MIN (Base rank+rankincrease)

  40. end while