## 3 Basic System Operation
### SBD Routing
Hence, the length of an intra-sector _TDMA_ time slot can be defined by:  
\[\ell=\frac{\Delta t}{\textit{(sizeof($\gamma$)+1)}} \tag{24}\]  
In the relaying phase, all member nodes report their buffered or aggregated sensed data to their associated SH during their allocated intra-sector TDMA transmission slot. A SH, after each epoch, _i.e._, after collecting data from all member nodes, forwards the mapped event data (according to Section 3.2) in a multi-hop fashion to the corresponding sector for storage. In this inter-sector communication, SHs continue forwarding their packets to their immediate neighbor SH, which lies on the same row in the virtual grid (Figure 1a) until the packet reaches the SH that is on the same column as the destination sector. The packet is then forwarded vertically up or down until it reaches the destination (Figure 1b). The same process of routing is followed for query request and response. A description of the next hop selection process or algorithm during the relaying phase is given in Algorithm 4, which facilitates the selection of next hop in inter-sector communication. SHs continue forwarding their packets to their immediate neighbor in the same track until the packet reaches the same column where the destination sector lies. The packet is then routed vertically up or down until it reaches the destination. A SH calls Algorithm 4 while acting as either: (I) a relaying node (receives a packet from MAC layer) or (II) a source node (receives packet from application layer). ```
Input: Target \(SH_{i}\), where \(SH_{i}\in[1...S]\)\(m\)- number of tracks (rows) and \(n\)- number of sectors per track (columns) Output: Next Hop \(SH_{k}\), where \(SH_{i}\in[1...S]\)
1: //Finding the row and column position of //destination sector head and current head in the //grid
2: \(\mathrm{destCol}\gets SH_{i}\%n\);
3: \(\mathrm{destRow}\gets SH_{i}/n\);
4: \(\mathrm{curCol}\leftarrow\mathrm{nextHopCol}\leftarrow(\mathrm{SELF\_NET\_ADDR})\%n\)
5: \(\mathrm{curRow}\leftarrow\mathrm{nextHopRow}\leftarrow(\mathrm{SELF\_NET\_ADDR})/n\)
6: \(SH_{k}\leftarrow-1\)
7: //Moving the packet to the same column where //destination sector lies
8:if\(\mathrm{curCol}<\mathrm{destcol}\)
9: //*Move toward right */
10:
```
11:elseif\(\mathrm{curCol}>\mathrm{destcol}\)
12: //*Move toward left */
13: ```
14: //It is in same column so move toward up or down
15:elseif\(\mathrm{curCol}=\mathrm{destCol}\)
16:
```
17: //*Move vertically up*/
18: ```
19:elseif\(\mathrm{curRow}>\mathrm{destRow}\)
20: //*Move vertically down*/
21:
```
22: ```
23:endif
24: /*convert to sector number*/
25: \(SH_{k}\leftarrow\mathit{nextHopRow}\times n+\mathit{nextHopCol}\)
26:Return\(SH_{k}\)
```

**Algorithm 4**Search_Next_Hop (SH\(i\)), implemented at each sector head node. ### Alternate Route

In the case of any primary route failure (_first travels toward a track and then a sector_), SBD switches to _recovery mode_ of operation. In _recovery mode_, SHs follow alternate route:

Case 1: Route interruption along **track** path

1. The last relay \(SH_{k}\) forwards the packet one hop up or down along **sector** path. 2. SBD returns to its normal mode of operation. Case 2: _Route interruption along **Sector**_

1. The last relay \(SH_{k}\) forwards the packet one hop left or right along the _track_ path 1. The recipient _SH\({}_{R}\)_ forwards the packet up or down along _sector_ path 2. SBD returns to its normal mode of operation. For example, Figure 5, the source of the packet is _SH\({}_{0}\)_ and destination is _SH\({}_{23}\)_. Hence the primary and possible routes of transmission are:

1. (0) \(\rightarrow\)(1) \(\rightarrow\) (2) \(\rightarrow\) (3) \(\rightarrow\) (8) \(\rightarrow\) (13) \(\rightarrow\) (18) \(\rightarrow\) (23)
2. (7) \(\rightarrow\) (8) \(\rightarrow\) (13) \(\rightarrow\) (18) \(\rightarrow\) (23)
3. (1) \(\rightarrow\) (6) \(\rightarrow\) (7) \(\rightarrow\) (8)\(\rightarrow\)(13) \(\rightarrow\) (18) \(\rightarrow\) (23)
4. (11) \(\rightarrow\) (12) \(\rightarrow\) (13) \(\rightarrow\) (18) \(\rightarrow\) (23) and so on.