## 4 Mobility Aware Duty Cycling Algorithm (MADCAL)  
### The Communication Threshold  
The basic premise of MADCAL is to establish a threshold of communication between each significant static node and the MSN, with significance based on whether the distance from the static node to the path of the sink is less than the node's interference range. In the case of a circular sink mobility pattern as utilised here, this involves establishing the coordinates of the start and end of the portion of the circle circumference where, when reached by the MSN, the particular static node should be awake for communication. This threshold is calculated during the initialisation stage of each static node and is detailed in Algorithm 1. \begin{table}
\begin{tabular}{c c} \hline \hline
**Test Parameters** & **Values** \\ \hline Number of Static Nodes & 25 \\ Playground Size & x = 500 m y = 500 m \\ Circle Radius & 150 m \\ Sink Start Position & x = 400 m, y = 250 m \\ Sink Node Speed (metres per second) & 2 mps, 10 mps, 20 mps, 40 mps \\ Simulation Time & 942.47779607694 s \\ Interference Distance & 77.52 m, 69.13 m, 62.02, 55.94 m \\ Number of Runs & 5 \\ Path-loss Alpha & 1.85, 1.9, 1.95, 2 \\ Carrier Frequency & 2.4 GHz \\ Maximum Sending Power & 1.0 mW \\ Signal Attenuation Threshold & \(-\)85 dBm \\ Sensitivity & \(-\)75 dBm \\ Transmitter Power & 1.0 mW \\ Thermal Noise & \(-\)85 dBm \\ Signal to Noise Ratio Threshold & 4 dB \\ Battery Capacity & 59,400 mWs \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Simulation parameters. ```
1:procedureinitialisation
2: set\(sinkSpeed\)
3:\(significantNode\gets false\)
4: set\(interDist\)
5: set\(Circumference\)
6: set\(firstSinkPos\)
7: set\(firstSinkQuartile\)
8: set\(distToCircle\)
9:if\(distToCircle<interDist\)then
10:\(significantNode\gets true\)
11:endif
12:if\(significantNode\)then
13: set\(circlePoint\)
14: set\(nodeQuartile\)
15: set\(distanceBetweenPoints\)
16: set\(angleOfNode\)
17:\(thresholdAfter\gets true\)
18:\(sinkThresholdAfter\gets establishThreshold(sinkRadius,thresholdAfter)\)
19:\(thresholdAfter\gets false\)
20:\(sinkThresholdBefore\gets establishThreshold(sinkRadius,thresholdAfter)\)
21: set\(thresholdDistance\)
22: set\(beforeQuartile\)
23: set\(thresholdOpposite\)
24:endif
25:endprocedure
26:functionestablSHThreshold(radius, after)
27:\(nodeDist\gets(radius+distToCircle)\)
28:\(angleTemp\leftarrow\frac{(radius^{2}+nodeDist^{2}-interDist^{2})}{(2*radius *nodeDist)}\)
29:\(angleRadius\gets arccos(angleTemp)\)
30:\(angle\leftarrow(angleRadius*(\frac{180}{PI})\)
31:\(factor\gets distToCircle\)
32:if\(sinkSpeed<10\)then
33:\(factorCheck\gets 0.5\)
34:elseif\(sinkSpeed<20\)then
35:\(factorCheck\gets 0.35\)
36:elseif\(sinkSpeed<40\)then
37:\(factorCheck\gets 0.25\)
38:endif
39:if\(factor<factorCheck\)then
40:\(factor\gets factorCheck\)
41:endif
42:\(angle\leftarrow(angle*factor)\)
43:ifafterthen
44:\(thresholdAngleDegrees\leftarrow(angle+angleOfNode)\)
45:else
46:\(thresholdAngleDegrees\leftarrow(angleOfNode-angle)\)
47:endif
48:\(threshold\_{}\)\(AngleRadians\leftarrow\frac{threshAngleDegrees}{(180*PI)}\)
49:\(threshold\_{}\)\(x\leftarrow circleCentre.x+(radius*cos(threshAngleRadians))\)
50:\(threshold\_{}\)\(y\leftarrow circleCentre.y+(radius*sin(threshAngleRadians))\)
51:returnCoordthreshold
52:endfunction
```  
**Algorithm 1** Communication threshold. * Lines 1-3--initialisation. The MSN speed is set from input (2, 10, 20, or 40 mps), significant node not established yet. * Line 4--the interference distance, interDist, of the node is calculated as per the algorithm previously stated. * Lines 5-7--the circumference of the circular path of the MSN is calculated, with the coordinates of the start point of the MSN set from input as firstSinkPos. Based on the sink start point, the quartile of the circle the sink initially resides in is calculated as firstSinkQuartile. These quartiles can be described as north-west, north-east, south-west, or south-east. * Line 8--the shortest distance from the node to the circular path of the MSN is calculated as distToCircle.