Research Article
FROG: A Robust and Green Wireless Sensor Node for Fog Computing Platforms
Algorithm 1
(Network Resilience Algorithm).
1: procedure BALANCEGAME | 2: timeLoop ← 1 | 3: lookForRouter ← FALSE | 4: whileTRUEdo | 5: secondLevelDevices ← coordinatorDevice.findConnectedDevices() | 6: indexDevice ← 0 | 7: forindexDevice < secondLevelDevices.size() do | 8: device ← secondLevelDevices[indexDevice] | 9: ifdevice.getRole() == ROUTER-NODE then | 10 ifdevice.getBatteryLevel() <= 50 then | 11: device.setRole(END − NODE) | 12: lookForRouter ← TRUE | 13: end if | 14: else | 15: iflookForRouter == TRUEthen | 16: ifdevice.getBatteryLevel() >= 70 then | 17: device.setRole(ROUTER − NODE) | 18: lookForRouter ← FALSE | 19: end if | 20: end if | 21: end if | 22: end for | 23: sleep(timeLoop) | 24: end while | 25: end procedure |
|