| Algorithm 2: Initial Routing Sub-Phase | |
|
Definitions the set of Ns located at distance ≥ do/2 from the BS |
|
| the set of CHs/INs located at distance ≥ do/2 from the BS | |
| RT: Routing Table | |
| NXN: Next hop node (N) | |
| NIN: Next hop node (CH/IN) | |
| DN[i]-CH: Distance from N[i] to its corresponding CH | |
| RRT[i]-CH: Set of available routes in RT for N[i] to reach CH DCH[m]/IN[m]-BS: Distance from CH[m]/IN[m] to BS RRT[m]-BS: Set of available routes in RT for CH[m]/IN[m] to reach BS |
|
| 1: | begin |
| 2: | for each (N[i]) |
| 3: | if (DN[i]-CH < do/2) |
| 4: | transmit sensed data directly to the CH; |
| 5: | else if (DN[i]-CH < RST[i]-CH) |
| 6: | transmit sensed data directly to the CH; |
| 7: | else |
| 8: | select NXN from RT[i]; |
| 9: | transmit the sensed data to the CH through it; |
| 10: | end if |
| 11: | end for |
| 12: | for each (CH[m]/IN[m]) |
| 13: | if (DCH[m]/IN[m]-BS < do/2) |
| 14: | transmit aggregated data directly to the BS; |
| 15: | else If (DCH[m]/IN[m]-BS < RRT[m]-BS) |
| 16: | transmit the aggregated data directly to the BS; |
| 17: | else |
| 18: | select NIN from RT[m]; |
| 19: | transmit aggregated data to the BS through it; |
| 20: | end if |
| 21: | end for |