| Algorithm 1: LSIP algorithm |
| Input: NBi(t), SFm, Ii, NIi, ts |
| Output: scheduled superframe |
| Initialize: t = 0 |
| // Phase 1: Calculate length of superframe |
| 1. Bi broadcasts {Ii, NIi} to all members in NBi(t) |
| 2. For each Cj ∈ NBi(t) |
| 3. Receive {Ij, NIj} |
| 4. Create a common list of neighbors: CI(t) = {sj(t) ∪ si(t), Ii ∪ Ij | j ∈ NBi(t), i ∈ NBj(t)}, CNI(t) = {NIi ∪NIj | j ∈ NBi(t), i ∈ NBj(t) } |
| 5. End For |
| 6. Calculate LCAP and LSP as in (6) and (7), respectively |
| 7. TISF = LSP + LCAP |
| 8. If TISF > SFm |
| 9. Calculate TSPm as in (12) |
| 10. Calculate Ti as in (11) |
| 11. Update LSP = TSPm |
| 12. End If |
| // Phase 2: TDMA scheduling by using greedy algorithm |
| 13. For each sensor s ∈ CI(t) |
| 14. Return the sensor sx with the highest contention value in CI(t) |
| 15. Assign time slot to sx with length ts (ts is transmission time of sx) |
| 16. Update t = t + ts |
| 17. Remove s of CI(t) |
| 18. If t > LSP |
| 19. break |
| 20. End If |
| 21. End For |